PSA: Updated frame matching behavior in `chrome.scripting` API

141 views
Skip to first unread message

Oliver Dunk

unread,
Jan 16, 2025, 8:49:01 AM1/16/25
to Chromium Extensions
Hi all,

Starting in Chrome 133, we have updated the behavior of the `scripting.executeScript`, `scripting.insertCSS` and `scripting.removeCSS` methods of the `chrome.scripting` API to use match_origin_as_fallback` by default.

Consider the following scenario:

```
<iframe src="about:blank"></iframe>
<iframe srcdoc="<h1>Hello world!</h1>" sandbox></iframe>
```

And making the following API call:

```
chrome.scripting.executeScript({
  target: { tabId, allFrames: true },
  func: () => console.log("Hello world!")
});
```

Previously, the first frame would be matched but the second frame would not be. This matched the behavior of the `match_about_blank` key for content scripts in Manifest V2.

Now, frames are matched with the `match_origin_as_fallback` logic implemented in Manifest V3. This means both frames would be included by default.

This follows discussions in the WebExtensions Community Group: https://github.com/w3c/webextensions/issues/673

This should not be a significant difference for most developers but does mean these API methods will now inject into more frames. If you need to inject into specific frames, you can still use the `frameIds` key in the target selector.

Thanks,
Oliver on behalf of Chrome Extensions DevRel
Reply all
Reply to author
Forward
0 new messages