Frame scripts in bootstrapped add-ons can enter any frame, regardless of whether the parent and the frame have the same origin or not. I find this very convenient. In VimFx I have this function:
function querySelectorAllDeep(window, selector) {
const elements = Array.from(window.document.querySelectorAll(selector))
for (const frame of window.frames) {
elements.push(...querySelectorAllDeep(frame, selector))
}
return elements
}
For example, it allows me to easily find every single link on the screen (no matter how many nested frames there might be on the page).
With WebExtensions, though, the good old “same origin” policy applies. As far as I can see, I need to load a content script into every frame and use window.postMessage
to communicate between them, which is a whole lot fiddlier (but doable).
Is there a reason why content scripts in WebExtensions have this restriction, when frame scripts in bootstrapped add-ons seem to work so well?