зеркало из https://github.com/mozilla/gecko-dev.git
Bug 822093 - Make browser_819510_perwindowpb.js wait for the sessionstore data to update before performing tests on it. r=jdm
This commit is contained in:
Родитель
d165c2299d
Коммит
5ef9c3160a
|
@ -8,7 +8,6 @@ function test() {
|
||||||
waitForExplicitFinish();
|
waitForExplicitFinish();
|
||||||
|
|
||||||
registerCleanupFunction(function() {
|
registerCleanupFunction(function() {
|
||||||
Services.prefs.clearUserPref("browser.sessionstore.interval");
|
|
||||||
ss.setBrowserState(originalState);
|
ss.setBrowserState(originalState);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -34,8 +33,6 @@ function runNextTest() {
|
||||||
let currentTest = tests.shift();
|
let currentTest = tests.shift();
|
||||||
waitForBrowserState(testState, currentTest);
|
waitForBrowserState(testState, currentTest);
|
||||||
} else {
|
} else {
|
||||||
Services.prefs.clearUserPref("browser.sessionstore.interval");
|
|
||||||
ss.setBrowserState(originalState);
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,12 +102,11 @@ function test_2() {
|
||||||
// Test opening default-normal-private-normal windows and closing a normal window
|
// Test opening default-normal-private-normal windows and closing a normal window
|
||||||
function test_3() {
|
function test_3() {
|
||||||
testOnWindow(false, function(normalWindow) {
|
testOnWindow(false, function(normalWindow) {
|
||||||
let tab = normalWindow.gBrowser.addTab("http://www.example.com/1");
|
waitForTabLoad(normalWindow, "http://www.example.com/", function() {
|
||||||
whenBrowserLoaded(tab.linkedBrowser, function() {
|
|
||||||
testOnWindow(true, function(aWindow) {
|
testOnWindow(true, function(aWindow) {
|
||||||
aWindow.gBrowser.addTab("http://www.example.com/2");
|
waitForTabLoad(aWindow, "http://www.example.com/", function() {
|
||||||
testOnWindow(false, function(aWindow) {
|
testOnWindow(false, function(aWindow) {
|
||||||
aWindow.gBrowser.addTab("http://www.example.com/3");
|
waitForTabLoad(aWindow, "http://www.example.com/", function() {
|
||||||
|
|
||||||
let curState = JSON.parse(ss.getBrowserState());
|
let curState = JSON.parse(ss.getBrowserState());
|
||||||
is(curState.windows.length, 4, "Browser has opened 4 windows");
|
is(curState.windows.length, 4, "Browser has opened 4 windows");
|
||||||
|
@ -138,33 +134,32 @@ function test_3() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForWindowClose(aWin, aCallback) {
|
function waitForWindowClose(aWin, aCallback) {
|
||||||
Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
|
let winCount = JSON.parse(ss.getBrowserState()).windows.length;
|
||||||
if (aTopic == "domwindowclosed" && aWin == aSubject) {
|
aWin.addEventListener("SSWindowClosing", function onWindowClosing() {
|
||||||
Services.obs.removeObserver(observe, aTopic);
|
aWin.removeEventListener("SSWindowClosing", onWindowClosing, false);
|
||||||
checkWindowIsClosed(aWin, aCallback);
|
function checkCount() {
|
||||||
}
|
let state = JSON.parse(ss.getBrowserState());
|
||||||
}, "domwindowclosed", false);
|
if (state.windows.length == (winCount - 1)) {
|
||||||
aWin.close();
|
aCallback();
|
||||||
}
|
|
||||||
|
|
||||||
function checkWindowIsClosed(aWin, aCallback) {
|
|
||||||
if (aWin.closed) {
|
|
||||||
info("Window is closed");
|
|
||||||
executeSoon(aCallback);
|
|
||||||
} else {
|
} else {
|
||||||
executeSoon(function() {
|
executeSoon(checkCount);
|
||||||
checkWindowIsClosed(aWin, aCallback);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
executeSoon(checkCount);
|
||||||
|
}, false);
|
||||||
|
aWin.close();
|
||||||
|
}
|
||||||
|
|
||||||
function forceWriteState(aCallback) {
|
function forceWriteState(aCallback) {
|
||||||
Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
|
Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
|
||||||
if (aTopic == "sessionstore-state-write") {
|
if (aTopic == "sessionstore-state-write") {
|
||||||
Services.obs.removeObserver(observe, aTopic);
|
Services.obs.removeObserver(observe, aTopic);
|
||||||
|
Services.prefs.clearUserPref("browser.sessionstore.interval");
|
||||||
aSubject.QueryInterface(Ci.nsISupportsString);
|
aSubject.QueryInterface(Ci.nsISupportsString);
|
||||||
aCallback(JSON.parse(aSubject.data));
|
aCallback(JSON.parse(aSubject.data));
|
||||||
}
|
}
|
||||||
|
@ -179,3 +174,11 @@ function testOnWindow(aIsPrivate, aCallback) {
|
||||||
executeSoon(function() { aCallback(win); });
|
executeSoon(function() { aCallback(win); });
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waitForTabLoad(aWin, aURL, aCallback) {
|
||||||
|
aWin.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||||
|
aWin.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||||
|
aCallback();
|
||||||
|
}, true);
|
||||||
|
aWin.gBrowser.selectedBrowser.loadURI(aURL);
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче