Closed Bug 1293761 Opened 9 years ago Closed 9 years ago

contentScriptWhen not working properly in e10s

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(e10s+)

RESOLVED WONTFIX
Tracking Status
e10s + ---

People

(Reporter: siavash.askari.nasr, Assigned: rpl)

Details

I created a small script with the issue: https://gist.github.com/CIAvash/6a95931b4d43abeb7ae5d05719ed335f I show the problem with an example, when I open a png image in non-e10s window contentType is "image/png" but when I open it in an e10s window, contentType is "text/html"(and url of the tab is about:blank), when I refresh the page, contentType shows "image/png". Also it correctly shows "image/png" when I change contentScriptWhen to "end". from #addons IRC channel: <John-Galt> I'm guessing the problem is that we replace the first about:blank document with the image document after the about:blank document has partially loaded. And then the SDK code ignores it, because it checks whether it's seen that document already.
triage in Monday meeting
Flags: needinfo?(sescalante)
tracking-e10s: --- → +
luca is looking at alternatives in webextensinos on content scripts and will write up ideas/ new bugs
Assignee: nobody → lgreco
Flags: needinfo?(sescalante)
Priority: -- → P3
Follows a workaround, that use the same Addon SDK PageMod API used in the example linked in the Comment 0 but with a slightly different approach, which works on both non-e10s and e10s modes: const { PageMod } = require('sdk/page-mod'); let pm = PageMod({ include: /.*/, contentScriptWhen: 'start', contentScript: ` self.port.emit("attachedDocumentInfo", { contentType: document.contentType, url: document.documentURI, }); `, onAttach: function onAttach(worker) { worker.port.on("attachedDocumentInfo", (args) => { const {contentType, url} = args; console.log(`Attached document "${url}"`, `with contentType "${contentType}"`); }); } }); The above code snippet simply sends the document contentType from the content script code (where the value of `document.contentType` is directly accessible and always updated) to the Addon SDK code running in the main process (instead of using tab.contentType, which is actually retrieved from a value that is cached in the main process).
does the work-around work for you in comment 3? Looking at fixing the core issue of timing is likely to break other items - so if work around can fix it - that would best.
Flags: needinfo?(siavash.askari.nasr)
Yes, the workaround works. Thanks :)
Flags: needinfo?(siavash.askari.nasr)
sounds great Siavash - going to close as won't fix - since there's a work-around and any fix is likely to break other timing
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.