Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/windowObserver.js

Issue 8795010: Topic 11502 - EHH fails to recognize the first browser window opened (Closed)
Patch Set: Created Nov. 8, 2012, 2:44 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld