Bug 1270067 - fix browser_bug522545.js to actually test what it intends to test, r=mconley
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 04 May 2016 14:22:01 +0100
changeset 296138 68b0d2af5b6d907bc6efa2e555b674e45200baee
parent 296137 6eb3ce095a70f5a450dc321df946e0054be2bb79
child 296139 8fcd13137658c394a2f7ce497c36e0359c7ee865
push id76214
push usergijskruitbosch@gmail.com
push dateWed, 04 May 2016 21:13:43 +0000
treeherdermozilla-inbound@68b0d2af5b6d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1270067, 522545
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1270067 - fix browser_bug522545.js to actually test what it intends to test, r=mconley MozReview-Commit-ID: IySO69Ic1yT
browser/components/sessionstore/test/browser_522545.js
--- 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();
 }