зеркало из https://github.com/mozilla/pjs.git
Bug 741070. (Cv1a-FF) Sessionstore tests: Improve and merge 'provideWindow()' and 'whenWindowLoaded()' into 'head.js', Add an 'info()' call, Nits. r=paul (a=test-only).
This commit is contained in:
Родитель
653e4d4800
Коммит
6decdbb602
|
@ -35,36 +35,6 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function provideWindow(aCallback, aURL, aFeatures) {
|
||||
function callback() {
|
||||
executeSoon(function () {
|
||||
aCallback(win);
|
||||
});
|
||||
}
|
||||
|
||||
let win = openDialog(getBrowserURL(), "", aFeatures || "chrome,all,dialog=no", aURL);
|
||||
|
||||
whenWindowLoaded(win, function () {
|
||||
if (!aURL) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
win.gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
win.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
callback();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
function whenWindowLoaded(aWin, aCallback) {
|
||||
aWin.addEventListener("load", function () {
|
||||
aWin.removeEventListener("load", arguments.callee, false);
|
||||
executeSoon(function () {
|
||||
aCallback(aWin);
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
|
|
|
@ -35,43 +35,13 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function provideWindow(aCallback, aURL, aFeatures) {
|
||||
function callback() {
|
||||
executeSoon(function () {
|
||||
aCallback(win);
|
||||
});
|
||||
}
|
||||
|
||||
let win = openDialog(getBrowserURL(), "", aFeatures || "chrome,all,dialog=no", aURL);
|
||||
|
||||
whenWindowLoaded(win, function () {
|
||||
if (!aURL) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
win.gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||
win.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
callback();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
function whenWindowLoaded(aWin, aCallback) {
|
||||
aWin.addEventListener("load", function () {
|
||||
aWin.removeEventListener("load", arguments.callee, false);
|
||||
executeSoon(function () {
|
||||
aCallback(aWin);
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function test() {
|
||||
// This test takes quite some time, and timeouts frequently, so we require
|
||||
// more time to run.
|
||||
// See Bug 518970.
|
||||
requestLongerTimeout(2);
|
||||
|
||||
waitForExplicitFinish();
|
||||
waitForExplicitFinish();
|
||||
|
||||
// helper function that does the actual testing
|
||||
function openWindowRec(windowsToOpen, expectedResults, recCallback) {
|
||||
|
@ -94,13 +64,14 @@ function test() {
|
|||
executeSoon(recCallback);
|
||||
return;
|
||||
}
|
||||
|
||||
// hack to force window to be considered a popup (toolbar=no didn't work)
|
||||
let winData = windowsToOpen.shift();
|
||||
let settings = "chrome,dialog=no," +
|
||||
(winData.isPopup ? "all=no" : "all");
|
||||
let url = "http://example.com/?window=" + windowsToOpen.length;
|
||||
|
||||
provideWindow(function (win) {
|
||||
provideWindow(function onTestURLLoaded(win) {
|
||||
win.close();
|
||||
openWindowRec(windowsToOpen, expectedResults, recCallback);
|
||||
}, url, settings);
|
||||
|
|
|
@ -93,14 +93,6 @@ let TabsProgressListener = {
|
|||
}
|
||||
}
|
||||
|
||||
// ----------
|
||||
function whenWindowLoaded(win, callback) {
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
executeSoon(callback);
|
||||
}, false);
|
||||
}
|
||||
|
||||
// ----------
|
||||
function newWindowWithState(state, callback) {
|
||||
let opts = "chrome,all,dialog=no,height=800,width=800";
|
||||
|
@ -108,10 +100,10 @@ function newWindowWithState(state, callback) {
|
|||
|
||||
registerCleanupFunction(function () win.close());
|
||||
|
||||
whenWindowLoaded(win, function () {
|
||||
TabsProgressListener.init(win);
|
||||
whenWindowLoaded(win, function onWindowLoaded(aWin) {
|
||||
TabsProgressListener.init(aWin);
|
||||
TabsProgressListener.setCallback(callback);
|
||||
|
||||
ss.setWindowState(win, JSON.stringify(state), true);
|
||||
ss.setWindowState(aWin, JSON.stringify(state), true);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -27,14 +27,6 @@ function test() {
|
|||
});
|
||||
}
|
||||
|
||||
// ----------
|
||||
function whenWindowLoaded(aWindow, aCallback) {
|
||||
aWindow.addEventListener("load", function onLoad() {
|
||||
aWindow.removeEventListener("load", onLoad, false);
|
||||
executeSoon(aCallback);
|
||||
}, false);
|
||||
}
|
||||
|
||||
// ----------
|
||||
function newWindowWithState(aState, aCallback) {
|
||||
let opts = "chrome,all,dialog=no,height=800,width=800";
|
||||
|
@ -42,8 +34,8 @@ function newWindowWithState(aState, aCallback) {
|
|||
|
||||
registerCleanupFunction(function () win.close());
|
||||
|
||||
whenWindowLoaded(win, function () {
|
||||
ss.setWindowState(win, JSON.stringify(aState), true);
|
||||
executeSoon(function () aCallback(win));
|
||||
whenWindowLoaded(win, function onWindowLoaded(aWin) {
|
||||
ss.setWindowState(aWin, JSON.stringify(aState), true);
|
||||
executeSoon(function () aCallback(aWin));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,6 +49,28 @@ registerCleanupFunction(function () {
|
|||
// session restore tests to be run standalone without triggering errors.
|
||||
Cc["@mozilla.org/browser/clh;1"].getService(Ci.nsIBrowserHandler).defaultArgs;
|
||||
|
||||
function provideWindow(aCallback, aURL, aFeatures) {
|
||||
function callbackSoon(aWindow) {
|
||||
executeSoon(function executeCallbackSoon() {
|
||||
aCallback(aWindow);
|
||||
});
|
||||
}
|
||||
|
||||
let win = openDialog(getBrowserURL(), "", aFeatures || "chrome,all,dialog=no", aURL);
|
||||
whenWindowLoaded(win, function onWindowLoaded(aWin) {
|
||||
if (!aURL) {
|
||||
info("Loaded a blank window.");
|
||||
callbackSoon(aWin);
|
||||
return;
|
||||
}
|
||||
|
||||
aWin.gBrowser.selectedBrowser.addEventListener("load", function selectedBrowserLoadListener() {
|
||||
aWin.gBrowser.selectedBrowser.removeEventListener("load", selectedBrowserLoadListener, true);
|
||||
callbackSoon(aWin);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
// This assumes that tests will at least have some state/entries
|
||||
function waitForBrowserState(aState, aSetStateCallback) {
|
||||
let windows = [window];
|
||||
|
@ -198,6 +220,15 @@ function whenBrowserLoaded(aBrowser, aCallback) {
|
|||
}, true);
|
||||
}
|
||||
|
||||
function whenWindowLoaded(aWindow, aCallback) {
|
||||
aWindow.addEventListener("load", function windowLoadListener() {
|
||||
aWindow.removeEventListener("load", windowLoadListener, false);
|
||||
executeSoon(function executeWhenWindowLoaded() {
|
||||
aCallback(aWindow);
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
var gUniqueCounter = 0;
|
||||
function r() {
|
||||
return Date.now() + "-" + (++gUniqueCounter);
|
||||
|
|
Загрузка…
Ссылка в новой задаче