Bug 618188 - browser-chrome: browser_600545.js (and _601955.js) intermittently times out; r=zpao

This commit is contained in:
Tim Taubert 2011-05-17 00:41:28 +02:00
Родитель 399bb3195e
Коммит 1da498063b
2 изменённых файлов: 22 добавлений и 6 удалений

Просмотреть файл

@ -49,6 +49,12 @@ function test() {
function testBug600545() {
// Set the pref to false to cause non-app tabs to be stripped out on a save
Services.prefs.setBoolPref("browser.sessionstore.resume_from_crash", false);
Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
registerCleanupFunction(function () {
Services.prefs.clearUserPref("browser.sessionstore.resume_from_crash");
Services.prefs.clearUserPref("browser.sessionstore.interval");
});
// This tests the following use case:
// When multiple windows are open and browser.sessionstore.resume_from_crash
@ -92,11 +98,6 @@ function testBug600545() {
}
function done() {
// Reset the pref
try {
Services.prefs.clearUserPref("browser.sessionstore.resume_from_crash");
} catch (e) {}
// Enumerate windows and close everything but our primary window. We can't
// use waitForFocus() because apparently it's buggy. See bug 599253.
let windowsEnum = Services.wm.getEnumerator("navigator:browser");

Просмотреть файл

@ -112,18 +112,33 @@ function waitForBrowserState(aState, aSetStateCallback) {
// waitForSaveState waits for a state write but not necessarily for the state to
// turn dirty.
function waitForSaveState(aSaveStateCallback) {
let topic = "sessionstore-state-write";
let observing = false;
let topic = "sessionstore-state-write";
let sessionSaveTimeout = 1000 +
Services.prefs.getIntPref("browser.sessionstore.interval");
let timeout = setTimeout(function () {
Services.obs.removeObserver(observer, topic, false);
aSaveStateCallback();
}, sessionSaveTimeout);
function observer(aSubject, aTopic, aData) {
Services.obs.removeObserver(observer, topic, false);
timeout = clearTimeout(timeout);
observing = false;
executeSoon(aSaveStateCallback);
}
registerCleanupFunction(function() {
if (observing) {
Services.obs.removeObserver(observer, topic, false);
}
if (timeout) {
clearTimeout(timeout);
}
});
observing = true;
Services.obs.addObserver(observer, topic, false);
};