Closed Bug 610624 Opened 14 years ago Closed 14 years ago

error "window is null" in page-mods

Categories

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

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 616785

People

(Reporter: dietrich, Assigned: irakli)

Details

Attachments

(1 file)

made a simple page-mod in main.js global scope. seeing this on every page load in the nightly and beta 6: error: An exception occurred. Traceback (most recent call last): File "chrome://global/content/bindings/autocomplete.xml", line 1100, in document.getAnonymousElementByAttribute(this, "anonid", "richlistbox"); File "resource://jid0-bqnxcbiimtovbokmk1n4s8f1eqe-jetpack-core-lib/observer-service.js", line 174, in this.callback(subject, data); File "resource://jid0-bqnxcbiimtovbokmk1n4s8f1eqe-addon-kit-lib/page-mod.js", line 180, in _onContentWindow if (RULES[rule].test(window.document.URL)) TypeError: window is null
Summary: page-mods errors → error "window is null" in page-mods
Seeing this still. I think it blocks, since the page-mod is not executed. Code: const pageMods = require("page-mod"); pageMods.PageMod({ include: "https://builder.mozillalabs.com/addon/*", contentScriptURL: require("self").data.url("addon-builder.js"), contentScriptWhen: "ready" }); Error: error: An exception occurred. Traceback (most recent call last): File "resource://jid0-bqnxcbiimtovbokmk1n4s8f1eqe-jetpack-core-lib/observer-service.js", line 174, in this.callback(subject, data); File "resource://jid0-bqnxcbiimtovbokmk1n4s8f1eqe-addon-kit-lib/page-mod.js", line 184, in _onContentWindow if (RULES[rule].test(window.document.URL)) TypeError: window is null
Blocking 0.10 until we figure it out.
Blocks: 611250
Assignee: nobody → rFobic
Attachment #494359 - Flags: review?(dietrich)
It seems that awesomebar's atocomplete dialog triggers document-element-inserted with an argument who's defaultView is null. Pull request contains a workaround to this problem.
Unblocking 0.10 on this, since the reason my script wasn't executing was because I was using contentScriptURL instead of contentScriptFile :P However, this patch *does* fix the reported error. I'm not clear on what the root cause is - can you explain how/why autocomplete code would send that event?
No longer blocks: 611250
The root cause is that Gecko notifiers observers about document-element-inserted for all documents, including chrome XML documents; but page-mod only supports HTML documents and assumes all inserted documents have windows, thus generating this exception. Back before document-element-inserted, when page-mod was observing content-document-global-created, this wasn't a problem, presumably because XML documents don't have "content-document-global" objects (i.e. windows). I just checked in a fix over in bug 616785, not knowing about this bug until I had already filed that one and created a patch. I decided to check in that patch instead of this one because its comment mentions that these are XML documents. In any case, this is now resolved.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Attachment #494359 - Flags: review?(dietrich)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: