Bug 1334052 - Fix racy tab switching. r=mrbkap, a=test-only
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Tue, 31 Jan 2017 10:12:55 +0100
changeset 378051 42caf6d5245ff30d0a4bd7249d1d7ebb7044d6c7
parent 378050 2678b49156fb6cc9b7f1cb61e90983b78f2c849a
child 378052 27fed9b44e87b15f4fd76bc1c3db5f954e4a3e55
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap, test-only
bugs1334052
milestone53.0a2
Bug 1334052 - Fix racy tab switching. r=mrbkap, a=test-only
browser/base/content/test/referrer/head.js
--- a/browser/base/content/test/referrer/head.js
+++ b/browser/base/content/test/referrer/head.js
@@ -198,19 +198,20 @@ function doContextMenuCommand(aWindow, a
 function referrerTestCaseLoaded(aTestNumber, aParams) {
   let test = getReferrerTest(aTestNumber);
   let server = rounds == 0 ? REFERRER_POLICYSERVER_URL :
                              REFERRER_POLICYSERVER_URL_ATTRIBUTE;
   let url = test.fromScheme + server +
             "?scheme=" + escape(test.toScheme) +
             "&policy=" + escape(test.policy || "") +
             "&rel=" + escape(test.rel || "");
-  var browser = gTestWindow.gBrowser;
-  browser.selectedTab = browser.addTab(url, aParams);
-  return BrowserTestUtils.browserLoaded(browser.selectedBrowser);
+  let browser = gTestWindow.gBrowser;
+  return BrowserTestUtils.openNewForegroundTab(browser, () => {
+    browser.selectedTab = browser.addTab(url, aParams);
+  });
 }
 
 /**
  * Checks the result of the referrer test, and moves on to the next test.
  * @param aTestNumber The test number - 0, 1, 2, ...
  * @param aNewWindow The new window where the referrer target opened, or null.
  * @param aNewTab The new tab where the referrer target opened, or null.
  * @param aStartTestCase The callback to start the next test, aTestNumber + 1.