| Index: lib/windowObserver.js |
| =================================================================== |
| --- a/lib/windowObserver.js |
| +++ b/lib/windowObserver.js |
| @@ -35,6 +35,7 @@ |
| this._listener = listener; |
| this._when = when; |
| + let windows = []; |
| let e = Services.wm.getZOrderDOMWindowEnumerator(null, true); |
| if (!e.hasMoreElements()) |
| { |
| @@ -43,11 +44,18 @@ |
| } |
|
Wladimir Palant
2013/09/11 11:31:26
I think we can drop the fallback here, ww.getWindo
|
| 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, "chrome-document-global-created", null); |
| + let element = e.getNext(); |
| + this._addWindowListener(element); |
| + windows.push(element); |
| + } |
| + |
| + // Check if there are any windows that we missed because they are not visible yet |
| + let eAll = Services.ww.getWindowEnumerator(); |
| + while (eAll.hasMoreElements()) |
| + { |
| + let element = eAll.getNext(); |
| + if (windows.indexOf(element) < 0) |
| + this._addWindowListener(element); |
|
Wladimir Palant
2013/09/11 11:31:26
I'd rather have windows.push(element) here - simpl
|
| } |
| Services.obs.addObserver(this, "chrome-document-global-created", true); |
| @@ -68,6 +76,15 @@ |
| _when: null, |
| _shutdownHandler: null, |
| + _addWindowListener: function(e) |
| + { |
| + let window = e.QueryInterface(Ci.nsIDOMWindow); |
| + if (this._when == "start" || window.document.readyState == "complete") |
| + this._listener.applyToWindow(window); |
| + else |
| + this.observe(window, "chrome-document-global-created", null); |
| + }, |
| + |
| shutdown: function() |
| { |
| if (!this._shutdownHandler) |