NEW296702
browser.scripting.executeScript() does not inject scripts into about:blank and about:srcdoc frames
https://bugs.webkit.org/show_bug.cgi?id=296702
Summary browser.scripting.executeScript() does not inject scripts into about:blank an...
Andrey Meshkov
Reported 2025-07-30 08:45:13 PDT
## Description browser.scripting.executeScript does not inject scripts into about:blank and about:srcdoc frames. It returns "Failed to execute script. Extension does not have access to this frame." even though content script is allowed to run in these frames. ## Steps to reproduce Create a test extension to reproduce this issue. Manifest: ``` { ... "background": { "scripts": [ "background.js" ], "type": "module" }, "content_scripts": [ { "js": [ "content.js" ], "matches": [ "<all_urls>" ], "run_at": "document_start", "all_frames": true, "match_about_blank": true, "match_origin_as_fallback": true } ], ... "permissions": [ "<all_urls>", ..., "scripting" ] } ``` Content script: ``` browser.runtime.sendMessage({}); ``` Background page: ``` browser.runtime.onMessage.addListener(async (request, sender) => { const tabId = sender.tab?.id ?? 0; const frameId = sender.frameId ?? 0; const result = await browser.scripting.executeScript({ target: { tabId: tabId, frameIds: [frameId] }, func: (id) => { console.log(`injected into ${id}!`) }, args: [frameId], world: 'MAIN', injectImmediately: true, }); console.log(result); }) ``` Install it and open the test page: https://testcases.agrd.dev/Filters/extended-css-rules/extended-css-iframejs-injection/extended-css-iframejs-injection Open Dev tools and look for "injected into ${id}" messages in the console. ## Expected result Four messages (one for the main frame, three for iframes). ## Actual result Two messages (one for the main frame, one for an iframe with URL). If you inspect the background page, you'll see that they failed due to "Failed to execute script. Extension does not have access to this frame.".
Attachments
Radar WebKit Bug Importer
Comment 1 2025-07-30 08:45:23 PDT
Note You need to log in before you can comment on or make changes to this bug.