WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
263817
Safari Web Extension content scripts (and scripting.executeScript) won't inject into about:srcdoc and about:blank iframes
https://bugs.webkit.org/show_bug.cgi?id=263817
Summary
Safari Web Extension content scripts (and scripting.executeScript) won't inje...
Guilherme Rizzo
Reported
2023-10-27 19:04:26 PDT
I was trying to convert my extension to Safari Web Extension, but there's a major problem. Setting a content script like this in the manifest.json: "content_scripts": [ { "matches": ["<all_urls>"], "match_about_blank": true, "match_origin_as_fallback": true, "include_globs": true, "all_frames": true, "js": ["main.js"] } ], Won't inject the content script into iframes without a standard URL, for example, about:srcdoc as the URL. Example page:
https://tailwindui.com/components/application-ui/forms/form-layouts
This page has iframes that for Safari are "about:srcdoc" and the content script won't get injected into them. I've tried adding/removing match_about_blank, match_origin_as_fallback, include_globs, all_frames, nothing worked. The same happens if you try to inject it with browser.scripting.executeScript: browser.scripting.executeScript({ files: ['main.js'], target: { tabId: tab.id, allFrames: true, }, }) This won't inject the script into about:srcdoc iframes. I've also tried directly specifying the frameIds and it still doesn't work.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-10-27 19:04:36 PDT
<
rdar://problem/117613804
>
Guilherme Rizzo
Comment 2
2023-10-27 20:31:26 PDT
PS: My host_permissions is "<all_urls>"
Jeff Johnson
Comment 3
2024-01-29 19:04:25 PST
This also applies to about:blank iframes. For the sake of searchability, can about:blank be added to the bug title?
Jeff Johnson
Comment 4
2024-01-29 19:13:17 PST
Here's an example of a page that causes major problems for my Safari web extension on iPhone:
https://www.barstoolsports.com/blog/3501810/dave-portnoy-has-cancelled-barstool-radio-until-further-notice-after-their-refusal-to-talk-about-barstool-drama-today
My extension has a number of video features, but the features don't work on this page, because there's a video in iframe src="about:blank" role="caffeine-embed", where my content script doesn't run. (Apparently the iframe is added to the page by setting the innerHTML of a parent element.)
Guilherme Rizzo
Comment 5
2025-03-28 18:39:37 PDT
(In reply to Jeff Johnson from
comment #3
)
> This also applies to about:blank iframes. For the sake of searchability, can > about:blank be added to the bug title?
Added "about:blank" to the title
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug