Accessing iframe contents from frame script (e10s)

Hi,

We’ve been migrating our XUL-based addon to e10s. There’s a part of webpage-related logic that works with iframes on page and manipulates parts of their content on page when called by user.

The old approach was to use contentDocument property of iframe which was available for addon script even if it wasn’t for page scripts due to same-origin policy.

With e10s iframe manipulation goes to frame scripts and I’ve found out that policy restrictions are applied to them so if page script doesn’t access the iframe then frame script also doesn’t.

Is there a way to enable access for addon’s frame scripts in this situation?

This should work:

this // frame script global object
.addEventListener('DOMWindowCreated', ({ target: document, }) => {
    // check if document is the one you want
});

As far as I understand, the listener function in your example will be run when frame is created. But how do I manipulate the frame when user wants it (e.g. clicks addon button “Change iframes on this page”)? This may happen some time after page load finished.

Well, if you say that querying the top window for iframe elements and using their contentDocument doesn’t work (and something like top.frames[0] doesn’t either), then I see no other pomposity than always keeping all list of all frames.