Bug 263817
| Summary: | Safari Web Extension content scripts (and scripting.executeScript) won't inject into about:srcdoc and about:blank iframes | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Guilherme Rizzo <guivr2011> |
| Component: | WebKit Extensions | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | jberlin, kiara_rose, opendarwin, timothy, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 16 | ||
| Hardware: | Mac (Apple Silicon) | ||
| OS: | macOS 13 | ||
Guilherme Rizzo
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
<rdar://problem/117613804>
Guilherme Rizzo
PS: My host_permissions is "<all_urls>"
Jeff Johnson
This also applies to about:blank iframes. For the sake of searchability, can about:blank be added to the bug title?
Jeff Johnson
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
(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