(scripts, forceContent, tabId, frameId, bag)
| 603 | } |
| 604 | |
| 605 | function triageRealms(scripts, forceContent, tabId, frameId, bag) { |
| 606 | let code; |
| 607 | let wantsPage; |
| 608 | const toContent = []; |
| 609 | for (const /**@type{VMInjection.Script}*/ scr of scripts) { |
| 610 | const metaStr = scr[META_STR]; |
| 611 | if (isContentRealm(scr[INJECT_INTO], forceContent)) { |
| 612 | if (!metaStr[0]) { |
| 613 | const [, i, from, to] = metaStr; |
| 614 | metaStr[0] = scr[__CODE][i].slice(from, to); |
| 615 | } |
| 616 | code = ''; |
| 617 | toContent.push([scr.id, scr.key.data]); |
| 618 | } else { |
| 619 | metaStr[0] = ''; |
| 620 | code = forceContent ? ID_BAD_REALM : scr[__CODE]; |
| 621 | if (!forceContent) wantsPage = true; |
| 622 | } |
| 623 | scr.code = code; |
| 624 | } |
| 625 | if (bag) { |
| 626 | bag[INJECT][PAGE] = wantsPage || triagePageRealm(bag[MORE]); |
| 627 | } |
| 628 | if (toContent[0]) { |
| 629 | // Processing known feedback without waiting for InjectionFeedback message. |
| 630 | // Running in a separate task as executeScript may take a long time to serialize code. |
| 631 | setTimeout(injectContentRealm, 0, toContent, tabId, frameId); |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | function triagePageRealm(env, forceContent) { |
| 636 | return env?.[SCRIPTS].some(isPageRealmScript, forceContent || null); |
no test coverage detected