Index: lib/windowObserver.js |
=================================================================== |
--- a/lib/windowObserver.js |
+++ b/lib/windowObserver.js |
@@ -37,17 +37,17 @@ function WindowObserver(listener, when) |
let e = Services.ww.getWindowEnumerator(); |
while (e.hasMoreElements()) |
{ |
let window = e.getNext().QueryInterface(Ci.nsIDOMWindow); |
if (when == "start" || window.document.readyState == "complete") |
this._listener.applyToWindow(window); |
else |
- this.observe(window, "domwindowopened", null); |
+ this.observe(window, "chrome-document-global-created", null); |
} |
Services.obs.addObserver(this, "chrome-document-global-created", true); |
this._shutdownHandler = function() |
{ |
let e = Services.ww.getWindowEnumerator(); |
while (e.hasMoreElements()) |
@@ -71,25 +71,25 @@ WindowObserver.prototype = |
onShutdown.remove(this._shutdownHandler); |
this._shutdownHandler(); |
this._shutdownHandler = null; |
}, |
observe: function(subject, topic, data) |
{ |
// Make sure page is not about:blank (work-around for bug 795961) |
- if (subject instanceof Ci.nsIDOMWindow && subject.location.href !== "about:blank") |
+ if (topic == "chrome-document-global-created") |
{ |
+ let window = subject.QueryInterface(Ci.nsIDOMWindow); |
if (this._when == "start") |
{ |
this._listener.applyToWindow(window); |
return; |
} |
- let window = subject.QueryInterface(Ci.nsIDOMWindow); |
let event = (this._when == "ready" ? "DOMContentLoaded" : "load"); |
let listener = function() |
{ |
window.removeEventListener(event, listener, false); |
if (this._shutdownHandler) |
this._listener.applyToWindow(window); |
}.bind(this); |
window.addEventListener(event, listener, false); |