Closed Bug 664700 Opened 15 years ago Closed 15 years ago

addProgressListener in addon js causes in SM2.1 "gBrowser is null" and "uncaught exception: 2147500037" and hangs processing of this js file

Categories

(SeaMonkey :: Tabbed Browser, defect)

SeaMonkey 2.1 Branch
x86
Windows XP
defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: scripter1, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20110608 Firefox/4.0.1 SeaMonkey/2.1 Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20110608 Firefox/4.0.1 SeaMonkey/2.1 Recently i created new versions of my addons adding to them new tools menu option which is activated on specific sites and deactivated on others so i'm using function gBrowser.addProgressListener In FF3.6, FF4, FF5 (newest beta) and SM2.0.14 it works perfectly without any errors but not in SM2.1 In SeaMonkey 2.1 my js file is processed only to point when is added listener and anything after that point is ignored. And if I'm starting SM with opened tabs from last session and focused tab is that on which my addon should do it's job then it is working but progress listener isn't fired (in FF3.6, FF4, FF5 and SM2.0.14 everything works)... I'm pretty sure that it's a bug in SeaMonkey 2.1 because both of my addons works perfectly in FF3.6, FF4, FF5 (newest beta) and SM2.0.14 without any errors but not in SM2.1 and i spent many hours checking my code and trying to workaround that. I described my problem also here (with sample code): https://forums.mozilla.org/addons/viewtopic.php?f=7&t=3301 I thin this bug may broke many addons as many addons may use ProgressListener... Reproducible: Always Steps to Reproduce: 1. Install my addon YouTube to ALLPlayer 0.7 (addon is windows specific; https://addons.mozilla.org/pl/seamonkey/addon/youtube-to-allplayer/versions/0.7); 2. Restart SeaMonkey; 3. Check your Error Console (you should see that errors; you may clear error list before next step); 4. Go to YouTube video site (eg: http://www.youtube.com/watch?v=05ZM9NvKE_8); 5. Check again your Error Console (you should see more of those errors). Actual Results: Error console shows error "gBrowser is null" in line where addon calls gBrowser.addProgressListener and/or "uncaught exception: 2147500037" and YouTube video site isn't changed. Expected Results: Should be no errors and on YouTube video site should be added button "YouTube to ALLPlayer" under a video (check screenshots on addon detail page). In FF3.6, FF4, FF5 and SM2.0.14 everything works as it should.
Version: unspecified → SeaMonkey 2.1 Branch
> https://forums.mozilla.org/addons/viewtopic.php?f=7&t=3301 Your code as described in: > https://forums.mozilla.org/addons/viewtopic.php?f=7&t=3301 has several errors. Please fix your errors first. Please visit news://news.mozilla.org/mozilla.dev.apps.seamonkey/ and/or news://news.mozilla.org/mozilla.dev.extensions for help in fixing your extension. > window.document.addEventListener("DOMContentLoaded", myAddon.DOMContentLoaded, true) This should be: window.addEventListener("load" .. ) not "DOMContentLoaded". That's why you are getting gBrowser is null. Please use getBrowser() as our gBrowser isn't initialized that early. > gBrowser.addProgressListener(myAddon_urlBarListener, // here in SM 2.1 problems starts... Make sure you only add your progress listener only once. SeaMonkey is stricter than Firefox. SeaMonkey will throw an error the second time. Firefox will just ignore the second attempt. Please see: http://hg.mozilla.org/comm-central/file/00d0a464d61e/suite/browser/tabbrowser.xml#l1923 NS_ERROR_FAILURE is 0x80004005 or 2147500037 decimal, the error you are encountering.
(In reply to comment #1) > > gBrowser.addProgressListener(myAddon_urlBarListener, // here in SM 2.1 problems starts... > Make sure you only add your progress listener only once. Easiest way to do this is to use addEventListener("load", myAddon.onLoad, false);
I replaced: window.document.addEventListener("DOMContentLoaded", myAddon.DOMContentLoaded, true) to: addEventListener("load", myAddon.onLoad, false); and added function: onLoad : function() { gBrowser.addProgressListener(myAddon_urlBarListener, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION); window.document.addEventListener("DOMContentLoaded", myAddon.DOMContentLoaded, true); }, Now everything works in SM 2.1 and FF 5.0 (newest beta) but FF 5.0 throws in error console "gBrowser.addProgressListener was called with a second argument, which is not supported. See bug 608628. Plik źródłowy: chrome://browser/content/tabbrowser.xml Wiersz: 1840" (but still addon works), before that i didn't get this error... I don't if i should do something with that (DOMContentLoaded listener is needed as my addon operates on it in other functions).
(In reply to comment #3) > FF 5.0 throws in > error console "gBrowser.addProgressListener was called with a second > argument, which is not supported. Sorry, that was caused by unfixed version of my other addon. Problem solved.
Severity: major → trivial
Closing as NOTOURBUG
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.