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

Unified Diff: lib/windowObserver.js

Issue 11624001: Fixed: WindowObserver ignoring primary browser window if instantiated before window visible (Closed)
Patch Set: Created Sept. 16, 2013, 3:25 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
@@ -35,15 +35,23 @@
this._listener = listener;
this._when = when;
+ let windows = [];
let e = Services.wm.getZOrderDOMWindowEnumerator(null, true);
- if (!e.hasMoreElements())
+ while (e.hasMoreElements())
+ windows.push(e.getNext());
+
+ // Check if there are any windows that we missed
+ let eAll = Services.ww.getWindowEnumerator();
+ while (eAll.hasMoreElements())
{
- // On Linux the list returned will be empty, see bug 156333. Fall back to random order.
- e = Services.wm.getEnumerator(null);
+ let element = eAll.getNext();
+ if (windows.indexOf(element) < 0)
+ windows.push(element);
}
- while (e.hasMoreElements())
+
+ for (let i = 0; i < windows.length; i++)
{
- let window = e.getNext().QueryInterface(Ci.nsIDOMWindow);
+ let window = windows[i].QueryInterface(Ci.nsIDOMWindow);
if (when == "start" || window.document.readyState == "complete")
this._listener.applyToWindow(window);
else
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld