Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #945 from ochameau/bug855484-platform
Browse files Browse the repository at this point in the history
Bug 855484 - Wait for toplevel-window-ready instead of domwindowopen to avoid issues with private windows. r=@erikvold
  • Loading branch information
ochameau committed May 15, 2013
2 parents 86fb910 + 5dafabf commit 8d780ab
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/sdk/deprecated/window-utils.js
Expand Up @@ -11,6 +11,7 @@ const { Cc, Ci } = require('chrome');
const { EventEmitter } = require('../deprecated/events');
const { Trait } = require('../deprecated/traits');
const { when } = require('../system/unload');
const events = require('../system/events');
const { getInnerId, getOuterId, windows, isDocumentLoaded, isBrowser,
getMostRecentBrowserWindow, getMostRecentWindow } = require('../window/utils');
const errors = require('../deprecated/errors');
Expand Down Expand Up @@ -68,6 +69,8 @@ function WindowTracker(delegate) {
for each (let window in getWindows())
this._regWindow(window);
windowWatcher.registerNotification(this);
this._onToplevelWindowReady = this._onToplevelWindowReady.bind(this);
events.on('toplevel-window-ready', this._onToplevelWindowReady);

require('../system/unload').ensure(this);

Expand Down Expand Up @@ -116,6 +119,7 @@ WindowTracker.prototype = {

unload: function unload() {
windowWatcher.unregisterNotification(this);
events.off('toplevel-window-ready', this._onToplevelWindowReady);
for each (let window in getWindows())
this._unregWindow(window);
},
Expand All @@ -128,14 +132,20 @@ WindowTracker.prototype = {
}
}),

_onToplevelWindowReady: function _onToplevelWindowReady({subject}) {
let window = subject;
// ignore private windows if they are not supported
if (ignoreWindow(window))
return;
this._regWindow(window);
},

observe: errors.catchAndLog(function observe(subject, topic, data) {
var window = subject.QueryInterface(Ci.nsIDOMWindow);
// ignore private windows if they are not supported
if (ignoreWindow(window))
return;
if (topic == 'domwindowopened')
this._regWindow(window);
else
if (topic == 'domwindowclosed')
this._unregWindow(window);
})
};
Expand Down

0 comments on commit 8d780ab

Please sign in to comment.