Merge mozilla-central to autoland on a CLOSED TREE
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 16 May 2017 15:11:18 +0200
changeset 358603 2cb9844330a3d529b834746eec36784cb1172bad
parent 358602 5f44d08bfcb9b2ba65a672785fe3f2ee7c54456e (current diff)
parent 358573 b9a4a6e2292e923684c2d25b78addaca23c6abd5 (diff)
child 358608 985b3ee939338022ef44028b5251f77af19c3638
push id90353
push userryanvm@gmail.com
push dateWed, 17 May 2017 00:10:47 +0000
treeherdermozilla-inbound@41958333867b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone55.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
Merge mozilla-central to autoland on a CLOSED TREE
--- a/browser/base/content/test/alerts/browser_notification_do_not_disturb.js
+++ b/browser/base/content/test/alerts/browser_notification_do_not_disturb.js
@@ -30,17 +30,17 @@ function test() {
   });
 
   pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
 
   // Make sure that do-not-disturb is not enabled.
   ok(!ALERT_SERVICE.manualDoNotDisturb, "Alert service should not be disabled when test starts");
   ALERT_SERVICE.manualDoNotDisturb = false;
 
-  tab = gBrowser.addTab(notificationURL);
+  tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
   gBrowser.selectedTab = tab;
   tab.linkedBrowser.addEventListener("load", onLoad, true);
 }
 
 function onLoad() {
   tab.linkedBrowser.removeEventListener("load", onLoad, true);
   openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
 }
--- a/browser/base/content/test/alerts/browser_notification_remove_permission.js
+++ b/browser/base/content/test/alerts/browser_notification_remove_permission.js
@@ -12,17 +12,17 @@ function test() {
   registerCleanupFunction(function() {
     pm.remove(makeURI(notificationURL), "desktop-notification");
     gBrowser.removeTab(tab);
     window.restore();
   });
 
   pm.add(makeURI(notificationURL), "desktop-notification", pm.ALLOW_ACTION);
 
-  tab = gBrowser.addTab(notificationURL);
+  tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
   gBrowser.selectedTab = tab;
   tab.linkedBrowser.addEventListener("load", onLoad, true);
 }
 
 function onLoad() {
   tab.linkedBrowser.removeEventListener("load", onLoad, true);
   openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
 }
--- a/browser/base/content/test/captivePortal/browser_captivePortal_certErrorUI.js
+++ b/browser/base/content/test/captivePortal/browser_captivePortal_certErrorUI.js
@@ -20,17 +20,17 @@ add_task(async function checkCaptivePort
 
   info("Waiting for captive portal state to be propagated to the content process.");
   await captivePortalStatePropagated;
 
   // Open a page with a cert error.
   let browser;
   let certErrorLoaded;
   let errorTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    let tab = gBrowser.addTab(BAD_CERT_PAGE);
+    let tab = BrowserTestUtils.addTab(gBrowser, BAD_CERT_PAGE);
     gBrowser.selectedTab = tab;
     browser = gBrowser.selectedBrowser;
     certErrorLoaded = BrowserTestUtils.waitForContentEvent(browser, "DOMContentLoaded");
     return tab;
   }, false);
 
   info("Waiting for cert error page to load.")
   await certErrorLoaded;
--- a/browser/base/content/test/general/browser_aboutCertError.js
+++ b/browser/base/content/test/general/browser_aboutCertError.js
@@ -12,17 +12,17 @@ const BAD_STS_CERT = "https://badchain.i
 const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
 add_task(async function checkReturnToAboutHome() {
   info("Loading a bad cert page directly and making sure 'return to previous page' goes to about:home");
   let browser;
   let certErrorLoaded;
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    gBrowser.selectedTab = gBrowser.addTab(BAD_CERT);
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, BAD_CERT);
     browser = gBrowser.selectedBrowser;
     certErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
   }, false);
 
   info("Loading and waiting for the cert error");
   await certErrorLoaded;
 
   is(browser.webNavigation.canGoBack, false, "!webNavigation.canGoBack");
@@ -121,17 +121,17 @@ add_task(async function checkAppBuildIDI
 
 const PREF_BLOCKLIST_CLOCK_SKEW_SECONDS = "services.blocklist.clock_skew_seconds";
 
 add_task(async function checkWrongSystemTimeWarning() {
   async function setUpPage() {
     let browser;
     let certErrorLoaded;
     await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-      gBrowser.selectedTab = gBrowser.addTab(BAD_CERT);
+      gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, BAD_CERT);
       browser = gBrowser.selectedBrowser;
       certErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
     }, false);
 
     info("Loading and waiting for the cert error");
     await certErrorLoaded;
 
     return await ContentTask.spawn(browser, null, async function() {
@@ -219,17 +219,17 @@ add_task(async function checkWrongSystem
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 add_task(async function checkAdvancedDetails() {
   info("Loading a bad cert page and verifying the main error and advanced details section");
   let browser;
   let certErrorLoaded;
   await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    gBrowser.selectedTab = gBrowser.addTab(BAD_CERT);
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, BAD_CERT);
     browser = gBrowser.selectedBrowser;
     certErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
   }, false);
 
   info("Loading and waiting for the cert error");
   await certErrorLoaded;
 
   let message = await ContentTask.spawn(browser, null, async function() {
@@ -281,17 +281,17 @@ add_task(async function checkAdvancedDet
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 add_task(async function checkAdvancedDetailsForHSTS() {
   info("Loading a bad STS cert page and verifying the advanced details section");
   let browser;
   let certErrorLoaded;
   await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    gBrowser.selectedTab = gBrowser.addTab(BAD_STS_CERT);
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, BAD_STS_CERT);
     browser = gBrowser.selectedBrowser;
     certErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
   }, false);
 
   info("Loading and waiting for the cert error");
   await certErrorLoaded;
 
   let message = await ContentTask.spawn(browser, null, async function() {
@@ -350,17 +350,17 @@ add_task(async function checkAdvancedDet
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 add_task(async function checkUnknownIssuerLearnMoreLink() {
   info("Loading a cert error for self-signed pages and checking the correct link is shown");
   let browser;
   let certErrorLoaded;
   await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    gBrowser.selectedTab = gBrowser.addTab(UNKNOWN_ISSUER);
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, UNKNOWN_ISSUER);
     browser = gBrowser.selectedBrowser;
     certErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
   }, false);
 
   info("Loading and waiting for the cert error");
   await certErrorLoaded;
 
   let href = await ContentTask.spawn(browser, null, async function() {
--- a/browser/base/content/test/general/browser_aboutHealthReport.js
+++ b/browser/base/content/test/general/browser_aboutHealthReport.js
@@ -110,17 +110,17 @@ function test() {
     }
 
     finish();
   })();
 }
 
 function promiseNewTabLoadEvent(aUrl, aEventType = "load") {
   return new Promise(resolve => {
-    let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl);
+    let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, aUrl);
     tab.linkedBrowser.addEventListener(aEventType, function(event) {
       let iframe = tab.linkedBrowser.contentDocument.getElementById("remote-report");
         iframe.addEventListener("load", function frameLoad(e) {
           if (iframe.contentWindow.location.href == "about:blank" ||
               e.target != iframe) {
             return;
           }
           iframe.removeEventListener("load", frameLoad);
--- a/browser/base/content/test/general/browser_aboutNetError.js
+++ b/browser/base/content/test/general/browser_aboutNetError.js
@@ -11,17 +11,17 @@ const LOW_TLS_VERSION = "https://tls1.ex
 const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
 add_task(async function checkReturnToPreviousPage() {
   info("Loading a TLS page that isn't supported, ensure we have a fix button and clicking it then loads the page");
   let browser;
   let pageLoaded;
   await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    gBrowser.selectedTab = gBrowser.addTab(LOW_TLS_VERSION);
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, LOW_TLS_VERSION);
     browser = gBrowser.selectedBrowser;
     pageLoaded = BrowserTestUtils.waitForErrorPage(browser);
   }, false);
 
   info("Loading and waiting for the net error");
   await pageLoaded;
 
   // NB: This code assumes that the error page and the test page load in the
--- a/browser/base/content/test/general/browser_alltabslistener.js
+++ b/browser/base/content/test/general/browser_alltabslistener.js
@@ -82,18 +82,18 @@ var gFrontNotifications, gAllNotificatio
 var gBackgroundTab, gForegroundTab, gBackgroundBrowser, gForegroundBrowser, gTestBrowser;
 var gTestPage = "/browser/browser/base/content/test/general/alltabslistener.html";
 const kBasePage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
 var gNextTest;
 
 function test() {
   waitForExplicitFinish();
 
-  gBackgroundTab = gBrowser.addTab();
-  gForegroundTab = gBrowser.addTab();
+  gBackgroundTab = BrowserTestUtils.addTab(gBrowser);
+  gForegroundTab = BrowserTestUtils.addTab(gBrowser);
   gBackgroundBrowser = gBrowser.getBrowserForTab(gBackgroundTab);
   gForegroundBrowser = gBrowser.getBrowserForTab(gForegroundTab);
   gBrowser.selectedTab = gForegroundTab;
 
   // We must wait until a page has completed loading before
   // starting tests or we get notifications from that
   let promises = [
     waitForDocLoadComplete(gBackgroundBrowser),
--- a/browser/base/content/test/general/browser_bookmark_titles.js
+++ b/browser/base/content/test/general/browser_bookmark_titles.js
@@ -15,17 +15,17 @@ var tests = [
     ["data:application/vnd.mozilla.xul+xml,",
      "data:application/vnd.mozilla.xul+xml,"],
     // about:certerror
     ["https://untrusted.example.com/somepage.html",
      "https://untrusted.example.com/somepage.html"]
 ];
 
 add_task(async function() {
-    gBrowser.selectedTab = gBrowser.addTab();
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
     let browser = gBrowser.selectedBrowser;
     browser.stop(); // stop the about:blank load.
 
     // Test that a bookmark of each URI gets the corresponding default title.
     for (let i = 0; i < tests.length; ++i) {
         let [uri, title] = tests[i];
 
         let promiseLoaded = promisePageLoaded(browser);
--- a/browser/base/content/test/general/browser_bug1015721.js
+++ b/browser/base/content/test/general/browser_bug1015721.js
@@ -6,18 +6,18 @@
 const TEST_PAGE = "http://example.org/browser/browser/base/content/test/general/zoom_test.html";
 
 var gTab1, gTab2, gLevel1;
 
 function test() {
   waitForExplicitFinish();
 
   (async function() {
-    gTab1 = gBrowser.addTab();
-    gTab2 = gBrowser.addTab();
+    gTab1 = BrowserTestUtils.addTab(gBrowser);
+    gTab2 = BrowserTestUtils.addTab(gBrowser);
 
     await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
     await FullZoomHelper.load(gTab1, TEST_PAGE);
     await FullZoomHelper.load(gTab2, TEST_PAGE);
   })().then(zoomTab1, FullZoomHelper.failAndContinue(finish));
 }
 
 function zoomTab1() {
--- a/browser/base/content/test/general/browser_bug380960.js
+++ b/browser/base/content/test/general/browser_bug380960.js
@@ -1,11 +1,11 @@
 function test() {
-  var tab = gBrowser.addTab("about:blank", { skipAnimation: true });
+  var tab = BrowserTestUtils.addTab(gBrowser, "about:blank", { skipAnimation: true });
   gBrowser.removeTab(tab);
   is(tab.parentNode, null, "tab removed immediately");
 
-  tab = gBrowser.addTab("about:blank", { skipAnimation: true });
+  tab = BrowserTestUtils.addTab(gBrowser, "about:blank", { skipAnimation: true });
   gBrowser.removeTab(tab, { animate: true });
   gBrowser.removeTab(tab);
   is(tab.parentNode, null, "tab removed immediately when calling removeTab again after the animation was kicked off");
 }
 
--- a/browser/base/content/test/general/browser_bug386835.js
+++ b/browser/base/content/test/general/browser_bug386835.js
@@ -4,19 +4,19 @@ var gTab1, gTab2, gTab3;
 var gLevel;
 const BACK = 0;
 const FORWARD = 1;
 
 function test() {
   waitForExplicitFinish();
 
   (async function() {
-    gTab1 = gBrowser.addTab(gTestPage);
-    gTab2 = gBrowser.addTab();
-    gTab3 = gBrowser.addTab();
+    gTab1 = BrowserTestUtils.addTab(gBrowser, gTestPage);
+    gTab2 = BrowserTestUtils.addTab(gBrowser);
+    gTab3 = BrowserTestUtils.addTab(gBrowser);
 
     await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
     await FullZoomHelper.load(gTab1, gTestPage);
     await FullZoomHelper.load(gTab2, gTestPage);
   })().then(secondPageLoaded, FullZoomHelper.failAndContinue(finish));
 }
 
 function secondPageLoaded() {
--- a/browser/base/content/test/general/browser_bug406216.js
+++ b/browser/base/content/test/general/browser_bug406216.js
@@ -15,17 +15,17 @@ const URIS = ["about:config",
               "data:text/html,<title>OK</title>"];
 
 function test() {
   waitForExplicitFinish();
   URIS.forEach(addTab);
 }
 
 function addTab(aURI, aIndex) {
-  var tab = gBrowser.addTab(aURI);
+  var tab = BrowserTestUtils.addTab(gBrowser, aURI);
   if (aIndex == 0)
     gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
 
   tab.linkedBrowser.addEventListener("load", function(event) {
     if (++count == URIS.length)
       executeSoon(doTabsTest);
   }, {capture: true, once: true});
 }
@@ -41,12 +41,12 @@ function doTabsTest() {
       if (aTab != closedTab && aTab.linkedBrowser.currentURI.scheme == scheme)
         gBrowser.removeTab(aTab, {skipPermitUnload: true});
     });
   }, {capture: true, once: true});
 
   gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
   is(gBrowser.tabs.length, 1, "Related tabs are not closed unexpectedly");
 
-  gBrowser.addTab("about:blank");
+  BrowserTestUtils.addTab(gBrowser, "about:blank");
   gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
   finish();
 }
--- a/browser/base/content/test/general/browser_bug416661.js
+++ b/browser/base/content/test/general/browser_bug416661.js
@@ -31,13 +31,13 @@ function end_test_prefNotSet() {
     finish();
   })();
 }
 
 function test() {
   waitForExplicitFinish();
 
   (async function() {
-    tabElm = gBrowser.addTab();
+    tabElm = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.selectTabAndWaitForLocationChange(tabElm);
     await FullZoomHelper.load(tabElm, "http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html");
   })().then(start_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
 }
--- a/browser/base/content/test/general/browser_bug419612.js
+++ b/browser/base/content/test/general/browser_bug419612.js
@@ -1,18 +1,18 @@
 function test() {
   waitForExplicitFinish();
 
   (async function() {
     let testPage = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
-    let tab1 = gBrowser.addTab();
+    let tab1 = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
     await FullZoomHelper.load(tab1, testPage);
 
-    let tab2 = gBrowser.addTab();
+    let tab2 = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.load(tab2, testPage);
 
     FullZoom.enlarge();
     let tab1Zoom = ZoomManager.getZoomForBrowser(tab1.linkedBrowser);
 
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab2);
     let tab2Zoom = ZoomManager.getZoomForBrowser(tab2.linkedBrowser);
     is(tab2Zoom, tab1Zoom, "Zoom should affect background tabs");
--- a/browser/base/content/test/general/browser_bug423833.js
+++ b/browser/base/content/test/general/browser_bug423833.js
@@ -10,17 +10,17 @@ var test2tab;
 var test3window;
 
 // We use setInterval instead of setTimeout to avoid race conditions on error doc loads
 var intervalID;
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", test1Setup, true);
   content.location = testPage;
 }
 
 function test1Setup() {
   if (content.frames.length < 2 ||
       content.frames[1].location != invalidPage)
     // The error frame hasn't loaded yet
--- a/browser/base/content/test/general/browser_bug431826.js
+++ b/browser/base/content/test/general/browser_bug431826.js
@@ -1,14 +1,14 @@
 function remote(task) {
   return ContentTask.spawn(gBrowser.selectedBrowser, null, task);
 }
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let promise = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser);
   gBrowser.loadURI("https://nocert.example.com/");
   await promise;
 
   await remote(() => {
     // Confirm that we are displaying the contributed error page, not the default
     let uri = content.document.documentURI;
--- a/browser/base/content/test/general/browser_bug432599.js
+++ b/browser/base/content/test/general/browser_bug432599.js
@@ -38,17 +38,17 @@ function add_bookmark(aURI, aTitle) {
                                               aURI, PlacesUtils.bookmarks.DEFAULT_INDEX,
                                               aTitle);
 }
 
 // test bug 432599
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function() {
     waitForStarChange(false, initTest);
   }, {capture: true, once: true});
 
   content.location = testURL;
 }
 
 function initTest() {
--- a/browser/base/content/test/general/browser_bug435325.js
+++ b/browser/base/content/test/general/browser_bug435325.js
@@ -14,17 +14,17 @@ function test() {
   // Tests always connect to localhost, and per bug 87717, localhost is now
   // reachable in offline mode.  To avoid this, disable any proxy.
   proxyPrefValue = Services.prefs.getIntPref("network.proxy.type");
   Services.prefs.setIntPref("network.proxy.type", 0);
 
   Services.prefs.setBoolPref("browser.cache.disk.enable", false);
   Services.prefs.setBoolPref("browser.cache.memory.enable", false);
 
-  gBrowser.selectedTab = gBrowser.addTab("http://example.com/");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "http://example.com/");
 
   let contentScript = `
     let listener = function () {
       removeEventListener("DOMContentLoaded", listener);
       sendAsyncMessage("Test:DOMContentLoaded", { uri: content.document.documentURI });
     };
     addEventListener("DOMContentLoaded", listener);
   `;
--- a/browser/base/content/test/general/browser_bug441778.js
+++ b/browser/base/content/test/general/browser_bug441778.js
@@ -10,17 +10,17 @@
 function test() {
   waitForExplicitFinish();
 
   const TEST_PAGE_URL = 'data:text/html,<body><iframe src=""></iframe></body>';
   const TEST_IFRAME_URL = "http://test2.example.org/";
 
   (async function() {
     // Prepare the test tab
-    let tab = gBrowser.addTab();
+    let tab = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
 
     let testBrowser = tab.linkedBrowser;
 
     await FullZoomHelper.load(tab, TEST_PAGE_URL);
 
     // Change the zoom level and then save it so we can compare it to the level
     // after loading the sub-document.
--- a/browser/base/content/test/general/browser_bug462289.js
+++ b/browser/base/content/test/general/browser_bug462289.js
@@ -6,18 +6,18 @@ function focus_in_navbar() {
     parent = parent.parentNode;
 
   return parent != null;
 }
 
 function test() {
   waitForExplicitFinish();
 
-  tab1 = gBrowser.addTab("about:blank", {skipAnimation: true});
-  tab2 = gBrowser.addTab("about:blank", {skipAnimation: true});
+  tab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
+  tab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
 
   EventUtils.synthesizeMouseAtCenter(tab1, {});
   executeSoon(step2);
 }
 
 function step2() {
   is(gBrowser.selectedTab, tab1, "1st click on tab1 selects tab");
   isnot(document.activeElement, tab1, "1st click on tab1 does not activate tab");
--- a/browser/base/content/test/general/browser_bug477014.js
+++ b/browser/base/content/test/general/browser_bug477014.js
@@ -2,17 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // That's a gecko!
 const iconURLSpec = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==";
 var testPage = "data:text/plain,test bug 477014";
 
 add_task(async function() {
-  let tabToDetach = gBrowser.addTab(testPage);
+  let tabToDetach = BrowserTestUtils.addTab(gBrowser, testPage);
   await waitForDocLoadComplete(tabToDetach.linkedBrowser);
 
   gBrowser.setIcon(tabToDetach, iconURLSpec,
                    Services.scriptSecurityManager.getSystemPrincipal());
   tabToDetach.setAttribute("busy", "true");
 
   // detach and set the listener on the new window
   let newWindow = gBrowser.replaceTabWithWindow(tabToDetach);
--- a/browser/base/content/test/general/browser_bug479408.js
+++ b/browser/base/content/test/general/browser_bug479408.js
@@ -1,11 +1,11 @@
 function test() {
   waitForExplicitFinish();
-  let tab = gBrowser.selectedTab = gBrowser.addTab(
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser,
     "http://mochi.test:8888/browser/browser/base/content/test/general/browser_bug479408_sample.html");
 
   gBrowser.addEventListener("DOMLinkAdded", function(aEvent) {
     executeSoon(function() {
       ok(!tab.linkedBrowser.engines,
          "the subframe's search engine wasn't detected");
 
       gBrowser.removeTab(tab);
--- a/browser/base/content/test/general/browser_bug491431.js
+++ b/browser/base/content/test/general/browser_bug491431.js
@@ -5,22 +5,22 @@
 var testPage = "data:text/plain,test bug 491431 Page";
 
 function test() {
   waitForExplicitFinish();
 
   let newWin, tabA, tabB;
 
   // test normal close
-  tabA = gBrowser.addTab(testPage);
+  tabA = BrowserTestUtils.addTab(gBrowser, testPage);
   gBrowser.tabContainer.addEventListener("TabClose", function(firstTabCloseEvent) {
     ok(!firstTabCloseEvent.detail.adoptedBy, "This was a normal tab close");
 
     // test tab close by moving
-    tabB = gBrowser.addTab(testPage);
+    tabB = BrowserTestUtils.addTab(gBrowser, testPage);
     gBrowser.tabContainer.addEventListener("TabClose", function(secondTabCloseEvent) {
       executeSoon(function() {
         ok(secondTabCloseEvent.detail.adoptedBy, "This was a tab closed by moving");
 
         // cleanup
         newWin.close();
         executeSoon(finish);
       });
--- a/browser/base/content/test/general/browser_bug495058.js
+++ b/browser/base/content/test/general/browser_bug495058.js
@@ -6,17 +6,17 @@
 const URIS = [
   "about:blank",
   "about:sessionrestore",
   "about:privatebrowsing",
 ];
 
 add_task(async function() {
   for (let uri of URIS) {
-    let tab = gBrowser.addTab();
+    let tab = BrowserTestUtils.addTab(gBrowser);
     await BrowserTestUtils.loadURI(tab.linkedBrowser, uri);
 
     let win = gBrowser.replaceTabWithWindow(tab);
     await TestUtils.topicObserved("browser-delayed-startup-finished",
                                   subject => subject == win);
     tab = win.gBrowser.selectedTab;
 
     // BrowserTestUtils doesn't get the add-on shims, which means that
--- a/browser/base/content/test/general/browser_bug521216.js
+++ b/browser/base/content/test/general/browser_bug521216.js
@@ -3,17 +3,17 @@ var actual = [];
 var tabIndex = -1;
 this.__defineGetter__("tab", () => gBrowser.tabs[tabIndex]);
 
 function test() {
   waitForExplicitFinish();
   tabIndex = gBrowser.tabs.length;
   gBrowser.addTabsProgressListener(progressListener);
   gBrowser.tabContainer.addEventListener("TabOpen", TabOpen);
-  gBrowser.addTab("data:text/html,<html><head><link href='about:logo' rel='shortcut icon'>");
+  BrowserTestUtils.addTab(gBrowser, "data:text/html,<html><head><link href='about:logo' rel='shortcut icon'>");
 }
 
 function record(aName) {
   info("got " + aName);
   if (actual.indexOf(aName) == -1)
     actual.push(aName);
   if (actual.length == expected.length) {
     is(actual.toString(), expected.toString(),
--- a/browser/base/content/test/general/browser_bug533232.js
+++ b/browser/base/content/test/general/browser_bug533232.js
@@ -1,30 +1,30 @@
 function test() {
   var tab1 = gBrowser.selectedTab;
-  var tab2 = gBrowser.addTab();
+  var tab2 = BrowserTestUtils.addTab(gBrowser);
   var childTab1;
   var childTab2;
 
-  childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
+  childTab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", { relatedToCurrent: true });
   gBrowser.selectedTab = childTab1;
   gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true });
   is(idx(gBrowser.selectedTab), idx(tab1),
      "closing a tab next to its parent selects the parent");
 
-  childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
+  childTab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", { relatedToCurrent: true });
   gBrowser.selectedTab = tab2;
   gBrowser.selectedTab = childTab1;
   gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true });
   is(idx(gBrowser.selectedTab), idx(tab2),
      "closing a tab next to its parent doesn't select the parent if another tab had been selected ad interim");
 
   gBrowser.selectedTab = tab1;
-  childTab1 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
-  childTab2 = gBrowser.addTab("about:blank", { relatedToCurrent: true });
+  childTab1 = BrowserTestUtils.addTab(gBrowser, "about:blank", { relatedToCurrent: true });
+  childTab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", { relatedToCurrent: true });
   gBrowser.selectedTab = childTab1;
   gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true });
   is(idx(gBrowser.selectedTab), idx(childTab2),
      "closing a tab next to its parent selects the next tab with the same parent");
   gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true });
   is(idx(gBrowser.selectedTab), idx(tab2),
      "closing the last tab in a set of child tabs doesn't go back to the parent");
 
--- a/browser/base/content/test/general/browser_bug537013.js
+++ b/browser/base/content/test/general/browser_bug537013.js
@@ -10,18 +10,18 @@ var texts = [
   "Klein bottle for sale. Inquire within.",
   "To err is human; to forgive is not company policy."
 ];
 
 var Clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
 var HasFindClipboard = Clipboard.supportsFindClipboard();
 
 function addTabWithText(aText, aCallback) {
-  let newTab = gBrowser.addTab("data:text/html;charset=utf-8,<h1 id='h1'>" +
-                               aText + "</h1>");
+  let newTab = BrowserTestUtils.addTab(gBrowser, "data:text/html;charset=utf-8,<h1 id='h1'>" +
+                                       aText + "</h1>");
   tabs.push(newTab);
   gBrowser.selectedTab = newTab;
 }
 
 function setFindString(aString) {
   gFindBar.open();
   gFindBar._findField.focus();
   gFindBar._findField.select();
--- a/browser/base/content/test/general/browser_bug553455.js
+++ b/browser/base/content/test/general/browser_bug553455.js
@@ -432,17 +432,17 @@ function test_restartless() {
     let pm = Services.perms;
     pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
 
     let progressPromise = waitForProgressNotification();
     let dialogPromise = waitForInstallDialog();
     let triggers = encodeURIComponent(JSON.stringify({
       "XPI": "restartless.xpi"
     }));
-    gBrowser.selectedTab = gBrowser.addTab();
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
     gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
     await progressPromise;
     let installDialog = await dialogPromise;
 
     let notificationPromise = waitForNotification("addon-installed");
     acceptInstallDialog(installDialog);
     await notificationPromise;
 
@@ -585,17 +585,17 @@ function test_allUnverified() {
     await removeTab();
   })();
 },
 
 function test_url() {
   return (async function() {
     let progressPromise = waitForProgressNotification();
     let dialogPromise = waitForInstallDialog();
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     gBrowser.loadURI(TESTROOT + "amosigned.xpi");
     await progressPromise;
     let installDialog = await dialogPromise;
 
     let notificationPromise = waitForNotification("addon-install-restart");
     acceptInstallDialog(installDialog);
     let panel = await notificationPromise;
@@ -626,17 +626,17 @@ function test_localFile() {
     }
 
     let failPromise = new Promise(resolve => {
       Services.obs.addObserver(function observer() {
         Services.obs.removeObserver(observer, "addon-install-failed");
         resolve();
       }, "addon-install-failed");
     });
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     gBrowser.loadURI(path);
     await failPromise;
 
     // Wait for the browser code to add the failure notification
     await waitForSingleNotification();
 
     let notification = PopupNotifications.panel.childNodes[0];
@@ -653,17 +653,17 @@ function test_tabClose() {
   return (async function() {
     if (!Preferences.get("xpinstall.customConfirmationUI", false)) {
       info("Test skipped due to xpinstall.customConfirmationUI being false.");
       return;
     }
 
     let progressPromise = waitForProgressNotification();
     let dialogPromise = waitForInstallDialog();
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     gBrowser.loadURI(TESTROOT + "amosigned.xpi");
     await progressPromise;
     await dialogPromise;
 
     let installs = await getInstalls();
     is(installs.length, 1, "Should be one pending install");
 
@@ -709,17 +709,17 @@ function test_tabNavigate() {
   })();
 },
 
 function test_urlBar() {
   return (async function() {
     let progressPromise = waitForProgressNotification();
     let dialogPromise = waitForInstallDialog();
 
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     gURLBar.value = TESTROOT + "amosigned.xpi";
     gURLBar.focus();
     EventUtils.synthesizeKey("VK_RETURN", {});
 
     await progressPromise;
     let installDialog = await dialogPromise;
 
@@ -739,17 +739,17 @@ function test_urlBar() {
 
     await removeTab();
   })();
 },
 
 function test_wrongHost() {
   return (async function() {
     let requestedUrl = TESTROOT2 + "enabled.html";
-    gBrowser.selectedTab = gBrowser.addTab();
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
     let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, requestedUrl);
     gBrowser.loadURI(TESTROOT2 + "enabled.html");
     await loadedPromise;
 
     let progressPromise = waitForProgressNotification();
     let notificationPromise = waitForNotification("addon-install-failed");
     gBrowser.loadURI(TESTROOT + "corrupt.xpi");
--- a/browser/base/content/test/general/browser_bug555224.js
+++ b/browser/base/content/test/general/browser_bug555224.js
@@ -19,22 +19,22 @@ function testBackgroundLoad() {
 function testInitialZoom() {
   (async function() {
     is(ZoomManager.zoom, 1, "initial zoom level should be 1");
     FullZoom.enlarge();
 
     gTestZoom = ZoomManager.zoom;
     isnot(gTestZoom, 1, "zoom level should have changed");
 
-    gBgTab = gBrowser.addTab();
+    gBgTab = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.load(gBgTab, "http://mochi.test:8888" + TEST_PAGE);
   })().then(testBackgroundLoad, FullZoomHelper.failAndContinue(finish));
 }
 
 function test() {
   waitForExplicitFinish();
 
   (async function() {
-    gTestTab = gBrowser.addTab();
+    gTestTab = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.selectTabAndWaitForLocationChange(gTestTab);
     await FullZoomHelper.load(gTestTab, "http://example.org" + TEST_PAGE);
   })().then(testInitialZoom, FullZoomHelper.failAndContinue(finish));
 }
--- a/browser/base/content/test/general/browser_bug555767.js
+++ b/browser/base/content/test/general/browser_bug555767.js
@@ -2,25 +2,25 @@
      * License, v. 2.0. If a copy of the MPL was not distributed with this
      * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
     add_task(async function() {
       let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
       let tabSelected = false;
 
       // Open the base tab
-      let baseTab = gBrowser.addTab(testURL);
+      let baseTab = BrowserTestUtils.addTab(gBrowser, testURL);
 
       // Wait for the tab to be fully loaded so matching happens correctly
       await promiseTabLoaded(baseTab);
       if (baseTab.linkedBrowser.currentURI.spec == "about:blank")
         return;
       baseTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
 
-      let testTab = gBrowser.addTab();
+      let testTab = BrowserTestUtils.addTab(gBrowser);
 
       // Select the testTab
       gBrowser.selectedTab = testTab;
 
       // Set the urlbar to include the moz-action
       gURLBar.value = "moz-action:switchtab," + JSON.stringify({url: testURL});
       // Focus the urlbar so we can press enter
       gURLBar.focus();
--- a/browser/base/content/test/general/browser_bug559991.js
+++ b/browser/base/content/test/general/browser_bug559991.js
@@ -8,17 +8,17 @@ function test() {
   waitForExplicitFinish();
 
   gPrefService.setBoolPref("browser.zoom.updateBackgroundTabs", true);
   gPrefService.setBoolPref("browser.zoom.siteSpecific", true);
 
   let uri = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
 
   (async function() {
-    tab = gBrowser.addTab();
+    tab = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.load(tab, uri);
 
     // -------------------------------------------------------------------
     // Test - Trigger a tab switch that should update the zoom level
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
     ok(true, "applyPrefToSetting was called");
   })().then(endTest, FullZoomHelper.failAndContinue(endTest));
 }
--- a/browser/base/content/test/general/browser_bug561636.js
+++ b/browser/base/content/test/general/browser_bug561636.js
@@ -35,17 +35,17 @@ function getDocFooter() {
 }
 
 function getEmptyFrame() {
   return "<iframe style='width:100px; height:30px; margin:3px; border:1px solid lightgray;' " +
          "name='t' srcdoc=\"<html><head><meta charset='utf-8'></head><body>form target</body></html>\"></iframe>";
 }
 
 async function openNewTab(uri, background) {
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.getBrowserForTab(tab);
   if (!background) {
     gBrowser.selectedTab = tab;
   }
   await promiseTabLoadEvent(tab, "data:text/html," + escape(uri));
   return browser;
 }
 
--- a/browser/base/content/test/general/browser_bug563588.js
+++ b/browser/base/content/test/general/browser_bug563588.js
@@ -5,18 +5,18 @@ function press(key, expectedPos) {
      "accel+" + key + " doesn't change which tab is selected");
   is(gBrowser.tabContainer.selectedIndex, expectedPos,
      "accel+" + key + " moves the tab to the expected position");
   is(document.activeElement, gBrowser.selectedTab,
      "accel+" + key + " leaves the selected tab focused");
 }
 
 function test() {
-  gBrowser.addTab();
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
   is(gBrowser.tabs.length, 3, "got three tabs");
   is(gBrowser.tabs[0], gBrowser.selectedTab, "first tab is selected");
 
   gBrowser.selectedTab.focus();
   is(document.activeElement, gBrowser.selectedTab, "selected tab is focused");
 
   press("right", 1);
   press("down", 2);
--- a/browser/base/content/test/general/browser_bug575561.js
+++ b/browser/base/content/test/general/browser_bug575561.js
@@ -59,17 +59,17 @@ var waitForTabOpen = async function() {
 
   await waitForDocLoadComplete(event.target.linkedBrowser);
   await Promise.resolve();
 
   gBrowser.removeCurrentTab();
 };
 
 var testLink = async function(aLinkIndexOrFunction, pinTab, expectNewTab, testSubFrame, aURL = TEST_URL) {
-  let appTab = gBrowser.addTab(aURL, {skipAnimation: true});
+  let appTab = BrowserTestUtils.addTab(gBrowser, aURL, {skipAnimation: true});
   if (pinTab)
     gBrowser.pinTab(appTab);
   gBrowser.selectedTab = appTab;
 
   await waitForDocLoadComplete();
 
   let browser = appTab.linkedBrowser;
   if (testSubFrame)
--- a/browser/base/content/test/general/browser_bug575830.js
+++ b/browser/base/content/test/general/browser_bug575830.js
@@ -5,18 +5,18 @@
 
 function test() {
   let tab1, tab2;
   const TEST_IMAGE = "http://example.org/browser/browser/base/content/test/general/moz.png";
 
   waitForExplicitFinish();
 
   (async function() {
-    tab1 = gBrowser.addTab();
-    tab2 = gBrowser.addTab();
+    tab1 = BrowserTestUtils.addTab(gBrowser);
+    tab2 = BrowserTestUtils.addTab(gBrowser);
     await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
     await FullZoomHelper.load(tab1, TEST_IMAGE);
 
     is(ZoomManager.zoom, 1, "initial zoom level for first should be 1");
 
     FullZoom.enlarge();
     let zoom = ZoomManager.zoom;
     isnot(zoom, 1, "zoom level should have changed");
--- a/browser/base/content/test/general/browser_bug577121.js
+++ b/browser/base/content/test/general/browser_bug577121.js
@@ -5,18 +5,18 @@
 function test() {
   Services.prefs.setBoolPref("toolkit.cosmeticAnimations.enabled", false);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("toolkit.cosmeticAnimations.enabled");
   });
 
   // Open 2 other tabs, and pin the second one. Like that, the initial tab
   // should get closed.
-  let testTab1 = gBrowser.addTab();
-  let testTab2 = gBrowser.addTab();
+  let testTab1 = BrowserTestUtils.addTab(gBrowser);
+  let testTab2 = BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(testTab2);
 
   // Now execute "Close other Tabs" on the first manually opened tab (tab1).
   // -> tab2 ist pinned, tab1 should remain open and the initial tab should
   // get closed.
   gBrowser.removeAllTabsBut(testTab1);
 
   is(gBrowser.tabs.length, 2, "there are two remaining tabs open");
--- a/browser/base/content/test/general/browser_bug579872.js
+++ b/browser/base/content/test/general/browser_bug579872.js
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   waitForExplicitFinish();
   BrowserTestUtils.browserLoaded(newTab.linkedBrowser).then(mainPart);
 
   function mainPart() {
     gBrowser.pinTab(newTab);
     gBrowser.selectedTab = newTab;
 
     openUILinkIn("javascript:var x=0;", "current");
--- a/browser/base/content/test/general/browser_bug580638.js
+++ b/browser/base/content/test/general/browser_bug580638.js
@@ -23,17 +23,17 @@ function test() {
     }
   }
 
   let lastSelectedTab = gBrowser.selectedTab;
   ok(!lastSelectedTab.pinned, "We should have started with a regular tab selected");
 
   testState(false);
 
-  let pinnedTab = gBrowser.addTab("about:blank");
+  let pinnedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   gBrowser.pinTab(pinnedTab);
 
   // Just pinning the tab shouldn't change the key state.
   testState(false);
 
   // Test updating key state after selecting a tab.
   gBrowser.selectedTab = pinnedTab;
   testState(true);
--- a/browser/base/content/test/general/browser_bug580956.js
+++ b/browser/base/content/test/general/browser_bug580956.js
@@ -10,17 +10,17 @@ function isUndoCloseEnabled() {
 function test() {
   waitForExplicitFinish();
 
   gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", 0);
   gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
   is(numClosedTabs(), 0, "There should be 0 closed tabs.");
   ok(!isUndoCloseEnabled(), "Undo Close Tab should be disabled.");
 
-  var tab = gBrowser.addTab("http://mochi.test:8888/");
+  var tab = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/");
   var browser = gBrowser.getBrowserForTab(tab);
   BrowserTestUtils.browserLoaded(browser).then(() => {
     BrowserTestUtils.removeTab(tab).then(() => {
       ok(isUndoCloseEnabled(), "Undo Close Tab should be enabled.");
       finish();
     });
   });
 }
--- a/browser/base/content/test/general/browser_bug581242.js
+++ b/browser/base/content/test/general/browser_bug581242.js
@@ -1,15 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
   // Create a new tab and load about:addons
-  let blanktab = gBrowser.addTab();
+  let blanktab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = blanktab;
   BrowserOpenAddonsMgr();
 
   is(blanktab, gBrowser.selectedTab, "Current tab should be blank tab");
   // Verify that about:addons loads
   waitForExplicitFinish();
   gBrowser.selectedBrowser.addEventListener("load", function() {
     let browser = blanktab.linkedBrowser;
--- a/browser/base/content/test/general/browser_bug581253.js
+++ b/browser/base/content/test/general/browser_bug581253.js
@@ -10,17 +10,17 @@ function test() {
   registerCleanupFunction(function() {
     PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
     if (timerID > 0) {
       clearTimeout(timerID);
     }
   });
   waitForExplicitFinish();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   tab.linkedBrowser.addEventListener("load", (function(event) {
     let uri = makeURI(testURL);
     let bmTxn =
       new PlacesCreateBookmarkTransaction(uri,
                                           PlacesUtils.unfiledBookmarksFolderId,
                                           -1, "", null, []);
     PlacesUtils.transactionManager.doTransaction(bmTxn);
 
--- a/browser/base/content/test/general/browser_bug585785.js
+++ b/browser/base/content/test/general/browser_bug585785.js
@@ -1,14 +1,14 @@
 var tab;
 
 function test() {
   waitForExplicitFinish();
 
-  tab = gBrowser.addTab();
+  tab = BrowserTestUtils.addTab(gBrowser);
   isnot(tab.getAttribute("fadein"), "true", "newly opened tab is yet to fade in");
 
   // Try to remove the tab right before the opening animation's first frame
   window.requestAnimationFrame(checkAnimationState);
 }
 
 function checkAnimationState() {
   is(tab.getAttribute("fadein"), "true", "tab opening animation initiated");
--- a/browser/base/content/test/general/browser_bug585830.js
+++ b/browser/base/content/test/general/browser_bug585830.js
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
   let tab1 = gBrowser.selectedTab;
-  let tab2 = gBrowser.addTab("about:blank", {skipAnimation: true});
-  gBrowser.addTab();
+  let tab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
+  BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab2;
 
   gBrowser.removeCurrentTab({animate: true});
   gBrowser.tabContainer.advanceSelectedTab(-1, true);
   is(gBrowser.selectedTab, tab1, "First tab should be selected");
   gBrowser.removeTab(tab2);
 
   // test for "null has no properties" fix. See Bug 585830 Comment 13
--- a/browser/base/content/test/general/browser_bug592338.js
+++ b/browser/base/content/test/general/browser_bug592338.js
@@ -35,17 +35,17 @@ function promisePopupNotificationShown(n
 
 var TESTS = [
 function test_install_http() {
   is(LightweightThemeManager.currentTheme, null, "Should be no lightweight theme selected");
 
   var pm = Services.perms;
   pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION);
 
-  gBrowser.selectedTab = gBrowser.addTab("http://example.org/browser/browser/base/content/test/general/bug592338.html");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "http://example.org/browser/browser/base/content/test/general/bug592338.html");
   gBrowser.selectedBrowser.addEventListener("pageshow", function() {
     if (gBrowser.contentDocument.location.href == "about:blank")
       return;
 
     gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee);
 
     executeSoon(function() {
       BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser);
@@ -62,17 +62,17 @@ function test_install_http() {
 },
 
 function test_install_lwtheme() {
   is(LightweightThemeManager.currentTheme, null, "Should be no lightweight theme selected");
 
   var pm = Services.perms;
   pm.add(makeURI("https://example.com/"), "install", pm.ALLOW_ACTION);
 
-  gBrowser.selectedTab = gBrowser.addTab("https://example.com/browser/browser/base/content/test/general/bug592338.html");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "https://example.com/browser/browser/base/content/test/general/bug592338.html");
   gBrowser.selectedBrowser.addEventListener("pageshow", function() {
     if (gBrowser.contentDocument.location.href == "about:blank")
       return;
 
     gBrowser.selectedBrowser.removeEventListener("pageshow", arguments.callee);
 
     let promise = promisePopupNotificationShown("addon-installed");
     BrowserTestUtils.synthesizeMouse("#theme-install", 2, 2, {}, gBrowser.selectedBrowser);
--- a/browser/base/content/test/general/browser_bug594131.js
+++ b/browser/base/content/test/general/browser_bug594131.js
@@ -1,14 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
-  let newTab = gBrowser.addTab("http://example.com");
+  let newTab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
   waitForExplicitFinish();
   BrowserTestUtils.browserLoaded(newTab.linkedBrowser).then(mainPart);
 
   function mainPart() {
     gBrowser.pinTab(newTab);
     gBrowser.selectedTab = newTab;
 
     openUILinkIn("http://example.org/", "current", { inBackground: true });
--- a/browser/base/content/test/general/browser_bug595507.js
+++ b/browser/base/content/test/general/browser_bug595507.js
@@ -3,17 +3,17 @@
  */
 add_task(async function() {
   let uri = "<iframe src=\"data:text/html,<iframe name='t'></iframe><form target='t' action='data:text/html,'><input required id='i'><input id='s' type='submit'></form>\"</iframe>";
 
   var gInvalidFormPopup = document.getElementById("invalid-form-popup");
   ok(gInvalidFormPopup,
      "The browser should have a popup to show when a form is invalid");
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.getBrowserForTab(tab);
   gBrowser.selectedTab = tab;
 
   await promiseTabLoadEvent(tab, "data:text/html," + escape(uri));
 
   let popupShownPromise = promiseWaitForEvent(gInvalidFormPopup, "popupshown");
 
   await ContentTask.spawn(browser, {}, async function() {
--- a/browser/base/content/test/general/browser_bug624734.js
+++ b/browser/base/content/test/general/browser_bug624734.js
@@ -11,17 +11,17 @@ function finishTest() {
 
   gBrowser.removeCurrentTab();
   finish();
 }
 
 function test() {
   waitForExplicitFinish();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING) {
       waitForCondition(() => BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING, finishTest, "BookmarkingUI was updating for too long");
     } else {
       finishTest();
     }
   });
 
--- a/browser/base/content/test/general/browser_bug655584.js
+++ b/browser/base/content/test/general/browser_bug655584.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Bug 655584 - awesomebar suggestions don't update after tab is closed
 
 add_task(async function() {
-  var tab1 = gBrowser.addTab();
-  var tab2 = gBrowser.addTab();
+  var tab1 = BrowserTestUtils.addTab(gBrowser);
+  var tab2 = BrowserTestUtils.addTab(gBrowser);
 
   // When urlbar in a new tab is focused, and a tab switch occurs,
   // the urlbar popup should be closed
   await BrowserTestUtils.switchTab(gBrowser, tab2);
   gURLBar.focus(); // focus the urlbar in the tab we will switch to
   await BrowserTestUtils.switchTab(gBrowser, tab1);
   gURLBar.openPopup();
   await BrowserTestUtils.switchTab(gBrowser, tab2);
--- a/browser/base/content/test/general/browser_bug664672.js
+++ b/browser/base/content/test/general/browser_bug664672.js
@@ -1,12 +1,12 @@
 function test() {
   waitForExplicitFinish();
 
-  var tab = gBrowser.addTab();
+  var tab = BrowserTestUtils.addTab(gBrowser);
 
   tab.addEventListener("TabClose", function() {
     ok(tab.linkedBrowser, "linkedBrowser should still exist during the TabClose event");
 
     executeSoon(function() {
       ok(!tab.linkedBrowser, "linkedBrowser should be gone after the TabClose event");
 
       finish();
--- a/browser/base/content/test/general/browser_bug678392.js
+++ b/browser/base/content/test/general/browser_bug678392.js
@@ -155,17 +155,17 @@ function test2() {
   // Test growing of snapshot array across tabs.
   let tab = gBrowser.selectedTab;
 
   load(tab, HTTPROOT + "browser_bug678392-1.html", function() {
     load(tab, HTTPROOT + "browser_bug678392-2.html", function() {
       is(gHistorySwipeAnimation._trackedSnapshots.length, 2, "Length of " +
          "snapshot array is equal to 2 after loading two pages");
       let prevTab = tab;
-      tab = gBrowser.addTab("about:newtab");
+      tab = BrowserTestUtils.addTab(gBrowser, "about:newtab");
       gBrowser.selectedTab = tab;
       load(tab, HTTPROOT + "browser_bug678392-2.html" /* initial page */,
            function() {
         load(tab, HTTPROOT + "browser_bug678392-1.html", function() {
           load(tab, HTTPROOT + "browser_bug678392-2.html", function() {
             is(gHistorySwipeAnimation._trackedSnapshots.length, 4, "Length " +
                "of snapshot array is equal to 4 after loading two pages in " +
                "two tabs each.");
--- a/browser/base/content/test/general/browser_bug719271.js
+++ b/browser/base/content/test/general/browser_bug719271.js
@@ -7,18 +7,18 @@ const TEST_PAGE = "http://example.org/br
 const TEST_VIDEO = "http://example.org/browser/browser/base/content/test/general/video.ogg";
 
 var gTab1, gTab2, gLevel1;
 
 function test() {
   waitForExplicitFinish();
 
   (async function() {
-    gTab1 = gBrowser.addTab();
-    gTab2 = gBrowser.addTab();
+    gTab1 = BrowserTestUtils.addTab(gBrowser);
+    gTab2 = BrowserTestUtils.addTab(gBrowser);
 
     await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
     await FullZoomHelper.load(gTab1, TEST_PAGE);
     await FullZoomHelper.load(gTab2, TEST_VIDEO);
   })().then(zoomTab1, FullZoomHelper.failAndContinue(finish));
 }
 
 function zoomTab1() {
--- a/browser/base/content/test/general/browser_bug749738.js
+++ b/browser/base/content/test/general/browser_bug749738.js
@@ -4,17 +4,17 @@
 
 "use strict";
 
 const DUMMY_PAGE = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
 
 function test() {
   waitForExplicitFinish();
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab;
 
   BrowserTestUtils.loadURI(tab.linkedBrowser, DUMMY_PAGE);
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     gFindBar.onFindCommand();
     EventUtils.sendString("Dummy");
     gBrowser.removeTab(tab);
 
--- a/browser/base/content/test/general/browser_bug817947.js
+++ b/browser/base/content/test/general/browser_bug817947.js
@@ -26,23 +26,23 @@ function test() {
         win.close();
         finish();
       });
     });
   });
 }
 
 function preparePendingTab(aCallback) {
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
 
   whenLoaded(tab.linkedBrowser, function() {
     BrowserTestUtils.removeTab(tab).then(() => {
       let [{state}] = JSON.parse(SessionStore.getClosedTabData(window));
 
-      tab = gBrowser.addTab("about:blank");
+      tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
       whenLoaded(tab.linkedBrowser, function() {
         SessionStore.setTabState(tab, JSON.stringify(state));
         ok(tab.hasAttribute("pending"), "tab should be pending");
         aCallback(tab);
       });
     });
   });
 }
--- a/browser/base/content/test/general/browser_clipboard.js
+++ b/browser/base/content/test/general/browser_clipboard.js
@@ -2,17 +2,17 @@
 // types (html and images) are copied to and pasted from the clipboard properly.
 
 var testPage = "<body style='margin: 0'>" +
                "  <img id='img' tabindex='1' src='http://example.org/browser/browser/base/content/test/general/moz.png'>" +
                "  <div id='main' contenteditable='true'>Test <b>Bold</b> After Text</div>" +
                "</body>";
 
 add_task(async function() {
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.getBrowserForTab(tab);
 
   gBrowser.selectedTab = tab;
 
   await promiseTabLoadEvent(tab, "data:text/html," + escape(testPage));
   await SimpleTest.promiseFocus(browser.contentWindowAsCPOW);
 
   const modifier = (navigator.platform.indexOf("Mac") >= 0) ?
--- a/browser/base/content/test/general/browser_ctrlTab.js
+++ b/browser/base/content/test/general/browser_ctrlTab.js
@@ -1,14 +1,14 @@
 add_task(async function() {
   gPrefService.setBoolPref("browser.ctrlTab.previews", true);
 
-  gBrowser.addTab();
-  gBrowser.addTab();
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
 
   checkTabs(4);
 
   await ctrlTabTest([2], 1, 0);
   await ctrlTabTest([2, 3, 1], 2, 2);
   await ctrlTabTest([], 4, 2);
 
   {
@@ -32,17 +32,17 @@ add_task(async function() {
     let tabs = gBrowser.tabs.length;
     await pressCtrlTab();
     await pressCtrlTab(true);
     await synthesizeCtrlW();
     is(gBrowser.tabs.length, tabs - 1, "Ctrl+Tab -> Ctrl+W removes the selected tab");
     await releaseCtrl();
   }
 
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
   checkTabs(3);
   await ctrlTabTest([2, 1, 0], 7, 1);
 
   { // test for bug 1292049
     let tabToClose = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:buildconfig");
     checkTabs(4);
     selectTabs([0, 1, 2, 3]);
 
--- a/browser/base/content/test/general/browser_discovery.js
+++ b/browser/base/content/test/general/browser_discovery.js
@@ -8,17 +8,17 @@ function setHandlerFunc(aResultFunc) {
   gBrowser.addEventListener("DOMLinkAdded", function(event) {
     executeSoon(aResultFunc);
   }, {once: true});
 }
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   browser = gBrowser.selectedBrowser;
   browser.addEventListener("load", function(event) {
     iconDiscovery();
   }, {capture: true, once: true});
   var rootDir = getRootDirectory(gTestPath);
   content.location = rootDir + "discovery.html";
 }
 
--- a/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js
+++ b/browser/base/content/test/general/browser_domFullscreen_fullscreenMode.js
@@ -141,17 +141,17 @@ function checkState(expectedStates, cont
 const kPage = "http://example.org/browser/browser/" +
               "base/content/test/general/dummy_page.html";
 
 add_task(async function() {
   await pushPrefs(
     ["full-screen-api.transition-duration.enter", "0 0"],
     ["full-screen-api.transition-duration.leave", "0 0"]);
 
-  let tab = gBrowser.addTab(kPage);
+  let tab = BrowserTestUtils.addTab(gBrowser, kPage);
   let browser = tab.linkedBrowser;
   gBrowser.selectedTab = tab;
   await waitForDocLoadComplete();
 
   registerCleanupFunction(() => {
     if (browser.contentWindow.fullScreen) {
       BrowserFullScreen();
     }
--- a/browser/base/content/test/general/browser_double_close_tab.js
+++ b/browser/base/content/test/general/browser_double_close_tab.js
@@ -32,17 +32,17 @@ function waitForDialogDestroyed(node, ca
     clearTimeout(failureTimeout);
     observer.disconnect();
     observer = null;
     callback();
   }
 }
 
 add_task(async function() {
-  testTab = gBrowser.selectedTab = gBrowser.addTab();
+  testTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   await promiseTabLoadEvent(testTab, TEST_PAGE);
   // XXXgijs the reason this has nesting and callbacks rather than promises is
   // that DOM promises resolve on the next tick. So they're scheduled
   // in an event queue. So when we spin a new event queue for a modal dialog...
   // everything gets messed up and the promise's .then callbacks never get
   // called, despite resolve() being called just fine.
   await new Promise(resolveOuter => {
     waitForDialog(dialogNode => {
--- a/browser/base/content/test/general/browser_drag.js
+++ b/browser/base/content/test/general/browser_drag.js
@@ -26,17 +26,17 @@ function test() {
   var dt = EventUtils.synthesizeDragStart(document.getElementById("identity-box"), expected);
   is(dt, null, "drag on proxy icon");
   gURLBar.setAttribute("pageproxystate", oldstate);
   // Now, the identity information panel is opened by the proxy icon click.
   // We need to close it for next tests.
   EventUtils.synthesizeKey("VK_ESCAPE", {}, window);
 
   // now test dragging onto a tab
-  var tab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  var tab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   var browser = gBrowser.getBrowserForTab(tab);
 
   browser.addEventListener("load", function() {
     is(browser.contentWindow.location, "http://mochi.test:8888/", "drop on tab");
     gBrowser.removeTab(tab);
     finish();
   }, true);
 
--- a/browser/base/content/test/general/browser_e10s_chrome_process.js
+++ b/browser/base/content/test/general/browser_e10s_chrome_process.js
@@ -36,17 +36,17 @@ const CHROME_PROCESS = Ci.nsIXULRuntime.
 const CONTENT_PROCESS = Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
 const PATH = (getRootDirectory(gTestPath) + "test_process_flags_chrome.html").replace("chrome://mochitests", "");
 
 const CHROME = "chrome://mochitests" + PATH;
 const CANREMOTE = "chrome://mochitests-any" + PATH;
 const MUSTREMOTE = "chrome://mochitests-content" + PATH;
 
 add_task(async function init() {
-  gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 });
 
 registerCleanupFunction(() => {
   gBrowser.removeCurrentTab();
 });
 
 function test_url(url, chromeResult, contentResult) {
   is(E10SUtils.canLoadURIInProcess(url, CHROME_PROCESS),
--- a/browser/base/content/test/general/browser_e10s_switchbrowser.js
+++ b/browser/base/content/test/general/browser_e10s_switchbrowser.js
@@ -111,17 +111,17 @@ var forward = async function() {
 
 // Tests that navigating from a page that should be in the remote process and
 // a page that should be in the main process works and retains history
 add_task(async function test_navigation() {
   let expectedRemote = gMultiProcessBrowser;
 
   info("1");
   // Create a tab and load a remote page in it
-  gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   let {permanentKey} = gBrowser.selectedBrowser;
   await waitForLoad("http://example.org/" + DUMMY_PATH);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
   is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same");
 
   info("2");
   // Load another page
   await waitForLoad("http://example.com/" + DUMMY_PATH);
@@ -188,17 +188,17 @@ add_task(async function test_navigation(
 
 // Tests that calling gBrowser.loadURI or browser.loadURI to load a page in a
 // different process updates the browser synchronously
 add_task(async function test_synchronous() {
   let expectedRemote = gMultiProcessBrowser;
 
   info("1");
   // Create a tab and load a remote page in it
-  gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   let {permanentKey} = gBrowser.selectedBrowser;
   await waitForLoad("http://example.org/" + DUMMY_PATH);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
   is(gBrowser.selectedBrowser.permanentKey, permanentKey, "browser.permanentKey is still the same");
 
   info("2");
   // Load another page
   info("Loading about:robots");
@@ -228,17 +228,17 @@ add_task(async function test_synchronous
 
 // Tests that load flags are correctly passed through to the child process with
 // normal loads
 add_task(async function test_loadflags() {
   let expectedRemote = gMultiProcessBrowser;
 
   info("1");
   // Create a tab and load a remote page in it
-  gBrowser.selectedTab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   await waitForLoadWithFlags("about:robots");
   is(gBrowser.selectedBrowser.isRemoteBrowser, false, "Remote attribute should be correct");
   await check_history();
 
   info("2");
   // Load a page in the remote process with some custom flags
   await waitForLoadWithFlags("http://example.com/" + DUMMY_PATH, Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY);
   is(gBrowser.selectedBrowser.isRemoteBrowser, expectedRemote, "Remote attribute should be correct");
--- a/browser/base/content/test/general/browser_favicon_change.js
+++ b/browser/base/content/test/general/browser_favicon_change.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const TEST_URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_favicon_change.html"
 
 add_task(async function() {
-  let extraTab = gBrowser.selectedTab = gBrowser.addTab();
+  let extraTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   extraTab.linkedBrowser.loadURI(TEST_URL);
   let tabLoaded = BrowserTestUtils.browserLoaded(extraTab.linkedBrowser);
   let expectedFavicon = "http://example.org/one-icon";
   let haveChanged = new Promise.defer();
   let observer = new MutationObserver(function(mutations) {
     for (let mut of mutations) {
       if (mut.attributeName != "image") {
         continue;
--- a/browser/base/content/test/general/browser_favicon_change_not_in_document.js
+++ b/browser/base/content/test/general/browser_favicon_change_not_in_document.js
@@ -1,14 +1,14 @@
 "use strict";
 
 const TEST_URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_favicon_change_not_in_document.html"
 
 add_task(async function() {
-  let extraTab = gBrowser.selectedTab = gBrowser.addTab();
+  let extraTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   let tabLoaded = promiseTabLoaded(extraTab);
   extraTab.linkedBrowser.loadURI(TEST_URL);
   let expectedFavicon = "http://example.org/one-icon";
   let haveChanged = new Promise.defer();
   let observer = new MutationObserver(function(mutations) {
     for (let mut of mutations) {
       if (mut.attributeName != "image") {
         continue;
--- a/browser/base/content/test/general/browser_feed_discovery.js
+++ b/browser/base/content/test/general/browser_feed_discovery.js
@@ -1,15 +1,15 @@
 const URL = "http://mochi.test:8888/browser/browser/base/content/test/general/feed_discovery.html"
 
 /** Test for Bug 377611 **/
 
 add_task(async function() {
   // Open a new tab.
-  gBrowser.selectedTab = gBrowser.addTab(URL);
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
   registerCleanupFunction(() => gBrowser.removeCurrentTab());
 
   let browser = gBrowser.selectedBrowser;
   await BrowserTestUtils.browserLoaded(browser);
 
   let discovered = browser.feeds;
   ok(discovered.length > 0, "some feeds should be discovered");
 
--- a/browser/base/content/test/general/browser_findbarClose.js
+++ b/browser/base/content/test/general/browser_findbarClose.js
@@ -2,17 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests find bar auto-close behavior
 
 var newTab;
 
 add_task(async function findbar_test() {
   waitForExplicitFinish();
-  newTab = gBrowser.addTab("about:blank");
+  newTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   let promise = ContentTask.spawn(newTab.linkedBrowser, null, async function() {
     await ContentTaskUtils.waitForEvent(this, "DOMContentLoaded", false);
   });
   newTab.linkedBrowser.loadURI("http://example.com/browser/" +
     "browser/base/content/test/general/test_bug628179.html");
   await promise;
 
--- a/browser/base/content/test/general/browser_fullscreen-window-open.js
+++ b/browser/base/content/test/general/browser_fullscreen-window-open.js
@@ -11,17 +11,17 @@ const TEST_FILE = "file_fullscreen-windo
 const gHttpTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/",
                                                           "http://127.0.0.1:8888/");
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref(PREF_DISABLE_OPEN_NEW_WINDOW, true);
 
-  let newTab = gBrowser.addTab(gHttpTestRoot + TEST_FILE);
+  let newTab = BrowserTestUtils.addTab(gBrowser, gHttpTestRoot + TEST_FILE);
   gBrowser.selectedTab = newTab;
 
   whenTabLoaded(newTab, function() {
     // Enter browser fullscreen mode.
     BrowserFullScreen();
 
     runNextTest();
   });
--- a/browser/base/content/test/general/browser_gZipOfflineChild.js
+++ b/browser/base/content/test/general/browser_gZipOfflineChild.js
@@ -63,17 +63,17 @@ function handleMessageEvents(event) {
 }
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref("offline-apps.allow_by_default", true);
 
   // Open a new tab.
-  gBrowser.selectedTab = gBrowser.addTab(URL);
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
   registerCleanupFunction(() => gBrowser.removeCurrentTab());
 
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
     let window = gBrowser.selectedBrowser.contentWindow;
 
     window.addEventListener("message", handleMessageEvents);
   });
 }
--- a/browser/base/content/test/general/browser_gestureSupport.js
+++ b/browser/base/content/test/general/browser_gestureSupport.js
@@ -636,13 +636,13 @@ function test_rotateGesturesOnTab() {
   }
 
   gBrowser.removeTab(test_imageTab);
   test_imageTab = null;
   finish();
 }
 
 function test_rotateGestures() {
-  test_imageTab = gBrowser.addTab("chrome://branding/content/about-logo.png");
+  test_imageTab = BrowserTestUtils.addTab(gBrowser, "chrome://branding/content/about-logo.png");
   gBrowser.selectedTab = test_imageTab;
 
   gBrowser.selectedBrowser.addEventListener("load", test_rotateGesturesOnTab, true);
 }
--- a/browser/base/content/test/general/browser_hide_removing.js
+++ b/browser/base/content/test/general/browser_hide_removing.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Bug 587922: tabs don't get removed if they're hidden
 
 function test() {
   waitForExplicitFinish();
 
   // Add a tab that will get removed and hidden
-  let testTab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  let testTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   is(gBrowser.visibleTabs.length, 2, "just added a tab, so 2 tabs");
   gBrowser.selectedTab = testTab;
 
   let numVisBeforeHide, numVisAfterHide;
   gBrowser.tabContainer.addEventListener("TabSelect", function() {
     // While the next tab is being selected, hide the removing tab
     numVisBeforeHide = gBrowser.visibleTabs.length;
     gBrowser.hideTab(testTab);
--- a/browser/base/content/test/general/browser_keywordBookmarklets.js
+++ b/browser/base/content/test/general/browser_keywordBookmarklets.js
@@ -1,15 +1,15 @@
 "use strict"
 
 add_task(async function test_keyword_bookmarklet() {
   let bm = await PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
                                                 title: "bookmarklet",
                                                 url: "javascript:'1';" });
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(async function() {
     gBrowser.removeTab(tab);
     await PlacesUtils.bookmarks.remove(bm);
   });
   await promisePageShow();
   let originalPrincipal = gBrowser.contentPrincipal;
 
   function getPrincipalURI() {
--- a/browser/base/content/test/general/browser_keywordSearch.js
+++ b/browser/base/content/test/general/browser_keywordSearch.js
@@ -29,17 +29,17 @@ function test() {
         }, {once: true});
         executeSoon(finish);
       }
     }
   };
 
   Services.ww.registerNotification(windowObserver);
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onLocationChange(webProgress, req, flags, status) {
       // Only care about document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart))
         return;
--- a/browser/base/content/test/general/browser_keywordSearch_postData.js
+++ b/browser/base/content/test/general/browser_keywordSearch_postData.js
@@ -14,17 +14,17 @@ var gTests = [
     testText: "?   foo  ",
     expectText: "foo"
   }
 ];
 
 function test() {
   waitForExplicitFinish();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let searchObserver = function search_observer(aSubject, aTopic, aData) {
     let engine = aSubject.QueryInterface(Ci.nsISearchEngine);
     info("Observer: " + aData + " for " + engine.name);
 
     if (aData != "engine-added")
       return;
 
--- a/browser/base/content/test/general/browser_lastAccessedTab.js
+++ b/browser/base/content/test/general/browser_lastAccessedTab.js
@@ -21,17 +21,17 @@ function test() {
   waitForExplicitFinish();
 
   originalTab = gBrowser.selectedTab;
   nextStep(step2);
 }
 
 function step2() {
   isCurrent(originalTab, "selected tab has the current timestamp");
-  newTab = gBrowser.addTab("about:blank", {skipAnimation: true});
+  newTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   nextStep(step3);
 }
 
 function step3() {
   ok(newTab.lastAccessed < Date.now(), "new tab hasn't been selected so far");
   gBrowser.selectedTab = newTab;
   isCurrent(newTab, "new tab has the current timestamp after being selected");
   nextStep(step4);
--- a/browser/base/content/test/general/browser_offlineQuotaNotification.js
+++ b/browser/base/content/test/general/browser_offlineQuotaNotification.js
@@ -31,17 +31,17 @@ function checkInContentPreferences(win) 
 }
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref("offline-apps.allow_by_default", false);
 
   // Open a new tab.
-  gBrowser.selectedTab = gBrowser.addTab(URL);
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
   registerCleanupFunction(() => gBrowser.removeCurrentTab());
 
 
   Promise.all([
     // Wait for a notification that asks whether to allow offline storage.
     promiseNotification(),
     // Wait for the tab to load.
     BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser),
--- a/browser/base/content/test/general/browser_overflowScroll.js
+++ b/browser/base/content/test/general/browser_overflowScroll.js
@@ -31,17 +31,17 @@ function test() {
 }
 
 function doTest() {
   tabstrip.smoothScroll = false;
 
   var tabMinWidth = parseInt(getComputedStyle(gBrowser.selectedTab, null).minWidth);
   var tabCountForOverflow = Math.ceil(width(tabstrip) / tabMinWidth * 3);
   while (tabs.length < tabCountForOverflow)
-    gBrowser.addTab("about:blank", {skipAnimation: true});
+    BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   gBrowser.pinTab(tabs[0]);
 
   tabstrip.addEventListener("overflow", runOverflowTests);
 }
 
 function runOverflowTests(aEvent) {
   if (aEvent.detail != 1 ||
       aEvent.target != tabstrip)
--- a/browser/base/content/test/general/browser_pinnedTabs.js
+++ b/browser/base/content/test/general/browser_pinnedTabs.js
@@ -22,17 +22,17 @@ function PinUnpinHandler(tab, eventName)
   gBrowser.tabContainer.addEventListener(eventName, function(e) {
     if (e.originalTarget == tab) {
       self.eventCount++;
     }
   }, {capture: true, once: true});
 }
 
 function test() {
-  tabs = [gBrowser.selectedTab, gBrowser.addTab(), gBrowser.addTab(), gBrowser.addTab()];
+  tabs = [gBrowser.selectedTab, BrowserTestUtils.addTab(gBrowser), BrowserTestUtils.addTab(gBrowser), BrowserTestUtils.addTab(gBrowser)];
   indexTest(0, 0);
   indexTest(1, 1);
   indexTest(2, 2);
   indexTest(3, 3);
 
   var eh = new PinUnpinHandler(tabs[3], "TabPinned");
   gBrowser.pinTab(tabs[3]);
   is(eh.eventCount, 2, "TabPinned event should be fired");
--- a/browser/base/content/test/general/browser_relatedTabs.js
+++ b/browser/base/content/test/general/browser_relatedTabs.js
@@ -6,17 +6,17 @@ add_task(async function() {
   is(gBrowser.tabs.length, 1, "one tab is open initially");
 
   // Add several new tabs in sequence, interrupted by selecting a
   // different tab, moving a tab around and closing a tab,
   // returning a list of opened tabs for verifying the expected order.
   // The new tab behaviour is documented in bug 465673
   let tabs = [];
   function addTab(aURL, aReferrer) {
-    let tab = gBrowser.addTab(aURL, {referrerURI: aReferrer});
+    let tab = BrowserTestUtils.addTab(gBrowser, aURL, {referrerURI: aReferrer});
     tabs.push(tab);
     return BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   }
 
   await addTab("http://mochi.test:8888/#0");
   gBrowser.selectedTab = tabs[0];
   await addTab("http://mochi.test:8888/#1");
   await addTab("http://mochi.test:8888/#2", gBrowser.currentURI);
--- a/browser/base/content/test/general/browser_removeTabsToTheEnd.js
+++ b/browser/base/content/test/general/browser_removeTabsToTheEnd.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
   // Add two new tabs after the original tab. Pin the first one.
   let originalTab = gBrowser.selectedTab;
-  let newTab1 = gBrowser.addTab();
-  gBrowser.addTab();
+  let newTab1 = BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(newTab1);
 
   // Check that there is only one closable tab from originalTab to the end
   is(gBrowser.getTabsToTheEndFrom(originalTab).length, 1,
     "One unpinned tab to the right");
 
   // Remove tabs to the end
   gBrowser.removeTabsToTheEndFrom(originalTab);
--- a/browser/base/content/test/general/browser_restore_isAppTab.js
+++ b/browser/base/content/test/general/browser_restore_isAppTab.js
@@ -97,17 +97,17 @@ var restart = async function(browser) {
 
   let tab = gBrowser.getTabForBrowser(browser);
   SessionStore.reviveCrashedTab(tab);
 
   await promiseTabLoaded(tab);
 };
 
 add_task(async function navigate() {
-  let tab = gBrowser.addTab("about:robots");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:robots");
   let browser = tab.linkedBrowser;
   gBrowser.selectedTab = tab;
   await waitForDocLoadComplete();
   loadFrameScript(browser);
   let isAppTab = await isBrowserAppTab(browser);
   ok(!isAppTab, "Docshell shouldn't think it is an app tab");
 
   gBrowser.pinTab(tab);
@@ -136,17 +136,17 @@ add_task(async function navigate() {
 
   gBrowser.removeCurrentTab();
 });
 
 add_task(async function crash() {
   if (!gMultiProcessBrowser || !("nsICrashReporter" in Ci))
     return;
 
-  let tab = gBrowser.addTab(DUMMY);
+  let tab = BrowserTestUtils.addTab(gBrowser, DUMMY);
   let browser = tab.linkedBrowser;
   gBrowser.selectedTab = tab;
   await waitForDocLoadComplete();
   loadFrameScript(browser);
   let isAppTab = await isBrowserAppTab(browser);
   ok(!isAppTab, "Docshell shouldn't think it is an app tab");
 
   gBrowser.pinTab(tab);
--- a/browser/base/content/test/general/browser_save_video_frame.js
+++ b/browser/base/content/test/general/browser_save_video_frame.js
@@ -93,17 +93,17 @@ add_task(async function() {
 
   // Make sure that we clean these things up when we're done.
   registerCleanupFunction(function() {
     mockTransferRegisterer.unregister();
     MockFilePicker.cleanup();
     destDir.remove(true);
   });
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab;
   let browser = tab.linkedBrowser;
   info("Loading video tab");
   await promiseTabLoadEvent(tab, VIDEO_URL);
   info("Video tab loaded.");
 
   let context = document.getElementById("contentAreaContextMenu");
   let popupPromise = promisePopupShown(context);
--- a/browser/base/content/test/general/browser_selectTabAtIndex.js
+++ b/browser/base/content/test/general/browser_selectTabAtIndex.js
@@ -11,17 +11,17 @@ function test() {
   function sendAccelKey(key) {
     // Make sure the keystroke goes to chrome.
     document.activeElement.blur();
     EventUtils.synthesizeKey(key.toString(), { altKey: isLinux, accelKey: !isLinux });
   }
 
   function createTabs(count) {
     for (let n = 0; n < count; n++)
-      gBrowser.addTab();
+      BrowserTestUtils.addTab(gBrowser);
   }
 
   function testKey(key, expectedTab) {
     sendAccelKey(key);
     assertTab(expectedTab);
   }
 
   function testIndex(index, expectedTab) {
--- a/browser/base/content/test/general/browser_star_hsts.js
+++ b/browser/base/content/test/general/browser_star_hsts.js
@@ -11,17 +11,17 @@ add_task(async function test_star_redire
     let sss = Cc["@mozilla.org/ssservice;1"]
                 .getService(Ci.nsISiteSecurityService);
     sss.removeState(Ci.nsISiteSecurityService.HEADER_HSTS,
                     NetUtil.newURI("http://example.com/"), 0);
     PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
     gBrowser.removeCurrentTab();
   });
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   // This will add the page to the HSTS cache.
   await promiseTabLoadEvent(tab, secureURL, secureURL);
   // This should transparently be redirected to the secure page.
   await promiseTabLoadEvent(tab, unsecureURL, secureURL);
 
   await promiseStarState(BookmarkingUI.STATUS_UNSTARRED);
 
   let promiseBookmark = promiseOnBookmarkItemAdded(gBrowser.currentURI);
--- a/browser/base/content/test/general/browser_subframe_favicons_not_used.js
+++ b/browser/base/content/test/general/browser_subframe_favicons_not_used.js
@@ -1,16 +1,16 @@
 /* Make sure <link rel="..."> isn't respected in sub-frames. */
 
 function test() {
   waitForExplicitFinish();
 
   let testPath = getRootDirectory(gTestPath);
 
-  let tab = gBrowser.addTab(testPath + "file_bug970276_popup1.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, testPath + "file_bug970276_popup1.html");
 
   tab.linkedBrowser.addEventListener("load", function() {
     let expectedIcon = testPath + "file_bug970276_favicon1.ico";
     is(gBrowser.getIcon(tab), expectedIcon, "Correct icon.");
 
     gBrowser.removeTab(tab);
 
     finish();
--- a/browser/base/content/test/general/browser_tabReorder.js
+++ b/browser/base/content/test/general/browser_tabReorder.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 add_task(async function() {
   let initialTabsLength = gBrowser.tabs.length;
 
-  let newTab1 = gBrowser.selectedTab = gBrowser.addTab("about:robots", {skipAnimation: true});
-  let newTab2 = gBrowser.selectedTab = gBrowser.addTab("about:about", {skipAnimation: true});
-  let newTab3 = gBrowser.selectedTab = gBrowser.addTab("about:config", {skipAnimation: true});
+  let newTab1 = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:robots", {skipAnimation: true});
+  let newTab2 = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:about", {skipAnimation: true});
+  let newTab3 = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:config", {skipAnimation: true});
   registerCleanupFunction(function() {
     while (gBrowser.tabs.length > initialTabsLength) {
       gBrowser.removeTab(gBrowser.tabs[initialTabsLength]);
     }
   });
 
   is(gBrowser.tabs.length, initialTabsLength + 3, "new tabs are opened");
   is(gBrowser.tabs[initialTabsLength], newTab1, "newTab1 position is correct");
--- a/browser/base/content/test/general/browser_tab_detach_restore.js
+++ b/browser/base/content/test/general/browser_tab_detach_restore.js
@@ -4,17 +4,17 @@ const {TabStateFlusher} = Cu.import("res
 
 add_task(async function() {
   let uri = "http://example.com/browser/browser/base/content/test/general/dummy_page.html";
 
   // Clear out the closed windows set to start
   while (SessionStore.getClosedWindowCount() > 0)
     SessionStore.forgetClosedWindow(0);
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   tab.linkedBrowser.loadURI(uri);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
 
   let key = tab.linkedBrowser.permanentKey;
   let win = gBrowser.replaceTabWithWindow(tab);
   await new Promise(resolve => whenDelayedStartupFinished(win, resolve));
 
--- a/browser/base/content/test/general/browser_tab_dragdrop.js
+++ b/browser/base/content/test/general/browser_tab_dragdrop.js
@@ -101,20 +101,20 @@ function checkObjectValue(browser) {
 }
 
 add_task(async function() {
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED);
 
   // create a few tabs
   let tabs = [
     gBrowser.tabs[0],
-    gBrowser.addTab("about:blank", {skipAnimation: true}),
-    gBrowser.addTab("about:blank", {skipAnimation: true}),
-    gBrowser.addTab("about:blank", {skipAnimation: true}),
-    gBrowser.addTab("about:blank", {skipAnimation: true})
+    BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true}),
+    BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true}),
+    BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true}),
+    BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true})
   ];
 
   // Initially 0 1 2 3 4
   await loadURI(tabs[1], "data:text/html;charset=utf-8,<title>tab1</title><body>tab1<iframe>");
   await loadURI(tabs[2], "data:text/plain;charset=utf-8,tab2");
   await loadURI(tabs[3], "data:text/html;charset=utf-8,<title>tab3</title><body>tab3<iframe>");
   await loadURI(tabs[4], "http://example.com/browser/browser/base/content/test/general/browser_tab_dragdrop_embed.html");
   await BrowserTestUtils.switchTab(gBrowser, tabs[3]);
--- a/browser/base/content/test/general/browser_tabfocus.js
+++ b/browser/base/content/test/general/browser_tabfocus.js
@@ -122,20 +122,20 @@ function focusElementInChild(elementid, 
     browser.messageManager.sendAsyncMessage("Browser:ChangeFocus",
                                             { id: elementid, type });
   } else {
     browser.contentDocument.getElementById(elementid)[type]();
   }
 }
 
 add_task(async function() {
-  tab1 = gBrowser.addTab();
+  tab1 = BrowserTestUtils.addTab(gBrowser);
   browser1 = gBrowser.getBrowserForTab(tab1);
 
-  tab2 = gBrowser.addTab();
+  tab2 = BrowserTestUtils.addTab(gBrowser);
   browser2 = gBrowser.getBrowserForTab(tab2);
 
   await promiseTabLoadEvent(tab1, "data:text/html," + escape(testPage1));
   await promiseTabLoadEvent(tab2, "data:text/html," + escape(testPage2));
 
   var childFocusScript = "data:,(" + focusInChild.toString() + ")();";
   browser1.messageManager.loadFrameScript(childFocusScript, true);
   browser2.messageManager.loadFrameScript(childFocusScript, true);
--- a/browser/base/content/test/general/browser_tabs_isActive.js
+++ b/browser/base/content/test/general/browser_tabs_isActive.js
@@ -35,17 +35,17 @@ function waitForMs(aMs) {
       resolve(true);
     }
   });
 }
 
 add_task(async function() {
   let url = kTestPage;
   let originalTab = gBrowser.selectedTab; // test tab
-  let newTab = gBrowser.addTab(url, {skipAnimation: true});
+  let newTab = BrowserTestUtils.addTab(gBrowser, url, {skipAnimation: true});
   let parentSide, childSide;
 
   // new tab added but not selected checks
   parentSide = getParentTabState(newTab);
   childSide = await getChildTabState(newTab);
   checkState(parentSide, childSide, false, "newly added " + url + " tab is not active");
   parentSide = getParentTabState(originalTab);
   childSide = await getChildTabState(originalTab);
@@ -95,17 +95,17 @@ add_task(async function() {
   checkState(parentSide, childSide, false, "original tab is active again after switch back");
 
   gBrowser.removeTab(newTab);
 });
 
 add_task(async function() {
   let url = "about:about";
   let originalTab = gBrowser.selectedTab; // test tab
-  let newTab = gBrowser.addTab(url, {skipAnimation: true});
+  let newTab = BrowserTestUtils.addTab(gBrowser, url, {skipAnimation: true});
   let parentSide, childSide;
 
   parentSide = getParentTabState(newTab);
   childSide = await getChildTabState(newTab);
   checkState(parentSide, childSide, false, "newly added " + url + " tab is not active");
   parentSide = getParentTabState(originalTab);
   childSide = await getChildTabState(originalTab);
   checkState(parentSide, childSide, true, "original tab is active initially");
--- a/browser/base/content/test/general/browser_tabs_owner.js
+++ b/browser/base/content/test/general/browser_tabs_owner.js
@@ -6,19 +6,19 @@ thisTestLeaksUncaughtRejectionsAndShould
 
 //
 // Whitelisting this test.
 // As part of bug 1077403, the leaking uncaught rejection should be fixed.
 //
 thisTestLeaksUncaughtRejectionsAndShouldBeFixed("TypeError: gBrowser._finalizeTabSwitch is not a function");
 
 function test() {
-  gBrowser.addTab();
-  gBrowser.addTab();
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
 
   var tabs = gBrowser.tabs;
   var owner;
 
   is(tabs.length, 4, "4 tabs are open");
 
   owner = gBrowser.selectedTab = tabs[2];
   BrowserOpenTab();
--- a/browser/base/content/test/general/browser_unknownContentType_title.js
+++ b/browser/base/content/test/general/browser_unknownContentType_title.js
@@ -10,17 +10,17 @@ function waitForNewWindow() {
       });
     };
 
     Services.obs.addObserver(listener, "toplevel-window-ready")
   });
 }
 
 add_task(async function() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
   let browser = tab.linkedBrowser;
   await promiseTabLoaded(gBrowser.selectedTab);
 
   is(gBrowser.contentTitle, "Test Page", "Should have the right title.")
 
   browser.loadURI(unknown_url);
   let win = await waitForNewWindow();
   is(win.location, "chrome://mozapps/content/downloads/unknownContentType.xul",
--- a/browser/base/content/test/general/browser_utilityOverlay.js
+++ b/browser/base/content/test/general/browser_utilityOverlay.js
@@ -95,17 +95,17 @@ function test_openNewTabWith() {
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded");
     gBrowser.removeCurrentTab();
     runNextTest();
   });
 }
 
 function test_openUILink() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     is(tab.linkedBrowser.currentURI.spec, "http://example.org/", "example.org loaded");
     gBrowser.removeCurrentTab();
     runNextTest();
   });
 
   openUILink("http://example.org/"); // defaults to "current"
 }
--- a/browser/base/content/test/general/browser_visibleFindSelection.js
+++ b/browser/base/content/test/general/browser_visibleFindSelection.js
@@ -1,14 +1,14 @@
 add_task(async function() {
   const childContent = "<div style='position: absolute; left: 2200px; background: green; width: 200px; height: 200px;'>" +
                        "div</div><div  style='position: absolute; left: 0px; background: red; width: 200px; height: 200px;'>" +
                        "<span id='s'>div</span></div>";
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   await promiseTabLoadEvent(tab, "data:text/html," + escape(childContent));
   await SimpleTest.promiseFocus(gBrowser.selectedBrowser.contentWindowAsCPOW);
 
   let findBarOpenPromise = promiseWaitForEvent(gBrowser, "findbaropen");
   EventUtils.synthesizeKey("f", { accelKey: true });
   await findBarOpenPromise;
 
--- a/browser/base/content/test/general/browser_visibleTabs.js
+++ b/browser/base/content/test/general/browser_visibleTabs.js
@@ -4,20 +4,20 @@
 
 "use strict";
 
 add_task(function* () {
   // There should be one tab when we start the test
   let [origTab] = gBrowser.visibleTabs;
 
   // Add a tab that will get pinned
-  let pinned = gBrowser.addTab();
+  let pinned = BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(pinned);
 
-  let testTab = gBrowser.addTab();
+  let testTab = BrowserTestUtils.addTab(gBrowser);
 
   let visible = gBrowser.visibleTabs;
   is(visible.length, 3, "3 tabs should be open");
   is(visible[0], pinned, "the pinned tab is first");
   is(visible[1], origTab, "original tab is next");
   is(visible[2], testTab, "last created tab is last");
 
   // Only show the test tab (but also get pinned and selected)
--- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
+++ b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllPages.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
   waitForExplicitFinish();
 
-  let tabOne = gBrowser.addTab("about:blank");
-  let tabTwo = gBrowser.addTab("http://mochi.test:8888/");
+  let tabOne = BrowserTestUtils.addTab(gBrowser, "about:blank");
+  let tabTwo = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/");
   gBrowser.selectedTab = tabTwo;
 
   let browser = gBrowser.getBrowserForTab(tabTwo);
   let onLoad = function() {
     browser.removeEventListener("load", onLoad, true);
 
     gBrowser.showOnlyTheseTabs([tabTwo]);
 
--- a/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js
+++ b/browser/base/content/test/general/browser_visibleTabs_bookmarkAllTabs.js
@@ -6,34 +6,34 @@ function test() {
   waitForExplicitFinish();
 
   // There should be one tab when we start the test
   let [origTab] = gBrowser.visibleTabs;
   is(gBrowser.visibleTabs.length, 1, "1 tab should be open");
   is(Disabled(), true, "Bookmark All Tabs should be disabled");
 
   // Add a tab
-  let testTab1 = gBrowser.addTab();
+  let testTab1 = BrowserTestUtils.addTab(gBrowser);
   is(gBrowser.visibleTabs.length, 2, "2 tabs should be open");
   is(Disabled(), true, "Bookmark All Tabs should be disabled since there are two tabs with the same address");
 
-  let testTab2 = gBrowser.addTab("about:mozilla");
+  let testTab2 = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
   is(gBrowser.visibleTabs.length, 3, "3 tabs should be open");
   // Wait for tab load, the code checks for currentURI.
   testTab2.linkedBrowser.addEventListener("load", function() {
     is(Disabled(), false, "Bookmark All Tabs should be enabled since there are two tabs with different addresses");
 
     // Hide the original tab
     gBrowser.selectedTab = testTab2;
     gBrowser.showOnlyTheseTabs([testTab2]);
     is(gBrowser.visibleTabs.length, 1, "1 tab should be visible");
     is(Disabled(), true, "Bookmark All Tabs should be disabled as there is only one visible tab");
 
     // Add a tab that will get pinned
-    let pinned = gBrowser.addTab();
+    let pinned = BrowserTestUtils.addTab(gBrowser);
     is(gBrowser.visibleTabs.length, 2, "2 tabs should be visible now");
     is(Disabled(), false, "Bookmark All Tabs should be available as there are two visible tabs");
     gBrowser.pinTab(pinned);
     is(Hidden(), false, "Bookmark All Tabs should be visible on a normal tab");
     is(Disabled(), true, "Bookmark All Tabs should not be available since one tab is pinned");
     gBrowser.selectedTab = pinned;
     is(Hidden(), true, "Bookmark All Tabs should be hidden on a pinned tab");
 
--- a/browser/base/content/test/general/browser_visibleTabs_contextMenu.js
+++ b/browser/base/content/test/general/browser_visibleTabs_contextMenu.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const remoteClientsFixture = [ { id: 1, name: "Foo"}, { id: 2, name: "Bar"} ];
 
 add_task(async function test() {
   // There should be one tab when we start the test
   let [origTab] = gBrowser.visibleTabs;
   is(gBrowser.visibleTabs.length, 1, "there is one visible tab");
-  let testTab = gBrowser.addTab();
+  let testTab = BrowserTestUtils.addTab(gBrowser);
   is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs");
 
   // Check the context menu with two tabs
   updateTabContextMenu(origTab);
   is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled");
   is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled");
 
 
@@ -45,17 +45,17 @@ add_task(async function test() {
 
   // Check the context menu with one tab.
   updateTabContextMenu(testTab);
   is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists");
   is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled");
 
   // Add a tab that will get pinned
   // So now there's one pinned tab, one visible unpinned tab, and one hidden tab
-  let pinned = gBrowser.addTab();
+  let pinned = BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(pinned);
   is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs");
 
   // Check the context menu on the unpinned visible tab
   updateTabContextMenu(testTab);
   is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled");
   is(document.getElementById("context_closeTabsToTheEnd").disabled, true, "Close Tabs To The End is disabled");
 
--- a/browser/base/content/test/general/browser_visibleTabs_tabPreview.js
+++ b/browser/base/content/test/general/browser_visibleTabs_tabPreview.js
@@ -1,18 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 add_task(function* test() {
   gPrefService.setBoolPref("browser.ctrlTab.previews", true);
 
   let [origTab] = gBrowser.visibleTabs;
-  let tabOne = gBrowser.addTab();
-  let tabTwo = gBrowser.addTab();
+  let tabOne = BrowserTestUtils.addTab(gBrowser);
+  let tabTwo = BrowserTestUtils.addTab(gBrowser);
 
   // test the ctrlTab.tabList
   pressCtrlTab();
   ok(ctrlTab.tabList.length, 3, "Show 3 tabs in tab preview");
   releaseCtrl();
 
   gBrowser.showOnlyTheseTabs([origTab]);
   pressCtrlTab();
--- a/browser/base/content/test/general/browser_web_channel.js
+++ b/browser/base/content/test/general/browser_web_channel.js
@@ -28,17 +28,17 @@ var gTests = [
         channel.listen(function(id, message, target) {
           is(id, "generic");
           is(message.something.nested, "hello");
           channel.stopListening();
           gBrowser.removeTab(tab);
           resolve();
         });
 
-        tab = gBrowser.addTab(HTTP_PATH + HTTP_ENDPOINT + "?generic");
+        tab = BrowserTestUtils.addTab(gBrowser, HTTP_PATH + HTTP_ENDPOINT + "?generic");
       });
     }
   },
   {
     desc: "WebChannel generic message in a private window.",
     async run() {
       let promiseTestDone = new Promise(function(resolve, reject) {
         let channel = new WebChannel("generic", Services.io.newURI(HTTP_PATH));
@@ -75,17 +75,17 @@ var gTests = [
           if (message.command === "two") {
             is(message.detail.data.nested, true);
             channel.stopListening();
             gBrowser.removeTab(tab);
             resolve();
           }
         });
 
-        tab = gBrowser.addTab(HTTP_PATH + HTTP_ENDPOINT + "?twoway");
+        tab = BrowserTestUtils.addTab(gBrowser, HTTP_PATH + HTTP_ENDPOINT + "?twoway");
       });
     }
   },
   {
     desc: "WebChannel two way communication in an iframe",
     async run() {
       let parentChannel = new WebChannel("echo", Services.io.newURI(HTTP_PATH));
       let iframeChannel = new WebChannel("twoway", Services.io.newURI(HTTP_IFRAME_PATH));
@@ -190,17 +190,17 @@ var gTests = [
         let channel = new WebChannel("multichannel", Services.io.newURI(HTTP_PATH));
 
         channel.listen(function(id, message, sender) {
           is(id, "multichannel");
           gBrowser.removeTab(tab);
           resolve();
         });
 
-        tab = gBrowser.addTab(HTTP_PATH + HTTP_ENDPOINT + "?multichannel");
+        tab = BrowserTestUtils.addTab(gBrowser, HTTP_PATH + HTTP_ENDPOINT + "?multichannel");
       });
     }
   },
   {
     desc: "WebChannel unsolicited send, using system principal",
     async run() {
       let channel = new WebChannel("echo", Services.io.newURI(HTTP_PATH));
 
--- a/browser/base/content/test/general/browser_windowactivation.js
+++ b/browser/base/content/test/general/browser_windowactivation.js
@@ -13,17 +13,17 @@ var browser1, browser2;
 
 add_task(async function reallyRunTests() {
 
   let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, testPage);
   browser1 = tab1.linkedBrowser;
 
   // This can't use openNewForegroundTab because if we focus tab2 now, we
   // won't send a focus event during test 6, further down in this file.
-  let tab2 = gBrowser.addTab(testPage);
+  let tab2 = BrowserTestUtils.addTab(gBrowser, testPage);
   browser2 = tab2.linkedBrowser;
   await BrowserTestUtils.browserLoaded(browser2);
 
   browser1.messageManager.loadFrameScript("data:,(" + childFunction.toString() + ")();", true);
   browser2.messageManager.loadFrameScript("data:,(" + childFunction.toString() + ")();", true);
 
   gURLBar.focus();
 
--- a/browser/base/content/test/general/browser_zbug569342.js
+++ b/browser/base/content/test/general/browser_zbug569342.js
@@ -1,16 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 var gTab = null;
 
 function load(url, cb) {
-  gTab = gBrowser.addTab(url);
+  gTab = BrowserTestUtils.addTab(gBrowser, url);
   gBrowser.addEventListener("load", function(event) {
     if (event.target.location != url)
       return;
 
     gBrowser.removeEventListener("load", arguments.callee, true);
     // Trigger onLocationChange by switching tabs.
     gBrowser.selectedTab = gTab;
     cb();
--- a/browser/base/content/test/newtab/browser_newtab_bug1271075.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug1271075.js
@@ -2,17 +2,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 add_task(async function() {
   is(gBrowser.tabs.length, 1, "one tab is open initially");
 
   // Add a few tabs.
   let tabs = [];
   function addTab(aURL, aReferrer) {
-    let tab = gBrowser.addTab(aURL, {referrerURI: aReferrer});
+    let tab = BrowserTestUtils.addTab(gBrowser, aURL, {referrerURI: aReferrer});
     tabs.push(tab);
     return BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   }
 
   await addTab("http://mochi.test:8888/#0");
   await addTab("http://mochi.test:8888/#1");
   await addTab("http://mochi.test:8888/#2");
   await addTab("http://mochi.test:8888/#3");
--- a/browser/base/content/test/newtab/browser_newtab_reflow_load.js
+++ b/browser/base/content/test/newtab/browser_newtab_reflow_load.js
@@ -6,17 +6,17 @@
 const FRAME_SCRIPT = getRootDirectory(gTestPath) + "content-reflows.js";
 const ADDITIONAL_WAIT_MS = 2000;
 
 /*
  * Ensure that loading about:newtab doesn't cause uninterruptible reflows.
  */
 add_task(async function() {
   await BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
-    return gBrowser.selectedTab = gBrowser.addTab("about:blank", {animate: false});
+    return gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {animate: false});
   }, false);
 
   let browser = gBrowser.selectedBrowser;
   let mm = browser.messageManager;
   mm.loadFrameScript(FRAME_SCRIPT, true);
   mm.addMessageListener("newtab-reflow", ({data: stack}) => {
     ok(false, `unexpected uninterruptible reflow ${stack}`);
   });
--- a/browser/base/content/test/pageinfo/browser_pageInfo.js
+++ b/browser/base/content/test/pageinfo/browser_pageInfo.js
@@ -1,14 +1,14 @@
 function test() {
   waitForExplicitFinish();
 
   var pageInfo;
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function() {
     Services.obs.addObserver(observer, "page-info-dialog-loaded");
     pageInfo = BrowserPageInfo();
   }, {capture: true, once: true});
   content.location =
     "https://example.com/browser/browser/base/content/test/pageinfo/feed_tab.html";
 
   function observer(win, topic, data) {
--- a/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
@@ -1,14 +1,14 @@
 /* Make sure that "View Image Info" loads the correct image data */
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   gBrowser.selectedBrowser.addEventListener("load", function() {
     var doc = gBrowser.contentDocument;
     var testImg = doc.getElementById("test-image");
     var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
                                    "mediaTab", testImg);
 
     pageInfo.addEventListener("load", function() {
--- a/browser/base/content/test/pageinfo/browser_pageinfo_images.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_images.js
@@ -1,14 +1,14 @@
 /* Check proper image url retrieval from all kinds of elements/styles */
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   gBrowser.selectedBrowser.addEventListener("load", function() {
     var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
                                    "mediaTab");
 
     pageInfo.addEventListener("load", function() {
       pageInfo.onFinished.push(function() {
         executeSoon(function() {
--- a/browser/base/content/test/pageinfo/browser_pageinfo_svg_image.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_svg_image.js
@@ -1,12 +1,12 @@
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   gBrowser.selectedBrowser.addEventListener("load", function() {
     var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
                                    "mediaTab");
 
     pageInfo.addEventListener("load", function() {
       pageInfo.onFinished.push(function() {
         executeSoon(function() {
--- a/browser/base/content/test/plugins/browser_CTP_context_menu.js
+++ b/browser/base/content/test/plugins/browser_CTP_context_menu.js
@@ -12,17 +12,17 @@ add_task(async function() {
     window.focus();
   });
 });
 
 // Test that the activate action in content menus for CTP plugins works
 add_task(async function() {
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   let bindingPromise = waitForEvent(gBrowser.selectedBrowser, "PluginBindingAttached", null, true, true);
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
   await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
   await bindingPromise;
 
--- a/browser/base/content/test/plugins/browser_CTP_data_urls.js
+++ b/browser/base/content/test/plugins/browser_CTP_data_urls.js
@@ -10,17 +10,17 @@ add_task(async function() {
     setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
     Services.prefs.clearUserPref("plugins.click_to_play");
     Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
 
-  gBrowser.selectedTab =  gBrowser.addTab();
+  gBrowser.selectedTab =  BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
 });
--- a/browser/base/content/test/plugins/browser_CTP_drag_drop.js
+++ b/browser/base/content/test/plugins/browser_CTP_drag_drop.js
@@ -13,17 +13,17 @@ add_task(async function() {
     window.focus();
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
 
   // Work around for delayed PluginBindingAttached
   await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
 
@@ -38,17 +38,17 @@ add_task(async function() {
 
   await promisePopupNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser);
 
   ok(PopupNotifications.getNotification("click-to-play-plugins", gNewWindow.gBrowser.selectedBrowser), "Should have a click-to-play notification in the tab in the new window");
   ok(!PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should not have a click-to-play notification in the old window now");
 });
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, gNewWindow.gBrowser.selectedTab);
 
   await promisePopupNotification("click-to-play-plugins", gBrowser.selectedBrowser);
 
   ok(PopupNotifications.getNotification("click-to-play-plugins", gBrowser.selectedBrowser), "Should have a click-to-play notification in the initial tab again");
 
   // Work around for delayed PluginBindingAttached
   await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
--- a/browser/base/content/test/plugins/browser_CTP_hide_overlay.js
+++ b/browser/base/content/test/plugins/browser_CTP_hide_overlay.js
@@ -12,17 +12,17 @@ add_task(async function() {
     gBrowser.removeCurrentTab();
     window.focus();
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_test.html");
 
--- a/browser/base/content/test/plugins/browser_CTP_iframe.js
+++ b/browser/base/content/test/plugins/browser_CTP_iframe.js
@@ -11,17 +11,17 @@ add_task(async function() {
     gBrowser.removeCurrentTab();
     window.focus();
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_iframe.html");
 
   // Tests that the overlays are visible and actionable if the plugin is in an iframe.
 
--- a/browser/base/content/test/plugins/browser_CTP_multi_allow.js
+++ b/browser/base/content/test/plugins/browser_CTP_multi_allow.js
@@ -12,17 +12,17 @@ add_task(async function() {
     gBrowser.removeCurrentTab();
     window.focus();
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_two_types.html");
 
   // Work around for delayed PluginBindingAttached
--- a/browser/base/content/test/plugins/browser_CTP_nonplugins.js
+++ b/browser/base/content/test/plugins/browser_CTP_nonplugins.js
@@ -13,17 +13,17 @@ add_task(async function() {
     window.focus();
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_DISABLED, "Test Plug-in");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_two_types.html");
 
   // Work around for delayed PluginBindingAttached
   await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
 
--- a/browser/base/content/test/plugins/browser_CTP_notificationBar.js
+++ b/browser/base/content/test/plugins/browser_CTP_notificationBar.js
@@ -11,17 +11,17 @@ add_task(async function() {
     Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
 
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
--- a/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js
+++ b/browser/base/content/test/plugins/browser_CTP_outsideScrollArea.js
@@ -15,17 +15,17 @@ add_task(async function() {
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 1, Should not have a click-to-play notification");
 });
--- a/browser/base/content/test/plugins/browser_CTP_remove_navigate.js
+++ b/browser/base/content/test/plugins/browser_CTP_remove_navigate.js
@@ -20,17 +20,17 @@ add_task(async function() {
 });
 
 /**
  * Tests that if a plugin is removed just as we transition to
  * a different page, that we don't show the hidden plugin
  * notification bar on the new page.
  */
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   // Load up a page with a plugin...
   let notificationPromise = waitForNotificationBar("plugin-hidden", gBrowser.selectedBrowser);
   await promiseTabLoadEvent(gBrowser.selectedTab, gHttpTestRoot + "plugin_small.html");
   await promiseUpdatePluginBindings(gBrowser.selectedBrowser);
   await notificationPromise;
 
   // Trigger the PluginRemoved event to be fired, and then immediately
--- a/browser/base/content/test/plugins/browser_CTP_resize.js
+++ b/browser/base/content/test/plugins/browser_CTP_resize.js
@@ -14,17 +14,17 @@ add_task(async function() {
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 1, Should not have a click-to-play notification");
 
--- a/browser/base/content/test/plugins/browser_CTP_zoom.js
+++ b/browser/base/content/test/plugins/browser_CTP_zoom.js
@@ -18,17 +18,17 @@ add_task(async function() {
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
   ok(!popupNotification, "Test 1, Should not have a click-to-play notification");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_zoom.html");
--- a/browser/base/content/test/plugins/browser_blocking.js
+++ b/browser/base/content/test/plugins/browser_blocking.js
@@ -17,17 +17,17 @@ add_task(async function() {
     resetBlocklist();
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
 
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   // Prime the content process
--- a/browser/base/content/test/plugins/browser_blocklist_content.js
+++ b/browser/base/content/test/plugins/browser_blocklist_content.js
@@ -16,17 +16,17 @@ add_task(async function() {
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
 
   // Prime the blocklist service, the remote service doesn't launch on startup.
   await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
   let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
--- a/browser/base/content/test/plugins/browser_bug743421.js
+++ b/browser/base/content/test/plugins/browser_bug743421.js
@@ -11,17 +11,17 @@ add_task(async function() {
     resetBlocklist();
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
--- a/browser/base/content/test/plugins/browser_bug744745.js
+++ b/browser/base/content/test/plugins/browser_bug744745.js
@@ -18,17 +18,17 @@ add_task(async function() {
     setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   gTestBrowser.addEventListener("PluginBindingAttached", pluginBindingAttached, true, true);
 
--- a/browser/base/content/test/plugins/browser_bug787619.js
+++ b/browser/base/content/test/plugins/browser_bug787619.js
@@ -12,17 +12,17 @@ add_task(async function() {
     window.focus();
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   let testRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
   await promiseTabLoadEvent(gBrowser.selectedTab, testRoot + "plugin_bug787619.html");
 
   // Due to layout being async, "PluginBindAttached" may trigger later.
--- a/browser/base/content/test/plugins/browser_bug797677.js
+++ b/browser/base/content/test/plugins/browser_bug797677.js
@@ -11,17 +11,17 @@ add_task(async function() {
     setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Test Plug-in");
     setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
     consoleService.unregisterListener(errorListener);
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   let consoleService = Cc["@mozilla.org/consoleservice;1"]
                          .getService(Ci.nsIConsoleService);
   let errorListener = {
     observe(aMessage) {
       if (aMessage.message.includes("NS_ERROR_FAILURE"))
         gConsoleErrors++;
--- a/browser/base/content/test/plugins/browser_bug812562.js
+++ b/browser/base/content/test/plugins/browser_bug812562.js
@@ -8,17 +8,17 @@ add_task(async function() {
     setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
     await asyncSetAndUpdateBlocklist(gTestRoot + "blockNoPlugins.xml", gTestBrowser);
     resetBlocklist();
     Services.prefs.clearUserPref("plugins.click_to_play");
     gBrowser.removeCurrentTab();
     window.focus();
     gTestBrowser = null;
   });
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   // Prime the blocklist service, the remote service doesn't launch on startup.
   await promiseTabLoadEvent(gBrowser.selectedTab, "data:text/html,<html></html>");
   let exmsg = await promiseInitContentBlocklistSvc(gBrowser.selectedBrowser);
--- a/browser/base/content/test/plugins/browser_bug818118.js
+++ b/browser/base/content/test/plugins/browser_bug818118.js
@@ -11,17 +11,17 @@ add_task(async function() {
     window.focus();
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_both.html");
 
   // Work around for delayed PluginBindingAttached
   await promiseUpdatePluginBindings(gTestBrowser);
--- a/browser/base/content/test/plugins/browser_bug820497.js
+++ b/browser/base/content/test/plugins/browser_bug820497.js
@@ -12,17 +12,17 @@ add_task(async function() {
     window.focus();
     gTestBrowser = null;
   });
 });
 
 add_task(async function() {
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
 
   gTestBrowser.addEventListener("PluginBindingAttached", function() { gNumPluginBindingsAttached++ }, true, true);
 
   await promiseTabLoadEvent(gBrowser.selectedTab, gTestRoot + "plugin_bug820497.html");
--- a/browser/base/content/test/plugins/browser_clearplugindata.js
+++ b/browser/base/content/test/plugins/browser_clearplugindata.js
@@ -67,17 +67,17 @@ function setPrefs(cookies, pluginData) {
   itemPrefs.setBoolPref("passwords", false);
   itemPrefs.setBoolPref("sessions", false);
   itemPrefs.setBoolPref("siteSettings", false);
   itemPrefs.setBoolPref("pluginData", pluginData);
 }
 
 async function testClearingData(url) {
   // Load page to set data for the plugin.
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   await promiseTabLoadEvent(gBrowser.selectedTab, url);
 
   await promiseUpdatePluginBindings(gTestBrowser);
 
   ok(stored(["foo.com", "bar.com", "baz.com", "qux.com"]),
     "Data stored for sites");
--- a/browser/base/content/test/plugins/browser_pageInfo_plugins.js
+++ b/browser/base/content/test/plugins/browser_pageInfo_plugins.js
@@ -52,17 +52,17 @@ function finishTest() {
   executeSoon(finish);
 }
 
 function test() {
   waitForExplicitFinish();
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_ENABLED, "Second Test Plug-in");
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
   gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gTestPermissionString);
   gPermissionManager.remove(makeURI("http://127.0.0.1:8888/"), gSecondTestPermissionString);
   doOnPageLoad(gHttpTestRoot + "plugin_two_types.html", testPart1a);
 }
 
 // The first test plugin is CtP and the second test plugin is enabled.
 function testPart1a() {
--- a/browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js
+++ b/browser/base/content/test/plugins/browser_pluginCrashCommentAndURL.js
@@ -14,17 +14,17 @@ add_task(async function() {
   // which CrashSubmit.jsm uses as a server override.
   let env = Components.classes["@mozilla.org/process/environment;1"]
                       .getService(Components.interfaces.nsIEnvironment);
   let noReport = env.get("MOZ_CRASHREPORTER_NO_REPORT");
   let serverUrl = env.get("MOZ_CRASHREPORTER_URL");
   env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
   env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   // Crash immediately
   Services.prefs.setIntPref("dom.ipc.plugins.timeoutSecs", 0);
 
   registerCleanupFunction(async function() {
     Services.prefs.clearUserPref("dom.ipc.plugins.timeoutSecs");
     env.set("MOZ_CRASHREPORTER_NO_REPORT", noReport);
--- a/browser/base/content/test/plugins/browser_plugin_reloading.js
+++ b/browser/base/content/test/plugins/browser_plugin_reloading.js
@@ -17,17 +17,17 @@ add_task(async function() {
     resetBlocklist();
     gTestBrowser = null;
     gBrowser.removeCurrentTab();
     window.focus();
   });
 });
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
 
   // Prime the blocklist service, the remote service doesn't launch on startup.
--- a/browser/base/content/test/plugins/browser_pluginnotification.js
+++ b/browser/base/content/test/plugins/browser_pluginnotification.js
@@ -17,17 +17,17 @@ add_task(async function() {
     resetBlocklist();
     gTestBrowser = null;
     gBrowser.removeCurrentTab();
     window.focus();
   });
 });
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   updateAllTestPlugins(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
 
   // Prime the blocklist service, the remote service doesn't launch on startup.
--- a/browser/base/content/test/plugins/browser_plugins_added_dynamically.js
+++ b/browser/base/content/test/plugins/browser_plugins_added_dynamically.js
@@ -16,17 +16,17 @@ add_task(async function() {
     window.focus();
     gTestBrowser = null;
   });
 });
 
 // "Activate" of a given type -> plugins of that type dynamically added should
 // automatically play.
 add_task(async function() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
 
   Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
   Services.prefs.setBoolPref("plugins.click_to_play", true);
 
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Test Plug-in");
   setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY, "Second Test Plug-in");
--- a/browser/base/content/test/plugins/browser_private_clicktoplay.js
+++ b/browser/base/content/test/plugins/browser_private_clicktoplay.js
@@ -31,17 +31,17 @@ let createPrivateWindow = async function
 
 add_task(async function test() {
   registerCleanupFunction(function() {
     clearAllPluginPermissions();
     getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED;
     getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_ENABLED;
   });
 
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   let promise = BrowserTestUtils.browserLoaded(gTestBrowser);
 
   Services.prefs.setBoolPref("plugins.click_to_play", true);
   getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
   getTestPlugin("Second Test Plug-in").enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY;
   await promise;
--- a/browser/base/content/test/popupNotifications/browser_popupNotification.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification.js
@@ -104,17 +104,17 @@ var tests = [
       this.notification.remove();
       ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
     }
   },
   // test opening a notification for a background browser
   // Note: test 4 to 6 share a tab.
   { id: "Test#4",
     async run() {
-      let tab = gBrowser.addTab("http://example.com/");
+      let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/");
       await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
       isnot(gBrowser.selectedTab, tab, "new tab isn't selected");
       wrongBrowserNotificationObject.browser = gBrowser.getBrowserForTab(tab);
       let promiseTopic = promiseTopicObserved("PopupNotifications-backgroundShow");
       wrongBrowserNotification = showNotification(wrongBrowserNotificationObject);
       await promiseTopic;
       is(PopupNotifications.isPanelOpen, false, "panel isn't open");
       ok(!wrongBrowserNotificationObject.mainActionClicked, "main action wasn't clicked");
--- a/browser/base/content/test/popupNotifications/browser_reshow_in_background.js
+++ b/browser/base/content/test/popupNotifications/browser_reshow_in_background.js
@@ -4,20 +4,20 @@
  * Tests that when PopupNotifications for background tabs are reshown, they
  * don't show up in the foreground tab, but only in the background tab that
  * they belong to.
  */
 add_task(async function test_background_notifications_dont_reshow_in_foreground() {
   // Our initial tab will be A. Let's open two more tabs B and C, but keep
   // A selected. Then, we'll trigger a PopupNotification in C, and then make
   // it reshow.
-  let tabB = gBrowser.addTab("http://example.com/");
+  let tabB = BrowserTestUtils.addTab(gBrowser, "http://example.com/");
   await BrowserTestUtils.browserLoaded(tabB.linkedBrowser);
 
-  let tabC = gBrowser.addTab("http://example.com/");
+  let tabC = BrowserTestUtils.addTab(gBrowser, "http://example.com/");
   await BrowserTestUtils.browserLoaded(tabC.linkedBrowser);
 
   let seenEvents = [];
 
   let options = {
     dismissed: false,
     eventCallback(popupEvent) {
       seenEvents.push(popupEvent);
--- a/browser/base/content/test/siteIdentity/browser_bug1045809.js
+++ b/browser/base/content/test/siteIdentity/browser_bug1045809.js
@@ -12,17 +12,17 @@ add_task(async function() {
   });
 
   // Store original preferences so we can restore settings after testing
   origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
 
   // Make sure mixed content blocking is on
   Services.prefs.setBoolPref(PREF_ACTIVE, true);
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   // Test 1: mixed content must be blocked
   await promiseTabLoadEvent(tab, TEST_URL);
   await test1(gBrowser.getBrowserForTab(tab));
 
   await promiseTabLoadEvent(tab);
   // Test 2: mixed content must NOT be blocked
   await test2(gBrowser.getBrowserForTab(tab));
--- a/browser/base/content/test/siteIdentity/browser_bug435035.js
+++ b/browser/base/content/test/siteIdentity/browser_bug435035.js
@@ -1,14 +1,14 @@
 const TEST_URL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "https://example.com") + "test_bug435035.html";
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
     is(document.getElementById("identity-box").className,
        "unknownIdentity mixedDisplayContent",
        "identity box has class name for mixed content");
 
     gBrowser.removeCurrentTab();
     finish();
   });
--- a/browser/base/content/test/siteIdentity/browser_bug822367.js
+++ b/browser/base/content/test/siteIdentity/browser_bug822367.js
@@ -11,17 +11,17 @@ const HTTPS_TEST_ROOT = getRootDirectory
 const HTTPS_TEST_ROOT_2 = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "https://test1.example.com");
 
 var gTestBrowser = null;
 
 add_task(async function test() {
   await SpecialPowers.pushPrefEnv({ set: [[ PREF_DISPLAY, true ],
                                           [ PREF_ACTIVE, true  ]] });
 
-  var newTab = gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   newTab.linkedBrowser.stop()
 
   // Mixed Script Test
   var url = HTTPS_TEST_ROOT + "file_bug822367_1.html";
   BrowserTestUtils.loadURI(gTestBrowser, url);
   await BrowserTestUtils.browserLoaded(gTestBrowser);
--- a/browser/base/content/test/siteIdentity/browser_bug902156.js
+++ b/browser/base/content/test/siteIdentity/browser_bug902156.js
@@ -157,17 +157,17 @@ function test() {
   waitForExplicitFinish();
 
   // Store original preferences so we can restore settings after testing
   origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
 
   Services.prefs.setBoolPref(PREF_ACTIVE, true);
 
   // Not really sure what this is doing
-  var newTab = gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   newTab.linkedBrowser.stop()
 
   // Starting Test Number 1:
   BrowserTestUtils.browserLoaded(gTestBrowser).then(test1A);
   var url = HTTPS_TEST_ROOT_1 + "file_bug902156_1.html";
   gTestBrowser.loadURI(url);
--- a/browser/base/content/test/siteIdentity/browser_csp_block_all_mixedcontent.js
+++ b/browser/base/content/test/siteIdentity/browser_csp_block_all_mixedcontent.js
@@ -27,17 +27,17 @@ function verifyUInotDegraded() {
     }
   );
   // clean up and finish test
   cleanUpAfterTests();
 }
 
 // ------------------------------------------------------
 function runTests() {
-  var newTab = gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   newTab.linkedBrowser.stop();
 
   // Starting the test
   BrowserTestUtils.browserLoaded(gTestBrowser).then(verifyUInotDegraded);
   var url = PRE_PATH + "file_csp_block_all_mixedcontent.html";
   gTestBrowser.loadURI(url);
--- a/browser/base/content/test/siteIdentity/browser_insecureLoginForms.js
+++ b/browser/base/content/test/siteIdentity/browser_insecureLoginForms.js
@@ -22,17 +22,17 @@ add_task(async function test_simple() {
   });
 
   for (let [origin, expectWarning] of [
     ["http://example.com", true],
     ["http://127.0.0.1", false],
     ["https://example.com", false],
   ]) {
     let testUrlPath = origin + TEST_URL_PATH;
-    let tab = gBrowser.addTab(testUrlPath + "form_basic.html");
+    let tab = BrowserTestUtils.addTab(gBrowser, testUrlPath + "form_basic.html");
     let browser = tab.linkedBrowser;
     await Promise.all([
       BrowserTestUtils.switchTab(gBrowser, tab),
       BrowserTestUtils.browserLoaded(browser),
       // One event is triggered by pageshow and one by DOMFormHasPassword.
       waitForInsecureLoginFormsStateChange(browser, 2),
     ]);
 
@@ -83,17 +83,17 @@ add_task(async function test_simple() {
  */
 add_task(async function test_mixedcontent() {
   await SpecialPowers.pushPrefEnv({
     "set": [["security.mixed_content.block_active_content", false]],
   });
 
   // Load the page with the subframe in a new tab.
   let testUrlPath = "://example.com" + TEST_URL_PATH;
-  let tab = gBrowser.addTab("https" + testUrlPath + "insecure_test.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, "https" + testUrlPath + "insecure_test.html");
   let browser = tab.linkedBrowser;
   await Promise.all([
     BrowserTestUtils.switchTab(gBrowser, tab),
     BrowserTestUtils.browserLoaded(browser),
     // Two events are triggered by pageshow and one by DOMFormHasPassword.
     waitForInsecureLoginFormsStateChange(browser, 3),
   ]);
 
--- a/browser/base/content/test/siteIdentity/browser_mcb_redirect.js
+++ b/browser/base/content/test/siteIdentity/browser_mcb_redirect.js
@@ -283,15 +283,15 @@ function test() {
   waitForExplicitFinish();
 
   // Store original preferences so we can restore settings after testing
   origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
   origBlockDisplay = Services.prefs.getBoolPref(PREF_DISPLAY);
   Services.prefs.setBoolPref(PREF_ACTIVE, true);
   Services.prefs.setBoolPref(PREF_DISPLAY, true);
 
-  var newTab = gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   newTab.linkedBrowser.stop();
 
   executeSoon(test1);
 }
--- a/browser/base/content/test/social/browser_social_activation.js
+++ b/browser/base/content/test/social/browser_social_activation.js
@@ -234,17 +234,17 @@ var tests = {
           next();
         });
       });
     });
   },
 
   testAddonManagerDoubleInstall(next) {
     // Create a new tab and load about:addons
-    let addonsTab = gBrowser.addTab();
+    let addonsTab = BrowserTestUtils.addTab(gBrowser);
     gBrowser.selectedTab = addonsTab;
     BrowserOpenAddonsMgr("addons://list/service");
     gBrowser.selectedBrowser.addEventListener("load", function() {
       is(addonsTab.linkedBrowser.currentURI.spec, "about:addons", "about:addons should load into blank tab.");
 
       activateOneProvider(gProviders[0], true, function() {
         info("first activation completed");
         is(gBrowser.contentDocument.location.href, gProviders[0].origin + "/browser/browser/base/content/test/social/social_postActivation.html", "postActivationURL loaded");
--- a/browser/base/content/test/sync/browser_aboutAccounts.js
+++ b/browser/base/content/test/sync/browser_aboutAccounts.js
@@ -413,32 +413,32 @@ function promiseOneMessage(tab, messageN
     mm.addMessageListener(messageName, function onmessage(message) {
       mm.removeMessageListener(messageName, onmessage);
       resolve(message);
     });
   });
 }
 
 function promiseNewTabLoadEvent(aUrl) {
-  let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, aUrl);
   let browser = tab.linkedBrowser;
   let mm = browser.messageManager;
 
   // give it an e10s-friendly content script to help with our tests,
   // and wait for it to tell us about the load.
   let promise = promiseOneMessage(tab, "test:document:load");
   mm.loadFrameScript(CHROME_BASE + "content_aboutAccounts.js", true);
   return promise.then(() => tab);
 }
 
 // Returns a promise which is resolved with the iframe's URL after a new
 // tab is created and the iframe in that tab loads.
 function promiseNewTabWithIframeLoadEvent(aUrl) {
   return new Promise(resolve => {
-    let tab = gBrowser.selectedTab = gBrowser.addTab(aUrl);
+    let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, aUrl);
     let browser = tab.linkedBrowser;
     let mm = browser.messageManager;
 
     // give it an e10s-friendly content script to help with our tests,
     // and wait for it to tell us about the iframe load.
     mm.addMessageListener("test:iframe:load", function onFrameLoad(message) {
       mm.removeMessageListener("test:iframe:load", onFrameLoad);
       resolve([tab, message.data.url]);
--- a/browser/base/content/test/tabPrompts/browser_closeTabSpecificPanels.js
+++ b/browser/base/content/test/tabPrompts/browser_closeTabSpecificPanels.js
@@ -3,18 +3,18 @@
 /*
  * This test creates multiple panels, one that has been tagged as specific to its tab's content
  * and one that isn't. When a tab loses focus, panel specific to that tab should close.
  * The non-specific panel should remain open.
  *
  */
 
 add_task(async function() {
-  let tab1 = gBrowser.addTab("http://mochi.test:8888/#0");
-  let tab2 = gBrowser.addTab("http://mochi.test:8888/#1");
+  let tab1 = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/#0");
+  let tab2 = BrowserTestUtils.addTab(gBrowser, "http://mochi.test:8888/#1");
   let specificPanel = document.createElement("panel");
   specificPanel.setAttribute("tabspecific", "true");
   let generalPanel = document.createElement("panel");
   let anchor = document.getElementById(CustomizableUI.AREA_NAVBAR);
 
   anchor.appendChild(specificPanel);
   anchor.appendChild(generalPanel);
   is(specificPanel.state, "closed", "specificPanel starts as closed");
--- a/browser/base/content/test/tabs/browser_navigatePinnedTab.js
+++ b/browser/base/content/test/tabs/browser_navigatePinnedTab.js
@@ -4,17 +4,17 @@
 "use strict";
 
 add_task(async function() {
   // Test that changing the URL in a pinned tab works correctly
 
   let TEST_LINK_INITIAL = "about:";
   let TEST_LINK_CHANGED = "about:support";
 
-  let appTab = gBrowser.addTab(TEST_LINK_INITIAL);
+  let appTab = BrowserTestUtils.addTab(gBrowser, TEST_LINK_INITIAL);
   let browser = appTab.linkedBrowser;
   await BrowserTestUtils.browserLoaded(browser);
 
   gBrowser.pinTab(appTab);
   is(appTab.pinned, true, "Tab was successfully pinned");
 
   let initialTabsNo = gBrowser.tabs.length;
 
--- a/browser/base/content/test/tabs/browser_tabSpinnerTypeProbe.js
+++ b/browser/base/content/test/tabs/browser_tabSpinnerTypeProbe.js
@@ -112,17 +112,17 @@ add_task(async function test_unseenOld_s
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: "http://example.com",
   }, async function(browser) {
     const NEWNESS_THRESHOLD = gBrowser._getSwitcher().NEWNESS_THRESHOLD;
 
     // First, create a new background tab, ensuring that it's in the same process
     // as the current one.
-    let bgTab = gBrowser.addTab("about:blank", {
+    let bgTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
       sameProcessAsFrameLoader: browser.frameLoader,
       inBackground: true,
     });
 
     await BrowserTestUtils.browserLoaded(bgTab.linkedBrowser);
 
     // Now, let's fudge with the creationTime of the background tab so that
     // it seems old. We'll also add a fudge-factor to the NEWNESS_THRESHOLD of 100ms
@@ -154,17 +154,17 @@ add_task(async function test_unseenOld_s
  */
 add_task(async function test_unseenNew_spinner_type_probe() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: "http://example.com",
   }, async function(browser) {
     // First, create a new background tab, ensuring that it's in the same process
     // as the current one.
-    let bgTab = gBrowser.addTab("about:blank", {
+    let bgTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
       sameProcessAsFrameLoader: browser.frameLoader,
       inBackground: true,
     });
 
     await BrowserTestUtils.browserLoaded(bgTab.linkedBrowser);
 
     // Now, let's fudge with the creationTime of the background tab so that
     // it seems very new (created 1 minute into the future).
--- a/browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js
+++ b/browser/base/content/test/tabs/browser_tabSwitchPrintPreview.js
@@ -2,17 +2,17 @@ const kURL1 = "data:text/html,Should I s
 const kURL2 = "data:text/html,I shouldn't be here!";
 
 /**
  * Verify that if we open a new tab and try to make it the selected tab while
  * print preview is up, that doesn't happen.
  */
 add_task(async function() {
   await BrowserTestUtils.withNewTab(kURL1, async function(browser) {
-    let tab = gBrowser.addTab(kURL2);
+    let tab = BrowserTestUtils.addTab(gBrowser, kURL2);
     document.getElementById("cmd_printPreview").doCommand();
     gBrowser.selectedTab = tab;
     await BrowserTestUtils.waitForCondition(() => gInPrintPreviewMode, "should be in print preview mode");
     isnot(gBrowser.selectedTab, tab, "Selected tab should not be the tab we added");
     is(gBrowser.selectedTab, PrintPreviewListener._printPreviewTab, "Selected tab should be the print preview tab");
     gBrowser.selectedTab = tab;
     isnot(gBrowser.selectedTab, tab, "Selected tab should still not be the tab we added");
     is(gBrowser.selectedTab, PrintPreviewListener._printPreviewTab, "Selected tab should still be the print preview tab");
--- a/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js
+++ b/browser/base/content/test/urlbar/browser_autocomplete_edit_completed.js
@@ -5,17 +5,17 @@ add_task(async function() {
     { uri: makeURI("http://example.com/foo") },
     { uri: makeURI("http://example.com/foo/bar") },
   ]);
 
   registerCleanupFunction(async function() {
     await PlacesTestUtils.clearHistory();
   });
 
-  gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   gURLBar.focus();
 
   await promiseAutocompleteResultPopup("http://example.com");
 
   let popup = gURLBar.popup;
   let list = popup.richlistbox;
   let initialIndex = list.selectedIndex;
 
--- a/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js
+++ b/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js
@@ -4,17 +4,17 @@
 
 add_task(async function test_switchtab_override() {
   let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
 
   info("Opening first tab");
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testURL);
 
   info("Opening and selecting second tab");
-  let secondTab = gBrowser.selectedTab = gBrowser.addTab();
+  let secondTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(() => {
     try {
       gBrowser.removeTab(tab);
       gBrowser.removeTab(secondTab);
     } catch (ex) { /* tabs may have already been closed in case of failure */ }
   });
 
   info("Wait for autocomplete")
--- a/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js
+++ b/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js
@@ -4,17 +4,17 @@
 
 add_task(async function test_switchtab_override_keynav() {
   let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
 
   info("Opening first tab");
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testURL);
 
   info("Opening and selecting second tab");
-  let secondTab = gBrowser.selectedTab = gBrowser.addTab();
+  let secondTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(() => {
     try {
       gBrowser.removeTab(tab);
       gBrowser.removeTab(secondTab);
     } catch (ex) { /* tabs may have already been closed in case of failure */ }
     return PlacesTestUtils.clearHistory();
   });
 
--- a/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js
+++ b/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js
@@ -1,15 +1,15 @@
 add_task(async function test_switchtab_decodeuri() {
   info("Opening first tab");
   const TEST_URL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#test%7C1";
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
 
   info("Opening and selecting second tab");
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   info("Wait for autocomplete")
   await promiseAutocompleteResultPopup("dummy_page");
 
   info("Select autocomplete popup entry");
   EventUtils.synthesizeKey("VK_DOWN", {});
   ok(gURLBar.value.startsWith("moz-action:switchtab"), "switch to tab entry found");
 
--- a/browser/base/content/test/urlbar/browser_bug304198.js
+++ b/browser/base/content/test/urlbar/browser_bug304198.js
@@ -1,19 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 add_task(async function() {
   let charsToDelete, deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
 
   charsToDelete = 5;
-  deletedURLTab = gBrowser.addTab();
-  fullURLTab = gBrowser.addTab();
-  partialURLTab = gBrowser.addTab();
+  deletedURLTab = BrowserTestUtils.addTab(gBrowser);
+  fullURLTab = BrowserTestUtils.addTab(gBrowser);
+  partialURLTab = BrowserTestUtils.addTab(gBrowser);
   testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
 
   let loaded1 = BrowserTestUtils.browserLoaded(deletedURLTab.linkedBrowser, testURL);
   let loaded2 = BrowserTestUtils.browserLoaded(fullURLTab.linkedBrowser, testURL);
   let loaded3 = BrowserTestUtils.browserLoaded(partialURLTab.linkedBrowser, testURL);
   deletedURLTab.linkedBrowser.loadURI(testURL);
   fullURLTab.linkedBrowser.loadURI(testURL);
   partialURLTab.linkedBrowser.loadURI(testURL);
--- a/browser/base/content/test/urlbar/browser_bug556061.js
+++ b/browser/base/content/test/urlbar/browser_bug556061.js
@@ -84,14 +84,14 @@ var tests = [
     success() {
       is(gURLBar.value, testURL.substring(0, testURL.length - 10), "gURLBar.value has the correct value");
     }
   }
 ];
 
 function test() {
   waitForExplicitFinish();
-  testTab = gBrowser.addTab();
+  testTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = testTab;
 
   // Kick off the testing
   runNextTest();
 }
--- a/browser/base/content/test/urlbar/browser_bug562649.js
+++ b/browser/base/content/test/urlbar/browser_bug562649.js
@@ -3,17 +3,17 @@ function test() {
   window.browserDOMWindow.openURI(makeURI(URI),
                                   null,
                                   Ci.nsIBrowserDOMWindow.OPEN_NEWTAB,
                                   Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
 
   is(gBrowser.userTypedValue, URI, "userTypedValue matches test URI");
   is(gURLBar.value, URI, "location bar value matches test URI");
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.removeCurrentTab({ skipPermitUnload: true });
   is(gBrowser.userTypedValue, URI, "userTypedValue matches test URI after switching tabs");
   is(gURLBar.value, URI, "location bar value matches test URI after switching tabs");
 
   waitForExplicitFinish();
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
     is(gBrowser.userTypedValue, null, "userTypedValue is null as the page has loaded");
     is(gURLBar.value, URI, "location bar value matches test URI as the page has loaded");
--- a/browser/base/content/test/urlbar/browser_bug623155.js
+++ b/browser/base/content/test/urlbar/browser_bug623155.js
@@ -44,17 +44,17 @@ 8. End.
  */
 
 var gNewTab;
 
 function test() {
   waitForExplicitFinish();
 
   // Load a URI in the background.
-  gNewTab = gBrowser.addTab(REDIRECT_FROM + "#BG");
+  gNewTab = BrowserTestUtils.addTab(gBrowser, REDIRECT_FROM + "#BG");
   gBrowser.getBrowserForTab(gNewTab)
           .webProgress
           .addProgressListener(gWebProgressListener,
                                Components.interfaces.nsIWebProgress
                                                     .NOTIFY_LOCATION);
 }
 
 var gWebProgressListener = {
--- a/browser/base/content/test/urlbar/browser_locationBarCommand.js
+++ b/browser/base/content/test/urlbar/browser_locationBarCommand.js
@@ -180,17 +180,17 @@ function promiseLoadStarted() {
           resolve();
         }
       }
     });
   });
 }
 
 async function promiseOpenNewTab(url = "about:blank") {
-  let tab = gBrowser.addTab(url);
+  let tab = BrowserTestUtils.addTab(gBrowser, url);
   let tabSwitchPromise = promiseNewTabSwitched(tab);
   gBrowser.selectedTab = tab;
   await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
   await tabSwitchPromise;
   return tab;
 }
 
 function promiseNewTabSwitched() {
--- a/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js
+++ b/browser/base/content/test/urlbar/browser_locationBarExternalLoad.js
@@ -24,17 +24,17 @@ function promiseNewTabSwitched() {
     gBrowser.addEventListener("TabSwitchDone", function() {
       executeSoon(resolve);
     }, {once: true});
   });
 }
 
 async function testURL(url, loadFunc, endFunc) {
   let tabSwitchedPromise = promiseNewTabSwitched();
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   let browser = gBrowser.selectedBrowser;
 
   let pageshowPromise = BrowserTestUtils.waitForContentEvent(browser, "pageshow");
 
   await tabSwitchedPromise;
   await pageshowPromise;
 
   let pagePrincipal = gBrowser.contentPrincipal;
--- a/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js
+++ b/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js
@@ -16,17 +16,17 @@ var gController = Cc["@mozilla.org/autoc
 
 var gTabCounter = 0;
 
 add_task(async function step_1() {
   info("Running step 1");
   let maxResults = Services.prefs.getIntPref("browser.urlbar.maxRichResults");
   let promises = [];
   for (let i = 0; i < maxResults - 1; i++) {
-    let tab = gBrowser.addTab();
+    let tab = BrowserTestUtils.addTab(gBrowser);
     promises.push(loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter)));
   }
 
   await Promise.all(promises);
   await ensure_opentabs_match_db();
 });
 
 add_task(async function step_2() {
@@ -51,40 +51,40 @@ add_task(async function step_3() {
     promises.push(loadTab(gBrowser.tabs[i], TEST_URL_BASES[0] + gTabCounter));
 
   await Promise.all(promises);
   await ensure_opentabs_match_db();
 });
 
 add_task(async function step_4() {
   info("Running step 4 - ensure we don't register subframes as open pages");
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   tab.linkedBrowser.loadURI('data:text/html,<body><iframe src=""></iframe></body>');
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   await ContentTask.spawn(tab.linkedBrowser, null, async function() {
     let iframe_loaded = ContentTaskUtils.waitForEvent(content.document, "load", true);
     content.document.querySelector("iframe").src = "http://test2.example.org/";
     await iframe_loaded;
   });
 
   await ensure_opentabs_match_db();
 });
 
 add_task(async function step_5() {
   info("Running step 5 - remove tab immediately");
-  let tab = gBrowser.addTab("about:logo");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:logo");
   await BrowserTestUtils.removeTab(tab);
   await ensure_opentabs_match_db();
 });
 
 add_task(async function step_6() {
   info("Running step 6 - check swapBrowsersAndCloseOther preserves registered switch-to-tab result");
-  let tabToKeep = gBrowser.addTab();
-  let tab = gBrowser.addTab();
+  let tabToKeep = BrowserTestUtils.addTab(gBrowser);
+  let tab = BrowserTestUtils.addTab(gBrowser);
   tab.linkedBrowser.loadURI("about:mozilla");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   gBrowser.updateBrowserRemoteness(tabToKeep.linkedBrowser, tab.linkedBrowser.isRemoteBrowser);
   gBrowser.swapBrowsersAndCloseOther(tabToKeep, tab);
 
   await ensure_opentabs_match_db()
 
@@ -93,17 +93,17 @@ add_task(async function step_6() {
   await ensure_opentabs_match_db();
 });
 
 add_task(async function step_7() {
   info("Running step 7 - close all tabs");
 
   Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
 
-  gBrowser.addTab("about:blank", {skipAnimation: true});
+  BrowserTestUtils.addTab(gBrowser, "about:blank", {skipAnimation: true});
   while (gBrowser.tabs.length > 1) {
     info("Removing tab: " + gBrowser.tabs[0].linkedBrowser.currentURI.spec);
     gBrowser.selectTabAtIndex(0);
     gBrowser.removeCurrentTab();
   }
 
   await ensure_opentabs_match_db();
 });
--- a/browser/base/content/test/urlbar/browser_urlbarAboutHomeLoading.js
+++ b/browser/base/content/test/urlbar/browser_urlbarAboutHomeLoading.js
@@ -4,17 +4,17 @@ const {SessionSaver} = Cu.import("resour
 const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
 
 /**
  * Test what happens if loading a URL that should clear the
  * location bar after a parent process URL.
  */
 add_task(async function clearURLBarAfterParentProcessURL() {
   let tab = await new Promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab("about:preferences");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:preferences");
     let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
     newTabBrowser.addEventListener("Initialized", function() {
       resolve(gBrowser.selectedTab);
     }, {capture: true, once: true});
   });
   document.getElementById("home-button").click();
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   is(gURLBar.value, "", "URL bar should be empty");
@@ -23,17 +23,17 @@ add_task(async function clearURLBarAfter
 });
 
 /**
  * Same as above, but open the tab without passing the URL immediately
  * which changes behaviour in tabbrowser.xml.
  */
 add_task(async function clearURLBarAfterParentProcessURLInExistingTab() {
   let tab = await new Promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab();
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
     let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
     newTabBrowser.addEventListener("Initialized", function() {
       resolve(gBrowser.selectedTab);
     }, {capture: true, once: true});
     newTabBrowser.loadURI("about:preferences");
   });
   document.getElementById("home-button").click();
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
--- a/browser/base/content/test/urlbar/browser_urlbarCopying.js
+++ b/browser/base/content/test/urlbar/browser_urlbarCopying.js
@@ -10,17 +10,17 @@ function toUnicode(input) {
                     .createInstance(Ci.nsIScriptableUnicodeConverter);
   converter.charset = "UTF-8";
 
   return converter.ConvertToUnicode(input);
 }
 
 function test() {
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   registerCleanupFunction(function() {
     gBrowser.removeTab(tab);
     Services.prefs.clearUserPref(trimPref);
     Services.prefs.clearUserPref(phishyUserPassPref);
     Services.prefs.clearUserPref(decodeURLpref);
     URLBarSetURI();
   });
--- a/browser/base/content/test/urlbar/browser_urlbarEnter.js
+++ b/browser/base/content/test/urlbar/browser_urlbarEnter.js
@@ -3,17 +3,17 @@
 
 "use strict";
 
 const TEST_VALUE = "example.com/\xF7?\xF7";
 const START_VALUE = "example.com/%C3%B7?%C3%B7";
 
 add_task(async function() {
   info("Simple return keypress");
-  let tab = gBrowser.selectedTab = gBrowser.addTab(START_VALUE);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, START_VALUE);
 
   gURLBar.focus();
   EventUtils.synthesizeKey("VK_RETURN", {});
   await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
   // Check url bar and selected tab.
   is(gURLBar.textValue, TEST_VALUE, "Urlbar should preserve the value on return keypress");
   is(gBrowser.selectedTab, tab, "New URL was loaded in the current tab");
--- a/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js
+++ b/browser/base/content/test/urlbar/browser_urlbarEnterAfterMouseOver.js
@@ -29,17 +29,17 @@ add_task(async function() {
   let visits = [];
   repeat(gMaxResults, i => {
     visits.push({
       uri: makeURI("http://example.com/autocomplete/?" + i),
     });
   });
   await PlacesTestUtils.addVisits(visits);
 
-  gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await promiseAutoComplete("http://example.com/autocomplete/");
 
   let popup = gURLBar.popup;
   let results = popup.richlistbox.children;
   is(results.length, gMaxResults,
      "Should get gMaxResults=" + gMaxResults + " results");
 
   let initiallySelected = gURLBar.popup.richlistbox.selectedIndex;
--- a/browser/base/content/test/urlbar/browser_urlbarOneOffs.js
+++ b/browser/base/content/test/urlbar/browser_urlbarOneOffs.js
@@ -179,17 +179,17 @@ add_task(async function searchWith() {
                "Search with " + engineName,
                "First result's action text should be updated");
 
   await hidePopup();
 });
 
 // Clicks a one-off.
 add_task(async function oneOffClick() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   // We are explicitly using something that looks like a url, to make the test
   // stricter. Even if it looks like a url, we should search.
   let typedValue = "foo.bar";
   await promiseAutocompleteResultPopup(typedValue);
 
   assertState(0, -1, typedValue);
 
@@ -200,17 +200,17 @@ add_task(async function oneOffClick() {
   EventUtils.synthesizeMouseAtCenter(oneOffs[0], {});
   await resultsPromise;
 
   gBrowser.removeTab(gBrowser.selectedTab);
 });
 
 // Presses the Return key when a one-off is selected.
 add_task(async function oneOffReturn() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   // We are explicitly using something that looks like a url, to make the test
   // stricter. Even if it looks like a url, we should search.
   let typedValue = "foo.bar";
   await promiseAutocompleteResultPopup(typedValue, window, true);
 
   assertState(0, -1, typedValue);
 
--- a/browser/base/content/test/urlbar/browser_urlbarRevert.js
+++ b/browser/base/content/test/urlbar/browser_urlbarRevert.js
@@ -9,17 +9,17 @@ function test() {
           aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
         gBrowser.removeProgressListener(this);
         executeSoon(checkURLBarRevert);
       }
     }
   }
 
   gBrowser.addProgressListener(pageLoaded);
-  tab = gBrowser.addTab("http://example.com");
+  tab = BrowserTestUtils.addTab(gBrowser, "http://example.com");
   gBrowser.selectedTab = tab;
 }
 
 function checkURLBarRevert() {
   let originalValue = gURLBar.value;
 
   gBrowser.userTypedValue = "foobar";
   gBrowser.selectedTab = gBrowser.tabs[0];
--- a/browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
+++ b/browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
@@ -53,72 +53,72 @@ async function runURLBarSearchTest({valu
 
   await Promise.all([
     docLoadPromise,
     promiseNotification(aWindow.gBrowser, "keyword-uri-fixup", expectNotification, valueToOpen)
   ]);
 }
 
 add_task(async function test_navigate_full_domain() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "www.mozilla.org",
     expectSearch: false,
     expectNotification: false,
   });
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_navigate_decimal_ip() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "1234",
     expectSearch: true,
     expectNotification: false,
   });
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_navigate_decimal_ip_with_path() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "1234/12",
     expectSearch: true,
     expectNotification: false,
   });
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_navigate_large_number() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "123456789012345",
     expectSearch: true,
     expectNotification: false
   });
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_navigate_small_hex_number() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "0x1f00ffff",
     expectSearch: true,
     expectNotification: false
   });
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_navigate_large_hex_number() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "0x7f0000017f000001",
     expectSearch: true,
     expectNotification: false
   });
   gBrowser.removeTab(tab);
 });
@@ -182,17 +182,17 @@ function get_test_function_for_localhost
   }
 }
 
 add_task(get_test_function_for_localhost_with_hostname("localhost"));
 add_task(get_test_function_for_localhost_with_hostname("localhost."));
 add_task(get_test_function_for_localhost_with_hostname("localhost", true));
 
 add_task(async function test_navigate_invalid_url() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await runURLBarSearchTest({
     valueToOpen: "mozilla is awesome",
     expectSearch: true,
     expectNotification: false,
   });
   gBrowser.removeTab(tab);
 });
--- a/browser/base/content/test/urlbar/browser_urlbarStop.js
+++ b/browser/base/content/test/urlbar/browser_urlbarStop.js
@@ -1,23 +1,23 @@
 "use strict";
 
 const goodURL = "http://mochi.test:8888/";
 const badURL = "http://mochi.test:8888/whatever.html";
 
 add_task(async function() {
-  gBrowser.selectedTab = gBrowser.addTab(goodURL);
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, goodURL);
   await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
   is(gURLBar.textValue, gURLBar.trimValue(goodURL), "location bar reflects loaded page");
 
   await typeAndSubmitAndStop(badURL);
   is(gURLBar.textValue, gURLBar.trimValue(goodURL), "location bar reflects loaded page after stop()");
   gBrowser.removeCurrentTab();
 
-  gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   is(gURLBar.textValue, "", "location bar is empty");
 
   await typeAndSubmitAndStop(badURL);
   is(gURLBar.textValue, gURLBar.trimValue(badURL), "location bar reflects stopped page in an empty tab");
   gBrowser.removeCurrentTab();
 });
 
 async function typeAndSubmitAndStop(url) {
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_anim.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_anim.js
@@ -35,17 +35,17 @@ var gTests = [
          "the tab has the attribute to show the " + aSharing + " icon");
       let icon =
         document.getAnonymousElementByAttribute(tab, "anonid", "sharing-icon");
       is(window.getComputedStyle(icon).display, "none",
          "the animated sharing icon of the tab is hidden");
 
       // After selecting a new tab, check the attribute is still there,
       // and the icon is now visible.
-      await BrowserTestUtils.switchTab(gBrowser, gBrowser.addTab());
+      await BrowserTestUtils.switchTab(gBrowser, BrowserTestUtils.addTab(gBrowser));
       is(gBrowser.selectedTab.getAttribute("sharing"), "",
          "the new tab doesn't have the 'sharing' attribute");
       is(tab.getAttribute("sharing"), aSharing,
          "the tab still has the 'sharing' attribute");
       isnot(window.getComputedStyle(icon).display, "none",
             "the animated sharing icon of the tab is now visible");
 
       // Ensure the icon disappears when selecting the tab.
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_tear_off_tab.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_tear_off_tab.js
@@ -58,12 +58,12 @@ var gTests = [
 
 ];
 
 add_task(async function test() {
   await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 1]]});
 
   // An empty tab where we can load the content script without leaving it
   // behind at the end of the test.
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
 
   await runTests(gTests);
 });
--- a/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
+++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_unprompted_access_tear_off_tab.js
@@ -51,12 +51,12 @@ var gTests = [
 
 ];
 
 add_task(async function test() {
   await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 1]]});
 
   // An empty tab where we can load the content script without leaving it
   // behind at the end of the test.
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
 
   await runTests(gTests);
 });
--- a/browser/components/contextualidentity/test/browser/browser_aboutURLs.js
+++ b/browser/components/contextualidentity/test/browser/browser_aboutURLs.js
@@ -34,16 +34,16 @@ add_task(async function() {
     } catch (e) {
       // getService might have thrown if the component doesn't actually
       // implement nsIAboutModule
     }
   }
 
   for (let url of aboutURLs) {
     info("Loading about:" + url);
-    let tab = gBrowser.addTab("about:" + url, {userContextId: 1});
+    let tab = BrowserTestUtils.addTab(gBrowser, "about:" + url, {userContextId: 1});
     await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
     ok(true, "Done loading about:" + url);
 
     await BrowserTestUtils.removeTab(tab);
   }
 });
--- a/browser/components/contextualidentity/test/browser/browser_blobUrl.js
+++ b/browser/components/contextualidentity/test/browser/browser_blobUrl.js
@@ -8,33 +8,33 @@ const BASE_URI = "http://mochi.test:8888
 add_task(async function setup() {
   await SpecialPowers.pushPrefEnv({"set": [
     ["privacy.userContext.enabled", true]
   ]});
 });
 
 add_task(async function test() {
   info("Creating a tab with UCI = 1...");
-  let tab1 = gBrowser.addTab(BASE_URI, {userContextId: 1});
+  let tab1 = BrowserTestUtils.addTab(gBrowser, BASE_URI, {userContextId: 1});
   is(tab1.getAttribute("usercontextid"), 1, "New tab has UCI equal 1");
 
   let browser1 = gBrowser.getBrowserForTab(tab1);
   await BrowserTestUtils.browserLoaded(browser1);
 
   let blobURL;
 
   info("Creating a blob URL...");
   await ContentTask.spawn(browser1, null, function() {
     return Promise.resolve(content.window.URL.createObjectURL(new content.window.Blob([123])));
   }).then(newURL => { blobURL = newURL });
 
   info("Blob URL: " + blobURL);
 
   info("Creating a tab with UCI = 2...");
-  let tab2 = gBrowser.addTab(BASE_URI, {userContextId: 2});
+  let tab2 = BrowserTestUtils.addTab(gBrowser, BASE_URI, {userContextId: 2});
   is(tab2.getAttribute("usercontextid"), 2, "New tab has UCI equal 2");
 
   let browser2 = gBrowser.getBrowserForTab(tab2);
   await BrowserTestUtils.browserLoaded(browser2);
 
   await ContentTask.spawn(browser2, blobURL, function(url) {
     return new Promise(resolve => {
       var xhr = new content.window.XMLHttpRequest();
@@ -43,17 +43,17 @@ add_task(async function test() {
       xhr.open("GET", url);
       xhr.send();
     });
   }).then(status => {
     is(status, "SendErrored", "Using a blob URI from one user context id in another should not work");
   });
 
   info("Creating a tab with UCI = 1...");
-  let tab3 = gBrowser.addTab(BASE_URI, {userContextId: 1});
+  let tab3 = BrowserTestUtils.addTab(gBrowser, BASE_URI, {userContextId: 1});
   is(tab3.getAttribute("usercontextid"), 1, "New tab has UCI equal 1");
 
   let browser3 = gBrowser.getBrowserForTab(tab3);
   await BrowserTestUtils.browserLoaded(browser3);
 
   await ContentTask.spawn(browser3, blobURL, function(url) {
     return new Promise(resolve => {
       var xhr = new content.window.XMLHttpRequest();
--- a/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js
+++ b/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js
@@ -3,17 +3,17 @@ let { classes: Cc, interfaces: Ci } = Co
 const BASE_ORIGIN = "http://example.com";
 const URI = BASE_ORIGIN +
   "/browser/browser/components/contextualidentity/test/browser/empty_file.html";
 
 // opens `uri' in a new tab with the provided userContextId and focuses it.
 // returns the newly opened tab
 async function openTabInUserContext(uri, userContextId) {
   // open the tab in the correct userContextId
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_count_and_remove.js
+++ b/browser/components/contextualidentity/test/browser/browser_count_and_remove.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/ContextualIdentityService.jsm");
 
 function openTabInUserContext(userContextId) {
-  let tab = gBrowser.addTab("about:blank", {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank", {userContextId});
   gBrowser.selectedTab = tab;
 }
 
 add_task(async function setup() {
   // make sure userContext is enabled.
   await SpecialPowers.pushPrefEnv({"set": [
           ["privacy.userContext.enabled", true]
         ]});
--- a/browser/components/contextualidentity/test/browser/browser_eme.js
+++ b/browser/components/contextualidentity/test/browser/browser_eme.js
@@ -14,17 +14,17 @@ const TESTKEY = {
   sessionType: "persistent-license",
 };
 
 const USER_ID_DEFAULT = 0;
 const USER_ID_PERSONAL = 1;
 
 async function openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_favicon.js
+++ b/browser/components/contextualidentity/test/browser/browser_favicon.js
@@ -28,17 +28,17 @@ function getIconFile() {
         gFaviconData = NetUtil.readInputStreamToString(inputStream, size);
         resolve();
     });
   });
 }
 
 async function openTabInUserContext(uri, userContextId) {
   // open the tab in the correct userContextId
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_EME_forgetThisSite.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_EME_forgetThisSite.js
@@ -21,17 +21,17 @@ const TEST_EME_KEY = {
 };
 
 //
 // Support functions.
 //
 
 async function openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_cookie_getCookiesWithOriginAttributes.js
@@ -13,17 +13,17 @@ const USER_CONTEXTS = [
 ];
 
 //
 // Support functions.
 //
 
 async function openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js
@@ -13,17 +13,17 @@ const USER_CONTEXTS = [
 ];
 
 //
 // Support functions.
 //
 
 async function openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
+++ b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js
@@ -51,17 +51,17 @@ function loadImagePageHandler(metadata, 
                 <img src='image.png'>\
                 </body>\
               </html>";
   response.bodyOutputStream.write(body, body.length);
 }
 
 async function openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_imageCache.js
+++ b/browser/components/contextualidentity/test/browser/browser_imageCache.js
@@ -34,17 +34,17 @@ add_task(async function setup() {
   // make sure userContext is enabled.
   await SpecialPowers.pushPrefEnv({"set": [["privacy.userContext.enabled", true]]});
 });
 
 // opens `uri' in a new tab with the provided userContextId and focuses it.
 // returns the newly opened tab
 async function openTabInUserContext(uri, userContextId) {
   // open the tab in the correct userContextId
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return tab;
--- a/browser/components/contextualidentity/test/browser/browser_middleClick.js
+++ b/browser/components/contextualidentity/test/browser/browser_middleClick.js
@@ -2,17 +2,17 @@
 
 const BASE_ORIGIN = "http://example.com";
 const URI = BASE_ORIGIN +
   "/browser/browser/components/contextualidentity/test/browser/empty_file.html";
 
 add_task(async function() {
   info("Opening a new container tab...");
 
-  let tab = gBrowser.addTab(URI, { userContextId: 1 });
+  let tab = BrowserTestUtils.addTab(gBrowser, URI, { userContextId: 1 });
   gBrowser.selectedTab = tab;
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
 
   info("Create a HTMLAnchorElement...");
   await ContentTask.spawn(browser, URI,
     function(uri) {
--- a/browser/components/contextualidentity/test/browser/browser_relatedTab.js
+++ b/browser/components/contextualidentity/test/browser/browser_relatedTab.js
@@ -1,31 +1,31 @@
 "use strict";
 
 /*
  * Bug 1325014 - Adding tab related to current tab inherits current tab's container usercontextid unless otherwise specified
  */
 
 add_task(async function() {
-  let tab = gBrowser.addTab("about:blank", {userContextId: 1});
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank", {userContextId: 1});
 
   gBrowser.selectedTab = tab;
-  let relatedTab = gBrowser.addTab("about:blank", {relatedToCurrent: true});
+  let relatedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {relatedToCurrent: true});
   is(relatedTab.getAttribute("usercontextid"), 1, "Related tab (relatedToCurrent) inherits current tab's usercontextid");
   await BrowserTestUtils.removeTab(relatedTab);
 
   gBrowser.selectedTab = tab;
-  relatedTab = gBrowser.addTab("about:blank", {relatedToCurrent: true, userContextId: 2});
+  relatedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {relatedToCurrent: true, userContextId: 2});
   is(relatedTab.getAttribute("usercontextid"), 2, "Related tab (relatedToCurrent) with overridden usercontextid");
   await BrowserTestUtils.removeTab(relatedTab);
 
   gBrowser.selectedTab = tab;
-  relatedTab = gBrowser.addTab("about:blank", {referrerURI: gBrowser.currentURI});
+  relatedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {referrerURI: gBrowser.currentURI});
   is(relatedTab.getAttribute("usercontextid"), 1, "Related tab (referrer) inherits current tab's usercontextid");
   await BrowserTestUtils.removeTab(relatedTab);
 
   gBrowser.selectedTab = tab;
-  relatedTab = gBrowser.addTab("about:blank", {referrerURI: gBrowser.currentURI, userContextId: 2});
+  relatedTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {referrerURI: gBrowser.currentURI, userContextId: 2});
   is(relatedTab.getAttribute("usercontextid"), 2, "Related tab (referrer) with overridden usercontextid");
   await BrowserTestUtils.removeTab(relatedTab);
 
   await BrowserTestUtils.removeTab(tab);
 });
--- a/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js
+++ b/browser/components/contextualidentity/test/browser/browser_restore_getCookiesWithOriginAttributes.js
@@ -17,17 +17,17 @@ const DELETE_CONTEXT = 1;
 const COOKIE_NAME = "userContextId";
 
 //
 // Support functions.
 //
 
 async function openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/contextualidentity/test/browser/browser_serviceworkers.js
+++ b/browser/components/contextualidentity/test/browser/browser_serviceworkers.js
@@ -7,17 +7,17 @@ const BASE_ORIGIN = "https://example.com
 const URI = BASE_ORIGIN +
   "/browser/browser/components/contextualidentity/test/browser/serviceworker.html";
 const NUM_USER_CONTEXTS = 3;
 
 // opens `uri' in a new tab with the provided userContextId and focuses it.
 // returns the newly opened tab
 function openTabInUserContext(uri, userContextId) {
   // open the tab in the correct userContextId
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   return tab;
 }
 
--- a/browser/components/contextualidentity/test/browser/browser_usercontext.js
+++ b/browser/components/contextualidentity/test/browser/browser_usercontext.js
@@ -11,17 +11,17 @@ const USER_CONTEXTS = [
 const BASE_URI = "http://mochi.test:8888/browser/browser/components/"
   + "contextualidentity/test/browser/file_reflect_cookie_into_title.html";
 
 
 // opens `uri' in a new tab with the provided userContextId and focuses it.
 // returns the newly opened tab
 function openTabInUserContext(uri, userContextId) {
   // open the tab in the correct userContextId
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // select tab and make sure its browser is focused
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   return tab;
 }
 
--- a/browser/components/contextualidentity/test/browser/browser_usercontextid_tabdrop.js
+++ b/browser/components/contextualidentity/test/browser/browser_usercontextid_tabdrop.js
@@ -2,17 +2,17 @@
 
 let EventUtils = {};
 Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
 
 /**
  * Dragging an URL to a tab without userContextId set.
  */
 add_task(async function() {
-  let tab = gBrowser.addTab("http://example.com/");
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   let awaitDrop = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "drop");
   let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "http://test1.example.com/");
 
   // A drop type of "link" onto an existing tab would normally trigger a
   // load in that same tab, but tabbrowser code in _getDragTargetTab treats
   // drops on the outer edges of a tab differently (loading a new tab
@@ -49,17 +49,17 @@ add_task(async function() {
   await BrowserTestUtils.removeTab(tab2);
 });
 
 /**
  * When dragging an URL to a new tab, the new tab should have the same
  * userContextId as the original tab.
  */
 add_task(async function() {
-  let tab = gBrowser.addTab("http://example.com/", {userContextId: 1});
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/", {userContextId: 1});
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   let awaitDrop = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "drop");
   let newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, "http://test1.example.com/");
 
   // A drop type of "link" onto an existing tab would normally trigger a
   // load in that same tab, but tabbrowser code in _getDragTargetTab treats
   // drops on the outer edges of a tab differently (loading a new tab
@@ -98,20 +98,20 @@ add_task(async function() {
 
 /**
  * When dragging a URL from one tab or link on a tab to an existing tab, the
  * existing tab should not change its userContextId.
  * Ex: if you drag a link from tab 1 with userContext 1 to tab 2 with
  * userContext 2, the link will open in tab 2 with userContext 2.
  */
 add_task(async function() {
-  let tab = gBrowser.addTab("http://example.com/", {userContextId: 1});
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/", {userContextId: 1});
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
-  let tab2 = gBrowser.addTab("http://example.org/", {userContextId: 2});
+  let tab2 = BrowserTestUtils.addTab(gBrowser, "http://example.org/", {userContextId: 2});
   await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
 
   let awaitDrop = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "drop");
 
   EventUtils.synthesizeDrop(tab, tab2, [[{type: "text/plain", data: "http://test1.example.com/"}]], "link", window);
 
   await awaitDrop;
   Assert.equal(tab2.getAttribute("usercontextid"), 2);
--- a/browser/components/contextualidentity/test/browser/browser_windowName.js
+++ b/browser/components/contextualidentity/test/browser/browser_windowName.js
@@ -16,25 +16,25 @@ add_task(async function setup() {
   await SpecialPowers.pushPrefEnv({"set": [
     ["privacy.userContext.enabled", true],
     ["browser.link.open_newwindow", 3],
   ]});
 });
 
 add_task(async function test() {
   info("Creating first tab...");
-  let tab1 = gBrowser.addTab(BASE_URI + "?old", {userContextId: 1});
+  let tab1 = BrowserTestUtils.addTab(gBrowser, BASE_URI + "?old", {userContextId: 1});
   let browser1 = gBrowser.getBrowserForTab(tab1);
   await BrowserTestUtils.browserLoaded(browser1);
   await ContentTask.spawn(browser1, null, function(opts) {
     content.window.name = "tab-1";
   });
 
   info("Creating second tab...");
-  let tab2 = gBrowser.addTab(BASE_URI + "?old", {userContextId: 2});
+  let tab2 = BrowserTestUtils.addTab(gBrowser, BASE_URI + "?old", {userContextId: 2});
   let browser2 = gBrowser.getBrowserForTab(tab2);
   await BrowserTestUtils.browserLoaded(browser2);
   await ContentTask.spawn(browser2, null, function(opts) {
     content.window.name = "tab-2";
   });
 
   // Let's try to open a window from tab1 with a name 'tab-2'.
   info("Opening a window from the first tab...");
--- a/browser/components/contextualidentity/test/browser/browser_windowOpen.js
+++ b/browser/components/contextualidentity/test/browser/browser_windowOpen.js
@@ -11,17 +11,17 @@ add_task(async function setup() {
     ["privacy.userContext.enabled", true],
     ["browser.link.open_newwindow", 2],
   ]});
 });
 
 
 add_task(async function test() {
   info("Creating a tab with UCI = 1...");
-  let tab = gBrowser.addTab(BASE_URI, {userContextId: 1});
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URI, {userContextId: 1});
   is(tab.getAttribute("usercontextid"), 1, "New tab has UCI equal 1");
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
 
   info("Opening a new window from this tab...");
   ContentTask.spawn(browser, BASE_URI, function(url) {
     content.window.newWindow = content.window.open(url, "_blank");
--- a/browser/components/customizableui/CustomizableWidgets.jsm
+++ b/browser/components/customizableui/CustomizableWidgets.jsm
@@ -171,116 +171,112 @@ const CustomizableWidgets = [
   {
     id: "history-panelmenu",
     type: "view",
     viewId: "PanelUI-history",
     shortcutId: "key_gotoHistory",
     tooltiptext: "history-panelmenu.tooltiptext2",
     defaultArea: CustomizableUI.AREA_PANEL,
     onViewShowing(aEvent) {
-      aEvent.detail.addBlocker(new Promise((resolve, reject) => {
-        // Populate our list of history
-        const kMaxResults = 15;
-        let doc = aEvent.target.ownerDocument;
-        let win = doc.defaultView;
+      // Populate our list of history
+      const kMaxResults = 15;
+      let doc = aEvent.target.ownerDocument;
+      let win = doc.defaultView;
 
-        let options = PlacesUtils.history.getNewQueryOptions();
-        options.excludeQueries = true;
-        options.queryType = options.QUERY_TYPE_HISTORY;
-        options.sortingMode = options.SORT_BY_DATE_DESCENDING;
-        options.maxResults = kMaxResults;
-        let query = PlacesUtils.history.getNewQuery();
+      let options = PlacesUtils.history.getNewQueryOptions();
+      options.excludeQueries = true;
+      options.queryType = options.QUERY_TYPE_HISTORY;
+      options.sortingMode = options.SORT_BY_DATE_DESCENDING;
+      options.maxResults = kMaxResults;
+      let query = PlacesUtils.history.getNewQuery();
 
-        let items = doc.getElementById("PanelUI-historyItems");
-        // Clear previous history items.
-        while (items.firstChild) {
-          items.firstChild.remove();
-        }
+      let items = doc.getElementById("PanelUI-historyItems");
+      // Clear previous history items.
+      while (items.firstChild) {
+        items.firstChild.remove();
+      }
 
-        // Get all statically placed buttons to supply them with keyboard shortcuts.
-        let staticButtons = items.parentNode.getElementsByTagNameNS(kNSXUL, "toolbarbutton");
-        for (let i = 0, l = staticButtons.length; i < l; ++i)
-          CustomizableUI.addShortcut(staticButtons[i]);
+      // Get all statically placed buttons to supply them with keyboard shortcuts.
+      let staticButtons = items.parentNode.getElementsByTagNameNS(kNSXUL, "toolbarbutton");
+      for (let i = 0, l = staticButtons.length; i < l; ++i)
+        CustomizableUI.addShortcut(staticButtons[i]);
 
-        PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
-                           .asyncExecuteLegacyQueries([query], 1, options, {
-          handleResult(aResultSet) {
-            let onItemCommand = function(aItemCommandEvent) {
-              // Only handle the click event for middle clicks, we're using the command
-              // event otherwise.
-              if (aItemCommandEvent.type == "click" &&
-                  aItemCommandEvent.button != 1) {
-                return;
-              }
-              let item = aItemCommandEvent.target;
-              win.openUILink(item.getAttribute("targetURI"), aItemCommandEvent);
-              CustomizableUI.hidePanelForNode(item);
-            };
-            let fragment = doc.createDocumentFragment();
-            let row;
-            while ((row = aResultSet.getNextRow())) {
-              let uri = row.getResultByIndex(1);
-              let title = row.getResultByIndex(2);
+      PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
+                         .asyncExecuteLegacyQueries([query], 1, options, {
+        handleResult(aResultSet) {
+          let onItemCommand = function(aItemCommandEvent) {
+            // Only handle the click event for middle clicks, we're using the command
+            // event otherwise.
+            if (aItemCommandEvent.type == "click" &&
+                aItemCommandEvent.button != 1) {
+              return;
+            }
+            let item = aItemCommandEvent.target;
+            win.openUILink(item.getAttribute("targetURI"), aItemCommandEvent);
+            CustomizableUI.hidePanelForNode(item);
+          };
+          let fragment = doc.createDocumentFragment();
+          let row;
+          while ((row = aResultSet.getNextRow())) {
+            let uri = row.getResultByIndex(1);
+            let title = row.getResultByIndex(2);
 
-              let item = doc.createElementNS(kNSXUL, "toolbarbutton");
-              item.setAttribute("label", title || uri);
-              item.setAttribute("targetURI", uri);
-              item.setAttribute("class", "subviewbutton");
-              item.addEventListener("command", onItemCommand);
-              item.addEventListener("click", onItemCommand);
-              item.setAttribute("image", "page-icon:" + uri);
-              fragment.appendChild(item);
-            }
-            items.appendChild(fragment);
-          },
-          handleError(aError) {
-            log.debug("History view tried to show but had an error: " + aError);
-            reject();
-          },
-          handleCompletion(aReason) {
-            log.debug("History view is being shown!");
-            resolve();
-          },
-        });
+            let item = doc.createElementNS(kNSXUL, "toolbarbutton");
+            item.setAttribute("label", title || uri);
+            item.setAttribute("targetURI", uri);
+            item.setAttribute("class", "subviewbutton");
+            item.addEventListener("command", onItemCommand);
+            item.addEventListener("click", onItemCommand);
+            item.setAttribute("image", "page-icon:" + uri);
+            fragment.appendChild(item);
+          }
+          items.appendChild(fragment);
+        },
+        handleError(aError) {
+          log.debug("History view tried to show but had an error: " + aError);
+        },
+        handleCompletion(aReason) {
+          log.debug("History view is being shown!");
+        },
+      });
 
-        let recentlyClosedTabs = doc.getElementById("PanelUI-recentlyClosedTabs");
-        while (recentlyClosedTabs.firstChild) {
-          recentlyClosedTabs.firstChild.remove();
-        }
+      let recentlyClosedTabs = doc.getElementById("PanelUI-recentlyClosedTabs");
+      while (recentlyClosedTabs.firstChild) {
+        recentlyClosedTabs.firstChild.remove();
+      }
 
-        let recentlyClosedWindows = doc.getElementById("PanelUI-recentlyClosedWindows");
-        while (recentlyClosedWindows.firstChild) {
-          recentlyClosedWindows.firstChild.remove();
-        }
+      let recentlyClosedWindows = doc.getElementById("PanelUI-recentlyClosedWindows");
+      while (recentlyClosedWindows.firstChild) {
+        recentlyClosedWindows.firstChild.remove();
+      }
 
-        let utils = RecentlyClosedTabsAndWindowsMenuUtils;
-        let tabsFragment = utils.getTabsFragment(doc.defaultView, "toolbarbutton", true,
-                                                 "menuRestoreAllTabsSubview.label");
-        let separator = doc.getElementById("PanelUI-recentlyClosedTabs-separator");
-        let elementCount = tabsFragment.childElementCount;
-        separator.hidden = !elementCount;
-        while (--elementCount >= 0) {
-          let element = tabsFragment.children[elementCount];
-          CustomizableUI.addShortcut(element);
-          element.classList.add("subviewbutton", "cui-withicon");
-        }
-        recentlyClosedTabs.appendChild(tabsFragment);
+      let utils = RecentlyClosedTabsAndWindowsMenuUtils;
+      let tabsFragment = utils.getTabsFragment(doc.defaultView, "toolbarbutton", true,
+                                               "menuRestoreAllTabsSubview.label");
+      let separator = doc.getElementById("PanelUI-recentlyClosedTabs-separator");
+      let elementCount = tabsFragment.childElementCount;
+      separator.hidden = !elementCount;
+      while (--elementCount >= 0) {
+        let element = tabsFragment.children[elementCount];
+        CustomizableUI.addShortcut(element);
+        element.classList.add("subviewbutton", "cui-withicon");
+      }
+      recentlyClosedTabs.appendChild(tabsFragment);
 
-        let windowsFragment = utils.getWindowsFragment(doc.defaultView, "toolbarbutton", true,
-                                                       "menuRestoreAllWindowsSubview.label");
-        separator = doc.getElementById("PanelUI-recentlyClosedWindows-separator");
-        elementCount = windowsFragment.childElementCount;
-        separator.hidden = !elementCount;
-        while (--elementCount >= 0) {
-          let element = windowsFragment.children[elementCount];
-          CustomizableUI.addShortcut(element);
-          element.classList.add("subviewbutton", "cui-withicon");
-        }
-        recentlyClosedWindows.appendChild(windowsFragment);
-      }));
+      let windowsFragment = utils.getWindowsFragment(doc.defaultView, "toolbarbutton", true,
+                                                     "menuRestoreAllWindowsSubview.label");
+      separator = doc.getElementById("PanelUI-recentlyClosedWindows-separator");
+      elementCount = windowsFragment.childElementCount;
+      separator.hidden = !elementCount;
+      while (--elementCount >= 0) {
+        let element = windowsFragment.children[elementCount];
+        CustomizableUI.addShortcut(element);
+        element.classList.add("subviewbutton", "cui-withicon");
+      }
+      recentlyClosedWindows.appendChild(windowsFragment);
     },
     onCreated(aNode) {
       // Middle clicking recently closed items won't close the panel - cope:
       let onRecentlyClosedClick = function(aEvent) {
         if (aEvent.button == 1) {
           CustomizableUI.hidePanelForNode(this);
         }
       };
--- a/browser/components/customizableui/test/browser_1087303_button_preferences.js
+++ b/browser/components/customizableui/test/browser_1087303_button_preferences.js
@@ -21,17 +21,17 @@ add_task(async function() {
   await waitForPageLoad(newTab);
 
   let openedPage = gBrowser.currentURI.spec;
   is(openedPage, "about:preferences", "Preferences page was opened");
 });
 
 add_task(function asyncCleanup() {
   if (gBrowser.tabs.length == 1)
-    gBrowser.addTab("about:blank");
+    BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   gBrowser.removeTab(gBrowser.selectedTab);
   info("Tabs were restored");
 });
 
 function waitForPageLoad(aTab) {
   return new Promise((resolve, reject) => {
 
--- a/browser/components/customizableui/test/browser_880164_customization_context_menus.js
+++ b/browser/components/customizableui/test/browser_880164_customization_context_menus.js
@@ -38,17 +38,17 @@ add_task(async function() {
   await hiddenPromise;
 });
 
 // Right-click on an empty bit of tabstrip should
 // show a context menu without options to move it,
 // but with tab-specific options instead.
 add_task(async function() {
   // ensure there are tabs to reload/bookmark:
-  let extraTab = gBrowser.selectedTab = gBrowser.addTab();
+  let extraTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   await promiseTabLoadEvent(extraTab, "http://example.com/");
   let contextMenu = document.getElementById("toolbar-context-menu");
   let shownPromise = popupShown(contextMenu);
   let tabstrip = document.getElementById("tabbrowser-tabs");
   let rect = tabstrip.getBoundingClientRect();
   EventUtils.synthesizeMouse(tabstrip, rect.width - 2, 2, {type: "contextmenu", button: 2 });
   await shownPromise;
 
--- a/browser/components/customizableui/test/browser_934951_zoom_in_toolbar.js
+++ b/browser/components/customizableui/test/browser_934951_zoom_in_toolbar.js
@@ -4,19 +4,19 @@
 
 "use strict";
 
 const kTimeoutInMS = 20000;
 
 // Bug 934951 - Zoom controls percentage label doesn't update when it's in the toolbar and you navigate.
 add_task(async function() {
   CustomizableUI.addWidgetToArea("zoom-controls", CustomizableUI.AREA_NAVBAR);
-  let tab1 = gBrowser.addTab("about:mozilla");
+  let tab1 = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
   await BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
-  let tab2 = gBrowser.addTab("about:robots");
+  let tab2 = BrowserTestUtils.addTab(gBrowser, "about:robots");
   await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
   gBrowser.selectedTab = tab1;
   let zoomResetButton = document.getElementById("zoom-reset-button");
 
   registerCleanupFunction(() => {
     info("Cleaning up.");
     CustomizableUI.reset();
     gBrowser.removeTab(tab2);
--- a/browser/components/customizableui/test/browser_947914_button_addons.js
+++ b/browser/components/customizableui/test/browser_947914_button_addons.js
@@ -23,12 +23,12 @@ add_task(async function() {
                                gBrowser.currentURI.spec == "about:addons");
 
   let addonsPage = gBrowser.selectedBrowser.contentWindow.document.
                             getElementById("addons-page");
   ok(addonsPage, "Add-ons page was opened");
 });
 
 add_task(async function asyncCleanup() {
-  gBrowser.addTab(initialLocation);
+  BrowserTestUtils.addTab(gBrowser, initialLocation);
   gBrowser.removeTab(gBrowser.selectedTab);
   info("Tabs were restored");
 });
--- a/browser/components/customizableui/test/browser_967000_button_feeds.js
+++ b/browser/components/customizableui/test/browser_967000_button_feeds.js
@@ -51,11 +51,11 @@ add_task(async function() {
 });
 
 add_task(async function asyncCleanup() {
   // reset the panel UI to the default state
   await resetCustomization();
   ok(CustomizableUI.inDefaultState, "The UI is in default state again.");
 
   // restore the initial location
-  gBrowser.addTab(initialLocation);
+  BrowserTestUtils.addTab(gBrowser, initialLocation);
   gBrowser.removeTab(newTab);
 });
--- a/browser/components/customizableui/test/browser_973641_button_addon.js
+++ b/browser/components/customizableui/test/browser_973641_button_addon.js
@@ -12,17 +12,17 @@ add_task(async function() {
 
   info("Check addon button functionality");
 
   // create mocked addon button on the navigation bar
   let widgetSpec = {
     id: kButton,
     type: "button",
     onClick() {
-      gBrowser.selectedTab = gBrowser.addTab("about:addons");
+      gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:addons");
     }
   };
   CustomizableUI.createWidget(widgetSpec);
   CustomizableUI.addWidgetToArea(kButton, CustomizableUI.AREA_NAVBAR);
 
   // check the button's functionality in navigation bar
   let addonButton = document.getElementById(kButton);
   let navBar = document.getElementById("nav-bar");
@@ -57,17 +57,17 @@ add_task(async function asyncCleanup() {
 
 function resetTabs() {
   // close all opened tabs
   while (gBrowser.tabs.length > 1) {
     gBrowser.removeTab(gBrowser.selectedTab);
   }
 
   // restore the initial tab
-  gBrowser.addTab(initialLocation);
+  BrowserTestUtils.addTab(gBrowser, initialLocation);
   gBrowser.removeTab(gBrowser.selectedTab);
 }
 
 async function checkButtonFunctionality(aButton) {
   aButton.click();
   await waitForCondition(() => gBrowser.currentURI &&
                                gBrowser.currentURI.spec == "about:addons");
 }
--- a/browser/components/customizableui/test/browser_synced_tabs_menu.js
+++ b/browser/components/customizableui/test/browser_synced_tabs_menu.js
@@ -120,17 +120,17 @@ function panelUIHide() {
 
 async function asyncCleanup() {
   Services.prefs.clearUserPref("identity.fxaccounts.remote.signup.uri");
   // reset the panel UI to the default state
   await resetCustomization();
   ok(CustomizableUI.inDefaultState, "The panel UI is in default state again.");
 
   // restore the tabs
-  gBrowser.addTab(initialLocation);
+  BrowserTestUtils.addTab(gBrowser, initialLocation);
   gBrowser.removeTab(newTab);
   UITour.tourBrowsersByWindow.delete(window);
 }
 
 // When Sync is not setup.
 add_task(async function() {
   document.getElementById("sync-reauth-state").hidden = true;
   document.getElementById("sync-setup-state").hidden = false;
--- a/browser/components/extensions/ExtensionPopups.jsm
+++ b/browser/components/extensions/ExtensionPopups.jsm
@@ -441,100 +441,98 @@ class ViewPopup extends BasePopup {
    *
    * @param {Element} viewNode
    *        The node to attach the browser to.
    * @returns {Promise<boolean>}
    *        Resolves when the browser is ready. Resolves to `false` if the
    *        browser was destroyed before it was fully loaded, and the popup
    *        should be closed, or `true` otherwise.
    */
-  attach(viewNode) {
-    return (async () => {
-      this.viewNode = viewNode;
-      this.viewNode.addEventListener(this.DESTROY_EVENT, this);
+  async attach(viewNode) {
+    this.viewNode = viewNode;
+    this.viewNode.addEventListener(this.DESTROY_EVENT, this);
 
-      // Wait until the browser element is fully initialized, and give it at least
-      // a short grace period to finish loading its initial content, if necessary.
-      //
-      // In practice, the browser that was created by the mousdown handler should
-      // nearly always be ready by this point.
-      await Promise.all([
-        this.browserReady,
-        Promise.race([
-          // This promise may be rejected if the popup calls window.close()
-          // before it has fully loaded.
-          this.browserLoaded.catch(() => {}),
-          new Promise(resolve => setTimeout(resolve, POPUP_LOAD_TIMEOUT_MS)),
-        ]),
-      ]);
+    // Wait until the browser element is fully initialized, and give it at least
+    // a short grace period to finish loading its initial content, if necessary.
+    //
+    // In practice, the browser that was created by the mousdown handler should
+    // nearly always be ready by this point.
+    await Promise.all([
+      this.browserReady,
+      Promise.race([
+        // This promise may be rejected if the popup calls window.close()
+        // before it has fully loaded.
+        this.browserLoaded.catch(() => {}),
+        new Promise(resolve => setTimeout(resolve, POPUP_LOAD_TIMEOUT_MS)),
+      ]),
+    ]);
 
-      if (!this.destroyed && !this.panel) {
-        this.destroy();
-      }
+    if (!this.destroyed && !this.panel) {
+      this.destroy();
+    }
 
-      if (this.destroyed) {
-        CustomizableUI.hidePanelForNode(viewNode);
-        return false;
-      }
+    if (this.destroyed) {
+      CustomizableUI.hidePanelForNode(viewNode);
+      return false;
+    }
 
-      this.attached = true;
+    this.attached = true;
 
 
-      // Store the initial height of the view, so that we never resize menu panel
-      // sub-views smaller than the initial height of the menu.
-      this.viewHeight = this.viewNode.boxObject.height;
+    // Store the initial height of the view, so that we never resize menu panel
+    // sub-views smaller than the initial height of the menu.
+    this.viewHeight = this.viewNode.boxObject.height;
 
-      // Calculate the extra height available on the screen above and below the
-      // menu panel. Use that to calculate the how much the sub-view may grow.
-      let popupRect = this.panel.getBoundingClientRect();
+    // Calculate the extra height available on the screen above and below the
+    // menu panel. Use that to calculate the how much the sub-view may grow.
+    let popupRect = this.panel.getBoundingClientRect();
 
-      this.setBackground(this.background);
+    this.setBackground(this.background);
 
-      let win = this.window;
-      let popupBottom = win.mozInnerScreenY + popupRect.bottom;
-      let popupTop = win.mozInnerScreenY + popupRect.top;
+    let win = this.window;
+    let popupBottom = win.mozInnerScreenY + popupRect.bottom;
+    let popupTop = win.mozInnerScreenY + popupRect.top;
 
-      let screenBottom = win.screen.availTop + win.screen.availHeight;
-      this.extraHeight = {
-        bottom: Math.max(0, screenBottom - popupBottom),
-        top:  Math.max(0, popupTop - win.screen.availTop),
-      };
+    let screenBottom = win.screen.availTop + win.screen.availHeight;
+    this.extraHeight = {
+      bottom: Math.max(0, screenBottom - popupBottom),
+      top:  Math.max(0, popupTop - win.screen.availTop),
+    };
 
-      // Create a new browser in the real popup.
-      let browser = this.browser;
-      await this.createBrowser(this.viewNode);
+    // Create a new browser in the real popup.
+    let browser = this.browser;
+    await this.createBrowser(this.viewNode);
 
-      this.ignoreResizes = false;
+    this.ignoreResizes = false;
 
-      this.browser.swapDocShells(browser);
-      this.destroyBrowser(browser);
+    this.browser.swapDocShells(browser);
+    this.destroyBrowser(browser);
 
-      if (this.dimensions && !this.fixedWidth) {
-        this.resizeBrowser(this.dimensions);
-      }
+    if (this.dimensions && !this.fixedWidth) {
+      this.resizeBrowser(this.dimensions);
+    }
 
-      this.tempPanel.remove();
-      this.tempPanel = null;
+    this.tempPanel.remove();
+    this.tempPanel = null;
 
-      this.shown = true;
+    this.shown = true;
 
-      if (this.destroyed) {
-        this.closePopup();
-        this.destroy();
-        return false;
-      }
+    if (this.destroyed) {
+      this.closePopup();
+      this.destroy();
+      return false;
+    }
 
-      let event = new this.window.CustomEvent("WebExtPopupLoaded", {
-        bubbles: true,
-        detail: {extension: this.extension},
-      });
-      this.browser.dispatchEvent(event);
+    let event = new this.window.CustomEvent("WebExtPopupLoaded", {
+      bubbles: true,
+      detail: {extension: this.extension},
+    });
+    this.browser.dispatchEvent(event);
 
-      return true;
-    })();
+    return true;
   }
 
   destroy() {
     return super.destroy().then(() => {
       if (this.tempPanel) {
         this.tempPanel.remove();
         this.tempPanel = null;
       }
--- a/browser/components/extensions/ext-bookmarks.js
+++ b/browser/components/extensions/ext-bookmarks.js
@@ -171,30 +171,32 @@ function incrementListeners() {
     PlacesUtils.bookmarks.addObserver(observer);
   }
 }
 
 this.bookmarks = class extends ExtensionAPI {
   getAPI(context) {
     return {
       bookmarks: {
-        get: function(idOrIdList) {
+        async get(idOrIdList) {
           let list = Array.isArray(idOrIdList) ? idOrIdList : [idOrIdList];
 
-          return (async function() {
+          try {
             let bookmarks = [];
             for (let id of list) {
               let bookmark = await PlacesUtils.bookmarks.fetch({guid: id});
               if (!bookmark) {
                 throw new Error("Bookmark not found");
               }
               bookmarks.push(convert(bookmark));
             }
             return bookmarks;
-          })().catch(error => Promise.reject({message: error.message}));
+          } catch (error) {
+            return Promise.reject({message: error.message});
+          }
         },
 
         getChildren: function(id) {
           // TODO: We should optimize this.
           return getTree(id, true);
         },
 
         getTree: function() {
--- a/browser/components/extensions/ext-devtools.js
+++ b/browser/components/extensions/ext-devtools.js
@@ -30,38 +30,36 @@ let initDevTools;
  * the first time that it is accessed).
  *
  * @param {DevToolsExtensionPageContextParent} context
  *   A devtools extension proxy context.
  *
  * @returns {Promise<TabTarget>}
  *   The cloned devtools target associated to the context.
  */
-global.getDevToolsTargetForContext = (context) => {
-  return (async function asyncGetTabTarget() {
-    if (context.devToolsTarget) {
-      await context.devToolsTarget.makeRemote();
-      return context.devToolsTarget;
-    }
+global.getDevToolsTargetForContext = async (context) => {
+  if (context.devToolsTarget) {
+    await context.devToolsTarget.makeRemote();
+    return context.devToolsTarget;
+  }
 
-    if (!context.devToolsToolbox || !context.devToolsToolbox.target) {
-      throw new Error("Unable to get a TabTarget for a context not associated to any toolbox");
-    }
+  if (!context.devToolsToolbox || !context.devToolsToolbox.target) {
+    throw new Error("Unable to get a TabTarget for a context not associated to any toolbox");
+  }
 
-    if (!context.devToolsToolbox.target.isLocalTab) {
-      throw new Error("Unexpected target type: only local tabs are currently supported.");
-    }
-
-    const {TabTarget} = require("devtools/client/framework/target");
+  if (!context.devToolsToolbox.target.isLocalTab) {
+    throw new Error("Unexpected target type: only local tabs are currently supported.");
+  }
 
-    context.devToolsTarget = new TabTarget(context.devToolsToolbox.target.tab);
-    await context.devToolsTarget.makeRemote();
+  const {TabTarget} = require("devtools/client/framework/target");
 
-    return context.devToolsTarget;
-  })();
+  context.devToolsTarget = new TabTarget(context.devToolsToolbox.target.tab);
+  await context.devToolsTarget.makeRemote();
+
+  return context.devToolsTarget;
 };
 
 /**
  * Retrieve the devtools target for the devtools extension proxy context
  * (lazily cloned from the target of the toolbox associated to the context
  * the first time that it is accessed).
  *
  * @param {Toolbox} toolbox
@@ -112,47 +110,45 @@ class DevToolsPage extends HiddenExtensi
 
     this.unwatchExtensionProxyContextLoad = null;
 
     this.waitForTopLevelContext = new Promise(resolve => {
       this.resolveTopLevelContext = resolve;
     });
   }
 
-  build() {
-    return (async () => {
-      await this.createBrowserElement();
+  async build() {
+    await this.createBrowserElement();
 
-      // Listening to new proxy contexts.
-      this.unwatchExtensionProxyContextLoad = watchExtensionProxyContextLoad(this, context => {
-        // Keep track of the toolbox and target associated to the context, which is
-        // needed by the API methods implementation.
-        context.devToolsToolbox = this.toolbox;
+    // Listening to new proxy contexts.
+    this.unwatchExtensionProxyContextLoad = watchExtensionProxyContextLoad(this, context => {
+      // Keep track of the toolbox and target associated to the context, which is
+      // needed by the API methods implementation.
+      context.devToolsToolbox = this.toolbox;
 
-        if (!this.topLevelContext) {
-          this.topLevelContext = context;
+      if (!this.topLevelContext) {
+        this.topLevelContext = context;
 
-          // Ensure this devtools page is destroyed, when the top level context proxy is
-          // closed.
-          this.topLevelContext.callOnClose(this);
+        // Ensure this devtools page is destroyed, when the top level context proxy is
+        // closed.
+        this.topLevelContext.callOnClose(this);
 
-          this.resolveTopLevelContext(context);
-        }
-      });
+        this.resolveTopLevelContext(context);
+      }
+    });
 
-      extensions.emit("extension-browser-inserted", this.browser, {
-        devtoolsToolboxInfo: {
-          inspectedWindowTabId: getTargetTabIdForToolbox(this.toolbox),
-        },
-      });
+    extensions.emit("extension-browser-inserted", this.browser, {
+      devtoolsToolboxInfo: {
+        inspectedWindowTabId: getTargetTabIdForToolbox(this.toolbox),
+      },
+    });
 
-      this.browser.loadURI(this.url);
+    this.browser.loadURI(this.url);
 
-      await this.waitForTopLevelContext;
-    })();
+    await this.waitForTopLevelContext;
   }
 
   close() {
     if (this.closed) {
       throw new Error("Unable to shutdown a closed DevToolsPage instance");
     }
 
     this.closed = true;
--- a/browser/components/newtab/tests/browser/browser.ini
+++ b/browser/components/newtab/tests/browser/browser.ini
@@ -1,8 +1,9 @@
 [DEFAULT]
 support-files =
   blue_page.html
   dummy_page.html
 
 [browser_PreviewProvider.js]
+skip-if = os == 'linux' # bug 1343150
 [browser_remotenewtab_pageloads.js]
 [browser_newtab_overrides.js]
--- a/browser/components/originattributes/test/browser/browser_favicon_firstParty.js
+++ b/browser/components/originattributes/test/browser/browser_favicon_firstParty.js
@@ -156,17 +156,17 @@ function waitOnFaviconLoaded(aFaviconURL
       },
     };
 
     PlacesUtils.history.addObserver(observer);
   });
 }
 
 async function openTab(aURL) {
-  let tab = gBrowser.addTab(aURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, aURL);
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/originattributes/test/browser/browser_firstPartyIsolation.js
+++ b/browser/components/originattributes/test/browser/browser_firstPartyIsolation.js
@@ -9,17 +9,17 @@ add_task(async function setup() {
   });
 });
 
 /**
  * Test for the top-level document and child iframes should have the
  * firstPartyDomain attribute.
  */
 add_task(async function principal_test() {
-  let tab = gBrowser.addTab(BASE_URL + "test_firstParty.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty.html");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser, true, function(url) {
     return url == BASE_URL + "test_firstParty.html";
   });
 
   await ContentTask.spawn(tab.linkedBrowser, { firstPartyDomain: BASE_DOMAIN }, async function(attrs) {
     info("document principal: " + content.document.nodePrincipal.origin);
     Assert.equal(docShell.getOriginAttributes().firstPartyDomain, "",
                  "top-level docShell shouldn't have firstPartyDomain attribute.");
@@ -39,17 +39,17 @@ add_task(async function principal_test()
   gBrowser.removeTab(tab);
 });
 
 /**
  * Test for the cookie jars of the top-level document and child iframe should be
  * isolated by firstPartyDomain.
  */
 add_task(async function cookie_test() {
-  let tab = gBrowser.addTab(BASE_URL + "test_firstParty_cookie.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty_cookie.html");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser, true);
 
   let iter = Services.cookies.enumerator;
   let count = 0;
   while (iter.hasMoreElements()) {
     count++;
     let cookie = iter.getNext().QueryInterface(Ci.nsICookie2);
     Assert.equal(cookie.value, "foo", "Cookie value should be foo");
@@ -64,44 +64,44 @@ add_task(async function cookie_test() {
 });
 
 /**
  * Test for after redirect, the top-level document should update the firstPartyDomain
  * attribute. However if the redirect is happening on the iframe, the attribute
  * should remain the same.
  */
 add_task(async function redirect_test() {
-  let tab = gBrowser.addTab(BASE_URL + "test_firstParty_http_redirect.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty_http_redirect.html");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await ContentTask.spawn(tab.linkedBrowser, { firstPartyDomain: "example.com" }, async function(attrs) {
     info("document principal: " + content.document.nodePrincipal.origin);
     info("document uri: " + content.document.documentURI);
 
     Assert.equal(content.document.documentURI, "http://example.com/browser/browser/components/originattributes/test/browser/dummy.html",
                  "The page should have been redirected to http://example.com/browser/browser/components/originattributes/test/browser/dummy.html");
     Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                  attrs.firstPartyDomain, "The document should have firstPartyDomain");
   });
 
   // Since this is a HTML redirect, we wait until the final page is loaded.
-  let tab2 = gBrowser.addTab(BASE_URL + "test_firstParty_html_redirect.html");
+  let tab2 = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty_html_redirect.html");
   await BrowserTestUtils.browserLoaded(tab2.linkedBrowser, false, function(url) {
     return url == "http://example.com/";
   });
 
   await ContentTask.spawn(tab2.linkedBrowser, { firstPartyDomain: "example.com" }, async function(attrs) {
     info("2nd tab document principal: " + content.document.nodePrincipal.origin);
     info("2nd tab document uri: " + content.document.documentURI);
     Assert.equal(content.document.documentURI, "http://example.com/",
                  "The page should have been redirected to http://example.com");
     Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                  attrs.firstPartyDomain, "The document should have firstPartyDomain");
   });
 
-  let tab3 = gBrowser.addTab(BASE_URL + "test_firstParty_iframe_http_redirect.html");
+  let tab3 = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty_iframe_http_redirect.html");
   await BrowserTestUtils.browserLoaded(tab3.linkedBrowser, true, function(url) {
     return url == (BASE_URL + "test_firstParty_iframe_http_redirect.html");
   });
 
   // This redirect happens on the iframe, so unlike the two redirect tests above,
   // the firstPartyDomain should still stick to the current top-level document,
   // which is mochi.test.
   await ContentTask.spawn(tab3.linkedBrowser, { firstPartyDomain: "mochi.test" }, async function(attrs) {
@@ -119,17 +119,17 @@ add_task(async function redirect_test() 
   gBrowser.removeTab(tab2);
   gBrowser.removeTab(tab3);
 });
 
 /**
  * Test for postMessage between document and iframe.
  */
 add_task(async function postMessage_test() {
-  let tab = gBrowser.addTab(BASE_URL + "test_firstParty_postMessage.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_firstParty_postMessage.html");
 
   // The top-level page will post a message to its child iframe, and wait for
   // another message from the iframe, once it receives the message, it will
   // create another iframe, dummy.html.
   // So we wait until dummy.html is loaded
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser, true, function(url) {
     return url == BASE_URL + "dummy.html";
   });
@@ -148,17 +148,17 @@ add_task(async function postMessage_test
  * firstPartyDomain attribute.
  */
 add_task(async function openWindow_test() {
   Services.prefs.setIntPref("browser.link.open_newwindow", 2);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("browser.link.open_newwindow");
   });
 
-  let tab = gBrowser.addTab(BASE_URL + "window.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "window.html");
   let win = await BrowserTestUtils.waitForNewWindow();
 
   await ContentTask.spawn(win.gBrowser.selectedBrowser, { firstPartyDomain: "mochi.test" }, async function(attrs) {
     Assert.equal(docShell.getOriginAttributes().firstPartyDomain, attrs.firstPartyDomain,
                  "window.open() should have firstPartyDomain attribute");
     Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                  attrs.firstPartyDomain, "The document should have firstPartyDomain");
 
@@ -178,17 +178,17 @@ add_task(async function openWindow_test(
  * created window will have firstPartyDomain set.
  */
 add_task(async function window_open_redirect_test() {
   Services.prefs.setIntPref("browser.link.open_newwindow", 2);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("browser.link.open_newwindow");
   });
 
-  let tab = gBrowser.addTab(BASE_URL + "window_redirect.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "window_redirect.html");
   let win = await BrowserTestUtils.waitForNewWindow();
   await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
 
   await ContentTask.spawn(win.gBrowser.selectedBrowser, { firstPartyDomain: "mochi.test" }, async function(attrs) {
     Assert.equal(docShell.getOriginAttributes().firstPartyDomain, attrs.firstPartyDomain,
                  "window.open() should have firstPartyDomain attribute");
     Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                  attrs.firstPartyDomain, "The document should have firstPartyDomain");
@@ -205,17 +205,17 @@ add_task(async function window_open_redi
  * document is from another domain.
  */
 add_task(async function window_open_iframe_test() {
   Services.prefs.setIntPref("browser.link.open_newwindow", 2);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("browser.link.open_newwindow");
   });
 
-  let tab = gBrowser.addTab(BASE_URL + "window2.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "window2.html");
   let win = await BrowserTestUtils.waitForNewWindow();
   await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser, true);
 
   await ContentTask.spawn(win.gBrowser.selectedBrowser, { firstPartyDomain: "mochi.test" }, async function(attrs) {
     Assert.equal(docShell.getOriginAttributes().firstPartyDomain, attrs.firstPartyDomain,
                  "window.open() should have firstPartyDomain attribute");
 
     // The document is http://example.com/browser/browser/components/originattributes/test/browser/test_firstParty.html
@@ -233,17 +233,17 @@ add_task(async function window_open_ifra
   gBrowser.removeTab(tab);
   await BrowserTestUtils.closeWindow(win);
 });
 
 /**
  * Test for the loadInfo->TriggeringPrincipal is the document itself.
  */
 add_task(async function form_test() {
-  let tab = gBrowser.addTab(BASE_URL + "test_form.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "test_form.html");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   await ContentTask.spawn(tab.linkedBrowser, { firstPartyDomain: "mochi.test" }, async function(attrs) {
     Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                  attrs.firstPartyDomain, "The document should have firstPartyDomain");
 
     let submit = content.document.getElementById("submit");
     submit.click();
@@ -256,17 +256,17 @@ add_task(async function form_test() {
  * Another test for loadInfo->TriggeringPrincipal in the window.open case.
  */
 add_task(async function window_open_form_test() {
   Services.prefs.setIntPref("browser.link.open_newwindow", 2);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("browser.link.open_newwindow");
   });
 
-  let tab = gBrowser.addTab(BASE_URL + "window3.html");
+  let tab = BrowserTestUtils.addTab(gBrowser, BASE_URL + "window3.html");
   let win = await BrowserTestUtils.waitForNewWindow();
   await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser, true);
 
   await ContentTask.spawn(win.gBrowser.selectedBrowser, { firstPartyDomain: "mochi.test" }, async function(attrs) {
     Assert.equal(docShell.getOriginAttributes().firstPartyDomain, attrs.firstPartyDomain,
                  "window.open() should have firstPartyDomain attribute");
     Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                  "example.com", "The document should have firstPartyDomain");
--- a/browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
+++ b/browser/components/originattributes/test/browser/browser_firstPartyIsolation_aboutPages.js
@@ -167,17 +167,17 @@ add_task(async function test_aboutURL() 
       }
     } catch (e) {
       // getService might have thrown if the component doesn't actually
       // implement nsIAboutModule
     }
   }
 
   for (let url of aboutURLs) {
-    let tab = gBrowser.addTab("about:" + url);
+    let tab = BrowserTestUtils.addTab(gBrowser, "about:" + url);
     await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
     let attrs = { firstPartyDomain: "about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla" };
     await ContentTask.spawn(tab.linkedBrowser, { attrs, url }, async function(args) {
       info("loading page about:" + args.url + ", origin is " + content.document.nodePrincipal.origin);
       info("principal " + content.document.nodePrincipal);
       Assert.equal(content.document.nodePrincipal.originAttributes.firstPartyDomain,
                    args.attrs.firstPartyDomain, "The about page should have firstPartyDomain set");
--- a/browser/components/originattributes/test/browser/browser_windowOpenerRestriction.js
+++ b/browser/components/originattributes/test/browser/browser_windowOpenerRestriction.js
@@ -11,17 +11,17 @@ const OPENER_PAGE = "http://" + FIRST_PA
 const TARGET_PAGE = "http://" + FIRST_PARTY_TARGET + "/browser/browser/components/" +
                     "originattributes/test/browser/file_windowOpenerRestrictionTarget.html";
 
 async function testPref(aIsPrefEnabled) {
   // Use a random key so we don't access it in later tests.
   let cookieStr = "key" + Math.random().toString() + "=" + Math.random().toString();
 
   // Open the tab for the opener page.
-  let tab = gBrowser.addTab(OPENER_PAGE);
+  let tab = BrowserTestUtils.addTab(gBrowser, OPENER_PAGE);
 
   // Select this tab and make sure its browser is loaded and focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
 
--- a/browser/components/originattributes/test/browser/head.js
+++ b/browser/components/originattributes/test/browser/head.js
@@ -33,17 +33,17 @@ let gFirstPartyBasicPage = TEST_URL_PATH
  * @param aUserContextId
  *    The user context id for this tab.
  *
  * @return tab     - The tab object of this tab.
  *         browser - The browser object of this tab.
  */
 async function openTabInUserContext(aURL, aUserContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(aURL, {userContextId: aUserContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, aURL, {userContextId: aUserContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
@@ -75,17 +75,17 @@ async function openTabInFirstParty(aURL,
   // If the first party domain ends with '/', we remove it.
   if (aFirstPartyDomain.endsWith("/")) {
     aFirstPartyDomain = aFirstPartyDomain.slice(0, -1);
   }
 
   let basicPageURL = aFirstPartyDomain + gFirstPartyBasicPage;
 
   // Open the tab for the basic first party page.
-  let tab = gBrowser.addTab(basicPageURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, basicPageURL);
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
 
--- a/browser/components/places/tests/browser/browser_sidebarpanels_click.js
+++ b/browser/components/places/tests/browser/browser_sidebarpanels_click.js
@@ -126,17 +126,17 @@ function test() {
     while (gBrowser.tabs.length > 1) {
       gBrowser.removeTab(gBrowser.tabContainer.lastChild);
     }
 
     if (tests.length == 0) {
       finish();
     } else {
       // Create a new tab and run the test.
-      gBrowser.selectedTab = gBrowser.addTab();
+      gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
       currentTest = tests.shift();
       testPlacesPanel(function() {
                         changeSidebarDirection("ltr");
                         info("Running " + currentTest.desc + " in LTR mode");
                       },
                       function() {
                         testPlacesPanel(function() {
                           // Run the test in RTL mode.
--- a/browser/components/preferences/in-content-old/tests/browser_bug1020245_openPreferences_to_paneContent.js
+++ b/browser/components/preferences/in-content-old/tests/browser_bug1020245_openPreferences_to_paneContent.js
@@ -20,17 +20,17 @@ add_task(async function() {
   prefs = await openPreferencesViaHash("nonexistant-category");
   is(prefs.selectedPane, "paneGeneral", "General pane is selected when hash is a nonexistant-category");
   prefs = await openPreferencesViaHash();
   is(prefs.selectedPane, "paneGeneral", "General pane is selected by default");
 });
 
 function openPreferencesViaHash(aPane) {
   return new Promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab("about:preferences" + (aPane ? "#" + aPane : ""));
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:preferences" + (aPane ? "#" + aPane : ""));
     let newTabBrowser = gBrowser.selectedBrowser;
 
     newTabBrowser.addEventListener("Initialized", function() {
       newTabBrowser.contentWindow.addEventListener("load", function() {
         let win = gBrowser.contentWindow;
         let selectedPane = win.history.state;
         gBrowser.removeCurrentTab();
         resolve({selectedPane});
--- a/browser/components/preferences/in-content-old/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
+++ b/browser/components/preferences/in-content-old/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
@@ -60,17 +60,17 @@ add_task(async function() {
   const CRASH_TAB = {entries: [CRASH_SHENTRY], image: CRASH_FAVICON};
   const CRASH_STATE = {windows: [{tabs: [CRASH_TAB]}]};
 
   const TAB_URL = "about:sessionrestore";
   const TAB_FORMDATA = {url: TAB_URL, id: {sessionData: CRASH_STATE}};
   const TAB_SHENTRY = {url: TAB_URL, triggeringPrincipal_base64};
   const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA};
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   // Fake a post-crash tab
   ss.setTabState(tab, JSON.stringify(TAB_STATE));
 
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   let doc = tab.linkedBrowser.contentDocument;
 
   // Make body scrollable
--- a/browser/components/preferences/in-content-old/tests/head.js
+++ b/browser/components/preferences/in-content-old/tests/head.js
@@ -34,17 +34,17 @@ function is_element_visible(aElement, aM
 }
 
 function is_element_hidden(aElement, aMsg) {
   isnot(aElement, null, "Element should not be null, when checking visibility");
   ok(is_hidden(aElement), aMsg);
 }
 
 function open_preferences(aCallback) {
-  gBrowser.selectedTab = gBrowser.addTab("about:preferences");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:preferences");
   let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
   newTabBrowser.addEventListener("Initialized", function() {
     aCallback(gBrowser.contentWindow);
   }, {capture: true, once: true});
 }
 
 function openAndLoadSubDialog(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
   let promise = promiseLoadSubDialog(aURL);
@@ -125,17 +125,17 @@ function waitForEvent(aSubject, aEventNa
     return aEventOrError;
   }
   aSubject.addEventListener(aEventName, listener);
   return eventDeferred.promise.then(cleanup, cleanup);
 }
 
 function openPreferencesViaOpenPreferencesAPI(aPane, aAdvancedTab, aOptions) {
   return new Promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     openPreferences(aPane, aAdvancedTab ? {advancedTab: aAdvancedTab} : undefined);
     let newTabBrowser = gBrowser.selectedBrowser;
 
     newTabBrowser.addEventListener("Initialized", function() {
       newTabBrowser.contentWindow.addEventListener("load", function() {
         let win = gBrowser.contentWindow;
         let selectedPane = win.history.state;
         let doc = win.document;
--- a/browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
+++ b/browser/components/preferences/in-content/tests/browser_bug1020245_openPreferences_to_paneContent.js
@@ -56,17 +56,17 @@ add_task(async function() {
   ok(doc.querySelector("#locationBarGroup").hidden, "Location Bar prefs should be hidden when only Reports are requested");
   ok(!doc.querySelector("#header-privacy").hidden, "The header should be visible when a subcategory is requested");
   await BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 
 function openPreferencesViaHash(aPane) {
   return new Promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab("about:preferences" + (aPane ? "#" + aPane : ""));
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:preferences" + (aPane ? "#" + aPane : ""));
     let newTabBrowser = gBrowser.selectedBrowser;
 
     newTabBrowser.addEventListener("Initialized", function() {
       newTabBrowser.contentWindow.addEventListener("load", function() {
         let win = gBrowser.contentWindow;
         let selectedPane = win.history.state;
         gBrowser.removeCurrentTab();
         resolve({selectedPane});
--- a/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
+++ b/browser/components/preferences/in-content/tests/browser_bug1184989_prevent_scrolling_when_preferences_flipped.js
@@ -60,17 +60,17 @@ add_task(async function() {
   const CRASH_TAB = {entries: [CRASH_SHENTRY], image: CRASH_FAVICON};
   const CRASH_STATE = {windows: [{tabs: [CRASH_TAB]}]};
 
   const TAB_URL = "about:sessionrestore";
   const TAB_FORMDATA = {url: TAB_URL, id: {sessionData: CRASH_STATE}};
   const TAB_SHENTRY = {url: TAB_URL, triggeringPrincipal_base64};
   const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA};
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   // Fake a post-crash tab
   ss.setTabState(tab, JSON.stringify(TAB_STATE));
 
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   let doc = tab.linkedBrowser.contentDocument;
 
   // Make body scrollable
--- a/browser/components/preferences/in-content/tests/head.js
+++ b/browser/components/preferences/in-content/tests/head.js
@@ -25,17 +25,17 @@ function is_element_visible(aElement, aM
 }
 
 function is_element_hidden(aElement, aMsg) {
   isnot(aElement, null, "Element should not be null, when checking visibility");
   ok(is_hidden(aElement), aMsg);
 }
 
 function open_preferences(aCallback) {
-  gBrowser.selectedTab = gBrowser.addTab("about:preferences");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:preferences");
   let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
   newTabBrowser.addEventListener("Initialized", function() {
     aCallback(gBrowser.contentWindow);
   }, {capture: true, once: true});
 }
 
 function openAndLoadSubDialog(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
   let promise = promiseLoadSubDialog(aURL);
@@ -116,17 +116,17 @@ function waitForEvent(aSubject, aEventNa
     return aEventOrError;
   }
   aSubject.addEventListener(aEventName, listener);
   return eventDeferred.promise.then(cleanup, cleanup);
 }
 
 function openPreferencesViaOpenPreferencesAPI(aPane, aOptions) {
   return new Promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     openPreferences(aPane);
     let newTabBrowser = gBrowser.selectedBrowser;
 
     newTabBrowser.addEventListener("Initialized", function() {
       newTabBrowser.contentWindow.addEventListener("load", function() {
         let win = gBrowser.contentWindow;
         let selectedPane = win.history.state;
         if (!aOptions || !aOptions.leaveOpen)
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_placesTitleNoUpdate.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_placesTitleNoUpdate.js
@@ -33,17 +33,17 @@ add_task(async function test() {
       };
 
       PlacesUtils.history.addObserver(historyObserver);
     });
   }
 
   await PlacesTestUtils.clearHistory();
 
-  let tabToClose = gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
+  let tabToClose = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
   await waitForTitleChanged();
   is(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1, "The title matches the orignal title after first visit");
 
   let place = {
     uri: TEST_URI,
     title: TITLE_2,
     visits: [{
       visitDate: Date.now() * 1000,
--- a/browser/components/safebrowsing/content/test/browser_bug400731.js
+++ b/browser/components/safebrowsing/content/test/browser_bug400731.js
@@ -23,17 +23,17 @@ function onDOMContentLoaded(callback) {
   }
   mm.loadFrameScript("data:,(" + contentScript.toString() + ")();", true);
 }
 
 function test() {
   waitForExplicitFinish();
 
   waitForDBInit(() => {
-    gBrowser.selectedTab = gBrowser.addTab("http://www.itisatrap.org/firefox/its-an-attack.html");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "http://www.itisatrap.org/firefox/its-an-attack.html");
     onDOMContentLoaded(testMalware);
   });
 }
 
 function testMalware(data) {
   ok(data.buttonPresent, "Ignore warning button should be present for malware");
 
   Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);
--- a/browser/components/search/test/browser_aboutSearchReset.js
+++ b/browser/components/search/test/browser_aboutSearchReset.js
@@ -131,17 +131,17 @@ function test() {
     let oldCanRecord = Services.telemetry.canRecordExtended;
     Services.telemetry.canRecordExtended = true;
     checkTelemetryRecords();
 
     for (let testCase of gTests) {
       info(testCase.desc);
 
       // Create a tab to run the test.
-      let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+      let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
       // Start loading about:searchreset and wait for it to complete.
       let url = "about:searchreset?data=" + encodeURIComponent(kSearchStr) +
                 "&purpose=" + kSearchPurpose;
       await promiseTabLoadEvent(tab, url);
 
       info("Running test");
       await testCase.run();
--- a/browser/components/search/test/browser_abouthome_behavior.js
+++ b/browser/components/search/test/browser_abouthome_behavior.js
@@ -97,17 +97,17 @@ function test() {
       info("Running : " + gCurrTest.name);
       executeSoon(gCurrTest.run);
     } else {
       // Make sure we listen again for uncaught exceptions in the next test or cleanup.
       executeSoon(finish);
     }
   }
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onStateChange(webProgress, req, flags, status) {
       info("onStateChange");
       // Only care about top-level document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart) || !webProgress.isTopLevel)
--- a/browser/components/search/test/browser_amazon_behavior.js
+++ b/browser/components/search/test/browser_amazon_behavior.js
@@ -119,17 +119,17 @@ function test() {
       gCurrTest = gTests.shift();
       info("Running : " + gCurrTest.name);
       executeSoon(gCurrTest.run);
     } else {
       finish();
     }
   }
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onStateChange(webProgress, req, flags, status) {
       info("onStateChange");
       // Only care about top-level document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart) || !webProgress.isTopLevel)
--- a/browser/components/search/test/browser_bing_behavior.js
+++ b/browser/components/search/test/browser_bing_behavior.js
@@ -119,17 +119,17 @@ function test() {
       gCurrTest = gTests.shift();
       info("Running : " + gCurrTest.name);
       executeSoon(gCurrTest.run);
     } else {
       finish();
     }
   }
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onStateChange(webProgress, req, flags, status) {
       info("onStateChange");
       // Only care about top-level document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart) || !webProgress.isTopLevel)
--- a/browser/components/search/test/browser_contextSearchTabPosition.js
+++ b/browser/components/search/test/browser_contextSearchTabPosition.js
@@ -28,17 +28,17 @@ add_task(async function test() {
     if (tabs.length == 3) {
       tabsLoadedDeferred.resolve();
     }
   }
 
   let container = gBrowser.tabContainer;
   container.addEventListener("TabOpen", tabAdded);
 
-  gBrowser.addTab("about:blank");
+  BrowserTestUtils.addTab(gBrowser, "about:blank");
   BrowserSearch.loadSearchFromContext("mozilla");
   BrowserSearch.loadSearchFromContext("firefox");
 
   // Wait for all the tabs to open.
   await tabsLoadedDeferred.promise;
 
   is(tabs[0], gBrowser.tabs[3], "blank tab has been pushed to the end");
   is(tabs[1], gBrowser.tabs[1], "first search tab opens next to the current tab");
--- a/browser/components/search/test/browser_ddg_behavior.js
+++ b/browser/components/search/test/browser_ddg_behavior.js
@@ -119,17 +119,17 @@ function test() {
       gCurrTest = gTests.shift();
       info("Running : " + gCurrTest.name);
       executeSoon(gCurrTest.run);
     } else {
       finish();
     }
   }
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onStateChange(webProgress, req, flags, status) {
       info("onStateChange");
       // Only care about top-level document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart) || !webProgress.isTopLevel)
--- a/browser/components/search/test/browser_google_behavior.js
+++ b/browser/components/search/test/browser_google_behavior.js
@@ -117,17 +117,17 @@ function test() {
       gCurrTest = gTests.shift();
       info("Running : " + gCurrTest.name);
       executeSoon(gCurrTest.run);
     } else {
       finish();
     }
   }
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onStateChange(webProgress, req, flags, status) {
       info("onStateChange");
       // Only care about top-level document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart) || !webProgress.isTopLevel)
--- a/browser/components/search/test/browser_healthreport.js
+++ b/browser/components/search/test/browser_healthreport.js
@@ -19,17 +19,17 @@ function test() {
       if (histogramKey in hs) {
         numSearchesBefore = hs[histogramKey].sum;
       }
     } catch (ex) {
       // No searches performed yet, not a problem, |numSearchesBefore| is 0.
     }
 
     // Now perform a search and ensure the count is incremented.
-    let tab = gBrowser.addTab();
+    let tab = BrowserTestUtils.addTab(gBrowser);
     gBrowser.selectedTab = tab;
     let searchBar = BrowserSearch.searchBar;
 
     searchBar.value = "firefox health report";
     searchBar.focus();
 
      function afterSearch() {
         searchBar.value = "";
--- a/browser/components/search/test/browser_searchbar_openpopup.js
+++ b/browser/components/search/test/browser_searchbar_openpopup.js
@@ -402,17 +402,17 @@ add_task(async function refocus_window_d
   await new Promise(resolve => executeSoon(resolve));
 
   searchPopup.removeEventListener("popupshowing", listener);
   textbox.value = "";
 });
 
 // Clicking the search go button shouldn't open the popup
 add_no_popup_task(async function search_go_doesnt_open_popup() {
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   gURLBar.focus();
   textbox.value = "foo";
   searchbar.updateGoButtonVisibility();
 
   let promise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
   EventUtils.synthesizeMouseAtCenter(goButton, {});
   await promise;
--- a/browser/components/search/test/browser_webapi.js
+++ b/browser/components/search/test/browser_webapi.js
@@ -3,17 +3,17 @@ const searchBundle = Services.strings.cr
 const brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
 const brandName = brandBundle.GetStringFromName("brandShortName");
 
 function getString(key, ...params) {
   return searchBundle.formatStringFromName(key, params, params.length);
 }
 
 function AddSearchProvider(...args) {
-  return gBrowser.addTab(ROOT + "webapi.html?" + encodeURIComponent(JSON.stringify(args)));
+  return BrowserTestUtils.addTab(gBrowser, ROOT + "webapi.html?" + encodeURIComponent(JSON.stringify(args)));
 }
 
 function promiseDialogOpened() {
   return new Promise((resolve, reject) => {
     Services.wm.addListener({
       onOpenWindow(xulWin) {
         Services.wm.removeListener(this);
 
--- a/browser/components/search/test/browser_yahoo_behavior.js
+++ b/browser/components/search/test/browser_yahoo_behavior.js
@@ -119,17 +119,17 @@ function test() {
       gCurrTest = gTests.shift();
       info("Running : " + gCurrTest.name);
       executeSoon(gCurrTest.run);
     } else {
       finish();
     }
   }
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let listener = {
     onStateChange: function onStateChange(webProgress, req, flags, status) {
       info("onStateChange");
       // Only care about top-level document starts
       let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
                      Ci.nsIWebProgressListener.STATE_START;
       if (!(flags & docStart) || !webProgress.isTopLevel)
--- a/browser/components/sessionstore/test/browser_339445.js
+++ b/browser/components/sessionstore/test/browser_339445.js
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 add_task(async function test() {
   /** Test for Bug 339445 **/
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser_339445_sample.html";
 
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   await ContentTask.spawn(tab.linkedBrowser, null, function() {
     let doc = content.document;
     is(doc.getElementById("storageTestItem").textContent, "PENDING",
        "sessionStorage value has been set");
   });
 
--- a/browser/components/sessionstore/test/browser_350525.js
+++ b/browser/components/sessionstore/test/browser_350525.js
@@ -37,17 +37,17 @@ add_task(async function() {
   // test deleting a non-existent value
   ok(test(() => ss.deleteWindowValue(window, key)), "delete non-existent window value");
 
   /**
    * setTabValue, et al.
    */
   key = "Unique name: " + Math.random();
   value = "Unique value: " + Date.now();
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   tab.linkedBrowser.stop();
 
   // test adding
   ok(test(() => ss.setTabValue(tab, key, value)), "store a tab value");
 
   // test retrieving
   is(ss.getTabValue(tab, key), value, "stored tab value match original");
 
@@ -70,17 +70,17 @@ add_task(async function() {
   // get closed tab count
   let count = ss.getClosedTabCount(window);
   let max_tabs_undo = gPrefService.getIntPref("browser.sessionstore.max_tabs_undo");
   ok(0 <= count && count <= max_tabs_undo,
      "getClosedTabCount returns zero or at most max_tabs_undo");
 
   // create a new tab
   let testURL = "about:";
-  tab = gBrowser.addTab(testURL);
+  tab = BrowserTestUtils.addTab(gBrowser, testURL);
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   // make sure that the next closed tab will increase getClosedTabCount
   gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", max_tabs_undo + 1);
   registerCleanupFunction(() => gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo"));
 
   // remove tab
   await promiseRemoveTab(tab);
--- a/browser/components/sessionstore/test/browser_367052.js
+++ b/browser/components/sessionstore/test/browser_367052.js
@@ -11,17 +11,17 @@ add_task(async function() {
   registerCleanupFunction(() => gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo"));
 
   // Empty the list of closed tabs.
   while (ss.getClosedTabCount(window)) {
     ss.forgetClosedTab(window, 0);
   }
 
   // restore a blank tab
-  let tab = gBrowser.addTab("about:");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:");
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   let count = await promiseSHistoryCount(tab.linkedBrowser);
   ok(count >= 1, "the new tab does have at least one history entry");
 
   await promiseTabState(tab, {entries: []});
 
   // We may have a different sessionHistory object if the tab
--- a/browser/components/sessionstore/test/browser_393716.js
+++ b/browser/components/sessionstore/test/browser_393716.js
@@ -8,17 +8,17 @@ const URL = "about:config";
 /**
  * Bug 393716 - Basic tests for getTabState(), setTabState(), and duplicateTab().
  */
 add_task(async function test_set_tabstate() {
   let key = "Unique key: " + Date.now();
   let value = "Unique value: " + Math.random();
 
   // create a new tab
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   ss.setTabValue(tab, key, value);
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   // get the tab's state
   await TabStateFlusher.flush(tab.linkedBrowser);
   let state = ss.getTabState(tab);
   ok(state, "get the tab's state");
 
@@ -37,17 +37,17 @@ add_task(async function test_set_tabstat
 
 add_task(async function test_set_tabstate_and_duplicate() {
   let key2 = "key2";
   let value2 = "Value " + Math.random();
   let value3 = "Another value: " + Date.now();
   let state = {entries: [{ url: URL, triggeringPrincipal_base64}], extData: { key2: value2 }};
 
   // create a new tab
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   // set the tab's state
   ss.setTabState(tab, JSON.stringify(state));
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   // verify the correctness of the restored tab
   ok(ss.getTabValue(tab, key2) == value2 && tab.linkedBrowser.currentURI.spec == URL,
      "the tab's state was correctly restored");
 
--- a/browser/components/sessionstore/test/browser_423132.js
+++ b/browser/components/sessionstore/test/browser_423132.js
@@ -10,17 +10,17 @@ add_task(async function() {
 
   Services.cookies.removeAll();
   // make sure that sessionstore.js can be forced to be created by setting
   // the interval pref to 0
   await SpecialPowers.pushPrefEnv({
     set: [["browser.sessionstore.interval", 0]]
   });
 
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
 
   // get the sessionstore state for the window
   let state = ss.getBrowserState();
 
   // verify our cookie got set during pageload
   let enumerator = Services.cookies.enumerator;
--- a/browser/components/sessionstore/test/browser_447951.js
+++ b/browser/components/sessionstore/test/browser_447951.js
@@ -12,17 +12,17 @@ function test() {
   // Make sure the functionality added in bug 943339 doesn't affect the results
   gPrefService.setIntPref("browser.sessionstore.max_serialize_back", -1);
   gPrefService.setIntPref("browser.sessionstore.max_serialize_forward", -1);
   registerCleanupFunction(function() {
     gPrefService.clearUserPref("browser.sessionstore.max_serialize_back");
     gPrefService.clearUserPref("browser.sessionstore.max_serialize_forward");
   });
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   promiseBrowserLoaded(tab.linkedBrowser).then(() => {
     let tabState = { entries: [] };
     let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries");
     for (let i = 0; i < max_entries; i++)
       tabState.entries.push({ url: baseURL + i, triggeringPrincipal_base64});
 
     promiseTabState(tab, tabState).then(() => {
       return TabStateFlusher.flush(tab.linkedBrowser);
--- a/browser/components/sessionstore/test/browser_454908.js
+++ b/browser/components/sessionstore/test/browser_454908.js
@@ -9,17 +9,17 @@ const PASS = "pwd-" + Math.random();
 /**
  * Bug 454908 - Don't save/restore values of password fields.
  */
 add_task(async function test_dont_save_passwords() {
   // Make sure we do save form data.
   Services.prefs.clearUserPref("browser.sessionstore.privacy_level");
 
   // Add a tab with a password field.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Fill in some values.
   let usernameValue = "User " + Math.random();
   await setInputValue(browser, {id: "username", value: usernameValue});
   await setInputValue(browser, {id: "passwd", value: PASS});
 
--- a/browser/components/sessionstore/test/browser_456342.js
+++ b/browser/components/sessionstore/test/browser_456342.js
@@ -5,17 +5,17 @@
 
 const URL = ROOT + "browser_456342_sample.xhtml";
 
 /**
  * Bug 456342 - Restore values from non-standard input field types.
  */
 add_task(async function test_restore_nonstandard_input_values() {
   // Add tab with various non-standard input field types.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Fill in form values.
   let expectedValue = Math.random();
   await setFormElementValues(browser, {value: expectedValue});
 
   // Remove tab and check collected form data.
--- a/browser/components/sessionstore/test/browser_459906.js
+++ b/browser/components/sessionstore/test/browser_459906.js
@@ -7,17 +7,17 @@ function test() {
 
   waitForExplicitFinish();
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser_459906_sample.html";
   let uniqueValue = "<b>Unique:</b> " + Date.now();
 
   var frameCount = 0;
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     // wait for all frames to load completely
     if (frameCount++ < 2)
       return;
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
 
     let iframes = tab.linkedBrowser.contentWindow.frames;
     iframes[1].document.body.innerHTML = uniqueValue;
--- a/browser/components/sessionstore/test/browser_461743.js
+++ b/browser/components/sessionstore/test/browser_461743.js
@@ -6,17 +6,17 @@ function test() {
   /** Test for Bug 461743 **/
 
   waitForExplicitFinish();
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser_461743_sample.html";
 
   let frameCount = 0;
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     // Wait for all frames to load completely.
     if (frameCount++ < 2)
       return;
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
     let tab2 = gBrowser.duplicateTab(tab);
     tab2.linkedBrowser.addEventListener("461743", function(eventTab2) {
       tab2.linkedBrowser.removeEventListener("461743", arguments.callee, true);
--- a/browser/components/sessionstore/test/browser_463205.js
+++ b/browser/components/sessionstore/test/browser_463205.js
@@ -7,17 +7,17 @@ const URL = ROOT + "browser_463205_sampl
 
 /**
  * Bug 463205 - Check URLs before restoring form data to make sure a malicious
  * website can't modify frame URLs and make us inject form data into the wrong
  * web pages.
  */
 add_task(async function test_check_urls_before_restoring() {
   // Add a blank tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Restore form data with a valid URL.
   await promiseTabState(tab, getState(URL));
 
   let value = await getInputValue(browser, {id: "text"});
   is(value, "foobar", "value was restored");
--- a/browser/components/sessionstore/test/browser_463206.js
+++ b/browser/components/sessionstore/test/browser_463206.js
@@ -4,17 +4,17 @@
 
 "use strict";
 
 const TEST_URL = "http://mochi.test:8888/browser/" +
                  "browser/components/sessionstore/test/browser_463206_sample.html";
 
 add_task(async function() {
   // Add a new tab.
-  let tab = gBrowser.addTab(TEST_URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   // "Type in" some random values.
   await ContentTask.spawn(tab.linkedBrowser, null, async function() {
     function typeText(aTextField, aValue) {
       aTextField.value = aValue;
 
       let event = aTextField.ownerDocument.createEvent("UIEvents");
--- a/browser/components/sessionstore/test/browser_464620_a.js
+++ b/browser/components/sessionstore/test/browser_464620_a.js
@@ -6,17 +6,17 @@ function test() {
   /** Test for Bug 464620 (injection on input) **/
 
   waitForExplicitFinish();
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser_464620_a.html";
 
   var frameCount = 0;
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     // wait for all frames to load completely
     if (frameCount++ < 4)
       return;
     this.removeEventListener("load", arguments.callee, true);
 
     executeSoon(function() {
       frameCount = 0;
--- a/browser/components/sessionstore/test/browser_464620_b.js
+++ b/browser/components/sessionstore/test/browser_464620_b.js
@@ -6,17 +6,17 @@ function test() {
   /** Test for Bug 464620 (injection on DOM node insertion) **/
 
   waitForExplicitFinish();
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser_464620_b.html";
 
   var frameCount = 0;
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     // wait for all frames to load completely
     if (frameCount++ < 6)
       return;
     this.removeEventListener("load", arguments.callee, true);
 
     executeSoon(function() {
       frameCount = 0;
--- a/browser/components/sessionstore/test/browser_465215.js
+++ b/browser/components/sessionstore/test/browser_465215.js
@@ -1,17 +1,17 @@
 "use strict";
 
 var uniqueName = "bug 465215";
 var uniqueValue1 = "as good as unique: " + Date.now();
 var uniqueValue2 = "as good as unique: " + Math.random();
 
 add_task(async function() {
   // set a unique value on a new, blank tab
-  let tab1 = gBrowser.addTab("about:blank");
+  let tab1 = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await promiseBrowserLoaded(tab1.linkedBrowser);
   ss.setTabValue(tab1, uniqueName, uniqueValue1);
 
   // duplicate the tab with that value
   let tab2 = ss.duplicateTab(window, tab1);
   await promiseTabRestored(tab2);
   is(ss.getTabValue(tab2, uniqueName), uniqueValue1, "tab value was duplicated");
 
--- a/browser/components/sessionstore/test/browser_466937.js
+++ b/browser/components/sessionstore/test/browser_466937.js
@@ -5,17 +5,17 @@
 
 const URL = ROOT + "browser_466937_sample.html";
 
 /**
  * Bug 466937 - Prevent file stealing with sessionstore.
  */
 add_task(async function test_prevent_file_stealing() {
   // Add a tab with some file input fields.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Generate a path to a 'secret' file.
   let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
   file.append("466937_test.file");
   file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
   let testPath = file.path;
--- a/browser/components/sessionstore/test/browser_467409-backslashplosion.js
+++ b/browser/components/sessionstore/test/browser_467409-backslashplosion.js
@@ -27,17 +27,17 @@ function createEntries(sessionData) {
   return {
     entries: [{url: "about:sessionrestore", triggeringPrincipal_base64}],
     formdata: {id: {sessionData}, url: "about:sessionrestore"}
   };
 }
 
 add_task(async function test_nested_about_sessionrestore() {
   // Prepare a blank tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // test 1
   await promiseTabState(tab, STATE);
   await checkState("test1", tab);
 
   // test 2
--- a/browser/components/sessionstore/test/browser_480893.js
+++ b/browser/components/sessionstore/test/browser_480893.js
@@ -6,17 +6,17 @@
  */
 add_task(async function() {
   await SpecialPowers.pushPrefEnv({
     "set": [
       ["browser.startup.page", 0],
     ]
   });
 
-  let tab = gBrowser.addTab("about:sessionrestore");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:sessionrestore");
   gBrowser.selectedTab = tab;
   let browser = tab.linkedBrowser;
   await BrowserTestUtils.browserLoaded(browser, false, "about:sessionrestore");
 
   let doc = browser.contentDocument;
 
   // Click on the "Close" button after about:sessionrestore is loaded.
   doc.getElementById("errorCancel").click();
--- a/browser/components/sessionstore/test/browser_485482.js
+++ b/browser/components/sessionstore/test/browser_485482.js
@@ -6,17 +6,17 @@
 const URL = ROOT + "browser_485482_sample.html";
 
 /**
  * Bug 485482 - Make sure that we produce valid XPath expressions even for very
  * weird HTML documents.
  */
 add_task(async function test_xpath_exp_for_strange_documents() {
   // Load a page with weird tag names.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Fill in some values.
   let uniqueValue = Math.random();
   await setInputValue(browser, {selector: "input[type=text]", value: uniqueValue});
   await setInputChecked(browser, {selector: "input[type=checkbox]", checked: true});
 
--- a/browser/components/sessionstore/test/browser_485563.js
+++ b/browser/components/sessionstore/test/browser_485563.js
@@ -4,17 +4,17 @@
 
 function test() {
   /** Test for Bug 485563 **/
 
   waitForExplicitFinish();
 
   let uniqueValue = Math.random() + "\u2028Second line\u2029Second paragraph\u2027";
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   promiseBrowserLoaded(tab.linkedBrowser).then(() => {
     ss.setTabValue(tab, "bug485563", uniqueValue);
     let tabState = JSON.parse(ss.getTabState(tab));
     is(tabState.extData["bug485563"], uniqueValue,
        "unicode line separator wasn't over-encoded");
     ss.deleteTabValue(tab, "bug485563");
     ss.setTabState(tab, JSON.stringify(tabState));
     is(ss.getTabValue(tab, "bug485563"), uniqueValue,
--- a/browser/components/sessionstore/test/browser_491168.js
+++ b/browser/components/sessionstore/test/browser_491168.js
@@ -6,17 +6,17 @@ const REFERRER2 = "http://example.org/?"
 add_task(async function() {
   async function checkDocumentReferrer(referrer, msg) {
     await ContentTask.spawn(gBrowser.selectedBrowser, { referrer, msg }, async function(args) {
       Assert.equal(content.document.referrer, args.referrer, args.msg);
     });
   }
 
   // Add a new tab.
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Load a new URI with a specific referrer.
   let referrerURI = Services.io.newURI(REFERRER1);
   browser.loadURI("http://example.org", referrerURI, null);
   await promiseBrowserLoaded(browser);
 
--- a/browser/components/sessionstore/test/browser_506482.js
+++ b/browser/components/sessionstore/test/browser_506482.js
@@ -40,17 +40,17 @@ function test() {
 
   // make sure sessionstore.js is saved ASAP on all events
   gPrefService.setIntPref(PREF_INTERVAL, 0);
 
   // get the initial sessionstore.js mtime (-1 if it doesn't exist yet)
   let mtime0 = getSessionstorejsModificationTime();
 
   // create and select a first tab
-  let tab = gBrowser.addTab(TEST_URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
   promiseBrowserLoaded(tab.linkedBrowser).then(() => {
     // step1: the above has triggered some saveStateDelayed(), sleep until
     // it's done, and get the initial sessionstore.js mtime
     setTimeout(function step1() {
       let mtime1 = getSessionstorejsModificationTime();
       isnot(mtime1, mtime0, "initial sessionstore.js update");
 
       // step2: test sessionstore.js is not updated on tab selection
--- a/browser/components/sessionstore/test/browser_579868.js
+++ b/browser/components/sessionstore/test/browser_579868.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function test() {
   waitForExplicitFinish();
 
-  let tab1 = gBrowser.addTab("about:rights");
-  let tab2 = gBrowser.addTab("about:mozilla");
+  let tab1 = BrowserTestUtils.addTab(gBrowser, "about:rights");
+  let tab2 = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 
   promiseBrowserLoaded(tab1.linkedBrowser).then(() => {
     // Tell the session storer that the tab is pinned
     let newTabState = '{"entries":[{"url":"about:rights"}],"pinned":true,"userTypedValue":"Hello World!"}';
     ss.setTabState(tab1, newTabState);
 
     // Undo pinning
     gBrowser.unpinTab(tab1);
--- a/browser/components/sessionstore/test/browser_579879.js
+++ b/browser/components/sessionstore/test/browser_579879.js
@@ -1,16 +1,16 @@
 "use strict";
 
 add_task(async function() {
-  let tab1 = gBrowser.addTab("data:text/plain;charset=utf-8,foo");
+  let tab1 = BrowserTestUtils.addTab(gBrowser, "data:text/plain;charset=utf-8,foo");
   gBrowser.pinTab(tab1);
 
   await promiseBrowserLoaded(tab1.linkedBrowser);
-  let tab2 = gBrowser.addTab();
+  let tab2 = BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(tab2);
 
   is(Array.indexOf(gBrowser.tabs, tab1), 0, "pinned tab 1 is at the first position");
   await promiseRemoveTab(tab1);
 
   tab1 = undoCloseTab();
   ok(tab1.pinned, "pinned tab 1 has been restored as a pinned tab");
   is(Array.indexOf(gBrowser.tabs, tab1), 0, "pinned tab 1 has been restored to the first position");
--- a/browser/components/sessionstore/test/browser_581937.js
+++ b/browser/components/sessionstore/test/browser_581937.js
@@ -1,15 +1,15 @@
 // Tests that an about:blank tab with no history will not be saved into
 // session store and thus, it will not show up in Recently Closed Tabs.
 
 "use strict";
 
 add_task(async function() {
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   is(tab.linkedBrowser.currentURI.spec, "about:blank",
      "we will be removing an about:blank tab");
 
   let r = `rand-${Math.random()}`;
   ss.setTabValue(tab, "foobar", r);
 
--- a/browser/components/sessionstore/test/browser_586147.js
+++ b/browser/components/sessionstore/test/browser_586147.js
@@ -10,24 +10,24 @@ function observeOneRestore(callback) {
   }, topic);
 }
 
 function test() {
   waitForExplicitFinish();
 
   // There should be one tab when we start the test
   let [origTab] = gBrowser.visibleTabs;
-  let hiddenTab = gBrowser.addTab();
+  let hiddenTab = BrowserTestUtils.addTab(gBrowser);
 
   is(gBrowser.visibleTabs.length, 2, "should have 2 tabs before hiding");
   gBrowser.showOnlyTheseTabs([origTab]);
   is(gBrowser.visibleTabs.length, 1, "only 1 after hiding");
   ok(hiddenTab.hidden, "sanity check that it's hidden");
 
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
   let state = ss.getBrowserState();
   let stateObj = JSON.parse(state);
   let tabs = stateObj.windows[0].tabs;
   is(tabs.length, 3, "just checking that browser state is correct");
   ok(!tabs[0].hidden, "first tab is visible");
   ok(tabs[1].hidden, "second is hidden");
   ok(!tabs[2].hidden, "third is visible");
 
--- a/browser/components/sessionstore/test/browser_601955.js
+++ b/browser/components/sessionstore/test/browser_601955.js
@@ -10,17 +10,17 @@ function test() {
   // We speed up the interval between session saves to ensure that the test
   // runs quickly.
   Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
 
   // Loading a tab causes a save state and this is meant to catch that event.
   waitForSaveState(testBug601955_1);
 
   // Assumption: Only one window is open and it has one tab open.
-  gBrowser.addTab("about:mozilla");
+  BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 }
 
 function testBug601955_1() {
   // Because pinned tabs are at the front of |gBrowser.tabs|, pinning tabs
   // re-arranges the |tabs| array.
   ok(!gBrowser.tabs[0].pinned, "first tab should not be pinned yet");
   ok(!gBrowser.tabs[1].pinned, "second tab should not be pinned yet");
 
--- a/browser/components/sessionstore/test/browser_624727.js
+++ b/browser/components/sessionstore/test/browser_624727.js
@@ -12,17 +12,17 @@ add_task(async function() {
     is(gBrowser._numPinnedTabs, num, msg);
   }
 
   // check prerequisites
   assertNumberOfTabs(1, "we start off with one tab");
   assertNumberOfPinnedTabs(0, "no pinned tabs so far");
 
   // setup
-  gBrowser.addTab("about:blank");
+  BrowserTestUtils.addTab(gBrowser, "about:blank");
   assertNumberOfTabs(2, "there are two tabs, now");
 
   let [tab1, tab2] = gBrowser.tabs;
   gBrowser.pinTab(tab1);
   gBrowser.pinTab(tab2);
   assertNumberOfPinnedTabs(2, "both tabs are now pinned");
 
   // run the test
--- a/browser/components/sessionstore/test/browser_625016.js
+++ b/browser/components/sessionstore/test/browser_625016.js
@@ -51,17 +51,17 @@ add_task(async function new_window() {
   }
 });
 
 // We'll open a tab, which should trigger another state save which would wipe
 // the _shouldRestore attribute from the closed window
 add_task(async function new_tab() {
   let newTab;
   try {
-    newTab = gBrowser.addTab("about:mozilla");
+    newTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
     await promiseBrowserLoaded(newTab.linkedBrowser);
     await TabStateFlusher.flush(newTab.linkedBrowser);
 
     let state = JSON.parse((await promiseRecoveryFileContents()));
     is(state.windows.length, 1,
       "observe2: 1 window in data being written to disk");
     is(state._closedWindows.length, 1,
       "observe2: 1 closed window in data being written to disk");
--- a/browser/components/sessionstore/test/browser_628270.js
+++ b/browser/components/sessionstore/test/browser_628270.js
@@ -11,17 +11,17 @@ function test() {
   }
 
   waitForExplicitFinish();
 
   // check prerequisites
   assertNumberOfTabs(1, "we start off with one tab");
 
   // setup
-  let tab = gBrowser.addTab("about:mozilla");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 
   whenTabIsLoaded(tab, function() {
     // hide the newly created tab
     assertNumberOfVisibleTabs(2, "there are two visible tabs");
     gBrowser.showOnlyTheseTabs([gBrowser.tabs[0]]);
     assertNumberOfVisibleTabs(1, "there is one visible tab");
     ok(tab.hidden, "newly created tab is now hidden");
 
--- a/browser/components/sessionstore/test/browser_635418.js
+++ b/browser/components/sessionstore/test/browser_635418.js
@@ -11,17 +11,17 @@ function test() {
   // We speed up the interval between session saves to ensure that the test
   // runs quickly.
   Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
 
   // Loading a tab causes a save state and this is meant to catch that event.
   waitForSaveState(testBug635418_1);
 
   // Assumption: Only one window is open and it has one tab open.
-  gBrowser.addTab("about:mozilla");
+  BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 }
 
 function testBug635418_1() {
   ok(!gBrowser.tabs[0].hidden, "first tab should not be hidden");
   ok(!gBrowser.tabs[1].hidden, "second tab should not be hidden");
 
   waitForSaveState(testBug635418_2);
 
--- a/browser/components/sessionstore/test/browser_662743.js
+++ b/browser/components/sessionstore/test/browser_662743.js
@@ -55,17 +55,17 @@ function test() {
     testTabCount++;
     testTabRestoreData(formData[i], expectedValues[i], callback);
   }
 }
 
 function testTabRestoreData(aFormData, aExpectedValue, aCallback) {
   let testURL =
     getRootDirectory(gTestPath) + "browser_662743_sample.html";
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
 
   aFormData.url = testURL;
   let tabState = { entries: [{ url: testURL, triggeringPrincipal_base64 }], formdata: aFormData };
 
   promiseBrowserLoaded(tab.linkedBrowser).then(() => {
     promiseTabState(tab, tabState).then(() => {
       // Flush to make sure we have the latest form data.
       return TabStateFlusher.flush(tab.linkedBrowser);
--- a/browser/components/sessionstore/test/browser_662812.js
+++ b/browser/components/sessionstore/test/browser_662812.js
@@ -15,17 +15,17 @@ function test() {
       executeSoon(() => {
         gBrowser.removeTab(gBrowser.tabs[1]);
         finish();
       });
     }, {once: true});
   }, {once: true});
 
   // create a new tab
-  let tab = gBrowser.addTab("about:mozilla");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
   let browser = tab.linkedBrowser;
 
   // close and restore it
   browser.addEventListener("load", function() {
     gBrowser.removeTab(tab);
     ss.undoCloseTab(window, 0);
   }, {capture: true, once: true});
 }
--- a/browser/components/sessionstore/test/browser_682507.js
+++ b/browser/components/sessionstore/test/browser_682507.js
@@ -1,14 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
-  gBrowser.addTab("about:mozilla");
+  BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 
   ss.setTabState(gBrowser.tabs[1], ss.getTabState(gBrowser.tabs[1]));
   ok(gBrowser.tabs[1].hasAttribute("pending"), "second tab should have 'pending' attribute");
 
   gBrowser.selectedTab = gBrowser.tabs[1];
   ok(!gBrowser.tabs[1].hasAttribute("pending"), "second tab should have not 'pending' attribute");
 
   gBrowser.removeTab(gBrowser.tabs[1]);
--- a/browser/components/sessionstore/test/browser_687710_2.js
+++ b/browser/components/sessionstore/test/browser_687710_2.js
@@ -21,17 +21,17 @@ var state = {entries: [
     triggeringPrincipal_base64,
     children: [{ docIdentifier: 10,
                  url: "http://example.com?10#aa",
                  triggeringPrincipal_base64 }]
   }
 ]};
 
 add_task(async function test() {
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   await promiseTabState(tab, state);
   await ContentTask.spawn(tab.linkedBrowser, null, function() {
     function compareEntries(i, j, history) {
       let e1 = history.getEntryAtIndex(i, false)
                       .QueryInterface(Ci.nsISHEntry)
                       .QueryInterface(Ci.nsISHContainer);
 
       let e2 = history.getEntryAtIndex(j, false)
--- a/browser/components/sessionstore/test/browser_705597.js
+++ b/browser/components/sessionstore/test/browser_705597.js
@@ -12,17 +12,17 @@ function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
 
   Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("browser.sessionstore.interval");
   });
 
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   let browser = tab.linkedBrowser;
 
   promiseTabState(tab, tabState).then(() => {
     let sessionHistory = browser.sessionHistory;
     let entry = sessionHistory.getEntryAtIndex(0, false);
     entry.QueryInterface(Ci.nsISHContainer);
 
--- a/browser/components/sessionstore/test/browser_707862.js
+++ b/browser/components/sessionstore/test/browser_707862.js
@@ -12,17 +12,17 @@ function test() {
   waitForExplicitFinish();
   requestLongerTimeout(2);
 
   Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
   registerCleanupFunction(function() {
     Services.prefs.clearUserPref("browser.sessionstore.interval");
   });
 
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   let browser = tab.linkedBrowser;
 
   promiseTabState(tab, tabState).then(() => {
     let sessionHistory = browser.sessionHistory;
     let entry = sessionHistory.getEntryAtIndex(0, false);
     entry.QueryInterface(Ci.nsISHContainer);
 
--- a/browser/components/sessionstore/test/browser_739531.js
+++ b/browser/components/sessionstore/test/browser_739531.js
@@ -7,17 +7,17 @@
 
 function test() {
   waitForExplicitFinish();
 
   let testURL = "http://mochi.test:8888/browser/" +
     "browser/components/sessionstore/test/browser_739531_sample.html";
 
   let loadCount = 0;
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   tab.linkedBrowser.addEventListener("load", function onLoad(aEvent) {
     // make sure both the page and the frame are loaded
     if (++loadCount < 2)
       return;
     tab.linkedBrowser.removeEventListener("load", onLoad, true);
 
     // executeSoon to allow the JS to execute on the page
     executeSoon(function() {
--- a/browser/components/sessionstore/test/browser_739805.js
+++ b/browser/components/sessionstore/test/browser_739805.js
@@ -11,17 +11,17 @@ function test() {
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   registerCleanupFunction(function() {
     if (gBrowser.tabs.length > 1)
       gBrowser.removeTab(gBrowser.tabs[1]);
     Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
   });
 
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
 
   promiseBrowserLoaded(browser).then(() => {
     isnot(gBrowser.selectedTab, tab, "newly created tab is not selected");
 
     ss.setTabState(tab, JSON.stringify(tabState));
     is(browser.__SS_restoreState, TAB_STATE_NEEDS_RESTORE, "tab needs restoring");
 
--- a/browser/components/sessionstore/test/browser_911547.js
+++ b/browser/components/sessionstore/test/browser_911547.js
@@ -3,17 +3,17 @@
 
 // This tests that session restore component does restore the right content
 // security policy with the document.
 // The policy being tested disallows inline scripts
 
 add_task(async function test() {
   // create a tab that has a CSP
   let testURL = "http://mochi.test:8888/browser/browser/components/sessionstore/test/browser_911547_sample.html";
-  let tab = gBrowser.selectedTab = gBrowser.addTab(testURL);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, testURL);
   gBrowser.selectedTab = tab;
 
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // this is a baseline to ensure CSP is active
   // attempt to inject and run a script via inline (pre-restore, allowed)
   await injectInlineScript(browser, `document.getElementById("test_id").value = "fail";`);
--- a/browser/components/sessionstore/test/browser_aboutPrivateBrowsing.js
+++ b/browser/components/sessionstore/test/browser_aboutPrivateBrowsing.js
@@ -1,16 +1,16 @@
 "use strict";
 
 // Tests that an about:privatebrowsing tab with no history will not
 // be saved into session store and thus, it will not show up in
 // Recently Closed Tabs.
 
 add_task(async function() {
-  let tab = gBrowser.addTab("about:privatebrowsing");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:privatebrowsing");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   is(gBrowser.browsers[1].currentURI.spec, "about:privatebrowsing",
      "we will be removing an about:privatebrowsing tab");
 
   let r = `rand-${Math.random()}`;
   ss.setTabValue(tab, "foobar", r);
--- a/browser/components/sessionstore/test/browser_aboutSessionRestore.js
+++ b/browser/components/sessionstore/test/browser_aboutSessionRestore.js
@@ -14,17 +14,17 @@ const TAB_FORMDATA = {url: TAB_URL, id: 
 const TAB_SHENTRY = {url: TAB_URL, triggeringPrincipal_base64};
 const TAB_STATE = {entries: [TAB_SHENTRY], formdata: TAB_FORMDATA};
 
 const FRAME_SCRIPT = "data:," +
                      "content.document.getElementById('errorTryAgain').click()";
 
 add_task(async function() {
   // Prepare a blank tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Fake a post-crash tab.
   ss.setTabState(tab, JSON.stringify(TAB_STATE));
   await promiseTabRestored(tab);
 
   ok(gBrowser.tabs.length > 1, "we have more than one tab");
--- a/browser/components/sessionstore/test/browser_async_duplicate_tab.js
+++ b/browser/components/sessionstore/test/browser_async_duplicate_tab.js
@@ -1,15 +1,15 @@
 "use strict";
 
 const URL = "data:text/html;charset=utf-8,<a href=%23>clickme</a>";
 
 add_task(async function test_duplicate() {
   // Create new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to empty any queued update messages.
   await TabStateFlusher.flush(browser);
 
   // Click the link to navigate, this will add second shistory entry.
   await ContentTask.spawn(browser, null, async function() {
@@ -37,17 +37,17 @@ add_task(async function test_duplicate()
 
   // Cleanup.
   await promiseRemoveTab(tab2);
   await promiseRemoveTab(tab);
 });
 
 add_task(async function test_duplicate_remove() {
   // Create new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to empty any queued update messages.
   await TabStateFlusher.flush(browser);
 
   // Click the link to navigate, this will add second shistory entry.
   await ContentTask.spawn(browser, null, async function() {
--- a/browser/components/sessionstore/test/browser_async_flushes.js
+++ b/browser/components/sessionstore/test/browser_async_flushes.js
@@ -1,15 +1,15 @@
 "use strict";
 
 const URL = "data:text/html;charset=utf-8,<a href=%23>clickme</a>";
 
 add_task(async function test_flush() {
   // Create new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to empty any queued update messages.
   await TabStateFlusher.flush(browser);
 
   // There should be one history entry.
   let {entries} = JSON.parse(ss.getTabState(tab));
@@ -36,17 +36,17 @@ add_task(async function test_flush() {
   is(entries.length, 2, "there are two shistory entries");
 
   // Cleanup.
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_crash() {
   // Create new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   gBrowser.selectedTab = tab;
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to empty any queued update messages.
   await TabStateFlusher.flush(browser);
 
   // There should be one history entry.
@@ -79,17 +79,17 @@ add_task(async function test_crash() {
   is(entries.length, 1, "still only one history entry");
 
   // Cleanup.
   gBrowser.removeTab(tab);
 });
 
 add_task(async function test_remove() {
   // Create new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to empty any queued update messages.
   await TabStateFlusher.flush(browser);
 
   // There should be one history entry.
   let {entries} = JSON.parse(ss.getTabState(tab));
--- a/browser/components/sessionstore/test/browser_async_remove_tab.js
+++ b/browser/components/sessionstore/test/browser_async_remove_tab.js
@@ -1,12 +1,12 @@
 "use strict";
 
 async function createTabWithRandomValue(url) {
-  let tab = gBrowser.addTab(url);
+  let tab = BrowserTestUtils.addTab(gBrowser, url);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Set a random value.
   let r = `rand-${Math.random()}`;
   ss.setTabValue(tab, "foobar", r);
 
   // Flush to ensure there are no scheduled messages.
--- a/browser/components/sessionstore/test/browser_attributes.js
+++ b/browser/components/sessionstore/test/browser_attributes.js
@@ -9,17 +9,17 @@
 
 const PREF = "browser.sessionstore.restore_on_demand";
 
 add_task(async function test() {
   Services.prefs.setBoolPref(PREF, true)
   registerCleanupFunction(() => Services.prefs.clearUserPref(PREF));
 
   // Add a new tab with a nice icon.
-  let tab = gBrowser.addTab("about:robots");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:robots");
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   // Check that the tab has 'image' and 'iconLoadingPrincipal' attributes.
   ok(tab.hasAttribute("image"), "tab.image exists");
   ok(tab.hasAttribute("iconLoadingPrincipal"), "tab.iconLoadingPrincipal exists");
 
   tab.toggleMuteAudio();
   // Check that the tab has a 'muted' attribute.
--- a/browser/components/sessionstore/test/browser_backup_recovery.js
+++ b/browser/components/sessionstore/test/browser_backup_recovery.js
@@ -45,17 +45,17 @@ add_task(async function test_creation() 
     ok(!(await File.exists(Paths[k])), "After wipe " + k + " sessionstore file doesn't exist");
   }
   ok(!(await File.exists(OLD_BACKUP)), "After wipe, old backup doesn't exist");
   ok(!(await File.exists(OLD_UPGRADE_BACKUP)), "After wipe, old upgrade backup doesn't exist");
 
   // Open a new tab, save session, ensure that the correct files exist.
   let URL_BASE = "http://example.com/?atomic_backup_test_creation=" + Math.random();
   let URL = URL_BASE + "?first_write";
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
 
   info("Testing situation after a single write");
   await promiseBrowserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
   await SessionSaver.run();
 
   ok((await File.exists(Paths.recovery)), "After write, recovery sessionstore file exists again");
   ok(!(await File.exists(Paths.recoveryBackup)), "After write, recoveryBackup sessionstore doesn't exist");
@@ -86,17 +86,17 @@ add_task(async function test_creation() 
   ok(!(await File.exists(Paths.nextUpgradeBackup)), "After second write, clean sutdown sessionstore doesn't exist, since we haven't shutdown yet");
 
   gBrowser.removeTab(tab);
   await SessionFile.wipe();
 });
 
 var promiseSource = async function(name) {
   let URL = "http://example.com/?atomic_backup_test_recovery=" + Math.random() + "&name=" + name;
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
 
   await promiseBrowserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
   await SessionSaver.run();
   gBrowser.removeTab(tab);
 
   let SOURCE = await promiseRead(Paths.recovery);
   await SessionFile.wipe();
--- a/browser/components/sessionstore/test/browser_capabilities.js
+++ b/browser/components/sessionstore/test/browser_capabilities.js
@@ -65,13 +65,13 @@ add_task(async function docshell_capabil
   ok(disallow.has("MetaRedirects"), "meta redirects not allowed anymore");
   is(disallow.size, 2, "two capabilities disallowed");
 
   // Clean up after ourselves.
   gBrowser.removeTab(tab);
 });
 
 async function createTab() {
-  let tab = gBrowser.addTab("about:mozilla");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   return tab;
 }
--- a/browser/components/sessionstore/test/browser_cleaner.js
+++ b/browser/components/sessionstore/test/browser_cleaner.js
@@ -38,20 +38,20 @@ var CLOSED_STATE;
 add_task(async function init() {
   forgetClosedWindows();
   while (ss.getClosedTabCount(window) > 0) {
     ss.forgetClosedTab(window, 0);
   }
 });
 
 add_task(async function test_open_and_close() {
-  let newTab1 = gBrowser.addTab(URL_TAB1);
+  let newTab1 = BrowserTestUtils.addTab(gBrowser, URL_TAB1);
   await promiseBrowserLoaded(newTab1.linkedBrowser);
 
-  let newTab2 = gBrowser.addTab(URL_TAB2);
+  let newTab2 = BrowserTestUtils.addTab(gBrowser, URL_TAB2);
   await promiseBrowserLoaded(newTab2.linkedBrowser);
 
   let newWin = await promiseNewWindowLoaded();
   let tab = newWin.gBrowser.addTab(URL_NEWWIN);
 
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   await TabStateFlusher.flushWindow(window);
--- a/browser/components/sessionstore/test/browser_cookies.js
+++ b/browser/components/sessionstore/test/browser_cookies.js
@@ -30,17 +30,17 @@ add_task(async function test_setup() {
   });
 });
 
 // Test session cookie storage.
 add_task(async function test_run() {
   Services.cookies.removeAll();
 
   // Add a new tab for testing.
-  gBrowser.selectedTab = gBrowser.addTab("http://example.com/");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "http://example.com/");
   await promiseBrowserLoaded(gBrowser.selectedBrowser);
 
   // Add a session cookie.
   await promiseSetCookie("foo=bar");
   ok(cookieExists("example.com", "foo", "bar"), "cookie was added");
 
   // Modify a session cookie.
   await promiseSetCookie("foo=baz");
--- a/browser/components/sessionstore/test/browser_crashedTabs.js
+++ b/browser/components/sessionstore/test/browser_crashedTabs.js
@@ -123,17 +123,17 @@ function promiseTabCrashedReady(browser)
   });
 }
 
 /**
  * Checks that if a tab crashes, that information about the tab crashed
  * page does not get added to the tab history.
  */
 add_task(async function test_crash_page_not_in_history() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
   await TabStateFlusher.flush(browser);
@@ -152,17 +152,17 @@ add_task(async function test_crash_page_
 });
 
 /**
  * Checks that if a tab crashes, that when we browse away from that page
  * to a non-blacklisted site (so the browser becomes remote again), that
  * we record history for that new visit.
  */
 add_task(async function test_revived_history_from_remote() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
   await TabStateFlusher.flush(browser);
@@ -191,17 +191,17 @@ add_task(async function test_revived_his
 });
 
 /**
  * Checks that if a tab crashes, that when we browse away from that page
  * to a blacklisted site (so the browser stays non-remote), that
  * we record history for that new visit.
  */
 add_task(async function test_revived_history_from_non_remote() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
   await TabStateFlusher.flush(browser);
@@ -229,26 +229,26 @@ add_task(async function test_revived_his
   gBrowser.removeTab(newTab);
 });
 
 /**
  * Checks that we can revive a crashed tab back to the page that
  * it was on when it crashed.
  */
 add_task(async function test_revive_tab_from_session_store() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
-  let newTab2 = gBrowser.addTab("about:blank", { sameProcessAsFrameLoader: browser.frameLoader });
+  let newTab2 = BrowserTestUtils.addTab(gBrowser, "about:blank", { sameProcessAsFrameLoader: browser.frameLoader });
   let browser2 = newTab2.linkedBrowser;
   ok(browser2.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser2);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_2);
@@ -282,17 +282,17 @@ add_task(async function test_revive_tab_
   gBrowser.removeTab(newTab2);
 });
 
 /**
  * Checks that we can revive multiple crashed tabs back to the pages
  * that they were on when they crashed.
  */
 add_task(async function test_revive_all_tabs_from_session_store() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
@@ -342,17 +342,17 @@ add_task(async function test_revive_all_
   await BrowserTestUtils.closeWindow(win2);
   gBrowser.removeTab(newTab);
 });
 
 /**
  * Checks that about:tabcrashed can close the current tab
  */
 add_task(async function test_close_tab_after_crash() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
@@ -371,17 +371,17 @@ add_task(async function test_close_tab_a
 });
 
 
 /**
  * Checks that "restore all" button is only shown if more than one tab
  * is showing about:tabcrashed
  */
 add_task(async function test_hide_restore_all_button() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
@@ -393,17 +393,17 @@ add_task(async function test_hide_restor
   let doc = browser.contentDocument;
   let restoreAllButton = doc.getElementById("restoreAll");
   let restoreOneButton = doc.getElementById("restoreTab");
 
   let restoreAllStyles = window.getComputedStyle(restoreAllButton);
   is(restoreAllStyles.display, "none", "Restore All button should be hidden");
   ok(restoreOneButton.classList.contains("primary"), "Restore Tab button should have the primary class");
 
-  let newTab2 = gBrowser.addTab();
+  let newTab2 = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
 
   browser.loadURI(PAGE_2);
   await promiseBrowserLoaded(browser);
 
   // Load up a second window so we can get another tab to show
   // about:tabcrashed
   let win2 = await BrowserTestUtils.openNewBrowserWindow();
@@ -429,17 +429,17 @@ add_task(async function test_hide_restor
   ok(!(restoreOneButton.classList.contains("primary")), "Restore Tab button should not have the primary class");
 
   await BrowserTestUtils.closeWindow(win2);
   gBrowser.removeTab(newTab);
   gBrowser.removeTab(newTab2);
 });
 
 add_task(async function test_aboutcrashedtabzoom() {
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let browser = newTab.linkedBrowser;
   ok(browser.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
--- a/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
+++ b/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
@@ -1,12 +1,12 @@
 // First test - open a tab and duplicate it, using session restore to restore the history into the new tab.
 add_task(async function duplicateTab() {
   const TEST_URL = "data:text/html,foo";
-  let tab = gBrowser.addTab(TEST_URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   await ContentTask.spawn(tab.linkedBrowser, null, function() {
     let docshell = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsIWebNavigation)
                                  .QueryInterface(Ci.nsIDocShell);
     let shEntry = docshell.sessionHistory.getEntryAtIndex(0, false);
     is(shEntry.docshellID.toString(), docshell.historyID.toString());
@@ -25,17 +25,17 @@ add_task(async function duplicateTab() {
 
   await BrowserTestUtils.removeTab(tab);
   await BrowserTestUtils.removeTab(tab2);
 });
 
 // Second test - open a tab and navigate across processes, which triggers sessionrestore to persist history.
 add_task(async function contentToChromeNavigate() {
   const TEST_URL = "data:text/html,foo";
-  let tab = gBrowser.addTab(TEST_URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URL);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   await ContentTask.spawn(tab.linkedBrowser, null, function() {
     let docshell = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsIWebNavigation)
                                  .QueryInterface(Ci.nsIDocShell);
     let sh = docshell.sessionHistory;
     is(sh.count, 1);
--- a/browser/components/sessionstore/test/browser_dynamic_frames.js
+++ b/browser/components/sessionstore/test/browser_dynamic_frames.js
@@ -15,17 +15,17 @@ add_task(async function() {
   const URL = "data:text/html;charset=utf-8," +
               "<frameset cols=50%25,50%25><frame src='data:text/html,A'>" +
               "<frame src='data:text/html,B'></frameset>" +
               "<script>var i=document.createElement('iframe');" +
               "i.setAttribute('src', 'data:text/html,C');" +
               "document.body.appendChild(i);</script>";
 
   // Add a new tab with two "static" and one "dynamic" frame.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
 
   // Check URLs.
   ok(entries[0].url.startsWith("data:text/html"), "correct root url");
@@ -52,17 +52,17 @@ add_task(async function() {
   const URL = "data:text/html;charset=utf-8," +
               "<iframe name=t src='data:text/html,A'></iframe>" +
               "<a id=lnk href='data:text/html,B' target=t>clickme</a>" +
               "<script>var i=document.createElement('iframe');" +
               "i.setAttribute('src', 'data:text/html,C');" +
               "document.body.appendChild(i);</script>";
 
   // Add a new tab with one "static" and one "dynamic" frame.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
 
   // Check URLs.
   ok(entries[0].url.startsWith("data:text/html"), "correct root url");
--- a/browser/components/sessionstore/test/browser_forget_async_closings.js
+++ b/browser/components/sessionstore/test/browser_forget_async_closings.js
@@ -23,17 +23,17 @@ let forgetTabHelper = async function(for
   // Forget any previous closed tabs from other tests that may have
   // run in the same session.
   Services.obs.notifyObservers(null, "browser:purge-session-history");
 
   is(ss.getClosedTabCount(window), 0,
      "We should have 0 closed tabs being stored.");
 
   // Create a tab worth remembering.
-  let tab = gBrowser.addTab(PAGE);
+  let tab = BrowserTestUtils.addTab(gBrowser, PAGE);
   let browser = tab.linkedBrowser;
   await BrowserTestUtils.browserLoaded(browser, false, PAGE);
   await TabStateFlusher.flush(browser);
 
   // Now close the tab, and immediately choose to forget it.
   let promise = BrowserTestUtils.removeTab(tab);
 
   // At this point, the tab will have closed, but the final update
--- a/browser/components/sessionstore/test/browser_form_restore_events.js
+++ b/browser/components/sessionstore/test/browser_form_restore_events.js
@@ -6,17 +6,17 @@
 const URL = ROOT + "browser_form_restore_events_sample.html";
 
 /**
  * Originally a test for Bug 476161, but then expanded to include all input
  * types in bug 640136.
  */
 add_task(async function() {
   // Load a page with some form elements.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // text fields
   await setInputValue(browser, {id: "modify01", value: Math.random()});
   await setInputValue(browser, {id: "modify02", value: Date.now()});
 
   // textareas
--- a/browser/components/sessionstore/test/browser_formdata.js
+++ b/browser/components/sessionstore/test/browser_formdata.js
@@ -15,17 +15,17 @@ add_task(async function test_formdata() 
 
   const OUTER_VALUE = "browser_formdata_" + Math.random();
   const INNER_VALUE = "browser_formdata_" + Math.random();
 
   // Creates a tab, loads a page with some form fields,
   // modifies their values and closes the tab.
   async function createAndRemoveTab() {
     // Create a new tab.
-    let tab = gBrowser.addTab(URL);
+    let tab = BrowserTestUtils.addTab(gBrowser, URL);
     let browser = tab.linkedBrowser;
     await promiseBrowserLoaded(browser);
 
     // Modify form data.
     await setInputValue(browser, {id: "txt", value: OUTER_VALUE});
     await setInputValue(browser, {id: "txt", value: INNER_VALUE, frame: 0});
 
     // Remove the tab.
@@ -61,17 +61,17 @@ add_task(async function test_formdata() 
  * form data into a wrong website and that we always check the stored URL
  * before doing so.
  */
 add_task(async function test_url_check() {
   const URL = "data:text/html;charset=utf-8,<input%20id=input>";
   const VALUE = "value-" + Math.random();
 
   // Create a tab with an iframe containing an input field.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Restore a tab state with a given form data url.
   function restoreStateWithURL(url) {
     let state = {entries: [{url: URL, triggeringPrincipal_base64}], formdata: {id: {input: VALUE}}};
 
     if (url) {
@@ -104,17 +104,17 @@ add_task(async function test_nested() {
   const FORM_DATA = {
     children: [{
       xpath: {"/xhtml:html/xhtml:body/xhtml:input": "M"},
       url: "data:text/html;charset=utf-8,<input%20autofocus=true>"
     }]
   };
 
   // Create a tab with an iframe containing an input field.
-  let tab = gBrowser.selectedTab = gBrowser.addTab(URL);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Modify the input field's value.
   await sendMessage(browser, "ss-test:sendKeyEvent", {key: "m", frame: 0});
 
   // Remove the tab and check that we stored form data correctly.
   await promiseRemoveTab(tab);
@@ -141,17 +141,17 @@ add_task(async function test_nested() {
  * This test ensures that collecting form data for documents with
  * designMode=on works as expected.
  */
 add_task(async function test_design_mode() {
   const URL = "data:text/html;charset=utf-8,<h1>mozilla</h1>" +
               "<script>document.designMode='on'</script>";
 
   // Load a tab with an editable document.
-  let tab = gBrowser.selectedTab = gBrowser.addTab(URL);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Modify the document content.
   await sendMessage(browser, "ss-test:sendKeyEvent", {key: "m"});
 
   // Close and restore the tab.
   await promiseRemoveTab(tab);
--- a/browser/components/sessionstore/test/browser_formdata_cc.js
+++ b/browser/components/sessionstore/test/browser_formdata_cc.js
@@ -40,17 +40,17 @@ add_task(async function() {
     "8276996369036686", "4449796938248871",
     "3350852696538147", "5011802870046957"
   ];
 
   // Creates a tab, loads a page with a form field, sets the value of the
   // field, and then removes the tab to trigger data collection.
   async function createAndRemoveTab(formValue) {
     // Create a new tab.
-    let tab = gBrowser.addTab(URL);
+    let tab = BrowserTestUtils.addTab(gBrowser, URL);
     let browser = tab.linkedBrowser;
     await promiseBrowserLoaded(browser);
 
     // Set form value.
     await setInputValue(browser, formValue);
 
     // Remove the tab.
     await promiseRemoveTab(tab);
--- a/browser/components/sessionstore/test/browser_formdata_format.js
+++ b/browser/components/sessionstore/test/browser_formdata_format.js
@@ -59,17 +59,17 @@ function test() {
     promises.push(testTabRestoreData(formData[i], expectedValues[i]));
   }
 
   Promise.all(promises).then(() => finish(), ex => ok(false, ex));
 }
 
 async function testTabRestoreData(aFormData, aExpectedValue) {
   let URL = ROOT + "browser_formdata_format_sample.html";
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   aFormData.url = URL;
   let tabState = { entries: [{ url: URL, triggeringPrincipal_base64 }], formdata: aFormData };
 
   await promiseBrowserLoaded(tab.linkedBrowser);
   await promiseTabState(tab, tabState);
 
   await TabStateFlusher.flush(tab.linkedBrowser);
--- a/browser/components/sessionstore/test/browser_formdata_xpath.js
+++ b/browser/components/sessionstore/test/browser_formdata_xpath.js
@@ -35,17 +35,17 @@ const FIELDS = {
   "//textarea[2]":              "Some text... " + Math.random(),
   "//textarea[3]":              "Some more text\n" + new Date(),
   "//input[@type='file'][1]":   [FILE1],
   "//input[@type='file'][2]":   [FILE1, FILE2]
 };
 
 add_task(async function test_form_data_restoration() {
   // Load page with some input fields.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Fill in some values.
   for (let xpath of Object.keys(FIELDS)) {
     await setFormValue(browser, xpath);
   }
 
--- a/browser/components/sessionstore/test/browser_frame_history.js
+++ b/browser/components/sessionstore/test/browser_frame_history.js
@@ -5,17 +5,17 @@
 /**
  Ensure that frameset history works properly when restoring a tab,
  provided that the frameset is static.
  */
 
 // Loading a toplevel frameset
 add_task(async function() {
   let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index.html";
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   gBrowser.selectedTab = tab;
 
   info("Opening a page with three frames, 4 loads should take place");
   await waitForLoadsInBrowser(tab.linkedBrowser, 4);
 
   let browser_b = tab.linkedBrowser.contentDocument.getElementsByTagName("frame")[1];
   let document_b = browser_b.contentDocument;
   let links = document_b.getElementsByTagName("a");
@@ -48,17 +48,17 @@ add_task(async function() {
        "frame " + i + " has the right url");
   }
   gBrowser.removeTab(newTab);
 });
 
 // Loading the frameset inside an iframe
 add_task(async function() {
   let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index2.html";
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   gBrowser.selectedTab = tab;
 
   info("iframe: Opening a page with an iframe containing three frames, 5 loads should take place");
   await waitForLoadsInBrowser(tab.linkedBrowser, 5);
 
   let browser_b = tab.linkedBrowser.contentDocument.
     getElementById("iframe").contentDocument.
     getElementsByTagName("frame")[1];
@@ -105,17 +105,17 @@ add_task(async function() {
         tabs: [{ entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }],
         _closedTabs: []
       }],
       _closedWindows: []
     });
     ss.setBrowserState(blankState);
 
   let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index_blank.html";
-  let tab = gBrowser.addTab(testURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, testURL);
   gBrowser.selectedTab = tab;
   await waitForLoadsInBrowser(tab.linkedBrowser, 1);
 
   info("dynamic: Opening a page with an iframe containing three frames, 4 dynamic loads should take place");
   let doc = tab.linkedBrowser.contentDocument;
   let iframe = doc.createElement("iframe");
   iframe.id = "iframe";
   iframe.src = "browser_frame_history_index.html";
--- a/browser/components/sessionstore/test/browser_frametree.js
+++ b/browser/components/sessionstore/test/browser_frametree.js
@@ -16,17 +16,17 @@ const URL_FRAMESET = HTTPROOT + "browser
 add_task(async function test_frametree() {
   const FRAME_TREE_SINGLE = { href: URL };
   const FRAME_TREE_FRAMESET = {
     href: URL_FRAMESET,
     children: [{href: URL}, {href: URL}, {href: URL}]
   };
 
   // Create a tab with a single frame.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseNewFrameTree(browser);
   await checkFrameTree(browser, FRAME_TREE_SINGLE,
     "loading a page resets and creates the frame tree correctly");
 
   // Load the frameset and create two frames dynamically, the first on
   // DOMContentLoaded and the second on load.
   await sendMessage(browser, "ss-test:createDynamicFrames", {id: "frames", url: URL});
@@ -73,17 +73,17 @@ add_task(async function test_frametree_d
     children: [{href: URL}, {href: URL}, {href: URL}]
   };
   const FRAME_TREE_REMOVED = {
     href: URL_FRAMESET,
     children: [{href: URL}, {href: URL}]
   };
 
   // Add an empty tab for a start.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Create dynamic frames on "DOMContentLoaded" and on "load".
   await sendMessage(browser, "ss-test:createDynamicFrames", {id: "frames", url: URL});
   browser.loadURI(URL_FRAMESET);
   await promiseNewFrameTree(browser);
 
--- a/browser/components/sessionstore/test/browser_history_persist.js
+++ b/browser/components/sessionstore/test/browser_history_persist.js
@@ -4,29 +4,29 @@
 "use strict";
 
 /**
  * Ensure that history entries that should not be persisted are restored in the
  * same state.
  */
 add_task(async function check_history_not_persisted() {
   // Create an about:blank tab
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Retrieve the tab state.
   await TabStateFlusher.flush(browser);
   let state = JSON.parse(ss.getTabState(tab));
   ok(!state.entries[0].persist, "Should have collected the persistence state");
   await promiseRemoveTab(tab);
   browser = null;
 
   // Open a new tab to restore into.
-  tab = gBrowser.addTab("about:blank");
+  tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   browser = tab.linkedBrowser;
   await promiseTabState(tab, state);
 
   await ContentTask.spawn(browser, null, function() {
     let sessionHistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsISHistory);
 
     is(sessionHistory.count, 1, "Should be a single history entry");
@@ -48,29 +48,29 @@ add_task(async function check_history_no
 });
 
 /**
  * Check that entries default to being persisted when the attribute doesn't
  * exist
  */
 add_task(async function check_history_default_persisted() {
   // Create an about:blank tab
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Retrieve the tab state.
   await TabStateFlusher.flush(browser);
   let state = JSON.parse(ss.getTabState(tab));
   delete state.entries[0].persist;
   await promiseRemoveTab(tab);
   browser = null;
 
   // Open a new tab to restore into.
-  tab = gBrowser.addTab("about:blank");
+  tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   browser = tab.linkedBrowser;
   await promiseTabState(tab, state);
   await ContentTask.spawn(browser, null, function() {
     let sessionHistory = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                                  .getInterface(Ci.nsISHistory);
 
     is(sessionHistory.count, 1, "Should be a single history entry");
     is(sessionHistory.getEntryAtIndex(0, false).URI.spec, "about:blank", "Should be the right URL");
--- a/browser/components/sessionstore/test/browser_label_and_icon.js
+++ b/browser/components/sessionstore/test/browser_label_and_icon.js
@@ -17,28 +17,28 @@ add_task(function setup() {
   });
 });
 
 /**
  * Ensure that a pending tab has label and icon correctly set.
  */
 add_task(async function test_label_and_icon() {
   // Create a new tab.
-  let tab = gBrowser.addTab("about:robots");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:robots");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Retrieve the tab state.
   await TabStateFlusher.flush(browser);
   let state = ss.getTabState(tab);
   await promiseRemoveTab(tab);
   browser = null;
 
   // Open a new tab to restore into.
-  tab = gBrowser.addTab("about:blank");
+  tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   ss.setTabState(tab, state);
   await promiseTabRestoring(tab);
 
   // Check that label and icon are set for the restoring tab.
   ok(gBrowser.getIcon(tab).startsWith("data:image/png;"), "icon is set");
   is(tab.label, "Gort! Klaatu barada nikto!", "label is set");
 
   let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
--- a/browser/components/sessionstore/test/browser_multiple_navigateAndRestore.js
+++ b/browser/components/sessionstore/test/browser_multiple_navigateAndRestore.js
@@ -1,16 +1,16 @@
 "use strict";
 
 const PAGE_1 = "data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page.";
 const PAGE_2 = "data:text/html,<html><body>Another%20regular,%20everyday,%20normal%20page.";
 
 add_task(async function() {
   // Load an empty, non-remote tab at about:blank...
-  let tab = gBrowser.addTab("about:blank", {
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
     forceNotRemote: true,
   });
   gBrowser.selectedTab = tab;
   let browser = gBrowser.selectedBrowser;
   ok(!browser.isRemoteBrowser, "Ensure browser is not remote");
   // Load a remote page, and then another remote page immediately
   // after.
   browser.loadURI(PAGE_1);
--- a/browser/components/sessionstore/test/browser_pageStyle.js
+++ b/browser/components/sessionstore/test/browser_pageStyle.js
@@ -5,17 +5,17 @@
 
 const URL = getRootDirectory(gTestPath) + "browser_pageStyle_sample.html";
 const URL_NESTED = getRootDirectory(gTestPath) + "browser_pageStyle_sample_nested.html";
 
 /**
  * This test ensures that page style information is correctly persisted.
  */
 add_task(async function page_style() {
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   let sheets = await getStyleSheets(browser);
 
   // Enable all style sheets one by one.
   for (let [title, /*disabled */] of sheets) {
     await enableStyleSheetsForSet(browser, title);
 
@@ -49,17 +49,17 @@ add_task(async function page_style() {
   gBrowser.removeTab(tab2);
 });
 
 /**
  * This test ensures that page style notification from nested documents are
  * received and the page style is persisted correctly.
  */
 add_task(async function nested_page_style() {
-  let tab = gBrowser.addTab(URL_NESTED);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL_NESTED);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   await enableSubDocumentStyleSheetsForSet(browser, "alternate");
   await promiseRemoveTab(tab);
 
   let [{state: {pageStyle}}] = JSON.parse(ss.getClosedTabData(window));
   let expected = JSON.stringify({children: [{pageStyle: "alternate"}]});
--- a/browser/components/sessionstore/test/browser_page_title.js
+++ b/browser/components/sessionstore/test/browser_page_title.js
@@ -1,28 +1,28 @@
 "use strict";
 
 const URL = "data:text/html,<title>initial title</title>";
 
 add_task(async function() {
   // Create a new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   // Remove the tab.
   await promiseRemoveTab(tab);
 
   // Check the title.
   let [{state: {entries}}] = JSON.parse(ss.getClosedTabData(window));
   is(entries[0].title, "initial title", "correct title");
 });
 
 add_task(async function() {
   // Create a new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to ensure we collected the initial title.
   await TabStateFlusher.flush(browser);
 
   // Set a new title.
   await ContentTask.spawn(browser, null, async function() {
--- a/browser/components/sessionstore/test/browser_pending_tabs.js
+++ b/browser/components/sessionstore/test/browser_pending_tabs.js
@@ -4,17 +4,17 @@ const TAB_STATE = {
   entries: [
   { url: "about:mozilla", triggeringPrincipal_base64 },
   { url: "about:robots", triggeringPrincipal_base64 }],
   index: 1,
 };
 
 add_task(async function() {
   // Create a background tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // The tab shouldn't be restored right away.
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   // Prepare the tab state.
   let promise = promiseTabRestoring(tab);
--- a/browser/components/sessionstore/test/browser_privatetabs.js
+++ b/browser/components/sessionstore/test/browser_privatetabs.js
@@ -10,21 +10,21 @@ add_task(function cleanup() {
 
 add_task(async function() {
   let URL_PUBLIC = "http://example.com/public/" + Math.random();
   let URL_PRIVATE = "http://example.com/private/" + Math.random();
   let tab1, tab2;
   try {
     // Setup a public tab and a private tab
     info("Setting up public tab");
-    tab1 = gBrowser.addTab(URL_PUBLIC);
+    tab1 = BrowserTestUtils.addTab(gBrowser, URL_PUBLIC);
     await promiseBrowserLoaded(tab1.linkedBrowser);
 
     info("Setting up private tab");
-    tab2 = gBrowser.addTab();
+    tab2 = BrowserTestUtils.addTab(gBrowser);
     await promiseBrowserLoaded(tab2.linkedBrowser);
     await setUsePrivateBrowsing(tab2.linkedBrowser, true);
     tab2.linkedBrowser.loadURI(URL_PRIVATE);
     await promiseBrowserLoaded(tab2.linkedBrowser);
 
     info("Flush to make sure chrome received all data.");
     await TabStateFlusher.flush(tab1.linkedBrowser);
     await TabStateFlusher.flush(tab2.linkedBrowser);
--- a/browser/components/sessionstore/test/browser_purge_shistory.js
+++ b/browser/components/sessionstore/test/browser_purge_shistory.js
@@ -19,23 +19,23 @@ function checkTabContents(browser) {
     let history = webNavigation.sessionHistory.QueryInterface(Ci.nsISHistoryInternal);
     Assert.ok(history && history.count == 1 && content.document.documentURI == "about:mozilla",
       "expected tab contents found");
   });
 }
 
 add_task(async function() {
   // Create a new tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   await promiseTabState(tab, TAB_STATE);
 
   // Create another new tab.
-  let tab2 = gBrowser.addTab("about:blank");
+  let tab2 = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser2 = tab2.linkedBrowser;
   await promiseBrowserLoaded(browser2);
 
   // The tab shouldn't be restored right away.
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   // Prepare the tab state.
   let promise = promiseTabRestoring(tab2);
--- a/browser/components/sessionstore/test/browser_replace_load.js
+++ b/browser/components/sessionstore/test/browser_replace_load.js
@@ -14,17 +14,17 @@ const STATE = {
  */
 add_task(async function() {
   await testSwitchToTab("about:mozilla#fooobar", {ignoreFragment: "whenComparingAndReplace"});
   await testSwitchToTab("about:mozilla?foo=bar", {replaceQueryString: true});
 });
 
 var testSwitchToTab = async function(url, options) {
   // Create a background tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // The tab shouldn't be restored right away.
   Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
 
   // Prepare the tab state.
   let promise = promiseTabRestoring(tab);
--- a/browser/components/sessionstore/test/browser_restore_redirect.js
+++ b/browser/components/sessionstore/test/browser_restore_redirect.js
@@ -7,17 +7,17 @@ const TARGET = BASE + "restore_redirect_
  * Ensure that a http redirect leaves a working tab.
  */
 add_task(async function check_http_redirect() {
   let state = {
     entries: [{ url: BASE + "restore_redirect_http.html", triggeringPrincipal_base64}]
   };
 
   // Open a new tab to restore into.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseTabState(tab, state);
 
   info("Restored tab");
 
   await TabStateFlusher.flush(browser);
   let data = TabState.collect(tab);
   is(data.entries.length, 1, "Should be one entry in session history");
@@ -44,17 +44,17 @@ add_task(async function check_js_redirec
         resolve();
       }
     }
 
     window.messageManager.addMessageListener("ss-test:loadEvent", listener);
   });
 
   // Open a new tab to restore into.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseTabState(tab, state);
 
   info("Restored tab");
 
   await loadPromise;
 
   await TabStateFlusher.flush(browser);
--- a/browser/components/sessionstore/test/browser_revive_crashed_bg_tabs.js
+++ b/browser/components/sessionstore/test/browser_revive_crashed_bg_tabs.js
@@ -14,21 +14,21 @@ const PAGE_2 = "data:text/html,<html><bo
 
 add_task(async function setup() {
   await pushPrefs(["dom.ipc.processCount", 1],
                   ["toolkit.cosmeticAnimations.enabled", false],
                   ["browser.sessionstore.restore_on_demand", false]);
 });
 
 add_task(async function test_revive_bg_tabs_on_demand() {
-  let newTab1 = gBrowser.addTab(PAGE_1);
+  let newTab1 = BrowserTestUtils.addTab(gBrowser, PAGE_1);
   let browser1 = newTab1.linkedBrowser;
   gBrowser.selectedTab = newTab1;
 
-  let newTab2 = gBrowser.addTab(PAGE_2);
+  let newTab2 = BrowserTestUtils.addTab(gBrowser, PAGE_2);
   let browser2 = newTab2.linkedBrowser;
 
   await BrowserTestUtils.browserLoaded(browser1);
   await BrowserTestUtils.browserLoaded(browser2);
 
   await TabStateFlusher.flush(browser2);
 
   // Now crash the selected tab
--- a/browser/components/sessionstore/test/browser_scrollPositions.js
+++ b/browser/components/sessionstore/test/browser_scrollPositions.js
@@ -19,17 +19,17 @@ const SCROLL2_STR = SCROLL2_X + "," + SC
 
 requestLongerTimeout(2);
 
 /**
  * This test ensures that we properly serialize and restore scroll positions
  * for an average page without any frames.
  */
 add_task(async function test_scroll() {
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Scroll down a little.
   await sendMessage(browser, "ss-test:setScrollPosition", {x: SCROLL_X, y: SCROLL_Y});
   await checkScroll(tab, {scroll: SCROLL_STR}, "scroll is fine");
 
   // Duplicate and check that the scroll position is restored.
@@ -62,17 +62,17 @@ add_task(async function test_scroll() {
   await promiseRemoveTab(tab2);
 });
 
 /**
  * This tests ensures that we properly serialize and restore scroll positions
  * for multiple frames of pages with framesets.
  */
 add_task(async function test_scroll_nested() {
-  let tab = gBrowser.addTab(URL_FRAMESET);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL_FRAMESET);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Scroll the first child frame down a little.
   await sendMessage(browser, "ss-test:setScrollPosition", {x: SCROLL_X, y: SCROLL_Y, frame: 0});
   await checkScroll(tab, {children: [{scroll: SCROLL_STR}]}, "scroll is fine");
 
   // Scroll the second child frame down a little.
--- a/browser/components/sessionstore/test/browser_send_async_message_oom.js
+++ b/browser/components/sessionstore/test/browser_send_async_message_oom.js
@@ -35,17 +35,17 @@ function frameScript() {
   mm.sendSyncMessage = wrap(mm.sendSyncMessage);
 }
 
 add_task(async function() {
   // Capture original state.
   let snapshot = Services.telemetry.getHistogramById(HISTOGRAM_NAME).snapshot();
 
   // Open a browser, configure it to cause OOM.
-  let newTab = gBrowser.addTab("about:robots");
+  let newTab = BrowserTestUtils.addTab(gBrowser, "about:robots");
   let browser = newTab.linkedBrowser;
   await ContentTask.spawn(browser, null, frameScript);
 
 
   let promiseReported = new Promise(resolve => {
     browser.messageManager.addMessageListener("SessionStore:error", resolve);
   });
 
--- a/browser/components/sessionstore/test/browser_sessionHistory.js
+++ b/browser/components/sessionstore/test/browser_sessionHistory.js
@@ -5,17 +5,17 @@
 
 requestLongerTimeout(2);
 
 /**
  * Ensure that starting a load invalidates shistory.
  */
 add_task(async function test_load_start() {
   // Create a new tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Load a new URI.
   await BrowserTestUtils.loadURI(browser, "about:mozilla");
 
   // Remove the tab before it has finished loading.
   await promiseContentMessage(browser, "ss-test:OnHistoryReplaceEntry");
@@ -35,17 +35,17 @@ add_task(async function test_load_start(
 
 /**
  * Ensure that anchor navigation invalidates shistory.
  */
 add_task(async function test_hashchange() {
   const URL = "data:text/html;charset=utf-8,<a id=a href=%23>clickme</a>";
 
   // Create a new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Check that we start with a single shistory entry.
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
   is(entries.length, 1, "there is one shistory entry");
 
@@ -65,17 +65,17 @@ add_task(async function test_hashchange(
 /**
  * Ensure that loading pages from the bfcache invalidates shistory.
  */
 add_task(async function test_pageshow() {
   const URL = "data:text/html;charset=utf-8,<h1>first</h1>";
   const URL2 = "data:text/html;charset=utf-8,<h1>second</h1>";
 
   // Create a new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Create a second shistory entry.
   browser.loadURI(URL2);
   await promiseBrowserLoaded(browser);
 
   // Go back to the previous url which is loaded from the bfcache.
@@ -97,17 +97,17 @@ add_task(async function test_pageshow() 
  */
 add_task(async function test_subframes() {
   const URL = "data:text/html;charset=utf-8," +
               "<iframe src=http%3A//example.com/ name=t></iframe>" +
               "<a id=a1 href=http%3A//example.com/1 target=t>clickme</a>" +
               "<a id=a2 href=http%3A//example.com/%23 target=t>clickme</a>";
 
   // Create a new tab.
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Check that we have a single shistory entry.
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
   is(entries.length, 1, "there is one shistory entry");
   is(entries[0].children.length, 1, "the entry has one child");
@@ -140,17 +140,17 @@ add_task(async function test_subframes()
   gBrowser.removeTab(tab);
 });
 
 /**
  * Ensure that navigating from an about page invalidates shistory.
  */
 add_task(async function test_about_page_navigate() {
   // Create a new tab.
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Check that we have a single shistory entry.
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
   is(entries.length, 1, "there is one shistory entry");
   is(entries[0].url, "about:blank", "url is correct");
@@ -171,17 +171,17 @@ add_task(async function test_about_page_
   gBrowser.removeTab(tab);
 });
 
 /**
  * Ensure that history.pushState and history.replaceState invalidate shistory.
  */
 add_task(async function test_pushstate_replacestate() {
   // Create a new tab.
-  let tab = gBrowser.addTab("http://example.com/1");
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/1");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Check that we have a single shistory entry.
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
   is(entries.length, 1, "there is one shistory entry");
   is(entries[0].url, "http://example.com/1", "url is correct");
@@ -218,17 +218,17 @@ add_task(async function test_slow_subfra
                    "sessionstore/test/browser_sessionHistory_slow.sjs";
 
   const URL = "data:text/html;charset=utf-8," +
               "<frameset cols=50%25,50%25>" +
               "<frame src='" + SLOW_URL + "'>" +
               "</frameset>";
 
   // Add a new tab with a slow loading subframe
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   await TabStateFlusher.flush(browser);
   let {entries} = JSON.parse(ss.getTabState(tab));
 
   // Check the number of children.
   is(entries.length, 1, "there is one root entry ...");
--- a/browser/components/sessionstore/test/browser_sessionStorage.js
+++ b/browser/components/sessionstore/test/browser_sessionStorage.js
@@ -11,17 +11,17 @@ const URL = "http://mochi.test:8888/brow
 const OUTER_VALUE = "outer-value-" + RAND;
 const INNER_VALUE = "inner-value-" + RAND;
 
 /**
  * This test ensures that setting, modifying and restoring sessionStorage data
  * works as expected.
  */
 add_task(async function session_storage() {
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to make sure chrome received all data.
   await TabStateFlusher.flush(browser);
 
   let {storage} = JSON.parse(ss.getTabState(tab));
   is(storage["http://example.com"].test, INNER_VALUE,
@@ -98,17 +98,17 @@ add_task(async function session_storage(
   await promiseRemoveTab(tab2);
 });
 
 /**
  * This test ensures that purging domain data also purges data from the
  * sessionStorage data collected for tabs.
  */
 add_task(async function purge_domain() {
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Purge data for "mochi.test".
   await purgeDomainData(browser, "mochi.test");
 
   // Flush to make sure chrome received all data.
   await TabStateFlusher.flush(browser);
@@ -122,44 +122,44 @@ add_task(async function purge_domain() {
   await promiseRemoveTab(tab);
 });
 
 /**
  * This test ensures that collecting sessionStorage data respects the privacy
  * levels as set by the user.
  */
 add_task(async function respect_privacy_level() {
-  let tab = gBrowser.addTab(URL + "&secure");
+  let tab = BrowserTestUtils.addTab(gBrowser, URL + "&secure");
   await promiseBrowserLoaded(tab.linkedBrowser);
   await promiseRemoveTab(tab);
 
   let [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
   is(storage["http://mochi.test:8888"].test, OUTER_VALUE,
     "http sessionStorage data has been saved");
   is(storage["https://example.com"].test, INNER_VALUE,
     "https sessionStorage data has been saved");
 
   // Disable saving data for encrypted sites.
   Services.prefs.setIntPref("browser.sessionstore.privacy_level", 1);
 
-  tab = gBrowser.addTab(URL + "&secure");
+  tab = BrowserTestUtils.addTab(gBrowser, URL + "&secure");
   await promiseBrowserLoaded(tab.linkedBrowser);
   await promiseRemoveTab(tab);
 
   [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
   is(storage["http://mochi.test:8888"].test, OUTER_VALUE,
     "http sessionStorage data has been saved");
   ok(!storage["https://example.com"],
     "https sessionStorage data has *not* been saved");
 
   // Disable saving data for any site.
   Services.prefs.setIntPref("browser.sessionstore.privacy_level", 2);
 
   // Check that duplicating a tab copies all private data.
-  tab = gBrowser.addTab(URL + "&secure");
+  tab = BrowserTestUtils.addTab(gBrowser, URL + "&secure");
   await promiseBrowserLoaded(tab.linkedBrowser);
   let tab2 = gBrowser.duplicateTab(tab);
   await promiseTabRestored(tab2);
   await promiseRemoveTab(tab);
 
   // With privacy_level=2 the |tab| shouldn't have any sessionStorage data.
   [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
   ok(!storage, "sessionStorage data has *not* been saved");
--- a/browser/components/sessionstore/test/browser_sessionStorage_size.js
+++ b/browser/components/sessionstore/test/browser_sessionStorage_size.js
@@ -12,17 +12,17 @@ const OUTER_VALUE = "outer-value-" + RAN
 
 // Test that we record the size of messages.
 add_task(async function test_telemetry() {
   Services.telemetry.canRecordExtended = true;
   let suffix = gMultiProcessBrowser ? "#content" : "";
   let histogram = Services.telemetry.getHistogramById("FX_SESSION_RESTORE_DOM_STORAGE_SIZE_ESTIMATE_CHARS" + suffix);
   let snap1 = histogram.snapshot();
 
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to make sure we submitted telemetry data.
   await TabStateFlusher.flush(browser);
 
   // There is no good way to make sure that the parent received the histogram entries from the child processes.
   // Let's stick to the ugly, spinning the event loop until we have a good approach (Bug 1357509).
@@ -35,17 +35,17 @@ add_task(async function test_telemetry()
   Services.telemetry.canRecordExtended = false;
 });
 
 // Lower the size limit for DOM Storage content. Check that DOM Storage
 // is not updated, but that other things remain updated.
 add_task(async function test_large_content() {
   Services.prefs.setIntPref("browser.sessionstore.dom_storage_limit", 5);
 
-  let tab = gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(gBrowser, URL);
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
 
   // Flush to make sure chrome received all data.
   await TabStateFlusher.flush(browser);
 
   let state = JSON.parse(ss.getTabState(tab));
   info(JSON.stringify(state, null, "\t"));
--- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js
+++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 add_task(async function() {
   for (let i = 0; i < 3; ++i) {
-    let tab = gBrowser.addTab("http://example.com/", { userContextId: i });
+    let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/", { userContextId: i });
     let browser = tab.linkedBrowser;
 
     await promiseBrowserLoaded(browser);
 
     let tab2 = gBrowser.duplicateTab(tab);
     Assert.equal(tab2.getAttribute("usercontextid"), i);
     let browser2 = tab2.linkedBrowser;
     await promiseTabRestored(tab2)
@@ -23,17 +23,17 @@ add_task(async function() {
     });
 
     await promiseRemoveTab(tab);
     await promiseRemoveTab(tab2);
   }
 });
 
 add_task(async function() {
-  let tab = gBrowser.addTab("http://example.com/", { userContextId: 1 });
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/", { userContextId: 1 });
   let browser = tab.linkedBrowser;
 
   await promiseBrowserLoaded(browser);
 
   gBrowser.selectedTab = tab;
 
   let tab2 = gBrowser.duplicateTab(tab);
   let browser2 = tab2.linkedBrowser;
@@ -45,17 +45,17 @@ add_task(async function() {
                  "The docShell has the correct userContextId");
   });
 
   await promiseRemoveTab(tab);
   await promiseRemoveTab(tab2);
 });
 
 add_task(async function() {
-  let tab = gBrowser.addTab("http://example.com/", { userContextId: 1 });
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com/", { userContextId: 1 });
   let browser = tab.linkedBrowser;
 
   await promiseBrowserLoaded(browser);
 
   gBrowser.removeTab(tab);
 
   let tab2 = ss.undoCloseTab(window, 0);
   Assert.equal(tab2.getAttribute("usercontextid"), 1);
@@ -68,17 +68,17 @@ add_task(async function() {
 
   await promiseRemoveTab(tab2);
 });
 
 // Opens "uri" in a new tab with the provided userContextId and focuses it.
 // Returns the newly opened tab.
 async function openTabInUserContext(userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab("http://example.com", { userContextId });
+  let tab = BrowserTestUtils.addTab(gBrowser, "http://example.com", { userContextId });
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return { tab, browser };
--- a/browser/components/sessionstore/test/browser_swapDocShells.js
+++ b/browser/components/sessionstore/test/browser_swapDocShells.js
@@ -1,12 +1,12 @@
 "use strict";
 
 add_task(async function() {
-  let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
   await promiseBrowserLoaded(gBrowser.selectedBrowser);
 
   let win = gBrowser.replaceTabWithWindow(tab);
   await promiseDelayedStartupFinished(win);
   await promiseBrowserHasURL(win.gBrowser.browsers[0], "about:mozilla");
 
   win.duplicateTabIn(win.gBrowser.selectedTab, "tab");
   await promiseTabRestored(win.gBrowser.tabs[1]);
--- a/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js
+++ b/browser/components/sessionstore/test/browser_unrestored_crashedTabs.js
@@ -21,17 +21,17 @@ add_task(async function test() {
     url: PAGE,
   }, async function(browser) {
     await TabStateFlusher.flush(browser);
 
     // We'll create a second "pending" tab. This is the one we'll
     // ensure doesn't go to about:tabcrashed. We start it non-remote
     // since this is how SessionStore creates all browsers before
     // they are restored.
-    let unrestoredTab = gBrowser.addTab("about:blank", {
+    let unrestoredTab = BrowserTestUtils.addTab(gBrowser, "about:blank", {
       skipAnimation: true,
       forceNotRemote: true,
     });
 
     let state = {
       entries: [{url: PAGE, triggeringPrincipal_base64}],
     };
 
--- a/browser/components/shell/test/browser_420786.js
+++ b/browser/components/shell/test/browser_420786.js
@@ -75,14 +75,14 @@ function test() {
     // will fail
     Cc["@mozilla.org/gsettings-service;1"].
       getService(Ci.nsIGSettingsService).
       getCollectionForSchema("org.gnome.desktop.background");
     todo(false, "This test doesn't work when GSettings is available");
     return;
   } catch (e) { }
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", onPageLoad, true);
   content.location = "about:logo";
 
   waitForExplicitFinish();
 }
--- a/browser/components/translation/test/browser_translation_bing.js
+++ b/browser/components/translation/test/browser_translation_bing.js
@@ -115,17 +115,17 @@ function constructFixtureURL(filename) {
 
 /**
  * A helper function to open a new tab and wait for its content to load.
  *
  * @param String url  A URL to be loaded in the new tab.
  */
 function promiseTestPageLoad(url) {
   return new Promise(resolve => {
-    let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+    let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
     let browser = gBrowser.selectedBrowser;
     browser.addEventListener("load", function listener() {
       if (browser.currentURI.spec == "about:blank")
         return;
       info("Page loaded: " + browser.currentURI.spec);
       browser.removeEventListener("load", listener, true);
       resolve(tab);
     }, true);
--- a/browser/components/translation/test/browser_translation_exceptions.js
+++ b/browser/components/translation/test/browser_translation_exceptions.js
@@ -11,17 +11,17 @@ var {Translation, Promise} = tmp;
 
 const kLanguagesPref = "browser.translation.neverForLanguages";
 const kShowUIPref = "browser.translation.ui.show";
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref(kShowUIPref, true);
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab;
   registerCleanupFunction(function() {
     gBrowser.removeTab(tab);
     Services.prefs.clearUserPref(kShowUIPref);
   });
   tab.linkedBrowser.addEventListener("load", function() {
     (async function() {
       for (let testCase of gTests) {
--- a/browser/components/translation/test/browser_translation_infobar.js
+++ b/browser/components/translation/test/browser_translation_infobar.js
@@ -70,17 +70,17 @@ function showTranslationUI(aDetectedLang
 function hasTranslationInfoBar() {
   return !!gBrowser.getNotificationBox().getNotificationWithValue("translation");
 }
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref(kShowUIPref, true);
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab;
   tab.linkedBrowser.addEventListener("load", function() {
     TranslationStub.browser = gBrowser.selectedBrowser;
     registerCleanupFunction(function() {
       gBrowser.removeTab(tab);
       Services.prefs.clearUserPref(kShowUIPref);
     });
     run_tests(() => {
--- a/browser/components/translation/test/browser_translation_yandex.js
+++ b/browser/components/translation/test/browser_translation_yandex.js
@@ -103,17 +103,17 @@ function constructFixtureURL(filename) {
 
 /**
  * A helper function to open a new tab and wait for its content to load.
  *
  * @param String url  A URL to be loaded in the new tab.
  */
 function promiseTestPageLoad(url) {
   return new Promise(resolve => {
-    let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+    let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
     let browser = gBrowser.selectedBrowser;
     browser.addEventListener("load", function listener() {
       if (browser.currentURI.spec == "about:blank")
         return;
       info("Page loaded: " + browser.currentURI.spec);
       browser.removeEventListener("load", listener, true);
       resolve(tab);
     }, true);
--- a/browser/components/uitour/test/browser_UITour_observe.js
+++ b/browser/components/uitour/test/browser_UITour_observe.js
@@ -51,17 +51,17 @@ var tests = [
       is(event, "test-event-background-1", "Correct event name");
       is(params, null, "No param object");
       gContentAPI.observe(null);
       gBrowser.removeCurrentTab();
       done();
     }
 
     gContentAPI.observe(listener, () => {
-      gBrowser.selectedTab = gBrowser.addTab("about:blank");
+      gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
       isnot(gBrowser.selectedTab, gTestTab, "Make sure the selected tab changed");
 
       UITour.notify("test-event-background-1");
     });
   },
   // Make sure the tab isn't torn down when switching back to the tour one.
   function test_background_then_foreground_tab(done) {
     let blankTab = null;
@@ -69,17 +69,17 @@ var tests = [
       is(event, "test-event-4", "Correct event name");
       is(params, null, "No param object");
       gContentAPI.observe(null);
       gBrowser.removeTab(blankTab);
       done();
     }
 
     gContentAPI.observe(listener, () => {
-      blankTab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+      blankTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
       isnot(gBrowser.selectedTab, gTestTab, "Make sure the selected tab changed");
       gBrowser.selectedTab = gTestTab;
       is(gBrowser.selectedTab, gTestTab, "Switch back to the test tab");
 
       UITour.notify("test-event-4");
     });
   },
 ];
--- a/browser/components/uitour/test/browser_UITour_registerPageID.js
+++ b/browser/components/uitour/test/browser_UITour_registerPageID.js
@@ -70,17 +70,17 @@ add_UITour_task(async function test_seen
   checkExpectedSeenPageIDs(["savedID1", "savedID2", "testpage1"]);
 
   const PREFIX = BrowserUITelemetry.BUCKET_PREFIX;
   const SEP = BrowserUITelemetry.BUCKET_SEPARATOR;
 
   let bucket = PREFIX + "UITour" + SEP + "testpage1";
   is(BrowserUITelemetry.currentBucket, bucket, "Bucket should have correct name");
 
-  gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   bucket = PREFIX + "UITour" + SEP + "testpage1" + SEP + "inactive" + SEP + "1m";
   is(BrowserUITelemetry.currentBucket, bucket,
      "After switching tabs, bucket should be expiring");
 
   gBrowser.removeTab(gBrowser.selectedTab);
   gBrowser.selectedTab = gTestTab;
   BrowserUITelemetry.setBucket(null);
 });
--- a/browser/components/uitour/test/head.js
+++ b/browser/components/uitour/test/head.js
@@ -246,17 +246,17 @@ function promisePageEvent() {
 
 function loadUITourTestPage(callback, host = "https://example.org/") {
   if (gTestTab)
     gBrowser.removeTab(gTestTab);
 
   let url = getRootDirectory(gTestPath) + "uitour.html";
   url = url.replace("chrome://mochitests/content/", host);
 
-  gTestTab = gBrowser.addTab(url);
+  gTestTab = BrowserTestUtils.addTab(gBrowser, url);
   gBrowser.selectedTab = gTestTab;
 
   gTestTab.linkedBrowser.addEventListener("load", function() {
     if (gMultiProcessBrowser) {
       // When e10s is enabled, make gContentAPI and gContentWindow proxies which has every property
       // return a function which calls the method of the same name on
       // contentWin.Mozilla.UITour/contentWin in a ContentTask.
       let contentWinHandler = {
--- a/browser/extensions/pdfjs/test/browser_pdfjs_savedialog.js
+++ b/browser/extensions/pdfjs/test/browser_pdfjs_savedialog.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const RELATIVE_DIR = "browser/extensions/pdfjs/test/";
 const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
 
 function test() {
   var oldAction = changeMimeHandler(Ci.nsIHandlerInfo.useSystemDefault, true);
-  var tab = gBrowser.addTab(TESTROOT + "file_pdfjs_test.pdf");
+  var tab = BrowserTestUtils.addTab(gBrowser, TESTROOT + "file_pdfjs_test.pdf");
   // Test: "Open with" dialog comes up when pdf.js is not selected as the default
   // handler.
   addWindowListener("chrome://mozapps/content/downloads/unknownContentType.xul", finish);
 
   waitForExplicitFinish();
   registerCleanupFunction(function() {
     changeMimeHandler(oldAction[0], oldAction[1]);
     gBrowser.removeTab(tab);
--- a/browser/modules/test/browser/browser_ContentSearch.js
+++ b/browser/modules/test/browser/browser_ContentSearch.js
@@ -137,17 +137,17 @@ add_task(async function searchInBackgrou
   let submissionURL =
     engine.getSubmission(data.searchString, "", data.whence).uri.spec;
   gMsgMan.sendAsyncMessage(TEST_MSG, {
     type: "Search",
     data,
     expectedURL: submissionURL,
   });
 
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   registerCleanupFunction(() => gBrowser.removeTab(newTab));
 
   let msg = await waitForTestMsg("loadStopped");
   Assert.equal(msg.data.url, submissionURL, "Correct search page loaded");
 });
 
 add_task(async function badImage() {
@@ -342,17 +342,17 @@ function waitForNewEngine(basename, numI
     },
   });
 
   return Promise.all([addDeferred.promise].concat(eventPromises));
 }
 
 function addTab() {
   return new Promise(resolve => {
-    let tab = gBrowser.addTab();
+    let tab = BrowserTestUtils.addTab(gBrowser);
     gBrowser.selectedTab = tab;
     tab.linkedBrowser.addEventListener("load", function() {
       let url = getRootDirectory(gTestPath) + TEST_CONTENT_SCRIPT_BASENAME;
       gMsgMan = tab.linkedBrowser.messageManager;
       gMsgMan.sendAsyncMessage(CONTENT_SEARCH_MSG, {
         type: "AddToWhitelist",
         data: ["about:blank"],
       });
--- a/browser/modules/test/browser/browser_taskbar_preview.js
+++ b/browser/modules/test/browser/browser_taskbar_preview.js
@@ -20,19 +20,19 @@ function test() {
   waitForExplicitFinish();
 
   gPrefService.setBoolPref(ENABLE_PREF_NAME, true);
 
   is(1, AeroPeek.windows.length, "Got the expected number of windows");
 
   checkPreviews(1, "Browser starts with one preview");
 
-  gBrowser.addTab();
-  gBrowser.addTab();
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
+  BrowserTestUtils.addTab(gBrowser);
 
   checkPreviews(4, "Correct number of previews after adding");
 
   for (let preview of AeroPeek.previews)
     ok(preview.visible, "Preview is shown as expected");
 
   gPrefService.setBoolPref(ENABLE_PREF_NAME, false);
   is(0, AeroPeek.previews.length, "Should have 0 previews when disabled");
@@ -61,17 +61,17 @@ function test() {
   gBrowser.removeTab(gBrowser.tabContainer.lastChild);
   checkPreviews(2, "Expected number of previews after closing unselected via browser");
 
   // Remove #1 (active)
   gBrowser.removeTab(gBrowser.tabContainer.firstChild);
   checkPreviews(1, "Expected number of previews after closing selected tab via browser");
 
   // Add a new tab
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
   checkPreviews(2);
   // Check default selection
   checkSelectedTab();
 
   // Change selection
   gBrowser.selectedTab = gBrowser.tabs[0];
   checkSelectedTab();
   // Close nonselected tab via controller
--- a/devtools/client/commandline/test/helpers.js
+++ b/devtools/client/commandline/test/helpers.js
@@ -99,17 +99,17 @@ var { helpers, assert } = (function () {
  * Open a new tab at a URL and call a callback on load, and then tidy up when
  * the callback finishes.
  * The function will be passed a set of test options, and will usually return a
  * promise to indicate that the tab can be cleared up. (To be formal, we call
  * Promise.resolve() on the return value of the callback function)
  *
  * The options used by addTab include:
  * - chromeWindow: XUL window parent of created tab. a.k.a 'window' in mochitest
- * - tab: The new XUL tab element, as returned by gBrowser.addTab()
+ * - tab: The new XUL tab element, as returned by BrowserTestUtils.addTab(gBrowser)
  * - target: The debug target as defined by the devtools framework
  * - browser: The XUL browser element for the given tab
  * - isFirefox: Always true. Allows test sharing with GCLI
  *
  * Normally addTab will create an options object containing the values as
  * described above. However these options can be customized by the third
  * 'options' parameter. This has the ability to customize the value of
  * chromeWindow or isFirefox, and to add new properties.
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-chrome-debugging.js
@@ -72,17 +72,17 @@ add_task(function* () {
   gClient = initDebuggerClient();
 
   const [type] = yield gClient.connect();
   is(type, "browser", "Root actor should identify itself as a browser.");
 
   const response = yield gClient.getProcess();
   let actor = response.form.actor;
   gThreadClient = yield attachThread(gClient, actor);
-  gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
 
   // listen for a new source and global
   gThreadClient.addListener("newSource", onNewSource);
   gClient.addListener("newGlobal", onNewGlobal);
   yield promise.all([ gNewGlobal.promise, gNewChromeSource.promise ]);
 
   yield resumeAndCloseConnection();
 });
--- a/devtools/client/debugger/test/mochitest/browser_dbg_chrome-debugging.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_chrome-debugging.js
@@ -56,17 +56,17 @@ function testChromeActor() {
         if (aResponse.error) {
           ok(false, "Couldn't attach to the chrome debugger.");
           gAttached.reject();
         } else {
           ok(true, "Attached to the chrome debugger.");
           gAttached.resolve();
 
           // Ensure that a new chrome global will be created.
-          gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
+          gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
         }
       });
     });
   });
 }
 
 function onNewGlobal() {
   ok(true, "Received a new chrome global.");
--- a/devtools/client/framework/test/browser.ini
+++ b/devtools/client/framework/test/browser.ini
@@ -92,11 +92,11 @@ skip-if = e10s # Bug 1069044 - destroyIn
 [browser_toolbox_window_shortcuts.js]
 skip-if = os == "mac" && os_version == "10.8" || os == "win" && os_version == "5.1" # Bug 851129 - Re-enable browser_toolbox_window_shortcuts.js test after leaks are fixed
 [browser_toolbox_window_title_changes.js]
 [browser_toolbox_window_title_frame_select.js]
 [browser_toolbox_zoom.js]
 [browser_two_tabs.js]
 # We want these tests to run for mochitest-dt as well, so we include them here:
 [../../../../browser/base/content/test/static/browser_parsable_css.js]
-skip-if = debug || asan # no point in running on both opt and debug, and will likely intermittently timeout on debug
+skip-if = debug || asan || (os == 'linux' && bits == 32) # no point in running on both opt and debug, and will likely intermittently timeout on debug
 [../../../../browser/base/content/test/static/browser_all_files_referenced.js]
-skip-if = debug || asan # no point in running on both opt and debug, and will likely intermittently timeout on debug
+skip-if = debug || asan || (os == 'linux' && bits == 32) # no point in running on both opt and debug, and will likely intermittently timeout on debug
--- a/devtools/client/framework/test/browser_target_events.js
+++ b/devtools/client/framework/test/browser_target_events.js
@@ -4,27 +4,27 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 var target;
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(onLoad);
 }
 
 function onLoad() {
   target = TargetFactory.forTab(gBrowser.selectedTab);
 
   is(target.tab, gBrowser.selectedTab, "Target linked to the right tab.");
 
   target.once("hidden", onHidden);
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 }
 
 function onHidden() {
   ok(true, "Hidden event received");
   target.once("visible", onVisible);
   gBrowser.removeCurrentTab();
 }
 
--- a/devtools/client/framework/test/browser_toolbox_raise.js
+++ b/devtools/client/framework/test/browser_toolbox_raise.js
@@ -6,17 +6,17 @@
 const TEST_URL = "data:text/html,test for opening toolbox in different hosts";
 
 var {Toolbox} = require("devtools/client/framework/toolbox");
 
 var toolbox, tab1, tab2;
 
 function test() {
   addTab(TEST_URL).then(tab => {
-    tab2 = gBrowser.addTab();
+    tab2 = BrowserTestUtils.addTab(gBrowser);
     let target = TargetFactory.forTab(tab);
     gDevTools.showToolbox(target)
              .then(testBottomHost, console.error)
              .then(null, console.error);
   });
 }
 
 function testBottomHost(aToolbox) {
--- a/devtools/client/framework/test/shared-head.js
+++ b/devtools/client/framework/test/shared-head.js
@@ -117,17 +117,17 @@ registerCleanupFunction(function* cleanu
  */
 var addTab = Task.async(function* (url, options = { background: false, window: window }) {
   info("Adding a new tab with URL: " + url);
 
   let { background } = options;
   let { gBrowser } = options.window ? options.window : window;
   let { userContextId } = options;
 
-  let tab = gBrowser.addTab(url,
+  let tab = BrowserTestUtils.addTab(gBrowser, url,
     {userContextId, preferredRemoteType: options.preferredRemoteType});
   if (!background) {
     gBrowser.selectedTab = tab;
   }
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("Tab added and finished loading");
 
--- a/devtools/client/inspector/test/browser_inspector_open_on_neterror.js
+++ b/devtools/client/inspector/test/browser_inspector_open_on_neterror.js
@@ -6,17 +6,18 @@
 // Test that inspector works correctly when opened against a net error page
 
 const TEST_URL_1 = "http://127.0.0.1:36325/";
 const TEST_URL_2 = "data:text/html,<html><body>test-doc-2</body></html>";
 
 add_task(function* () {
   // Unfortunately, net error page are not firing load event, so that we can't
   // use addTab helper and have to do that:
-  let tab = gBrowser.selectedTab = gBrowser.addTab("data:text/html,empty");
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser,
+                                                           "data:text/html,empty");
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   yield ContentTask.spawn(tab.linkedBrowser, { url: TEST_URL_1 }, function* ({ url }) {
     // Also, the neterror being privileged, the DOMContentLoaded only fires on
     // the chromeEventHandler.
     let { chromeEventHandler } = docShell; // eslint-disable-line no-undef
     let onDOMContentLoaded = ContentTaskUtils.waitForEvent(chromeEventHandler,
       "DOMContentLoaded", true);
     content.location = url;
--- a/devtools/client/projecteditor/test/head.js
+++ b/devtools/client/projecteditor/test/head.js
@@ -52,17 +52,17 @@ registerCleanupFunction(() => {
  * Add a new test tab in the browser and load the given url.
  * @param {String} url The url to be loaded in the new tab
  * @return a promise that resolves to the tab object when the url is loaded
  */
 function addTab(url) {
   info("Adding a new tab with URL: '" + url + "'");
   let def = promise.defer();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(function () {
     info("URL '" + url + "' loading complete");
     waitForFocus(() => {
       def.resolve(tab);
     }, content);
   });
 
   return def.promise;
--- a/devtools/client/responsivedesign/test/head.js
+++ b/devtools/client/responsivedesign/test/head.js
@@ -190,17 +190,17 @@ function openRuleView() {
  * @param {String} url The url to be loaded in the new tab
  * @return a promise that resolves to the tab object when the url is loaded
  */
 var addTab = Task.async(function* (url) {
   info("Adding a new tab with URL: '" + url + "'");
 
   window.focus();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
   let browser = tab.linkedBrowser;
 
   yield BrowserTestUtils.browserLoaded(browser);
   info("URL '" + url + "' loading complete");
 
   return tab;
 });
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_browser_last_window_closing.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_browser_last_window_closing.js
@@ -8,17 +8,17 @@ const BUTTON_POSITION_DONT_SAVE = 2;
 
 function test()
 {
   waitForExplicitFinish();
 
   // Observer must be attached *before* Scratchpad is opened.
   CloseObserver.init();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,<p>test browser last window closing</p>";
 }
 
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_chrome_context_pref.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_chrome_context_pref.js
@@ -6,17 +6,17 @@
 var DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
 
 function test()
 {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,Scratchpad test for bug 646070 - chrome context preference";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_confirm_close.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_confirm_close.js
@@ -36,17 +36,17 @@ function test()
     confirmEx: function () {
       return promptButton;
     }
   };
 
   testNew();
   testSavedFile();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   content.location = "data:text/html,<p>test scratchpad save file prompt on closing";
 }
 
 function testNew()
 {
   openScratchpad(function (win) {
     win.Scratchpad.close(function () {
       ok(win.closed, "new scratchpad window should close without prompting");
--- a/devtools/client/scratchpad/test/browser_scratchpad_contexts.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_contexts.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,test context switch in Scratchpad";
 }
 
 function runTests() {
--- a/devtools/client/scratchpad/test/browser_scratchpad_display_non_error_exceptions.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_display_non_error_exceptions.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Bug 756681 */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests, {"state":{"text":""}});
   }, {capture: true, once: true});
 
   content.location = "data:text/html, test that exceptions are output as " +
       "comments correctly in Scratchpad";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_display_outputs_errors.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_display_outputs_errors.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Bug 690552 */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests, {"state":{"text":""}});
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test that exceptions are output as " +
       "comments for 'display' and not sent to the console in Scratchpad";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_edit_ui_updates.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_edit_ui_updates.js
@@ -6,17 +6,17 @@
 "use strict";
 
 var WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
 var DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
 
 function test()
 {
   waitForExplicitFinish();
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, false);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,test Edit menu updates Scratchpad - bug 699130";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_eval_func.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_eval_func.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,test Scratchpad eval function.";
 }
 
 function reportErrorAndQuit(error) {
--- a/devtools/client/scratchpad/test/browser_scratchpad_execute_print.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_execute_print.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test run() and display() in Scratchpad";
 }
 
 function runTests() {
--- a/devtools/client/scratchpad/test/browser_scratchpad_falsy.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_falsy.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Bug 679467 */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(testFalsy);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test falsy display() values in Scratchpad";
 }
 
 function testFalsy()
--- a/devtools/client/scratchpad/test/browser_scratchpad_files.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_files.js
@@ -10,17 +10,17 @@ var gFile;
 
 // The temporary file content.
 var gFileContent = "hello.world('bug636725');";
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test file open and save in Scratchpad";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_goto_line_ui.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_goto_line_ui.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Bug 714942 */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test the 'Jump to line' feature in Scratchpad";
 }
 
 function runTests(aWindow, aScratchpad)
--- a/devtools/client/scratchpad/test/browser_scratchpad_help_key.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_help_key.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Bug 650760 */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   content.location = "data:text/html,Test keybindings for opening Scratchpad MDN Documentation, bug 650760";
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTest);
   }, {capture: true, once: true});
 }
 
 function runTest()
 {
--- a/devtools/client/scratchpad/test/browser_scratchpad_initialization.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_initialization.js
@@ -4,17 +4,17 @@
 
 var DEVTOOLS_CHROME_ENABLED = "devtools.chrome.enabled";
 
 function test()
 {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, false);
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,initialization test for Scratchpad";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_inspect.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_inspect.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,<p>test inspect() in Scratchpad</p>";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_long_string.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_long_string.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,<p>test long string in Scratchpad</p>";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_modeline.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_modeline.js
@@ -9,17 +9,17 @@ var DEVTOOLS_CHROME_ENABLED = "devtools.
 
 // The temporary file content.
 var gFileContent = "function main() { return 0; }";
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, false);
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test file open and save in Scratchpad";
 }
 
 function runTests() {
--- a/devtools/client/scratchpad/test/browser_scratchpad_open_error_console.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_open_error_console.js
@@ -3,17 +3,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const HUDService = require("devtools/client/webconsole/hudservice");
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,test Scratchpad." +
                      "openErrorConsole()";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_pprint-02.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_pprint-02.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
 }
 
 var gTabsize;
--- a/devtools/client/scratchpad/test/browser_scratchpad_pprint.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_pprint.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
 }
 
 function runTests(sw)
--- a/devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js
@@ -4,17 +4,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,"
     + "test Scratchpad pretty print error goto line.";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_recent_files.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_recent_files.js
@@ -330,17 +330,17 @@ function test()
   });
 
   Services.prefs.setIntPref("devtools.scratchpad.recentFilesMax", 3);
 
   // Initiate the preference observer after we have set the temporary recent
   // files max for this test.
   PreferenceObserver.init();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(startTest);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test recent files in Scratchpad";
 }
 
 function finishTest()
--- a/devtools/client/scratchpad/test/browser_scratchpad_reload_and_run.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_reload_and_run.js
@@ -11,17 +11,17 @@ var EDITOR_TEXT = [
 ].join("\n");
 
 function test()
 {
   requestLongerTimeout(2);
   waitForExplicitFinish();
   Services.prefs.setBoolPref(DEVTOOLS_CHROME_ENABLED, true);
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,Scratchpad test for bug 740948";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_remember_view_options.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_remember_view_options.js
@@ -7,17 +7,17 @@
 function test()
 {
   waitForExplicitFinish();
 
   // To test for this bug we open a Scratchpad window and change all
   // view menu options. After each change we compare the correspondent
   // preference value with the expected value.
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<title>Bug 1140839</title>" +
     "<p>test Scratchpad should remember View options";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_reset_undo.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_reset_undo.js
@@ -19,17 +19,17 @@ var gFileBContent = "// File B ** Goodby
 
 // Help track if one or both files are saved
 var gFirstFileSaved = false;
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test that undo get's reset after file load in Scratchpad";
 }
 
 function runTests()
--- a/devtools/client/scratchpad/test/browser_scratchpad_revert_to_saved.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_revert_to_saved.js
@@ -118,16 +118,16 @@ function tempFileSaved(aStatus)
   gScratchpad.importFromFile(gFile.QueryInterface(Ci.nsILocalFile), true,
                              testAfterSaved);
 }
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(startTest);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<p>test reverting to last saved state of" +
                      " a file </p>";
 }
--- a/devtools/client/scratchpad/test/browser_scratchpad_run_error_goto_line.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_run_error_goto_line.js
@@ -4,17 +4,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,test Scratchpad pretty print.";
 }
 
 function runTests(sw)
--- a/devtools/client/scratchpad/test/browser_scratchpad_tab.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_tab.js
@@ -3,17 +3,17 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* Bug 660560 */
 
 "use strict";
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     Services.prefs.setIntPref("devtools.editor.tabsize", 5);
 
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,Scratchpad test for the Tab key, bug 660560";
 }
--- a/devtools/client/scratchpad/test/browser_scratchpad_tab_switch.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_tab_switch.js
@@ -5,20 +5,20 @@
 var tab1;
 var tab2;
 var sp;
 
 function test()
 {
   waitForExplicitFinish();
 
-  tab1 = gBrowser.addTab();
+  tab1 = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab1;
   gBrowser.selectedBrowser.addEventListener("load", function () {
-    tab2 = gBrowser.addTab();
+    tab2 = BrowserTestUtils.addTab(gBrowser);
     gBrowser.selectedTab = tab2;
     gBrowser.selectedBrowser.addEventListener("load", function () {
       openScratchpad(runTests);
     }, {capture: true, once: true});
     content.location = "data:text/html,test context switch in Scratchpad tab 2";
   }, {capture: true, once: true});
 
   content.location = "data:text/html,test context switch in Scratchpad tab 1";
--- a/devtools/client/scratchpad/test/browser_scratchpad_throw_output.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_throw_output.js
@@ -2,17 +2,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(testThrowOutput);
   }, {capture: true, once: true});
 
   content.location = "data:text/html;charset=utf8,<p>Test throw outputs in Scratchpad</p>";
 }
 
 function testThrowOutput()
--- a/devtools/client/scratchpad/test/browser_scratchpad_ui.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_ui.js
@@ -1,17 +1,17 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test()
 {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(runTests);
   }, {capture: true, once: true});
 
   content.location = "data:text/html,<title>foobarBug636725</title>" +
     "<p>test inspect() in Scratchpad";
 }
 
--- a/devtools/client/scratchpad/test/browser_scratchpad_unsaved.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_unsaved.js
@@ -18,17 +18,17 @@ function test()
 {
   waitForExplicitFinish();
 
   testListeners();
   testRestoreNotFromFile();
   testRestoreFromFileSaved();
   testRestoreFromFileUnsaved();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   content.location = "data:text/html,<p>test star* UI for unsaved file changes";
 }
 
 function testListeners()
 {
   openScratchpad(function (aWin, aScratchpad) {
     aScratchpad.setText("new text");
     ok(isStar(aWin), "show star if scratchpad text changes");
--- a/devtools/client/scratchpad/test/browser_scratchpad_wrong_window_focus.js
+++ b/devtools/client/scratchpad/test/browser_scratchpad_wrong_window_focus.js
@@ -20,17 +20,17 @@ function test()
   // Then we open a web console and execute a console.log statement
   // from the first Scratch window (that's why we needed to save its
   // reference).
   //
   // Then we wait for our message to appear in the console and click
   // on the location link. After that we check which Scratchpad window
   // is currently active (it should be the older one).
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     openScratchpad(function () {
       let sw = gScratchpadWindow;
       let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
       let {TargetFactory} = require("devtools/client/framework/target");
 
       openScratchpad(function () {
         let target = TargetFactory.forTab(gBrowser.selectedTab);
--- a/devtools/client/scratchpad/test/head.js
+++ b/devtools/client/scratchpad/test/head.js
@@ -84,17 +84,17 @@ function openScratchpad(aReadyCallback, 
  *        - tabContent
  *          A string providing the html content of the tab.
  * @return Promise
  */
 function openTabAndScratchpad(aOptions = {})
 {
   waitForExplicitFinish();
   return new promise(resolve => {
-    gBrowser.selectedTab = gBrowser.addTab();
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
     let {selectedBrowser} = gBrowser;
     selectedBrowser.addEventListener("load", function () {
       openScratchpad((win, sp) => resolve([win, sp]), aOptions);
     }, {capture: true, once: true});
     content.location = "data:text/html;charset=utf8," + (aOptions.tabContent || "");
   });
 }
 
--- a/devtools/client/sourceeditor/test/browser_css_getInfo.js
+++ b/devtools/client/sourceeditor/test/browser_css_getInfo.js
@@ -121,17 +121,17 @@ const TEST_URI = "data:text/html;charset
    "  </div>",
    " </body>",
    " </html>"
   ].join("\n"));
 
 let doc = null;
 function test() {
   waitForExplicitFinish();
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
     /* eslint-disable mozilla/no-cpows-in-tests */
     doc = content.document;
     /* eslint-enable mozilla/no-cpows-in-tests */
     runTests();
   });
   gBrowser.loadURI(TEST_URI);
 }
--- a/devtools/client/sourceeditor/test/browser_css_statemachine.js
+++ b/devtools/client/sourceeditor/test/browser_css_statemachine.js
@@ -52,17 +52,17 @@ const TEST_URI = "data:text/html;charset
    "  </div>",
    " </body>",
    " </html>"
   ].join("\n"));
 
 var doc = null;
 function test() {
   waitForExplicitFinish();
-  gBrowser.selectedTab = gBrowser.addTab(TEST_URI);
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
     /* eslint-disable mozilla/no-cpows-in-tests */
     doc = content.document;
     /* eslint-enable mozilla/no-cpows-in-tests */
     runTests();
   });
 }
 
--- a/devtools/client/styleeditor/test/browser_styleeditor_loading_with_containers.js
+++ b/devtools/client/styleeditor/test/browser_styleeditor_loading_with_containers.js
@@ -30,17 +30,17 @@ add_task(function* () {
 
   is(ui.editors.length, 2, "The UI contains two style sheets.");
   checkSheet(ui.editors[0], EXPECTED_SHEETS[0]);
   checkSheet(ui.editors[1], EXPECTED_SHEETS[1]);
 });
 
 function* openTabInUserContext(uri, userContextId) {
   // Open the tab in the correct userContextId.
-  let tab = gBrowser.addTab(uri, {userContextId});
+  let tab = BrowserTestUtils.addTab(gBrowser, uri, {userContextId});
 
   // Select tab and make sure its browser is focused.
   gBrowser.selectedTab = tab;
   tab.ownerDocument.defaultView.focus();
 
   let browser = gBrowser.getBrowserForTab(tab);
   yield BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/devtools/client/webconsole/test/browser_console_private_browsing.js
+++ b/devtools/client/webconsole/test/browser_console_private_browsing.js
@@ -19,18 +19,18 @@ function test() {
 
   // This test is slightly more involved: it opens the web console twice,
   // a new private window once, and the browser console twice. We can get
   // a timeout with debug builds on slower machines.
   requestLongerTimeout(2);
   start();
 
   function start() {
-    gBrowser.selectedTab = gBrowser.addTab("data:text/html;charset=utf8," +
-                                           "<p>hello world! I am not private!");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "data:text/html;charset=utf8," +
+                                                   "<p>hello world! I am not private!");
     gBrowser.selectedBrowser.addEventListener("load", onLoadTab, true);
   }
 
   function onLoadTab() {
     gBrowser.selectedBrowser.removeEventListener("load", onLoadTab, true);
     info("onLoadTab()");
 
     // Make sure we have a clean state to start with.
--- a/devtools/client/webconsole/test/browser_webconsole_bug_653531_highlighter_console_helper.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_653531_highlighter_console_helper.js
@@ -93,16 +93,16 @@ function performWebConsoleTests(hud) {
     gBrowser.removeCurrentTab();
     finishTest();
   }
 }
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedBrowser.addEventListener("load", function () {
     waitForFocus(createDocument, content);
   }, {capture: true, once: true});
 
   BrowserTestUtils.loadURI(gBrowser.selectedBrowser,
     "data:text/html;charset=utf-8,test for highlighter helper in web console");
 }
--- a/devtools/server/tests/browser/head.js
+++ b/devtools/server/tests/browser/head.js
@@ -36,17 +36,17 @@ waitForExplicitFinish();
  * @param {String} url The url to be loaded in the new tab
  * @return a promise that resolves to the new browser that the document
  *         is loaded in. Note that we cannot return the document
  *         directly, since this would be a CPOW in the e10s case,
  *         and Promises cannot be resolved with CPOWs (see bug 1233497).
  */
 var addTab = Task.async(function* (url) {
   info(`Adding a new tab with URL: ${url}`);
-  let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, url);
   yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info(`Tab added and URL ${url} loaded`);
 
   return tab.linkedBrowser;
 });
 
 function* initAnimationsFrontForUrl(url) {
--- a/devtools/shared/webconsole/test/test_console_serviceworker_cached.html
+++ b/devtools/shared/webconsole/test/test_console_serviceworker_cached.html
@@ -98,17 +98,19 @@ SimpleTest.registerCleanupFunction(() =>
   while (gBrowser.tabs.length > 1) {
     gBrowser.removeCurrentTab();
   }
 });
 
 function addTab(url) {
   info("Adding a new tab with URL: '" + url + "'");
   return new Promise(resolve => {
-    let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+    let tab = gBrowser.selectedTab = gBrowser.addTab(url, {
+      triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+    });
     gBrowser.selectedBrowser.addEventListener("load", function () {
       info("URL '" + url + "' loading complete");
       resolve(tab);
     }, {capture: true, once: true});
   });
 }
 
 </script>
--- a/docshell/test/browser/browser.ini
+++ b/docshell/test/browser/browser.ini
@@ -80,16 +80,17 @@ support-files =
 [browser_uriFixupIntegration.js]
 [browser_uriFixupAlternateRedirects.js]
 support-files =
   redirect_to_example.sjs
 [browser_loadDisallowInherit.js]
 [browser_loadURI.js]
 [browser_multiple_pushState.js]
 [browser_onbeforeunload_navigation.js]
+skip-if = os == 'win' && !debug # bug 1300351
 [browser_search_notification.js]
 [browser_tab_touch_events.js]
 [browser_timelineMarkers-01.js]
 [browser_timelineMarkers-02.js]
 skip-if = true # Bug 1220415
 [browser_timelineMarkers-03.js]
 [browser_timelineMarkers-04.js]
 [browser_timelineMarkers-05.js]
--- a/docshell/test/browser/browser_bug134911.js
+++ b/docshell/test/browser/browser_bug134911.js
@@ -5,17 +5,17 @@ const TEXT = {
   enteredText1: "The quick brown fox jumps over the lazy dog",
   enteredText2: "\u03BE\u03B5\u03C3\u03BA\u03B5\u03C0\u03AC\u03B6\u03C9\u0020\u03C4\u1F74\u03BD\u0020\u03C8\u03C5\u03C7\u03BF\u03C6\u03B8\u03CC\u03C1\u03B1\u0020\u03B2\u03B4\u03B5\u03BB\u03C5\u03B3\u03BC\u03AF\u03B1",
 };
 
 function test() {
   waitForExplicitFinish();
 
   var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
-  gBrowser.selectedTab = gBrowser.addTab(rootDir + "test-form_sjis.html");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, rootDir + "test-form_sjis.html");
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterOpen);
 }
 
 function afterOpen() {
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterChangeCharset);
 
   ContentTask.spawn(gBrowser.selectedBrowser, TEXT, function(TEXT) {
     content.document.getElementById("testtextarea").value = TEXT.enteredText1;
--- a/docshell/test/browser/browser_bug420605.js
+++ b/docshell/test/browser/browser_bug420605.js
@@ -110,13 +110,13 @@ function test() {
 
     // Make sure neither of the test pages haven't been loaded before.
     var info = getNavHistoryEntry(makeURI(pageurl));
     ok(!info, "The test page must not have been visited already.");
     info = getNavHistoryEntry(makeURI(fragmenturl));
     ok(!info, "The fragment test page must not have been visited already.");
 
     // Now open the test page in a new tab.
-    gBrowser.selectedTab = gBrowser.addTab();
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
     gBrowser.selectedBrowser.addEventListener(
         "DOMContentLoaded", onPageLoad, true);
     content.location = pageurl;
 }
--- a/docshell/test/browser/browser_bug441169.js
+++ b/docshell/test/browser/browser_bug441169.js
@@ -21,17 +21,17 @@ function task() {
   content.location = chromeURL;
 
   return promise;
 }
 
 function test() {
   waitForExplicitFinish();
 
-  var newTab = gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   newBrowser = gBrowser.getBrowserForTab(newTab);
 
   ContentTask.spawn(newBrowser, null, task).then(() => {
     gBrowser.removeCurrentTab();
     finish();
   });
 }
--- a/docshell/test/browser/browser_bug655270.js
+++ b/docshell/test/browser/browser_bug655270.js
@@ -12,17 +12,17 @@ function test() {
   const testDir = "http://mochi.test:8888/browser/docshell/test/browser/";
   const origURL = testDir + "file_bug655270.html";
   const newURL  = origURL + '?new_page';
 
   const faviconURL = testDir + "favicon_bug655270.ico";
 
   waitForExplicitFinish();
 
-  let tab = gBrowser.addTab(origURL);
+  let tab = BrowserTestUtils.addTab(gBrowser, origURL);
 
   // The page at origURL has a <link rel='icon'>, so we should get a call into
   // our observer below when it loads.  Once we verify that we have the right
   // favicon URI, we call pushState, which should trigger another onPageChange
   // event, this time for the URI after pushState.
 
   let observer = {
     onPageChanged: function(aURI, aWhat, aValue) {
--- a/docshell/test/browser/browser_bug673467.js
+++ b/docshell/test/browser/browser_bug673467.js
@@ -14,17 +14,17 @@ var doc = "data:text/html,<html><body on
  "    iframe.src = 'data:text/html,Hello!';" +
  "  }" +
  "</script>" +
  "</body></html>"
 
 function test() {
   waitForExplicitFinish();
 
-  let tab = gBrowser.addTab(doc);
+  let tab = BrowserTestUtils.addTab(gBrowser, doc);
   let tabBrowser = tab.linkedBrowser;
 
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     return ContentTask.spawn(tab.linkedBrowser, null, () => {
       return new Promise(resolve => {
         // The main page has loaded.  Now wait for the iframe to load.
         let iframe = content.document.getElementById('iframe');
         iframe.addEventListener('load', function listener(aEvent) {
--- a/docshell/test/browser/browser_bug852909.js
+++ b/docshell/test/browser/browser_bug852909.js
@@ -1,22 +1,22 @@
 var rootDir = "http://mochi.test:8888/browser/docshell/test/browser/";
 
 function test() {
   waitForExplicitFinish();
 
-  gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug852909.png");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, rootDir + "file_bug852909.png");
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(image);
 }
 
 function image(event) {
   ok(!gBrowser.selectedTab.mayEnableCharacterEncodingMenu, "Docshell should say the menu should be disabled for images.");
 
   gBrowser.removeCurrentTab();
-  gBrowser.selectedTab = gBrowser.addTab(rootDir + "file_bug852909.pdf");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, rootDir + "file_bug852909.pdf");
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(pdf);
 }
 
 function pdf(event) {
   ok(!gBrowser.selectedTab.mayEnableCharacterEncodingMenu, "Docshell should say the menu should be disabled for PDF.js.");
 
   gBrowser.removeCurrentTab();
   finish();
--- a/docshell/test/browser/browser_bug92473.js
+++ b/docshell/test/browser/browser_bug92473.js
@@ -44,11 +44,11 @@ function test() {
   // are always UTF-8 (bug 617339) and we are testing decoding from other
   // charsets.
   var jar = getJar(getRootDirectory(gTestPath));
   var dir = jar ?
               extractJarToTmp(jar) :
               getChromeDir(getResolvedURI(gTestPath));
   var rootDir = Services.io.newFileURI(dir).spec;
 
-  gBrowser.selectedTab = gBrowser.addTab(rootDir + "test-form_sjis.html");
+  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, rootDir + "test-form_sjis.html");
   BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(afterOpen);
 }
--- a/docshell/test/browser/browser_loadDisallowInherit.js
+++ b/docshell/test/browser/browser_loadDisallowInherit.js
@@ -1,15 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(function () {
     gBrowser.removeTab(tab);
   });
 
   let browser = gBrowser.getBrowserForTab(tab);
 
   function loadURL(url, flags, func) {
     browser.addEventListener("load", function loadListener(e) {
--- a/docshell/test/browser/browser_loadURI.js
+++ b/docshell/test/browser/browser_loadURI.js
@@ -4,17 +4,17 @@
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 
 const gPostData = "postdata=true";
 
 function test() {
   waitForExplicitFinish();
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(function () {
     gBrowser.removeTab(tab);
   });
 
   var dataStream = Cc["@mozilla.org/io/string-input-stream;1"].
                    createInstance(Ci.nsIStringInputStream);
   dataStream.data = gPostData;
 
--- a/docshell/test/browser/browser_onbeforeunload_navigation.js
+++ b/docshell/test/browser/browser_onbeforeunload_navigation.js
@@ -150,17 +150,17 @@ function runCurrentTest() {
 }
 
 var onAfterPageLoad = runNextTest;
 
 function test() {
   waitForExplicitFinish();
   gBrowser.addProgressListener(tabStateListener);
 
-  testTab = gBrowser.selectedTab = gBrowser.addTab();
+  testTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   testTab.linkedBrowser.addEventListener("load", onTabLoaded, true);
   testTab.linkedBrowser.loadURI(TEST_PAGE);
 }
 
 registerCleanupFunction(function() {
   // Remove the handler, or closing this tab will prove tricky:
   if (contentWindow) {
     try {
--- a/docshell/test/browser/browser_search_notification.js
+++ b/docshell/test/browser/browser_search_notification.js
@@ -20,17 +20,17 @@ function test() {
       Services.search.defaultEngine = oldDefaultEngine;
     }
     let engine = Services.search.getEngineByName(kSearchEngineID);
     if (engine) {
       Services.search.removeEngine(engine);
     }
   });
 
-  let tab = gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab;
 
   function observer(subject, topic, data) {
     Services.obs.removeObserver(observer, "keyword-search");
     is(topic, "keyword-search", "Got keyword-search notification");
 
     let engine = Services.search.defaultEngine;
     ok(engine, "Have default search engine.");
--- a/docshell/test/browser/browser_uriFixupIntegration.js
+++ b/docshell/test/browser/browser_uriFixupIntegration.js
@@ -25,17 +25,17 @@ add_task(function* setup() {
       Services.search.removeEngine(engine);
     }
   });
 });
 
 add_task(function* test() {
   for (let searchParams of ["foo bar", "brokenprotocol:somethingelse"]) {
     // Add a new blank tab.
-    gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
     // Enter search terms and start a search.
     gURLBar.value = searchParams;
     gURLBar.focus();
     EventUtils.synthesizeKey("VK_RETURN", {});
     yield BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
 
--- a/docshell/test/navigation/browser_bug343515.js
+++ b/docshell/test/navigation/browser_bug343515.js
@@ -47,17 +47,17 @@ function step1() {
   // Get a handle on the initial tab
   ctx.tab0 = gBrowser.selectedTab;
   ctx.tab0Browser = gBrowser.getBrowserForTab(ctx.tab0);
 
   // Our current tab should be active
   ok(ctx.tab0Browser.docShellIsActive, "Tab 0 should be active at test start");
 
   // Open a New Tab
-  ctx.tab1 = gBrowser.addTab(testPath + "bug343515_pg1.html");
+  ctx.tab1 = BrowserTestUtils.addTab(gBrowser, testPath + "bug343515_pg1.html");
   ctx.tab1Browser = gBrowser.getBrowserForTab(ctx.tab1);
   oneShotListener(ctx.tab1Browser, "load", step2);
 }
 
 function step2() {
   is(testPath + "bug343515_pg1.html", ctx.tab1Browser.currentURI.spec,
      "Got expected tab 1 url in step 2");
 
@@ -67,17 +67,17 @@ function step2() {
 
   // Switch to tab 1
   BrowserTestUtils.switchTab(gBrowser, ctx.tab1).then(() => {
     // Tab 1 should now be active
     ok(!ctx.tab0Browser.docShellIsActive, "Tab 0 should be inactive");
     ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active");
 
     // Open another tab
-    ctx.tab2 = gBrowser.addTab(testPath + "bug343515_pg2.html");
+    ctx.tab2 = BrowserTestUtils.addTab(gBrowser, testPath + "bug343515_pg2.html");
     ctx.tab2Browser = gBrowser.getBrowserForTab(ctx.tab2);
 
     // bug343515_pg2.html consists of a page with two iframes,
     // which will therefore generate 3 load events.
     nShotsListener(ctx.tab2Browser, "load", step3, 3);
   });
 }
 
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -2000,22 +2000,17 @@ Element::SetSMILOverrideStyleDeclaration
   if (aNotify) {
     nsIDocument* doc = GetComposedDoc();
     // Only need to request a restyle if we're in a document.  (We might not
     // be in a document, if we're clearing animation effects on a target node
     // that's been detached since the previous animation sample.)
     if (doc) {
       nsCOMPtr<nsIPresShell> shell = doc->GetShell();
       if (shell) {
-        // Pass both eRestyle_StyleAttribute and
-        // eRestyle_StyleAttribute_Animations since we don't know if
-        // this style represents only the ticking of an existing
-        // animation or whether it's a new or changed animation.
-        shell->RestyleForAnimation(this, eRestyle_StyleAttribute |
-                                         eRestyle_StyleAttribute_Animations);
+        shell->RestyleForAnimation(this, eRestyle_StyleAttribute_Animations);
       }
     }
   }
 
   return NS_OK;
 }
 
 bool
new file mode 100644
--- /dev/null
+++ b/dom/base/test/PASS.html
@@ -0,0 +1,1 @@
+PASS
--- a/dom/base/test/browser_bug1058164.js
+++ b/dom/base/test/browser_bug1058164.js
@@ -54,17 +54,17 @@ function prepareForVisibilityEvents(brow
 
 /**
  * Tests that frame scripts get pageshow / pagehide events when
  * swapping browser frameloaders (which occurs when moving a tab
  * into a different window).
  */
 add_task(function* test_swap_frameloader_pagevisibility_events() {
   // Load a new tab that we'll tear out...
-  let tab = gBrowser.addTab(PAGE);
+  let tab = BrowserTestUtils.addTab(gBrowser, PAGE);
   gBrowser.selectedTab = tab;
   let firstBrowser = tab.linkedBrowser;
   yield BrowserTestUtils.browserLoaded(firstBrowser);
 
   // Swap the browser out to a new window
   let newWindow = gBrowser.replaceTabWithWindow(tab);
 
   // We have to wait for the window to load so we can get the selected browser
@@ -73,17 +73,17 @@ add_task(function* test_swap_frameloader
   let newWindowBrowser = newWindow.gBrowser.selectedBrowser;
 
   // Wait for the expected pagehide and pageshow events on the initial browser
   yield prepareForVisibilityEvents(newWindowBrowser, ["pagehide", "pageshow"]);
 
   // Now let's send the browser back to the original window
 
   // First, create a new, empty browser tab to replace the window with
-  let newTab = gBrowser.addTab();
+  let newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   let emptyBrowser = newTab.linkedBrowser;
 
   // Wait for that initial browser to show its pageshow event so that we
   // don't confuse it with the other expected events. Note that we can't
   // use BrowserTestUtils.waitForEvent here because we're using the
   // e10s add-on shims in the e10s-case. I'm doing this because I couldn't
   // find a way of sending down a frame script to the newly opened windows
--- a/dom/base/test/browser_bug902350.js
+++ b/dom/base/test/browser_bug902350.js
@@ -21,17 +21,17 @@ function MixedTestsCompleted() {
 
 function test() {
   waitForExplicitFinish();
 
   origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
 
   Services.prefs.setBoolPref(PREF_ACTIVE, true);
 
-  var newTab = gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = newTab;
   gTestBrowser = gBrowser.selectedBrowser;
   newTab.linkedBrowser.stop()
 
   BrowserTestUtils.browserLoaded(gTestBrowser, true /*includeSubFrames*/).then(MixedTest1A);
   var url = gHttpTestRoot + "file_bug902350.html";
   gTestBrowser.loadURI(url);
 }
--- a/dom/base/test/browser_inputStream_structuredClone.js
+++ b/dom/base/test/browser_inputStream_structuredClone.js
@@ -3,17 +3,17 @@
 
 const { classes: Cc, interfaces: Ci } = Components;
 const URIs = [
   "about:about",
   "http://example.com/browser/dom/base/test/empty.html"
 ];
 
 function* runTest(input, url) {
-  let tab = gBrowser.addTab(url);
+  let tab = BrowserTestUtils.addTab(gBrowser, url);
   let browser = gBrowser.getBrowserForTab(tab);
 
   yield BrowserTestUtils.browserLoaded(browser);
 
   let stream = Cc['@mozilla.org/io/string-input-stream;1']
                .createInstance(Ci.nsIStringInputStream);
   stream.setData(input, input.length);
 
--- a/dom/base/test/browser_messagemanager_targetframeloader.js
+++ b/dom/base/test/browser_messagemanager_targetframeloader.js
@@ -3,17 +3,17 @@ function frameScript()
   sendSyncMessage("Test:Message");
   sendAsyncMessage("Test:Message");
   sendAsyncMessage("Test:Done");
 }
 
 function test() {
   waitForExplicitFinish();
 
-  var newTab = gBrowser.addTab("about:blank");
+  var newTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   gBrowser.selectedTab = newTab;
 
   let browser = newTab.linkedBrowser;
   let frameLoader = browser.frameLoader;
   ok(frameLoader !== null, "frameLoader looks okay");
 
   browser.messageManager.loadFrameScript("data:,(" + frameScript.toString() + ")()", false);
 
--- a/dom/base/test/browser_messagemanager_unload.js
+++ b/dom/base/test/browser_messagemanager_unload.js
@@ -61,17 +61,17 @@ const EXPECTED = [
   // outer-window-destroyed for both pages.
   ["outer-window-destroyed", false],
   ["outer-window-destroyed", true],
 ];
 
 function test() {
   waitForExplicitFinish();
 
-  var newTab = gBrowser.addTab("about:blank");
+  var newTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   gBrowser.selectedTab = newTab;
 
   let browser = newTab.linkedBrowser;
   let frameLoader = browser.frameLoader;
   ok(frameLoader !== null, "frameLoader looks okay");
 
   browser.messageManager.loadFrameScript("data:,(" + frameScript.toString() + ")()", false);
 
--- a/dom/base/test/browser_pagehide_on_tab_close.js
+++ b/dom/base/test/browser_pagehide_on_tab_close.js
@@ -1,12 +1,12 @@
 function test() {
   waitForExplicitFinish();
 
-  var tab = gBrowser.addTab();
+  var tab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.selectedTab = tab;
 
   tab.linkedBrowser.addEventListener("load", function() {
     tab.linkedBrowser.addEventListener("pagehide", function() {
       ok(true, "got page hide event");
       finish();
     });
 
--- a/dom/base/test/browser_state_notifications.js
+++ b/dom/base/test/browser_state_notifications.js
@@ -54,17 +54,17 @@ const receive = (topic, p, syncCallback)
   const id = setTimeout(timeout, 90000);
   addObserver(observer, topic, false);
   queue.push(topic, resolve);
 
   return promise;
 };
 receive.queue = [];
 
-const openTab = uri => gBrowser.selectedTab = gBrowser.addTab(uri);
+const openTab = uri => gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, uri);
 
 const sleep = ms => {
   const { promise, resolve } = Promise.defer();
   setTimeout(resolve, ms);
   return promise;
 };
 
 const isData = document => document.URL.startsWith("data:");
--- a/dom/base/test/browser_use_counters.js
+++ b/dom/base/test/browser_use_counters.js
@@ -119,17 +119,17 @@ function grabHistogramsFromContent(use_c
   return BrowserTestUtils.waitForCondition(() => {
     return page_before != telemetry.getHistogramById("USE_COUNTER2_" + use_counter_middlefix + "_PAGE" + suffix).snapshot().sum;
   }).then(gather, gather);
 }
 
 var check_use_counter_iframe = async function(file, use_counter_middlefix, check_documents=true) {
   info("checking " + file + " with histogram " + use_counter_middlefix);
 
-  let newTab = gBrowser.addTab( "about:blank");
+  let newTab = BrowserTestUtils.addTab(gBrowser,  "about:blank");
   gBrowser.selectedTab = newTab;
   newTab.linkedBrowser.stop();
 
   // Hold on to the current values of the telemetry histograms we're
   // interested in.
   let [histogram_page_before, histogram_document_before,
        histogram_docs_before, histogram_toplevel_docs_before] =
       await grabHistogramsFromContent(use_counter_middlefix);
@@ -183,17 +183,17 @@ var check_use_counter_iframe = async fun
     is(histogram_document_after, histogram_document_before + 1,
        "document counts for " + use_counter_middlefix + " after are correct");
   }
 };
 
 var check_use_counter_img = async function(file, use_counter_middlefix) {
   info("checking " + file + " as image with histogram " + use_counter_middlefix);
 
-  let newTab = gBrowser.addTab("about:blank");
+  let newTab = BrowserTestUtils.addTab(gBrowser, "about:blank");
   gBrowser.selectedTab = newTab;
   newTab.linkedBrowser.stop();
 
   // Hold on to the current values of the telemetry histograms we're
   // interested in.
   let [histogram_page_before, histogram_document_before,
        histogram_docs_before, histogram_toplevel_docs_before] =
       await grabHistogramsFromContent(use_counter_middlefix);
@@ -249,17 +249,17 @@ var check_use_counter_img = async functi
   // one for the SVG image itself.
   ok(histogram_docs_after >= histogram_docs_before + 2,
      "document counts are co