mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
Bug 880101 - part 1 - Add test that forces the gBrowser constructor a little too early; r=gavin
This commit is contained in:
parent
1a0d4f30d2
commit
7576aec33a
@ -184,6 +184,7 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_bug822367.js \
|
||||
browser_bug832435.js \
|
||||
browser_bug839103.js \
|
||||
browser_bug880101.js \
|
||||
browser_bug882977.js \
|
||||
browser_bug887515.js \
|
||||
browser_canonizeURL.js \
|
||||
|
50
browser/base/content/test/browser_bug880101.js
Normal file
50
browser/base/content/test/browser_bug880101.js
Normal file
@ -0,0 +1,50 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const URL = "about:robots";
|
||||
|
||||
function test() {
|
||||
let win;
|
||||
|
||||
let listener = {
|
||||
onLocationChange: (webProgress, request, uri, flags) => {
|
||||
ok(webProgress.isTopLevel, "Received onLocationChange from top frame");
|
||||
is(uri.spec, URL, "Received onLocationChange for correct URL");
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Remove the listener and window when we're done.
|
||||
registerCleanupFunction(() => {
|
||||
win.gBrowser.removeProgressListener(listener);
|
||||
win.close();
|
||||
});
|
||||
|
||||
// Wait for the newly opened window.
|
||||
whenNewWindowOpened(w => win = w);
|
||||
|
||||
// Open a link in a new window.
|
||||
openLinkIn(URL, "window", {});
|
||||
|
||||
// On the next tick, but before the window has finished loading, access the
|
||||
// window's gBrowser property to force the tabbrowser constructor early.
|
||||
(function tryAddProgressListener() {
|
||||
executeSoon(() => {
|
||||
try {
|
||||
win.gBrowser.addProgressListener(listener);
|
||||
} catch (e) {
|
||||
// win.gBrowser wasn't ready, yet. Try again in a tick.
|
||||
tryAddProgressListener();
|
||||
}
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
function whenNewWindowOpened(cb) {
|
||||
Services.obs.addObserver(function obs(win) {
|
||||
Services.obs.removeObserver(obs, "domwindowopened");
|
||||
cb(win);
|
||||
}, "domwindowopened", false);
|
||||
}
|
Loading…
Reference in New Issue
Block a user