Closed
Bug 649615
Opened 13 years ago
Closed 13 years ago
Page-Mod Content-Scripts loaded twice in some occasions
Categories
(Add-on SDK Graveyard :: General, defect, P1)
Tracking
(Not tracked)
RESOLVED
FIXED
1.0
People
(Reporter: nicolas.cotenolin, Assigned: ochameau)
References
Details
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16 Build Identifier: addon-sdk-1.0b4 In some specific occasions, the content-script of a page-mod is injected twice in a page. This happens when attaching the worker on the tabs.onReady event. For this to happens, a precise timing where the tabs.onReady is fired but the page isn't totally loaded yet (firefox still shows the page as loading) needs to be respected. Reproducible: Sometimes Steps to Reproduce: 1. Go to a page where the load time is longer 2. Just before the page finish completely loading, change the adress in the url and go to another page. Actual Results: From time to time (the timing issue makes it hard to reproduce), the content-scripts will be loaded twice. Expected Results: The worker of the 1st loaded page should unattach. Here some code : main.js tabs.on('ready', function(tab) { var worker = tab.attach({ contentScriptFile: listContentScriptFiles, onMessage: function() { // not important } }); }); content-script: console.log(document.domain); // Some logic that takes some times console.log(document.domain); // won't log the same domain FYI, I'm loading a long list of content-script, maybe it's one of the reason for this bug. For test purpose, I've used mostly www.cyberpresse.ca as the 1st domain and localhost as the 2nd.
Updated•13 years ago
|
Priority: -- → P1
Target Milestone: --- → 1.0
Assignee | ||
Comment 1•13 years ago
|
||
Thanks for the report! Yes I've implemented tab.attach that way. It will be attached once and be kept alive over all document loaded in the tab. But it has been recently considered as a bug and is going to be changed. A patch in bug 607601 is already in review and is going to unattach this worker at document unload. So if you do: window.documentaliste("load", function () { console.log(document.domain); }, false) Currently you will have a log message at each new document loaded. But with patch mentioned before, you won't ever had a message because this worker is going to be destroyed at first document unload. I let this bug open until you confirm me that bug 607601 patch fixed your problem.
Assignee: nobody → poirot.alex
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee | ||
Comment 2•13 years ago
|
||
Nicolas: Can you confirm that your problem is solved in 1.0b5 release? http://blog.mozilla.com/addons/2011/05/05/announcing-add-on-sdk-1-0b5/
Reporter | ||
Comment 3•13 years ago
|
||
I'll have a look. Right now, I'm having a little problem running my extension with 1.0b5 because I have mutliple TypeError: this._.ownerDocument.defaultView is null when opening new tabs. So I'll try to find what changes I need to make so my extensions work correctly.
Assignee | ||
Comment 4•13 years ago
|
||
This error seems to come from RightJS: https://github.com/rightjs/rightjs-core/blob/master/src/dom/element/styles.js#L69 We are working on content scripts sandboxes, there is some issues with js frameworks for the moment.
Reporter | ||
Comment 5•13 years ago
|
||
I've been trying to reproduce this bug with the 1.0b5 version of JetPack without any success, so this problem seems solved to me!
Assignee | ||
Updated•13 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•