Bug 634528 - Port Bug 597634 [Intermittent browser_522545.js | sessionstore got correct userTypedValue - Got undefined, expected example.org] to fix test failure from landing of bug 597584. r=Neil
This commit is contained in:
Родитель
0ee824b9fa
Коммит
69d2e7c6d9
|
@ -50,23 +50,11 @@ function test() {
|
|||
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
|
||||
|
||||
waitForExplicitFinish();
|
||||
requestLongerTimeout(2);
|
||||
|
||||
let ss = Components.classes["@mozilla.org/suite/sessionstore;1"]
|
||||
.getService(Components.interfaces.nsISessionStore);
|
||||
|
||||
function waitForBrowserState(aState, aSetStateCallback) {
|
||||
var locationChanges = 0;
|
||||
getBrowser().addTabsProgressListener({
|
||||
onLocationChange: function (aBrowser) {
|
||||
if (++locationChanges == aState.windows[0].tabs.length) {
|
||||
getBrowser().removeTabsProgressListener(this);
|
||||
executeSoon(aSetStateCallback);
|
||||
}
|
||||
}
|
||||
});
|
||||
ss.setBrowserState(JSON.stringify(aState));
|
||||
}
|
||||
|
||||
// This tests the following use case:
|
||||
// User opens a new tab which gets focus. The user types something into the
|
||||
// address bar, then crashes or quits.
|
||||
|
@ -252,24 +240,26 @@ function test() {
|
|||
is(browser.userTypedValue, null, "userTypedValue is empty to start");
|
||||
is(browser.userTypedClear, 0, "userTypedClear is 0 to start");
|
||||
|
||||
gURLBar.value = "mozilla.org";
|
||||
gURLBar.value = "example.org";
|
||||
let event = document.createEvent("Events");
|
||||
event.initEvent("input", true, false);
|
||||
gURLBar.dispatchEvent(event);
|
||||
|
||||
is(browser.userTypedValue, "mozilla.org",
|
||||
"userTypedValue was set when changing gURLBar.value");
|
||||
is(browser.userTypedClear, 0,
|
||||
"userTypedClear was not changed when changing gURLBar.value");
|
||||
|
||||
// Now make sure ss gets these values too
|
||||
let newState = JSON.parse(ss.getBrowserState());
|
||||
is(newState.windows[0].tabs[0].userTypedValue, "mozilla.org",
|
||||
"sessionstore got correct userTypedValue");
|
||||
is(newState.windows[0].tabs[0].userTypedClear, 0,
|
||||
"sessionstore got correct userTypedClear");
|
||||
runNextTest();
|
||||
});
|
||||
executeSoon(function() {
|
||||
is(browser.userTypedValue, "example.org",
|
||||
"userTypedValue was set when changing gURLBar.value");
|
||||
is(browser.userTypedClear, 0,
|
||||
"userTypedClear was not changed when changing gURLBar.value");
|
||||
|
||||
// Now make sure ss gets these values too
|
||||
let newState = JSON.parse(ss.getBrowserState());
|
||||
is(newState.windows[0].tabs[0].userTypedValue, "example.org",
|
||||
"sessionstore got correct userTypedValue");
|
||||
is(newState.windows[0].tabs[0].userTypedClear, 0,
|
||||
"sessionstore got correct userTypedClear");
|
||||
runNextTest();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// test_getBrowserState_lotsOfTabsOpening tested userTypedClear in a few cases,
|
||||
|
@ -284,17 +274,8 @@ function test() {
|
|||
}]
|
||||
};
|
||||
|
||||
// Set state here and listen for load event because waitForBrowserState
|
||||
// doesn't guarantee all the tabs have loaded, so the test could continue
|
||||
// before we're in a testable state. This is important here because of the
|
||||
// distinction between "http://example.com" and "http://example.com/".
|
||||
ss.setBrowserState(JSON.stringify(state));
|
||||
getBrowser().addEventListener("load", function(aEvent) {
|
||||
if (getBrowser().currentURI.spec == "about:blank")
|
||||
return;
|
||||
getBrowser().removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let browser = getBrowser().selectedBrowser;
|
||||
waitForBrowserState(state, function() {
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
is(browser.currentURI.spec, "http://example.com/",
|
||||
"userTypedClear=2 caused userTypedValue to be loaded");
|
||||
is(browser.userTypedValue, null,
|
||||
|
@ -304,7 +285,7 @@ function test() {
|
|||
is(gURLBar.value, "http://example.com/",
|
||||
"Address bar's value set after loading URI");
|
||||
runNextTest();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -313,9 +294,14 @@ function test() {
|
|||
test_getBrowserState_lotsOfTabsOpening,
|
||||
test_getBrowserState_userTypedValue, test_userTypedClearLoadURI];
|
||||
let originalState = ss.getBrowserState();
|
||||
let state = {
|
||||
windows: [{
|
||||
tabs: [{ entries: [{ url: "about:blank" }] }]
|
||||
}]
|
||||
};
|
||||
function runNextTest() {
|
||||
if (tests.length) {
|
||||
executeSoon(tests.shift());
|
||||
waitForBrowserState(state, tests.shift());
|
||||
} else {
|
||||
ss.setBrowserState(originalState);
|
||||
executeSoon(function () {
|
||||
|
|
Загрузка…
Ссылка в новой задаче