зеркало из https://github.com/mozilla/gecko-dev.git
change debug info for random failing browser_394759_privatebrowsing.js, and fix a wrong setTimeout.
This commit is contained in:
Родитель
6c62e29e31
Коммит
2928d30243
|
@ -55,12 +55,30 @@ function test() {
|
||||||
sessionStoreJS.remove(false);
|
sessionStoreJS.remove(false);
|
||||||
ok(sessionStoreJS.exists() == false, "sessionstore.js was removed");
|
ok(sessionStoreJS.exists() == false, "sessionstore.js was removed");
|
||||||
// Make sure that sessionstore.js can be forced to be created by setting
|
// Make sure that sessionstore.js can be forced to be created by setting
|
||||||
// the interval pref to 0
|
// the interval pref to a low value.
|
||||||
gPrefService.setIntPref("browser.sessionstore.interval", 0);
|
gPrefService.setIntPref("browser.sessionstore.interval", 100);
|
||||||
// sessionstore.js should be re-created at this point
|
// sessionstore.js should be re-created at this point
|
||||||
sessionStoreJS = profilePath.clone();
|
sessionStoreJS = profilePath.clone();
|
||||||
sessionStoreJS.append("sessionstore.js");
|
sessionStoreJS.append("sessionstore.js");
|
||||||
|
|
||||||
|
// Wait for the sessionstore.js file to be written before going on.
|
||||||
|
let os = Cc["@mozilla.org/observer-service;1"].
|
||||||
|
getService(Ci.nsIObserverService);
|
||||||
|
os.addObserver({observe: function(aSubject, aTopic, aData) {
|
||||||
|
gPrefService.clearUserPref("browser.sessionstore.interval");
|
||||||
|
os.removeObserver(this, aTopic);
|
||||||
|
executeSoon(continue_test);
|
||||||
|
}}, "sessionstore-state-write-complete", false);
|
||||||
|
|
||||||
|
//XXXDEBUG Detect spurious windows-restored notifications.
|
||||||
|
os.addObserver({observe: function(aSubject, aTopic, aData) {
|
||||||
|
// If this is not called in this test it will be called by next ones,
|
||||||
|
// but i don't mind actually, it's just an info(), and will go away once
|
||||||
|
// the randomness has been fixed.
|
||||||
|
info("Windows status has been restored, was that expected?");
|
||||||
|
os.removeObserver(this, aTopic);
|
||||||
|
}}, "sessionstore-windows-restored", false);
|
||||||
|
|
||||||
// Set up the browser in a blank state. Popup windows in previous tests result
|
// Set up the browser in a blank state. Popup windows in previous tests result
|
||||||
// in different states on different platforms.
|
// in different states on different platforms.
|
||||||
let blankState = JSON.stringify({
|
let blankState = JSON.stringify({
|
||||||
|
@ -71,27 +89,6 @@ function test() {
|
||||||
_closedWindows: []
|
_closedWindows: []
|
||||||
});
|
});
|
||||||
ss.setBrowserState(blankState);
|
ss.setBrowserState(blankState);
|
||||||
|
|
||||||
waitForSessionStoreJS();
|
|
||||||
}
|
|
||||||
|
|
||||||
let pass = 0;
|
|
||||||
const MAX_PASS = 6;
|
|
||||||
function waitForSessionStoreJS() {
|
|
||||||
if (++pass > MAX_PASS) {
|
|
||||||
ok(false, "Timed out waiting for sessionstore.js");
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
let profilePath = Cc["@mozilla.org/file/directory_service;1"].
|
|
||||||
getService(Ci.nsIProperties).
|
|
||||||
get("ProfD", Ci.nsIFile);
|
|
||||||
let sessionStoreJS = profilePath.clone();
|
|
||||||
sessionStoreJS.append("sessionstore.js");
|
|
||||||
if (sessionStoreJS.exists())
|
|
||||||
executeSoon(continue_test);
|
|
||||||
else
|
|
||||||
setTimeout(500, waitForSessionStoreJS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function continue_test() {
|
function continue_test() {
|
||||||
|
@ -105,8 +102,6 @@ function continue_test() {
|
||||||
let closedWindowCount = ss.getClosedWindowCount();
|
let closedWindowCount = ss.getClosedWindowCount();
|
||||||
is(closedWindowCount, 0, "Correctly set window count");
|
is(closedWindowCount, 0, "Correctly set window count");
|
||||||
|
|
||||||
gPrefService.clearUserPref("browser.sessionstore.interval");
|
|
||||||
|
|
||||||
// Prevent VM timers issues, cache now and increment it manually.
|
// Prevent VM timers issues, cache now and increment it manually.
|
||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
const TESTS = [
|
const TESTS = [
|
||||||
|
@ -118,6 +113,7 @@ function continue_test() {
|
||||||
value: "uniq" + (++now) },
|
value: "uniq" + (++now) },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let loadWasCalled = false;
|
||||||
function openWindowAndTest(aTestIndex, aRunNextTestInPBMode) {
|
function openWindowAndTest(aTestIndex, aRunNextTestInPBMode) {
|
||||||
info("Opening new window");
|
info("Opening new window");
|
||||||
let windowObserver = {
|
let windowObserver = {
|
||||||
|
@ -125,13 +121,13 @@ function continue_test() {
|
||||||
if (aTopic === "domwindowopened") {
|
if (aTopic === "domwindowopened") {
|
||||||
info("New window has been opened");
|
info("New window has been opened");
|
||||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||||
is(win.document.readyState, "uninitialized");
|
|
||||||
win.addEventListener("load", function onLoad(event) {
|
win.addEventListener("load", function onLoad(event) {
|
||||||
win.removeEventListener("load", onLoad, false);
|
win.removeEventListener("load", onLoad, false);
|
||||||
info("New window has been loaded");
|
info("New window has been loaded");
|
||||||
win.gBrowser.addEventListener("load", function(aEvent) {
|
win.gBrowser.addEventListener("load", function(aEvent) {
|
||||||
win.gBrowser.removeEventListener("load", arguments.callee, true);
|
win.gBrowser.removeEventListener("load", arguments.callee, true);
|
||||||
info("New window browser has been loaded");
|
info("New window browser has been loaded");
|
||||||
|
loadWasCalled = true;
|
||||||
executeSoon(function() {
|
executeSoon(function() {
|
||||||
// Add a tab.
|
// Add a tab.
|
||||||
win.gBrowser.addTab();
|
win.gBrowser.addTab();
|
||||||
|
@ -188,24 +184,20 @@ function continue_test() {
|
||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
}, false);
|
}, false);
|
||||||
// Ensure listener has been added.
|
|
||||||
let els = Cc["@mozilla.org/eventlistenerservice;1"].
|
|
||||||
getService(Ci.nsIEventListenerService);
|
|
||||||
let infos = els.getListenerInfoFor(win, {});
|
|
||||||
is(infos.length, 1, "Window has 1 listener");
|
|
||||||
is(infos[0].type, "load", "Window has load listener");
|
|
||||||
ok(!infos[0].capturing, "Window does not have a capture listener");
|
|
||||||
}
|
}
|
||||||
else if (aTopic === "domwindowclosed") {
|
else if (aTopic === "domwindowclosed") {
|
||||||
info("Window closed");
|
info("Window closed");
|
||||||
ww.unregisterNotification(this);
|
ww.unregisterNotification(this);
|
||||||
|
if (!loadWasCalled) {
|
||||||
|
ok(false, "Window was closed before load could fire!");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ww.registerNotification(windowObserver);
|
ww.registerNotification(windowObserver);
|
||||||
// Open a window.
|
// Open a window.
|
||||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no", TESTS[aTestIndex].url);
|
openDialog(location, "_blank", "chrome,all,dialog=no", TESTS[aTestIndex].url);
|
||||||
is(newWin.document.readyState, "uninitialized");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openWindowAndTest(0, true);
|
openWindowAndTest(0, true);
|
||||||
|
|
|
@ -69,7 +69,7 @@ function test() {
|
||||||
let iframes = tab2.linkedBrowser.contentWindow.frames;
|
let iframes = tab2.linkedBrowser.contentWindow.frames;
|
||||||
if (iframes[1].document.body.innerHTML != uniqueValue &&
|
if (iframes[1].document.body.innerHTML != uniqueValue &&
|
||||||
++pass <= MAX_PASS) {
|
++pass <= MAX_PASS) {
|
||||||
setTimeout(500, arguments.callee);
|
setTimeout(arguments.callee, 500);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
is(iframes[1].document.body.innerHTML, uniqueValue,
|
is(iframes[1].document.body.innerHTML, uniqueValue,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче