Bug 1270067 - fix browser_bug522545.js to actually test what it intends to test, r=mconley
MozReview-Commit-ID: IySO69Ic1yT
--- a/browser/components/sessionstore/test/browser_522545.js
+++ b/browser/components/sessionstore/test/browser_522545.js
@@ -154,26 +154,23 @@ function test() {
function firstLocationChange() {
let state = JSON.parse(ss.getBrowserState());
let hasUTV = state.windows[0].tabs.some(function(aTab) {
return aTab.userTypedValue && aTab.userTypedClear && !aTab.entries.length;
});
ok(hasUTV, "At least one tab has a userTypedValue with userTypedClear with no loaded URL");
- BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(firstLoad);
+ BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager, "SessionStore:update").then(firstLoad);
}
function firstLoad() {
- let state = JSON.parse(ss.getBrowserState());
- let hasSH = state.windows[0].tabs.some(function(aTab) {
- return !("userTypedValue" in aTab) && aTab.entries[0].url;
- });
-
- ok(hasSH, "At least one tab has its entry in SH");
+ let state = JSON.parse(ss.getTabState(gBrowser.selectedTab));
+ let hasSH = !("userTypedValue" in state) && state.entries[0].url;
+ ok(hasSH, "The selected tab has its entry in SH");
runNextTest();
}
gBrowser.loadTabs(uris);
}
// This simulates setting a userTypedValue and ensures that just typing in the
@@ -247,17 +244,25 @@ function test() {
let originalState = JSON.parse(ss.getBrowserState());
let state = {
windows: [{
tabs: [{ entries: [{ url: "about:blank" }] }]
}]
};
function runNextTest() {
if (tests.length) {
- waitForBrowserState(state, tests.shift());
+ waitForBrowserState(state, function() {
+ gBrowser.selectedBrowser.userTypedValue = null;
+ URLBarSetURI();
+ (tests.shift())();
+ });
} else {
- waitForBrowserState(originalState, finish);
+ waitForBrowserState(originalState, function() {
+ gBrowser.selectedBrowser.userTypedValue = null;
+ URLBarSetURI();
+ finish();
+ });
}
}
// Run the tests!
runNextTest();
}