Closed
Bug 1178692
Opened 8 years ago
Closed 5 years ago
[e10s] Loading frame scripts in newly open tab is a frustrating exercise
Categories
(Firefox :: Extension Compatibility, defect)
Tracking
()
RESOLVED
INVALID
Tracking | Status | |
---|---|---|
e10s | - | --- |
People
(Reporter: stefan.pieck, Unassigned)
References
Details
Attachments
(1 file)
2.34 KB,
application/x-zip-compressed
|
Details |
Same problem in 40.0a2 (2015-06-26) and 42.0a1 (2015-06-29) A WebProgressListener registered in a framescript only gets events for Tabs opened on startup. On Tabs opened later the WebProgressListener gets no events. When opening additional windows with multiple tabs for some of them the WebProgress Listener gets events, for some not. When deactivating e10s the events are always fired. Progresslistener registration in Framescript: {code} let Ci = this.Components.interfaces; let Cr = this.Components.results; let ifaceReq = this.docShell.QueryInterface(Ci.nsIInterfaceRequestor); let webProgress = ifaceReq.getInterface(Ci.nsIWebProgress); webProgress.addProgressListener(listener, (this.Ci.nsIWebProgress.NOTIFY_LOCATION | this.Ci.nsIWebProgress.NOTIFY_ALL)); {code}
Giorgio, could you work with the reporter on this? It seems like the code should work.
tracking-e10s:
--- → -
Flags: needinfo?(g.maone)
Comment 2•8 years ago
|
||
(In reply to stefan.pieck from comment #0) > Same problem in 40.0a2 (2015-06-26) and 42.0a1 (2015-06-29) > > A WebProgressListener registered in a framescript only gets events for Tabs > opened on startup. Stefan, May I look at the code you use to load the framescript and at the code of the listener? Even better, could you please produce a minimal add-on or a scratchpad script which reproduces this issue? Thanks!
Flags: needinfo?(g.maone)
Reporter | ||
Comment 3•8 years ago
|
||
I appended a minimal addon which registers a webProgress listener in a framescript and writes navigation events to the console. My observation is, that with e10s enabled the webProgress listener does not work on all tabs. The pattern I observed is, that when openin a new tab, The load of the newTab.xul is logged, but none of the following navigations on this tab. When opening a link in a new tab the progreeListener of the new tab seems to work. The progesslistener for the startpage on browser startup seems to work. When opening a new Window (with strg + n) the framescript is not initialized at all (the tabs.on "open" event seems to be missing) And on new tabs, the
Comment 4•8 years ago
|
||
(In reply to stefan.pieck from comment #3) > Created attachment 8628652 [details] > minimal addon registering a listener and logging navigation events. > > I appended a minimal addon which registers a webProgress listener in a > framescript and writes navigation events to the console. Thank you for providing this test-case. I can see what's happening here: 1) On new windows, the first tab doesn't emit any tabs.on("open") event, so no frame script gets loaded in that first tab. Tabs added afterwards do get injected with your frame script. Not sure whether this is the intended behavior or a bug, surely it's quite confusing. I'll ask and let you know. 2) Even when the frame script gets loaded properly, if the initial content is about:newTab (the default behavior), as soon as you navigate to a "normal" web page the frame script's "host" changes (probably some "magic" due to about:newTab running in the main process, rather than in a child one) and your script (with its listener) gets lost in deep space. Would it possible for you to work around by using the global message manager instead, in order to load your frame script on *any* new frame? require("chrome").import("resource://gre/modules/Services.jsm"); Services.mm.loadFrameScript(self.data.url("framescript.js"), true);
Comment 5•8 years ago
|
||
Another couple of suggestions: 1) Since you're using the SDK, you may want to try https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/remote_parent and https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/remote_child 2) In package.json, you need to turn the permissions.multiprocess property to true
Updated•8 years ago
|
Blocks: e10s-devdoc-lies
Summary: [e10s] webProgressListener in framescript gets no events → [e10s] Loading frame scripts in newly open tab is a frustrating exercise
Updated•8 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Reporter | ||
Comment 6•8 years ago
|
||
For point 1 I found a Workaround by using the window open event. windows.on("open", (win) => { for (let i = 0; i < win.tabs.length; i += 1) { onNewTab(win.tabs[i]); } }) Regarding point 2 I tried to use the global message manager as suggested. but I was not able to find a way to associate the framescript to a tab. Is there a way to get the tab id from a framescript?
Comment 7•8 years ago
|
||
(In reply to stefan.pieck from comment #6) > Regarding point 2 I tried to use the global message manager as suggested. > but I was not able to find a way to associate the framescript to a tab. Is > there a way to get the tab id from a framescript? Yes it is, since the message.target property in your listener is associated to the browser element linked to your frame script. Therefore the following should be a suitable replacement for your test case: require("chrome").Cu.import("resource://gre/modules/Services.jsm"); let mm = Services.mm; mm.loadFrameScript(self.data.url("framescript.js"), true); let logListener = { receiveMessage: function(message){ let browser = message.target; let tab = tabutils.getTabForBrowser(browser); let tabId = tab && tabutils.getTabId(tab); console.log("tab.id=" + tabId + ", " + message.data); } } mm.addMessageListener("log", logListener);
Reporter | ||
Comment 8•8 years ago
|
||
Thank you, the workaround seems to work, when im Ignoring messages from framescripts without a tabId.
Reporter | ||
Comment 9•8 years ago
|
||
The method "tabutils.getTabForBrowser(browser);" mentioned before is working, but it is missing in the documentation of sdk/tabs/utils https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/tabs_utils
Comment 10•8 years ago
|
||
(In reply to stefan.pieck from comment #9) > The method "tabutils.getTabForBrowser(browser);" mentioned before is > working, but it is missing in the documentation of sdk/tabs/utils > https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/tabs_utils In facts I found it by looking at the source code ;) Anyway, I've just edited the MDN (BTW, you could as well, it's a public Wiki): https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/tabs_utils#getTabForBrowser%28browser%29
Comment 11•5 years ago
|
||
With WebExtensions being the only valid way of doing extensions in Firefox 57, I don't think this bug is still relevant.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•