Bug 1362034 - Tests for addTab() to provide the correct triggering principal. r=ckerschb,Gijs
☠☠ backed out by 0b2ba0941694 ☠ ☠
authorJonathan Kingston <jkt@mozilla.com>
Mon, 06 Aug 2018 19:56:37 +0300
changeset 430245 8c8925b75aa2f484f64dadcf8d4b31a57a522c7c
parent 430244 ff6b05c9609449b9cd8016dd19131a87d9b8af68
child 430246 0b2ba0941694468a3da24e9b4e39225c0e2f3ae9
push id106100
push userarchaeopteryx@coole-files.de
push dateMon, 06 Aug 2018 16:58:52 +0000
treeherdermozilla-inbound@8c8925b75aa2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersckerschb, Gijs
bugs1362034
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1362034 - Tests for addTab() to provide the correct triggering principal. r=ckerschb,Gijs Summary: Depends on D2046 Reviewers: ckerschb, Gijs Reviewed By: ckerschb, Gijs Bug #: 1362034 Differential Revision: https://phabricator.services.mozilla.com/D2047
accessible/tests/mochitest/name/test_browserui.xul
browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js
browser/base/content/test/general/browser_bug462673.js
browser/base/content/test/general/browser_bug963945.js
browser/base/content/test/general/browser_tab_dragdrop2.js
browser/base/content/test/general/browser_trackingUI_5.js
browser/base/content/test/general/browser_utilityOverlay.js
browser/base/content/test/metaTags/browser_meta_tags.js
browser/base/content/test/performance/head.js
browser/base/content/test/referrer/head.js
browser/base/content/test/tabs/browser_new_tab_insert_position.js
browser/base/content/test/tabs/browser_pinnedTabs_closeByKeyboard.js
browser/base/content/test/tabs/browser_positional_attributes.js
browser/base/content/test/trackingUI/browser_trackingUI_animation.js
browser/base/content/test/trackingUI/browser_trackingUI_state.js
browser/base/content/test/urlbar/browser_URLBarSetURI.js
browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
browser/components/extensions/test/browser/browser-common.ini
browser/components/extensions/test/browser/browser_ext_tabs_create.js
browser/components/extensions/test/browser/browser_ext_tabs_create_url.js
browser/components/migration/tests/marionette/test_refresh_firefox.py
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutSessionRestore.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cache.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler.js
browser/components/safebrowsing/content/test/browser_whitelisted.js
browser/components/search/test/browser_contextSearchTabPosition.js
browser/components/search/test/browser_google_behavior.js
browser/components/search/test/browser_searchEngine_behaviors.js
browser/components/sessionstore/test/browser_354894_perwindowpb.js
browser/components/sessionstore/test/browser_625016.js
browser/components/sessionstore/test/browser_819510_perwindowpb.js
browser/components/sessionstore/test/browser_broadcast.js
browser/components/sessionstore/test/browser_cleaner.js
browser/components/sessionstore/test/browser_crashedTabs.js
browser/components/sessionstore/test/browser_dying_cache.js
browser/components/sessionstore/test/browser_privatetabs.js
browser/components/sessionstore/test/browser_scrollPositions.js
browser/components/sessionstore/test/browser_scrollPositionsReaderMode.js
browser/components/sessionstore/test/browser_switch_remoteness.js
browser/components/sessionstore/test/browser_undoCloseById.js
browser/components/sessionstore/test/browser_windowStateContainer.js
devtools/client/commandline/test/helpers.js
devtools/client/debugger/test/mochitest/head.js
devtools/client/styleeditor/test/head.js
devtools/client/webconsole/test/mochitest/browser_console_webconsole_private_browsing.js
devtools/startup/tests/browser/browser_shim_disable_devtools.js
docshell/test/browser/head.js
dom/base/test/browser_blocking_image.js
dom/broadcastchannel/tests/browser_private_browsing.js
dom/cache/test/mochitest/browser_cache_pb_window.js
dom/html/test/browser_bug1108547.js
dom/indexedDB/test/browser_permissionsPromptDeny.js
dom/indexedDB/test/browser_perwindow_privateBrowsing.js
dom/quota/test/browser_permissionsPromptUnknown.js
dom/tests/browser/browser_localStorage_privatestorageevent.js
dom/tests/browser/helper_largeAllocation.js
testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
testing/mochitest/api.js
testing/mochitest/browser-test.js
toolkit/components/extensions/test/browser/browser_ext_themes_tab_separators.js
toolkit/content/tests/browser/browser_block_autoplay_media.js
toolkit/content/tests/browser/browser_block_autoplay_media_pausedAfterPlay.js
toolkit/content/tests/browser/browser_block_autoplay_playAfterTabVisible.js
toolkit/content/tests/browser/browser_block_multipleMedia.js
toolkit/content/tests/browser/browser_block_notInTreeAudio.js
toolkit/content/tests/browser/browser_block_playMediaInMuteTab.js
toolkit/content/tests/browser/browser_block_plugIn.js
toolkit/content/tests/browser/browser_block_silentAudioTrack_media.js
toolkit/content/tests/browser/browser_block_webAudio.js
toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js
--- a/accessible/tests/mochitest/name/test_browserui.xul
+++ b/accessible/tests/mochitest/name/test_browserui.xul
@@ -27,17 +27,17 @@
     function addTab(aURL)
     {
       this.eventSeq = [
         new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, tabDocumentAt, 1)
       ];
 
       this.invoke = function addTab_invoke()
       {
-        tabBrowser().addTab(aURL);
+        tabBrowser().addTrustedTab(aURL);
       }
 
       this.getID = function addTab_getID()
       {
         return "add tab: " + aURL;
       }
     }
 
--- a/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js
+++ b/browser/base/content/test/general/browser_beforeunload_duplicate_dialogs.js
@@ -40,17 +40,17 @@ add_task(async function closeLastTabInWi
   ok(newWin.closed, "Window should be closed.");
 });
 
 add_task(async function closeWindowWithMultipleTabsIncludingOneBeforeUnload() {
   Services.prefs.setBoolPref("browser.tabs.warnOnClose", false);
   let newWin = await promiseOpenAndLoadWindow({}, true);
   let firstTab = newWin.gBrowser.selectedTab;
   await promiseTabLoadEvent(firstTab, TEST_PAGE);
-  await promiseTabLoadEvent(newWin.gBrowser.addTab(), "http://example.com/");
+  await promiseTabLoadEvent(BrowserTestUtils.addTab(newWin.gBrowser), "http://example.com/");
   let windowClosedPromise = BrowserTestUtils.domWindowClosed(newWin);
   expectingDialog = true;
   newWin.BrowserTryToCloseWindow();
   await windowClosedPromise;
   ok(!expectingDialog, "There should have been a dialog.");
   ok(newWin.closed, "Window should be closed.");
   Services.prefs.clearUserPref("browser.tabs.warnOnClose");
 });
--- a/browser/base/content/test/general/browser_bug462673.js
+++ b/browser/base/content/test/general/browser_bug462673.js
@@ -15,17 +15,17 @@ add_task(async function() {
 
 add_task(async function() {
   var win = openDialog(AppConstants.BROWSER_CHROME_URL, "_blank", "chrome,all,dialog=no");
   await SimpleTest.promiseFocus(win);
 
   let tab = win.gBrowser.tabContainer.firstChild;
   await promiseTabLoadEvent(tab, getRootDirectory(gTestPath) + "test_bug462673.html");
 
-  var newTab = win.gBrowser.addTab();
+  var newTab = BrowserTestUtils.addTab(win.gBrowser);
   var newBrowser = newTab.linkedBrowser;
   win.gBrowser.removeTab(tab);
   ok(!win.closed, "Window stays open");
   if (!win.closed) {
     is(win.gBrowser.tabContainer.childElementCount, 1, "Window has one tab");
     is(win.gBrowser.browsers.length, 1, "Window has one browser");
     is(win.gBrowser.selectedTab, newTab, "Remaining tab is selected");
     is(win.gBrowser.selectedBrowser, newBrowser, "Browser for remaining tab is selected");
--- a/browser/base/content/test/general/browser_bug963945.js
+++ b/browser/base/content/test/general/browser_bug963945.js
@@ -5,17 +5,17 @@
 /*
  * This test ensures the about:addons tab is only
  * opened one time when in private browsing.
  */
 
 add_task(async function test() {
   let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
 
-  let tab = win.gBrowser.selectedTab = win.gBrowser.addTab("about:addons");
+  let tab = win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser, "about:addons");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await promiseWaitForFocus(win);
 
   EventUtils.synthesizeKey("a", { ctrlKey: true, shiftKey: true }, win);
 
   is(win.gBrowser.tabs.length, 2, "about:addons tab was re-focused.");
   is(win.gBrowser.currentURI.spec, "about:addons", "Addons tab was opened.");
 
--- a/browser/base/content/test/general/browser_tab_dragdrop2.js
+++ b/browser/base/content/test/general/browser_tab_dragdrop2.js
@@ -12,17 +12,17 @@ add_task(async function() {
   let args = "chrome,all,dialog=no";
   let win = window.openDialog(AppConstants.BROWSER_CHROME_URL, "_blank", args, URI);
 
   // Wait until the tests were run.
   await promiseTestsDone(win);
   ok(true, "tests succeeded");
 
   // Create a second tab so that we can move the original one out.
-  win.gBrowser.addTab("about:blank", {skipAnimation: true});
+  BrowserTestUtils.addTab(win.gBrowser, "about:blank", {skipAnimation: true});
 
   // Tear off the original tab.
   let browser = win.gBrowser.selectedBrowser;
   let tabClosed = promiseWaitForEvent(browser, "pagehide", true);
   let win2 = win.gBrowser.replaceTabWithWindow(win.gBrowser.tabs[0]);
 
   // Add a 'TestsDone' event listener to ensure that the docShells is properly
   // swapped to the new window instead of the page being loaded again. If this
--- a/browser/base/content/test/general/browser_trackingUI_5.js
+++ b/browser/base/content/test/general/browser_trackingUI_5.js
@@ -92,17 +92,17 @@ add_task(async function testExceptionAdd
   let tabReloadPromise = promiseTabLoadEvent(tab);
   clickButton("#tracking-action-unblock");
   is(identityPopupState(), "closed", "foobar");
 
   await tabReloadPromise;
   testTrackingPageUnblocked();
 
   info("Test that the exception is remembered across tabs in the same private window");
-  tab = browser.selectedTab = browser.addTab();
+  tab = browser.selectedTab = BrowserTestUtils.addTab(browser);
 
   info("Load a test page containing tracking elements");
   await promiseTabLoadEvent(tab, TRACKING_PAGE);
   testTrackingPageUnblocked();
 
   await promiseWindowClosed(privateWin);
 });
 
--- a/browser/base/content/test/general/browser_utilityOverlay.js
+++ b/browser/base/content/test/general/browser_utilityOverlay.js
@@ -85,17 +85,17 @@ function test_getTopWin() {
 function test_getBoolPref() {
   is(getBoolPref("browser.search.openintab", false), false, "getBoolPref");
   is(getBoolPref("this.pref.doesnt.exist", true), true, "getBoolPref fallback");
   is(getBoolPref("this.pref.doesnt.exist", false), false, "getBoolPref fallback #2");
   runNextTest();
 }
 
 function test_openNewTabWith() {
-  openNewTabWith("http://example.com/");
+  openNewTabWith("http://example.com/", null, {triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal({})});
   let tab = gBrowser.selectedTab = gBrowser.tabs[1];
   BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
     is(tab.linkedBrowser.currentURI.spec, "http://example.com/", "example.com loaded");
     gBrowser.removeCurrentTab();
     runNextTest();
   });
 }
 
--- a/browser/base/content/test/metaTags/browser_meta_tags.js
+++ b/browser/base/content/test/metaTags/browser_meta_tags.js
@@ -27,17 +27,17 @@ add_task(async function test_metadata() 
  * make sure the extra tab does not cause the debounce logic to be skipped. If
  * incorrectly skipped, the updated metadata would not include the delayed meta.
  */
 add_task(async function multiple_tabs() {
   const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PATH);
 
   // Add a background tab to cause another page to load *without* putting the
   // desired URL in a background tab, which results in its timers being throttled.
-  gBrowser.addTab();
+  BrowserTestUtils.addTab(gBrowser);
 
   // Wait until places has stored the page info
   const pageInfo = await waitForPageInfo(TEST_PATH);
   is(pageInfo.description, "og:description", "got the correct description");
   is(pageInfo.previewImageURL.href, "https://test.com/og-image-secure-url.jpg", "got the correct preview image");
 
   BrowserTestUtils.removeTab(tab);
   BrowserTestUtils.removeTab(gBrowser.selectedTab);
--- a/browser/base/content/test/performance/head.js
+++ b/browser/base/content/test/performance/head.js
@@ -298,17 +298,20 @@ function computeMaxTabCount() {
  *        How many about:blank tabs to open.
  */
 async function createTabs(howMany) {
   let uris = [];
   while (howMany--) {
     uris.push("about:blank");
   }
 
-  gBrowser.loadTabs(uris, { inBackground: true });
+  gBrowser.loadTabs(uris, {
+    inBackground: true,
+    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+  });
 
   await BrowserTestUtils.waitForCondition(() => {
     return Array.from(gBrowser.tabs).every(tab => tab._fullyOpen);
   });
 }
 
 /**
  * Removes all of the tabs except the originally selected
--- a/browser/base/content/test/referrer/head.js
+++ b/browser/base/content/test/referrer/head.js
@@ -205,17 +205,17 @@ function referrerTestCaseLoaded(aTestNum
                              REFERRER_POLICYSERVER_URL_ATTRIBUTE;
   let url = test.fromScheme + server +
             "?scheme=" + escape(test.toScheme) +
             "&policy=" + escape(test.policy || "") +
             "&rel=" + escape(test.rel || "") +
             "&cross=" + escape(test.cross || "");
   let browser = gTestWindow.gBrowser;
   return BrowserTestUtils.openNewForegroundTab(browser, () => {
-    browser.selectedTab = browser.addTab(url, aParams);
+    browser.selectedTab = BrowserTestUtils.addTab(browser, url, aParams);
   }, false, true);
 }
 
 /**
  * Checks the result of the referrer test, and moves on to the next test.
  * @param aTestNumber The test number - 0, 1, 2, ...
  * @param aNewWindow The new window where the referrer target opened, or null.
  * @param aNewTab The new tab where the referrer target opened, or null.
--- a/browser/base/content/test/tabs/browser_new_tab_insert_position.js
+++ b/browser/base/content/test/tabs/browser_new_tab_insert_position.js
@@ -149,17 +149,20 @@ async function doTest(aInsertRelatedAfte
   verifyTabState(newState);
 
   // Bug 1442679 - Test bulk opening with loadTabs loads the tabs in order
 
   let loadPromises = Promise.all(bulkLoad.map(url => BrowserTestUtils.waitForNewTab(gBrowser, url, false, true)));
   // loadTabs will insertAfterCurrent
   let nextTab = aInsertAfterCurrent ? gBrowser.selectedTab._tPos + 1 : gBrowser.tabs.length;
 
-  gBrowser.loadTabs(bulkLoad, { inBackground: true });
+  gBrowser.loadTabs(bulkLoad, {
+    inBackground: true,
+    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+  });
   await loadPromises;
   for (let i = nextTab, j = 0; j < bulkLoad.length; i++, j++) {
     is(gBrowser.tabs[i].linkedBrowser.currentURI.spec, bulkLoad[j], `bulkLoad tab pos ${i} matched`);
   }
 
   // Now we want to test that positioning remains correct after a session restore.
 
   // Restore pre-test state so we can restore and test tab ordering.
--- a/browser/base/content/test/tabs/browser_pinnedTabs_closeByKeyboard.js
+++ b/browser/base/content/test/tabs/browser_pinnedTabs_closeByKeyboard.js
@@ -16,17 +16,17 @@ function test() {
        "menu_close should always have key_close set");
   }
 
   let unpinnedTab = gBrowser.selectedTab;
   ok(!unpinnedTab.pinned, "We should have started with a regular tab selected");
 
   testState(false);
 
-  let pinnedTab = gBrowser.addTab();
+  let pinnedTab = BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(pinnedTab);
 
   // Just pinning the tab shouldn't change the key state.
   testState(false);
 
   // Test key state after selecting a tab.
   gBrowser.selectedTab = pinnedTab;
   testState(true);
@@ -40,17 +40,17 @@ function test() {
   // Test the key state after un/pinning the tab.
   gBrowser.unpinTab(pinnedTab);
   testState(false);
 
   gBrowser.pinTab(pinnedTab);
   testState(true);
 
   // Test that accel+w in a pinned tab selects the next tab.
-  let pinnedTab2 = gBrowser.addTab();
+  let pinnedTab2 = BrowserTestUtils.addTab(gBrowser);
   gBrowser.pinTab(pinnedTab2);
   gBrowser.selectedTab = pinnedTab;
 
   EventUtils.synthesizeKey("w", { accelKey: true });
   is(gBrowser.tabs.length, 3, "accel+w in a pinned tab didn't close it");
   is(gBrowser.selectedTab, unpinnedTab, "accel+w in a pinned tab selected the first unpinned tab");
 
   // Test the key state after removing the tab.
--- a/browser/base/content/test/tabs/browser_positional_attributes.js
+++ b/browser/base/content/test/tabs/browser_positional_attributes.js
@@ -1,34 +1,39 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 var tabs = [];
 
-function addTab(aURL) {
-  tabs.push(gBrowser.addTab(aURL, {skipAnimation: true}));
+function addTab(aURL, done) {
+  tabs.push(BrowserTestUtils.addTab(gBrowser, aURL, {
+    skipAnimation: true,
+  }, done));
 }
 
 function switchTab(index) {
   return BrowserTestUtils.switchTab(gBrowser, gBrowser.tabs[index]);
 }
 
 function testAttrib(tabIndex, attrib, expected) {
   is(gBrowser.tabs[tabIndex].hasAttribute(attrib), expected,
      `tab #${tabIndex} should${expected ? "" : "n't"} have the ${attrib} attribute`);
 }
 
 add_task(async function setup() {
   is(gBrowser.tabs.length, 1, "one tab is open initially");
 
-  addTab("http://mochi.test:8888/#0");
-  addTab("http://mochi.test:8888/#1");
-  addTab("http://mochi.test:8888/#2");
-  addTab("http://mochi.test:8888/#3");
+  await new Promise(r => addTab("http://mochi.test:8888/#0", r));
+  await new Promise(r => addTab("http://mochi.test:8888/#1", r));
+  await new Promise(r => addTab("http://mochi.test:8888/#2", r));
+  await new Promise(r => addTab("http://mochi.test:8888/#3", r));
+
+  is(gBrowser.tabs.length, 5, "five tabs are open after setup");
+  EventUtils.synthesizeMouse(tabs[1], 1, 1, {type: "mouseover"});
 });
 
 // Add several new tabs in sequence, hiding some, to ensure that the
 // correct attributes get set
 add_task(async function test() {
   await switchTab(0);
 
   testAttrib(0, "first-visible-tab", true);
--- a/browser/base/content/test/trackingUI/browser_trackingUI_animation.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_animation.js
@@ -9,17 +9,17 @@ const TP_PREF = "privacy.trackingprotect
 const ANIMATIONS_PREF = "toolkit.cosmeticAnimations.enabled";
 
 // Test that the shield icon animation can be controlled by the cosmetic
 // animations pref and that one of the icons is visible in each case.
 add_task(async function testShieldAnimation() {
   await UrlClassifierTestUtils.addTestTrackers();
   Services.prefs.setBoolPref(TP_PREF, true);
 
-  let tab = gBrowser.selectedTab = gBrowser.addTab();
+  let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   let animationIcon = document.getElementById("tracking-protection-icon-animatable-image");
   let noAnimationIcon = document.getElementById("tracking-protection-icon");
 
   Services.prefs.setBoolPref(ANIMATIONS_PREF, true);
   await promiseTabLoadEvent(tab, TRACKING_PAGE);
   ok(BrowserTestUtils.is_hidden(noAnimationIcon), "the default icon is hidden when animations are enabled");
   ok(BrowserTestUtils.is_visible(animationIcon), "the animated icon is shown when animations are enabled");
--- a/browser/base/content/test/trackingUI/browser_trackingUI_state.js
+++ b/browser/base/content/test/trackingUI/browser_trackingUI_state.js
@@ -226,17 +226,17 @@ async function testTrackingProtectionDis
   await promiseTabLoadEvent(tab, TRACKING_PAGE);
   testTrackingPageUnblocked();
 }
 
 add_task(async function testNormalBrowsing() {
   await UrlClassifierTestUtils.addTestTrackers();
 
   tabbrowser = gBrowser;
-  let tab = tabbrowser.selectedTab = tabbrowser.addTab();
+  let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
 
   TrackingProtection = gBrowser.ownerGlobal.TrackingProtection;
   ok(TrackingProtection, "TP is attached to the browser window");
   is(TrackingProtection.enabled, Services.prefs.getBoolPref(PREF),
      "TP.enabled is based on the original pref value");
 
   Services.prefs.setBoolPref(PREF, true);
   ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
@@ -247,17 +247,17 @@ add_task(async function testNormalBrowsi
   ok(!TrackingProtection.enabled, "TP is disabled after setting the pref");
 
   await testTrackingProtectionDisabled(tab);
 });
 
 add_task(async function testPrivateBrowsing() {
   let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
   tabbrowser = privateWin.gBrowser;
-  let tab = tabbrowser.selectedTab = tabbrowser.addTab();
+  let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
 
   TrackingProtection = tabbrowser.ownerGlobal.TrackingProtection;
   ok(TrackingProtection, "TP is attached to the private window");
   is(TrackingProtection.enabled, Services.prefs.getBoolPref(PB_PREF),
      "TP.enabled is based on the pb pref value");
 
   Services.prefs.setBoolPref(PB_PREF, true);
   ok(TrackingProtection.enabled, "TP is enabled after setting the pref");
--- a/browser/base/content/test/urlbar/browser_URLBarSetURI.js
+++ b/browser/base/content/test/urlbar/browser_URLBarSetURI.js
@@ -62,17 +62,17 @@ var tests = [
       next();
     });
   }
 ];
 
 function loadTabInWindow(win, callback) {
   info("Loading tab");
   let url = "http://user:pass@example.com/";
-  let tab = win.gBrowser.selectedTab = win.gBrowser.addTab(url);
+  let tab = win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser, url);
   BrowserTestUtils.browserLoaded(tab.linkedBrowser, false, url).then(() => {
     info("Tab loaded");
     is(win.gURLBar.textValue, "example.com", "URL bar had user/pass stripped initially");
     callback(tab);
   }, true);
 }
 
 function openToolbarCustomizationUI(aCallback, aBrowserWin) {
--- a/browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
+++ b/browser/base/content/test/urlbar/browser_urlbarSearchSingleWordNotification.js
@@ -157,17 +157,17 @@ function get_test_function_for_localhost
     // check pref value
     let prefValue = Services.prefs.getBoolPref(pref);
     is(prefValue, !isPrivate, "Pref should have the correct state.");
 
     await docLoadPromise;
     browser.removeTab(tab);
 
     // Now try again with the pref set.
-    tab = browser.selectedTab = browser.addTab("about:blank");
+    tab = browser.selectedTab = BrowserTestUtils.addTab(browser, "about:blank");
     await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
     // In a private window, the notification should appear again.
     await runURLBarSearchTest({
       valueToOpen: hostName,
       expectSearch: isPrivate,
       expectNotification: isPrivate,
       aWindow: win,
     });
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -161,16 +161,17 @@ skip-if = !e10s || !crashreporter # the 
 [browser_ext_slow_script.js]
 skip-if = !e10s || debug || asan
 [browser_ext_tab_runtimeConnect.js]
 [browser_ext_tabs_audio.js]
 [browser_ext_tabs_captureTab.js]
 [browser_ext_tabs_captureVisibleTab.js]
 [browser_ext_tabs_create.js]
 skip-if = os == "linux" && debug && bits == 32 # Bug 1350189
+[browser_ext_tabs_create_url.js]
 [browser_ext_tabs_create_invalid_url.js]
 [browser_ext_tabs_detectLanguage.js]
 [browser_ext_tabs_discard.js]
 skip-if = !e10s
 [browser_ext_tabs_discarded.js]
 [browser_ext_tabs_duplicate.js]
 [browser_ext_tabs_events.js]
 [browser_ext_tabs_executeScript.js]
--- a/browser/components/extensions/test/browser/browser_ext_tabs_create.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_create.js
@@ -170,67 +170,16 @@ add_task(async function test_create_opti
 
   await extension.startup();
   await extension.awaitFinish("tabs.create");
   await extension.unload();
 
   BrowserTestUtils.removeTab(tab);
 });
 
-add_task(async function test_urlbar_focus() {
-  const extension = ExtensionTestUtils.loadExtension({
-    background() {
-      browser.tabs.onUpdated.addListener(function onUpdated(_, info) {
-        if (info.status === "complete") {
-          browser.test.sendMessage("complete");
-          browser.tabs.onUpdated.removeListener(onUpdated);
-        }
-      });
-      browser.test.onMessage.addListener(async (cmd, ...args) => {
-        const result = await browser.tabs[cmd](...args);
-        browser.test.sendMessage("result", result);
-      });
-    },
-  });
-
-  await extension.startup();
-
-  // Test content is focused after opening a regular url
-  extension.sendMessage("create", {url: "https://example.com"});
-  const [tab1] = await Promise.all([
-    extension.awaitMessage("result"),
-    extension.awaitMessage("complete"),
-  ]);
-
-  is(document.activeElement.tagName, "browser", "Content focused after opening a web page");
-
-  extension.sendMessage("remove", tab1.id);
-  await extension.awaitMessage("result");
-
-  // Test urlbar is focused after opening an empty tab
-  extension.sendMessage("create", {});
-  const tab2 = await extension.awaitMessage("result");
-
-  const active = document.activeElement;
-  info(`Active element: ${active.tagName}, id: ${active.id}, class: ${active.className}`);
-
-  const parent = active.parentNode;
-  info(`Parent element: ${parent.tagName}, id: ${parent.id}, class: ${parent.className}`);
-
-  info(`After opening an empty tab, gURLBar.focused: ${gURLBar.focused}`);
-
-  is(active.tagName, "html:input", "Input element focused");
-  ok(active.classList.contains("urlbar-input"), "Urlbar focused");
-
-  extension.sendMessage("remove", tab2.id);
-  await extension.awaitMessage("result");
-
-  await extension.unload();
-});
-
 add_task(async function test_create_with_popup() {
   const extension = ExtensionTestUtils.loadExtension({
     async background() {
       let normalWin = await browser.windows.create();
       let lastFocusedNormalWin = await browser.windows.getLastFocused({});
       browser.test.assertEq(lastFocusedNormalWin.id, normalWin.id, "The normal window is the last focused window.");
       let popupWin = await browser.windows.create({type: "popup"});
       let lastFocusedPopupWin = await browser.windows.getLastFocused({});
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_create_url.js
@@ -0,0 +1,55 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+add_task(async function test_urlbar_focus() {
+  const extension = ExtensionTestUtils.loadExtension({
+    background() {
+      browser.tabs.onUpdated.addListener(function onUpdated(_, info) {
+        if (info.status === "complete") {
+          browser.test.sendMessage("complete");
+          browser.tabs.onUpdated.removeListener(onUpdated);
+        }
+      });
+      browser.test.onMessage.addListener(async (cmd, ...args) => {
+        const result = await browser.tabs[cmd](...args);
+        browser.test.sendMessage("result", result);
+      });
+    },
+  });
+
+  await extension.startup();
+
+  // Test content is focused after opening a regular url
+  extension.sendMessage("create", {url: "https://example.com"});
+  const [tab1] = await Promise.all([
+    extension.awaitMessage("result"),
+    extension.awaitMessage("complete"),
+  ]);
+
+  is(document.activeElement.tagName, "browser", "Content focused after opening a web page");
+
+  extension.sendMessage("remove", tab1.id);
+  await extension.awaitMessage("result");
+
+  // Test urlbar is focused after opening an empty tab
+  extension.sendMessage("create", {});
+  const tab2 = await extension.awaitMessage("result");
+
+  const active = document.activeElement;
+  info(`Active element: ${active.tagName}, id: ${active.id}, class: ${active.className}`);
+
+  const parent = active.parentNode;
+  info(`Parent element: ${parent.tagName}, id: ${parent.id}, class: ${parent.className}`);
+
+  info(`After opening an empty tab, gURLBar.focused: ${gURLBar.focused}`);
+
+
+  is(active.tagName, "html:input", "Input element focused");
+  ok(active.classList.contains("urlbar-input"), "Urlbar focused");
+
+  extension.sendMessage("remove", tab2.id);
+  await extension.awaitMessage("result");
+
+  await extension.unload();
+});
--- a/browser/components/migration/tests/marionette/test_refresh_firefox.py
+++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py
@@ -166,17 +166,19 @@ class TestFirefoxRefresh(MarionetteTestC
                     resolve();
                   }
                 });
               }
             }
           });
           let expectedTabs = new Set();
           for (let url of expectedURLs) {
-            expectedTabs.add(gBrowser.addTab(url));
+            expectedTabs.add(gBrowser.addTab(url, {
+              triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+            }));
           }
           // Close any other tabs that might be open:
           let allTabs = Array.from(gBrowser.tabs);
           for (let tab of allTabs) {
             if (!expectedTabs.has(tab)) {
               gBrowser.removeTab(tab);
             }
           }
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutSessionRestore.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_aboutSessionRestore.js
@@ -4,17 +4,17 @@
 
 // This test checks that the session restore button from about:sessionrestore
 // is disabled in private mode
 add_task(async function testNoSessionRestoreButton() {
   // Opening, then closing, a private window shouldn't create session data.
   (await BrowserTestUtils.openNewBrowserWindow({private: true})).close();
 
   let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
-  let tab = win.gBrowser.addTab("about:sessionrestore");
+  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:sessionrestore");
   let browser = tab.linkedBrowser;
 
   await BrowserTestUtils.browserLoaded(browser);
 
   await ContentTask.spawn(browser, null, async function() {
     Assert.ok(content.document.getElementById("errorTryAgain").disabled,
       "The Restore about:sessionrestore button should be disabled");
   });
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cache.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_cache.js
@@ -56,17 +56,17 @@ function getStorageEntryCount(device, go
 
 function get_cache_for_private_window() {
   let win = whenNewWindowLoaded({private: true}, function() {
 
     executeSoon(function() {
 
       ok(true, "The private window got loaded");
 
-      let tab = win.gBrowser.addTab("http://example.org");
+      let tab = BrowserTestUtils.addTab(win.gBrowser, "http://example.org");
       win.gBrowser.selectedTab = tab;
       let newTabBrowser = win.gBrowser.getBrowserForTab(tab);
 
       BrowserTestUtils.browserLoaded(newTabBrowser).then(function() {
         executeSoon(function() {
 
           getStorageEntryCount("private", function(nrEntriesP) {
             ok(nrEntriesP >= 1, "Memory cache reports some entries from example.org domain");
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
@@ -154,17 +154,17 @@ async function assignCookies(aBrowser, a
   await ContentTask.spawn(tabInfo.browser, aCookieValue, async function(value) {
     content.document.cookie = value;
   });
 
   BrowserTestUtils.removeTab(tabInfo.tab);
 }
 
 async function openTab(aBrowser, aURL) {
-  let tab = aBrowser.addTab(aURL);
+  let tab = BrowserTestUtils.addTab(aBrowser, aURL);
 
   // Select tab and make sure its browser is focused.
   aBrowser.selectedTab = tab;
   tab.ownerGlobal.focus();
 
   let browser = aBrowser.getBrowserForTab(tab);
   await BrowserTestUtils.browserLoaded(browser);
   return {tab, browser};
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
@@ -6,17 +6,17 @@
 // control inside the private browsing mode.
 
 add_task(async function test() {
   const testPageURL = "https://example.com/browser/" +
     "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt_page.html";
 
   function checkGeolocation(aPrivateMode, aWindow) {
     return (async function() {
-      aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testPageURL);
+      aWindow.gBrowser.selectedTab = BrowserTestUtils.addTab(aWindow.gBrowser, testPageURL);
       await BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser);
 
       let notification = aWindow.PopupNotifications.getNotification("geolocation");
 
       // Wait until the notification is available.
       while (!notification) {
         await new Promise(resolve => { executeSoon(resolve); });
         notification = aWindow.PopupNotifications.getNotification("geolocation");
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
@@ -4,17 +4,17 @@
 
  add_task(async function test() {
   requestLongerTimeout(2);
   const page1 = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/" +
                 "browser_privatebrowsing_localStorage_page1.html";
 
   let win = await BrowserTestUtils.openNewBrowserWindow({private: true});
 
-  win.gBrowser.selectedTab = win.gBrowser.addTab(page1);
+  win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser, page1);
   let browser = win.gBrowser.selectedBrowser;
   await BrowserTestUtils.browserLoaded(browser);
 
   browser.loadURI(
     "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/" +
     "browser_privatebrowsing_localStorage_page2.html");
   await BrowserTestUtils.browserLoaded(browser);
 
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
@@ -10,25 +10,25 @@
 // Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item
 //   existing.
 
 add_task(async function test() {
   let prefix = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/";
 
   // Step 1.
   let privateWin = await BrowserTestUtils.openNewBrowserWindow({private: true});
-  let privateBrowser = privateWin.gBrowser.addTab(
+  let privateBrowser = BrowserTestUtils.addTab(privateWin.gBrowser,
     prefix + "browser_privatebrowsing_localStorage_before_after_page.html").linkedBrowser;
   await BrowserTestUtils.browserLoaded(privateBrowser);
 
   is(privateBrowser.contentTitle, "1", "localStorage should contain 1 item");
 
   // Step 2.
   let win = await BrowserTestUtils.openNewBrowserWindow();
-  let browser = win.gBrowser.addTab(
+  let browser = BrowserTestUtils.addTab(win.gBrowser,
     prefix + "browser_privatebrowsing_localStorage_before_after_page2.html").linkedBrowser;
   await BrowserTestUtils.browserLoaded(browser);
 
   is(browser.contentTitle, "null|0", "localStorage should contain 0 items");
 
   // Cleanup
   await BrowserTestUtils.closeWindow(privateWin);
   await BrowserTestUtils.closeWindow(win);
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
@@ -3,17 +3,17 @@
 /**
  * Tests that if we open a tab within a private browsing window, and then
  * close that private browsing window, that subsequent private browsing
  * windows do not allow the command for restoring the last session.
  */
 add_task(async function test_no_session_restore_menu_option() {
   let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
   ok(true, "The first private window got loaded");
-  win.gBrowser.addTab("about:mozilla");
+  BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
   await BrowserTestUtils.closeWindow(win);
 
   win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
   let srCommand = win.document.getElementById("Browser:RestoreLastSession");
   ok(srCommand, "The Session Restore command should exist");
   is(PrivateBrowsingUtils.isWindowPrivate(win), true,
      "PrivateBrowsingUtils should report the correct per-window private browsing status");
   is(srCommand.hasAttribute("disabled"), true,
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler.js
@@ -7,17 +7,17 @@
 // inside the private browsing mode.
 
 add_task(async function test() {
   let notificationValue = "Protocol Registration: web+testprotocol";
   let testURI = "https://example.com/browser/" +
     "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler_page.html";
 
   let doTest = async function(aIsPrivateMode, aWindow) {
-    let tab = aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testURI);
+    let tab = aWindow.gBrowser.selectedTab = BrowserTestUtils.addTab(aWindow.gBrowser, testURI);
     await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
     let promiseFinished = PromiseUtils.defer();
     setTimeout(function() {
       let notificationBox = aWindow.gBrowser.getNotificationBox();
       let notification = notificationBox.getNotificationWithValue(notificationValue);
 
       if (aIsPrivateMode) {
--- a/browser/components/safebrowsing/content/test/browser_whitelisted.js
+++ b/browser/components/safebrowsing/content/test/browser_whitelisted.js
@@ -22,17 +22,17 @@ function testWhitelistedPage(window) {
   var getmeout_button = window.document.getElementById("getMeOutButton");
   var ignorewarning_button = window.document.getElementById("ignoreWarningButton");
   ok(!getmeout_button, "GetMeOut button not present");
   ok(!ignorewarning_button, "IgnoreWarning button not present");
 }
 
 add_task(async function testNormalBrowsing() {
   tabbrowser = gBrowser;
-  let tab = tabbrowser.selectedTab = tabbrowser.addTab();
+  let tab = tabbrowser.selectedTab = BrowserTestUtils.addTab(tabbrowser);
 
   info("Load a test page that's whitelisted");
   Services.prefs.setCharPref(PREF_WHITELISTED_HOSTNAMES, "example.com,www.ItIsaTrap.org,example.net");
   await promiseTabLoadEvent(tab, TEST_PAGE, "load");
   testWhitelistedPage(tab.ownerGlobal);
 
   info("Load a test page that's no longer whitelisted");
   Services.prefs.setCharPref(PREF_WHITELISTED_HOSTNAMES, "");
--- a/browser/components/search/test/browser_contextSearchTabPosition.js
+++ b/browser/components/search/test/browser_contextSearchTabPosition.js
@@ -28,18 +28,18 @@ add_task(async function test() {
       tabsLoadedDeferred.resolve();
     }
   }
 
   let container = gBrowser.tabContainer;
   container.addEventListener("TabOpen", tabAdded);
 
   BrowserTestUtils.addTab(gBrowser, "about:blank");
-  BrowserSearch.loadSearchFromContext("mozilla");
-  BrowserSearch.loadSearchFromContext("firefox");
+  BrowserSearch.loadSearchFromContext("mozilla", Services.scriptSecurityManager.getSystemPrincipal());
+  BrowserSearch.loadSearchFromContext("firefox", Services.scriptSecurityManager.getSystemPrincipal());
 
   // 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");
   is(tabs[2], gBrowser.tabs[2], "second search tab opens next to the first search tab");
 
--- a/browser/components/search/test/browser_google_behavior.js
+++ b/browser/components/search/test/browser_google_behavior.js
@@ -88,17 +88,17 @@ async function testSearchEngine(engineDe
 
   let engineTests = [
     {
       name: "context menu search",
       searchURL: base + engineDetails.codes.context,
       run() {
         // Simulate a contextmenu search
         // FIXME: This is a bit "low-level"...
-        BrowserSearch.loadSearch("foo", false, "contextmenu");
+        BrowserSearch._loadSearch("foo", false, "contextmenu", Services.scriptSecurityManager.getSystemPrincipal());
       }
     },
     {
       name: "keyword search",
       searchURL: base + engineDetails.codes.keyword,
       run() {
         gURLBar.value = "? foo";
         gURLBar.focus();
--- a/browser/components/search/test/browser_searchEngine_behaviors.js
+++ b/browser/components/search/test/browser_searchEngine_behaviors.js
@@ -106,17 +106,17 @@ async function testSearchEngine(engineDe
 
   let engineTests = [
     {
       name: "context menu search",
       searchURL: base + engineDetails.codes.context,
       run() {
         // Simulate a contextmenu search
         // FIXME: This is a bit "low-level"...
-        BrowserSearch.loadSearch("foo", false, "contextmenu");
+        BrowserSearch._loadSearch("foo", false, "contextmenu", Services.scriptSecurityManager.getSystemPrincipal());
       }
     },
     {
       name: "keyword search",
       searchURL: base + engineDetails.codes.keyword,
       run() {
         gURLBar.value = "? foo";
         gURLBar.focus();
--- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js
@@ -158,17 +158,17 @@ let setupTest = async function(options, 
 
 /**
  * Loads a TEST_URLS into a browser window.
  *
  * @param win (Window)
  *        The browser window to load the tabs in
  */
 function injectTestTabs(win) {
-  let promises = TEST_URLS.map(url => win.gBrowser.addTab(url))
+  let promises = TEST_URLS.map(url => BrowserTestUtils.addTab(win.gBrowser, url))
                           .map(tab => BrowserTestUtils.browserLoaded(tab.linkedBrowser));
   return Promise.all(promises);
 }
 
 /**
  * Attempts to close a window via BrowserTryToCloseWindow so that
  * we get the browser-lastwindow-close-requested and
  * browser-lastwindow-close-granted observer notifications.
@@ -308,17 +308,17 @@ add_task(async function test_open_close_
     let popupPromise = BrowserTestUtils.waitForNewWindow();
     openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[0]);
     let popup = await popupPromise;
 
     let popup2Promise = BrowserTestUtils.waitForNewWindow();
     openDialog(location, "popup2", POPUP_FEATURES, TEST_URLS[1]);
     let popup2 = await popup2Promise;
 
-    popup2.gBrowser.addTab(TEST_URLS[0]);
+    BrowserTestUtils.addTab(popup2.gBrowser, TEST_URLS[0]);
 
     let closed = await closeWindowForRestoration(newWin);
     ok(closed, "Should be able to close the window");
 
     await BrowserTestUtils.closeWindow(popup2);
 
     newWin = await promiseNewWindowLoaded();
 
@@ -373,17 +373,17 @@ add_task(async function test_open_close_
 
     let closed = await closeWindowForRestoration(popup);
     ok(closed, "Should be able to close the window");
 
     popupPromise = BrowserTestUtils.waitForNewWindow();
     openDialog(location, "popup", POPUP_FEATURES, TEST_URLS[1]);
     popup = await popupPromise;
 
-    popup.gBrowser.addTab(TEST_URLS[0]);
+    BrowserTestUtils.addTab(popup.gBrowser, TEST_URLS[0]);
     is(popup.gBrowser.browsers.length, 2,
        "Did not restore to the popup window (2)");
 
     await BrowserTestUtils.closeWindow(popup);
 
     newWin = await promiseNewWindowLoaded();
     isnot(newWin.gBrowser.browsers.length, 2,
           "Did not restore the popup window");
--- a/browser/components/sessionstore/test/browser_625016.js
+++ b/browser/components/sessionstore/test/browser_625016.js
@@ -20,17 +20,17 @@ add_task(async function setup() {
   forgetClosedWindows();
   is(ss.getClosedWindowCount(), 0, "starting with no closed windows");
 });
 
 add_task(async function new_window() {
   let newWin;
   try {
     newWin = await promiseNewWindowLoaded();
-    let tab = newWin.gBrowser.addTab("http://example.com/browser_625016.js?" + Math.random());
+    let tab = BrowserTestUtils.addTab(newWin.gBrowser, "http://example.com/browser_625016.js?" + Math.random());
     await promiseBrowserLoaded(tab.linkedBrowser);
 
     // Double check that we have no closed windows
     is(ss.getClosedWindowCount(), 0, "no closed windows on first save");
 
     await BrowserTestUtils.closeWindow(newWin);
     newWin = null;
 
--- a/browser/components/sessionstore/test/browser_819510_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_819510_perwindowpb.js
@@ -108,12 +108,12 @@ add_task(async function test_3() {
     "Closed windows are not private");
 
   // Cleanup.
   await promiseAllButPrimaryWindowClosed();
   forgetClosedWindows();
 });
 
 async function promiseTabLoad(win, url) {
-  let tab = win.gBrowser.addTab(url);
+  let tab = BrowserTestUtils.addTab(win.gBrowser, url);
   await promiseBrowserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
 }
--- a/browser/components/sessionstore/test/browser_broadcast.js
+++ b/browser/components/sessionstore/test/browser_broadcast.js
@@ -111,17 +111,17 @@ add_task(async function flush_on_tabclos
 
 function promiseNewWindow() {
   return new Promise(resolve => {
     whenNewWindowLoaded({private: false}, resolve);
   });
 }
 
 async function createTabWithStorageData(urls, win = window) {
-  let tab = win.gBrowser.addTab();
+  let tab = BrowserTestUtils.addTab(win.gBrowser);
   let browser = tab.linkedBrowser;
 
   for (let url of urls) {
     browser.loadURI(url);
     await promiseBrowserLoaded(browser);
     await modifySessionStorage(browser, {test: INITIAL_VALUE});
   }
 
--- a/browser/components/sessionstore/test/browser_cleaner.js
+++ b/browser/components/sessionstore/test/browser_cleaner.js
@@ -45,17 +45,17 @@ add_task(async function init() {
 add_task(async function test_open_and_close() {
   let newTab1 = BrowserTestUtils.addTab(gBrowser, URL_TAB1);
   await promiseBrowserLoaded(newTab1.linkedBrowser);
 
   let newTab2 = BrowserTestUtils.addTab(gBrowser, URL_TAB2);
   await promiseBrowserLoaded(newTab2.linkedBrowser);
 
   let newWin = await promiseNewWindowLoaded();
-  let tab = newWin.gBrowser.addTab(URL_NEWWIN);
+  let tab = BrowserTestUtils.addTab(newWin.gBrowser, URL_NEWWIN);
 
   await promiseBrowserLoaded(tab.linkedBrowser);
 
   await TabStateFlusher.flushWindow(window);
   await TabStateFlusher.flushWindow(newWin);
 
   info("1. Making sure that before closing, we don't have closedAt");
   // For the moment, no "closedAt"
--- a/browser/components/sessionstore/test/browser_crashedTabs.js
+++ b/browser/components/sessionstore/test/browser_crashedTabs.js
@@ -295,17 +295,17 @@ add_task(async function test_revive_all_
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
   // In order to see a second about:tabcrashed page, we'll need
   // a second window, since only selected tabs will show
   // about:tabcrashed.
   let win2 = await BrowserTestUtils.openNewBrowserWindow();
-  let newTab2 = win2.gBrowser.addTab(PAGE_1, { sameProcessAsFrameLoader: browser.frameLoader });
+  let newTab2 = BrowserTestUtils.addTab(win2.gBrowser, PAGE_1, { sameProcessAsFrameLoader: browser.frameLoader });
   win2.gBrowser.selectedTab = newTab2;
   let browser2 = newTab2.linkedBrowser;
   ok(browser2.isRemoteBrowser, "Should be a remote browser");
   await promiseBrowserLoaded(browser2);
 
   browser.loadURI(PAGE_1);
   await promiseBrowserLoaded(browser);
 
@@ -402,17 +402,17 @@ add_task(async function test_hide_restor
   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();
-  let newTab3 = win2.gBrowser.addTab(PAGE_2, { sameProcessAsFrameLoader: browser.frameLoader });
+  let newTab3 = BrowserTestUtils.addTab(win2.gBrowser, PAGE_2, { sameProcessAsFrameLoader: browser.frameLoader });
   win2.gBrowser.selectedTab = newTab3;
   let otherWinBrowser = newTab3.linkedBrowser;
   await promiseBrowserLoaded(otherWinBrowser);
   // We'll need to make sure the second tab's browser has finished
   // sending its AboutTabCrashedReady event before we know for
   // sure whether or not we're showing the right Restore buttons.
   let otherBrowserReady = promiseTabCrashedReady(otherWinBrowser);
 
--- a/browser/components/sessionstore/test/browser_dying_cache.js
+++ b/browser/components/sessionstore/test/browser_dying_cache.js
@@ -11,17 +11,17 @@ add_task(async function test() {
   let win = await promiseNewWindowLoaded();
 
   // Load some URL in the current tab.
   let flags = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
   win.gBrowser.selectedBrowser.loadURI("about:robots", { flags });
   await promiseBrowserLoaded(win.gBrowser.selectedBrowser);
 
   // Open a second tab and close the first one.
-  let tab = win.gBrowser.addTab("about:mozilla");
+  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
   await promiseBrowserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
   await promiseRemoveTabAndSessionState(win.gBrowser.tabs[0]);
 
   // Make sure our window is still tracked by sessionstore
   // and the window state is as expected.
   ok("__SSi" in win, "window is being tracked by sessionstore");
   ss.setWindowValue(win, "foo", "bar");
--- a/browser/components/sessionstore/test/browser_privatetabs.js
+++ b/browser/components/sessionstore/test/browser_privatetabs.js
@@ -67,31 +67,31 @@ add_task(async function() {
   forgetClosedWindows();
 
   // Create a new window to attach our frame script to.
   let win = await promiseNewWindowLoaded();
   let mm = win.getGroupMessageManager("browsers");
   mm.loadFrameScript(FRAME_SCRIPT, true);
 
   // Create a new tab in the new window that will load the frame script.
-  let tab = win.gBrowser.addTab("about:mozilla");
+  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   await TabStateFlusher.flush(browser);
 
   // Check that we consider the tab as private.
   let state = JSON.parse(ss.getTabState(tab));
   ok(state.isPrivate, "tab considered private");
 
   // Ensure we don't allow restoring closed private tabs in non-private windows.
   win.gBrowser.removeTab(tab);
   is(ss.getClosedTabCount(win), 0, "no tabs to restore");
 
   // Create a new tab in the new window that will load the frame script.
-  tab = win.gBrowser.addTab("about:mozilla");
+  tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
   browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   await TabStateFlusher.flush(browser);
 
   // Check that we consider the tab as private.
   state = JSON.parse(ss.getTabState(tab));
   ok(state.isPrivate, "tab considered private");
 
@@ -104,17 +104,17 @@ add_task(async function() {
 add_task(async function() {
   // Clear the list of closed windows.
   forgetClosedWindows();
 
   // Create a new window to attach our frame script to.
   let win = await promiseNewWindowLoaded({private: true});
 
   // Create a new tab in the new window that will load the frame script.
-  let tab = win.gBrowser.addTab("about:mozilla");
+  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   await TabStateFlusher.flush(browser);
 
   // Check that we consider the tab as private.
   let state = JSON.parse(ss.getTabState(tab));
   ok(state.isPrivate, "tab considered private");
 
--- a/browser/components/sessionstore/test/browser_scrollPositions.js
+++ b/browser/components/sessionstore/test/browser_scrollPositions.js
@@ -111,17 +111,17 @@ add_task(async function test_scroll_nest
  * a restored window (bug 1228518).
  * Also test that scroll positions for previous session history entries
  * are preserved as well (bug 1265818).
  */
 add_task(async function test_scroll_background_tabs() {
   pushPrefs(["browser.sessionstore.restore_on_demand", true]);
 
   let newWin = await BrowserTestUtils.openNewBrowserWindow();
-  let tab = newWin.gBrowser.addTab(URL);
+  let tab = BrowserTestUtils.addTab(newWin.gBrowser, URL);
   let browser = tab.linkedBrowser;
   await BrowserTestUtils.browserLoaded(browser);
 
   // Scroll down a little.
   await sendMessage(browser, "ss-test:setScrollPosition", {x: SCROLL_X, y: SCROLL_Y});
   await checkScroll(tab, {scroll: SCROLL_STR}, "scroll on first page is fine");
 
   // Navigate to a different page and scroll there as well.
--- a/browser/components/sessionstore/test/browser_scrollPositionsReaderMode.js
+++ b/browser/components/sessionstore/test/browser_scrollPositionsReaderMode.js
@@ -16,17 +16,17 @@ requestLongerTimeout(2);
 /**
  * Test that scroll positions of about reader page after restoring background
  * tabs in a restored window (bug 1153393).
  */
 add_task(async function test_scroll_background_about_reader_tabs() {
   pushPrefs(["browser.sessionstore.restore_on_demand", true]);
 
   let newWin = await BrowserTestUtils.openNewBrowserWindow();
-  let tab = newWin.gBrowser.addTab(READER_MODE_URL);
+  let tab = BrowserTestUtils.addTab(newWin.gBrowser, READER_MODE_URL);
   let browser = tab.linkedBrowser;
   await Promise.all([
     BrowserTestUtils.browserLoaded(browser),
     BrowserTestUtils.waitForContentEvent(browser, "AboutReaderContentReady")
   ]);
 
   // Scroll down a little.
   await sendMessage(browser, "ss-test:setScrollPosition", {x: 0, y: SCROLL_READER_MODE_Y});
--- a/browser/components/sessionstore/test/browser_switch_remoteness.js
+++ b/browser/components/sessionstore/test/browser_switch_remoteness.js
@@ -11,17 +11,17 @@ function countHistoryEntries(browser, ex
   });
 }
 
 add_task(async function() {
   // Open a new window.
   let win = await promiseNewWindowLoaded();
 
   // Add a new tab.
-  let tab = win.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   await promiseBrowserLoaded(browser);
   ok(browser.isRemoteBrowser, "browser is remote");
 
   // Get the maximum number of preceding entries to save.
   const MAX_BACK = Services.prefs.getIntPref("browser.sessionstore.max_serialize_back");
   ok(MAX_BACK > -1, "check that the default has a value that caps data");
 
--- a/browser/components/sessionstore/test/browser_undoCloseById.js
+++ b/browser/components/sessionstore/test/browser_undoCloseById.js
@@ -3,17 +3,17 @@
 
 /**
  * This test is for the undoCloseById function.
  */
 
 ChromeUtils.import("resource:///modules/sessionstore/SessionStore.jsm");
 
 async function openAndCloseTab(window, url) {
-  let tab = window.gBrowser.addTab(url);
+  let tab = BrowserTestUtils.addTab(window.gBrowser, url);
   await promiseBrowserLoaded(tab.linkedBrowser, true, url);
   await TabStateFlusher.flush(tab.linkedBrowser);
   await promiseRemoveTabAndSessionState(tab);
 }
 
 async function openWindow(url) {
   let win = await promiseNewWindowLoaded();
   let flags = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
--- a/browser/components/sessionstore/test/browser_windowStateContainer.js
+++ b/browser/components/sessionstore/test/browser_windowStateContainer.js
@@ -8,17 +8,19 @@ add_task(async function setup() {
   });
 });
 
 add_task(async function() {
   let win = await BrowserTestUtils.openNewBrowserWindow();
 
   // Create 4 tabs with different userContextId.
   for (let userContextId = 1; userContextId < 5; userContextId++) {
-    let tab = win.gBrowser.addTab("http://example.com/", {userContextId});
+    let tab = BrowserTestUtils.addTab(win.gBrowser, "http://example.com/", {
+      userContextId,
+    });
     await promiseBrowserLoaded(tab.linkedBrowser);
     await TabStateFlusher.flush(tab.linkedBrowser);
   }
 
   // Move the default tab of window to the end.
   // We want the 1st tab to have non-default userContextId, so later when we
   // restore into win2 we can test restore into an existing tab with different
   // userContextId.
@@ -31,17 +33,19 @@ add_task(async function() {
                  "1st Window: tabs[" + i + "].userContextId should exist.");
   }
 
   let win2 = await BrowserTestUtils.openNewBrowserWindow();
 
   // Create tabs with different userContextId, but this time we create them with
   // fewer tabs and with different order with win.
   for (let userContextId = 3; userContextId > 0; userContextId--) {
-    let tab = win2.gBrowser.addTab("http://example.com/", {userContextId});
+    let tab = BrowserTestUtils.addTab(win2.gBrowser, "http://example.com/", {
+      userContextId,
+    });
     await promiseBrowserLoaded(tab.linkedBrowser);
     await TabStateFlusher.flush(tab.linkedBrowser);
   }
 
   await setWindowState(win2, winState, true);
 
   for (let i = 0; i < 4; i++) {
     let browser = win2.gBrowser.tabs[i].linkedBrowser;
@@ -71,33 +75,37 @@ add_task(async function() {
   await BrowserTestUtils.closeWindow(win);
   await BrowserTestUtils.closeWindow(win2);
 });
 
 add_task(async function() {
   let win = await BrowserTestUtils.openNewBrowserWindow();
   await TabStateFlusher.flush(win.gBrowser.selectedBrowser);
 
-  let tab = win.gBrowser.addTab("http://example.com/", { userContextId: 1 });
+  let tab = BrowserTestUtils.addTab(win.gBrowser, "http://example.com/", {
+    userContextId: 1,
+  });
   await promiseBrowserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
 
   // win should have 1 default tab, and 1 container tab.
   Assert.equal(win.gBrowser.tabs.length, 2, "win should have 2 tabs");
 
   let winState = JSON.parse(ss.getWindowState(win));
 
   for (let i = 0; i < 2; i++) {
     Assert.equal(winState.windows[0].tabs[i].userContextId, i,
                  "1st Window: tabs[" + i + "].userContextId should be " + i);
   }
 
   let win2 = await BrowserTestUtils.openNewBrowserWindow();
 
-  let tab2 = win2.gBrowser.addTab("http://example.com/", { userContextId: 1 });
+  let tab2 = BrowserTestUtils.addTab(win2.gBrowser, "http://example.com/", {
+    userContextId: 1,
+  });
   await promiseBrowserLoaded(tab2.linkedBrowser);
   await TabStateFlusher.flush(tab2.linkedBrowser);
 
   // Move the first normal tab to end, so the first tab of win2 will be a
   // container tab.
   win2.gBrowser.moveTabTo(win2.gBrowser.tabs[0], win2.gBrowser.tabs.length - 1);
   await TabStateFlusher.flush(win2.gBrowser.tabs[0].linkedBrowser);
 
--- a/devtools/client/commandline/test/helpers.js
+++ b/devtools/client/commandline/test/helpers.js
@@ -66,17 +66,17 @@ var { helpers, assert } = (function () {
   helpers.addTab = function (url, callback, options) {
     waitForExplicitFinish();
 
     options = options || {};
     options.chromeWindow = options.chromeWindow || window;
     options.isFirefox = true;
 
     var tabbrowser = options.chromeWindow.gBrowser;
-    options.tab = tabbrowser.addTab();
+    options.tab = BrowserTestUtils.addTab(tabbrowser);
     tabbrowser.selectedTab = options.tab;
     options.browser = tabbrowser.getBrowserForTab(options.tab);
     options.target = TargetFactory.forTab(options.tab);
 
     var loaded = BrowserTestUtils.browserLoaded(options.browser).then(function () {
       var reply = callback.call(null, options);
 
       return Promise.resolve(reply).catch(function (error) {
@@ -112,17 +112,17 @@ var { helpers, assert } = (function () {
   helpers.openTab = function (url, options) {
     waitForExplicitFinish();
 
     options = options || {};
     options.chromeWindow = options.chromeWindow || window;
     options.isFirefox = true;
 
     var tabbrowser = options.chromeWindow.gBrowser;
-    options.tab = tabbrowser.addTab();
+    options.tab = BrowserTestUtils.addTab(tabbrowser);
     tabbrowser.selectedTab = options.tab;
     options.browser = tabbrowser.getBrowserForTab(options.tab);
     options.target = TargetFactory.forTab(options.tab);
 
     return helpers.navigate(url, options);
   };
 
 /**
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -83,17 +83,17 @@ function getChromeWindow(aWindow) {
 this.addTab = function addTab(aUrl, aWindow) {
   info("Adding tab: " + aUrl);
 
   let deferred = promise.defer();
   let targetWindow = aWindow || window;
   let targetBrowser = targetWindow.gBrowser;
 
   targetWindow.focus();
-  let tab = targetBrowser.selectedTab = targetBrowser.addTab(aUrl);
+  let tab = targetBrowser.selectedTab = BrowserTestUtils.addTab(targetBrowser, aUrl);
   let linkedBrowser = tab.linkedBrowser;
 
   info("Loading frame script with url " + FRAME_SCRIPT_URL + ".");
   linkedBrowser.messageManager.loadFrameScript(FRAME_SCRIPT_URL, false);
 
   BrowserTestUtils.browserLoaded(linkedBrowser)
     .then(function () {
       info("Tab added and finished loading: " + aUrl);
--- a/devtools/client/styleeditor/test/head.js
+++ b/devtools/client/styleeditor/test/head.js
@@ -23,17 +23,17 @@ const TEST_HOST = "mochi.test:8888";
  */
 var addTab = function(url, win) {
   info("Adding a new tab with URL: '" + url + "'");
 
   return new Promise(resolve => {
     const targetWindow = win || window;
     const targetBrowser = targetWindow.gBrowser;
 
-    const tab = targetBrowser.selectedTab = targetBrowser.addTab(url);
+    const tab = targetBrowser.selectedTab = BrowserTestUtils.addTab(targetBrowser, url);
     BrowserTestUtils.browserLoaded(targetBrowser.selectedBrowser)
       .then(function() {
         info("URL '" + url + "' loading complete");
         resolve(tab);
       });
   });
 };
 
--- a/devtools/client/webconsole/test/mochitest/browser_console_webconsole_private_browsing.js
+++ b/devtools/client/webconsole/test/mochitest/browser_console_webconsole_private_browsing.js
@@ -26,17 +26,17 @@ const PRIVATE_TEST_URI = `data:text/html
   </script>`;
 
 add_task(async function() {
   await addTab(NON_PRIVATE_TEST_URI);
 
   const privateWindow = await openNewBrowserWindow({ private: true });
   ok(PrivateBrowsingUtils.isWindowPrivate(privateWindow), "window is private");
   const privateBrowser = privateWindow.gBrowser;
-  privateBrowser.selectedTab = privateBrowser.addTab(PRIVATE_TEST_URI);
+  privateBrowser.selectedTab = BrowserTestUtils.addTab(privateBrowser, PRIVATE_TEST_URI);
   const privateTab = privateBrowser.selectedTab;
 
   info("private tab opened");
   ok(PrivateBrowsingUtils.isBrowserPrivate(privateBrowser.selectedBrowser),
     "tab window is private");
 
   let hud = await openConsole(privateTab);
   ok(hud, "web console opened");
--- a/devtools/startup/tests/browser/browser_shim_disable_devtools.js
+++ b/devtools/startup/tests/browser/browser_shim_disable_devtools.js
@@ -29,17 +29,18 @@ add_task(async function() {
     CustomizableUI.removeWidgetFromArea("developer-button");
   }
 
   info("Open a new window, all window-specific hooks for DevTools will be disabled.");
   const win = OpenBrowserWindow({private: false});
   await waitForDelayedStartupFinished(win);
 
   info("Open a new tab on the new window to ensure the focus is on the new window");
-  const tab = win.gBrowser.addTab("data:text/html;charset=utf-8,<title>foo</title>");
+  const tab = BrowserTestUtils.addTab(win.gBrowser,
+    "data:text/html;charset=utf-8,<title>foo</title>");
   await BrowserTestUtils.browserLoaded(win.gBrowser.getBrowserForTab(tab));
 
   info("Synthesize a DevTools shortcut, the toolbox should not open on this new window.");
   synthesizeToggleToolboxKey(win);
 
   // There is no event to wait for here as this shortcut should have no effect.
   /* eslint-disable mozilla/no-arbitrary-setTimeout */
   await new Promise(r => setTimeout(r, 1000));
--- a/docshell/test/browser/head.js
+++ b/docshell/test/browser/head.js
@@ -43,17 +43,18 @@ function timelineTestOpenUrl(url) {
 
   let tabSwitchPromise = new Promise((resolve, reject) => {
     window.gBrowser.addEventListener("TabSwitchDone", function() {
       resolve();
     }, {once: true});
   });
 
   let loadPromise = new Promise(function(resolve, reject) {
-    let tab = window.gBrowser.selectedTab = window.gBrowser.addTab(url);
+    let browser = window.gBrowser;
+    let tab = browser.selectedTab = BrowserTestUtils.addTab(browser, url);
     let linkedBrowser = tab.linkedBrowser;
 
     BrowserTestUtils.browserLoaded(linkedBrowser).then(() => resolve(tab));
   });
 
   return Promise.all([tabSwitchPromise, loadPromise]).then(([_, tab]) => tab);
 }
 
--- a/dom/base/test/browser_blocking_image.js
+++ b/dom/base/test/browser_blocking_image.js
@@ -1,15 +1,15 @@
 const TEST_URI = getRootDirectory(gTestPath).replace("chrome://mochitests/content", "https://example.com") + "file_blocking_image.html";
 
 /**
  * Loading an image from https:// should work.
  */
 add_task(async function load_image_from_https_test() {
-  let tab = gBrowser.addTab(TEST_URI);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   gBrowser.selectedTab = tab;
 
   await ContentTask.spawn(tab.linkedBrowser, { }, async function() {
     function imgListener(img) {
       return new Promise((resolve, reject) => {
         img.addEventListener("load", () => resolve());
@@ -33,17 +33,17 @@ add_task(async function load_image_from_
 
   gBrowser.removeTab(tab);
 });
 
 /**
  * Loading an image from http:// should be rejected.
  */
 add_task(async function load_image_from_http_test() {
-  let tab = gBrowser.addTab(TEST_URI);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   gBrowser.selectedTab = tab;
 
   await ContentTask.spawn(tab.linkedBrowser, { }, async function () {
     function imgListener(img) {
       return new Promise((resolve, reject) => {
         img.addEventListener("load", () => reject());
@@ -69,17 +69,17 @@ add_task(async function load_image_from_
   gBrowser.removeTab(tab);
 });
 
 /**
  * Loading an image from http:// immediately after loading from https://
  * The load from https:// should be replaced.
  */
 add_task(async function load_https_and_http_test() {
-  let tab = gBrowser.addTab(TEST_URI);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   // Clear image cache, otherwise in non-e10s mode the image might be cached by
   // previous test, and make the image from https is loaded immediately.
   let imgTools = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools);
   let imageCache = imgTools.getImgCacheForDocument(window.document);
   imageCache.clearCache(false); // false=content
 
@@ -116,17 +116,17 @@ add_task(async function load_https_and_h
 /**
  * Loading an image from https.
  * Then after we have size information of the image, we immediately change the
  * location to a http:// site (hence should be blocked by CSP). This will make
  * the 2nd request as a PENDING_REQUEST, also blocking 2nd load shouldn't change
  * the imageBlockingStatus value.
  */
 add_task(async function block_pending_request_test() {
-  let tab = gBrowser.addTab(TEST_URI);
+  let tab = BrowserTestUtils.addTab(gBrowser, TEST_URI);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   gBrowser.selectedTab = tab;
 
   await ContentTask.spawn(tab.linkedBrowser, { }, async function () {
     let wrapper = {
       _resolve: null,
       _sizeAvail: false,
--- a/dom/broadcastchannel/tests/browser_private_browsing.js
+++ b/dom/broadcastchannel/tests/browser_private_browsing.js
@@ -15,21 +15,21 @@ add_task(async function() {
   var win2 = OpenBrowserWindow({private: false});
   var win2Promise = new win2.Promise(resolve => {
     win2.addEventListener("load", function() {
       resolve();
     }, {once: true});
   });
   await win2Promise;
 
-  var tab1 = win1.gBrowser.addTab(URL);
+  var tab1 = BrowserTestUtils.addTab(win1.gBrowser, URL);
   await BrowserTestUtils.browserLoaded(win1.gBrowser.getBrowserForTab(tab1));
   var browser1 = gBrowser.getBrowserForTab(tab1);
 
-  var tab2 = win2.gBrowser.addTab(URL);
+  var tab2 = BrowserTestUtils.addTab(win2.gBrowser, URL);
   await BrowserTestUtils.browserLoaded(win2.gBrowser.getBrowserForTab(tab2));
   var browser2 = gBrowser.getBrowserForTab(tab2);
 
   var p1 = ContentTask.spawn(browser1, null, function(opts) {
     return new content.window.Promise(resolve => {
       content.window.bc = new content.window.BroadcastChannel('foobar');
       content.window.bc.onmessage = function(e) { resolve(e.data); }
     });
--- a/dom/cache/test/mochitest/browser_cache_pb_window.js
+++ b/dom/cache/test/mochitest/browser_cache_pb_window.js
@@ -98,17 +98,17 @@ function test() {
   let privateWin, privateTab;
   waitForExplicitFinish();
   SpecialPowers.pushPrefEnv({'set': [['dom.caches.enabled', true],
                                      ['dom.caches.testing.enabled', true]]}
   ).then(() => {
     return BrowserTestUtils.openNewBrowserWindow({private: true});
   }).then(pw => {
     privateWin = pw;
-    privateTab = pw.gBrowser.addTab("http://example.com/");
+    privateTab = BrowserTestUtils.addTab(pw.gBrowser, "http://example.com/");
     return BrowserTestUtils.browserLoaded(privateTab.linkedBrowser);
   }).then(tab => {
     return Promise.all([
       testMatch(privateTab.linkedBrowser),
       testHas(privateTab.linkedBrowser),
       testOpen(privateTab.linkedBrowser),
       testDelete(privateTab.linkedBrowser),
       testKeys(privateTab.linkedBrowser),
--- a/dom/html/test/browser_bug1108547.js
+++ b/dom/html/test/browser_bug1108547.js
@@ -38,17 +38,17 @@ function runPass(getterFile, finishedCal
 
     // Now, open a private window.
     privateWin = OpenBrowserWindow({private: true});
       whenDelayedStartupFinished(privateWin, afterPrivateWindowOpened);
   }
 
   function afterPrivateWindowOpened() {
     // In the private window, open the getter file, and wait for a new tab to be opened.
-    privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + getterFile);
+    privateWin.gBrowser.selectedTab = BrowserTestUtils.addTab(privateWin.gBrowser, rootDir + getterFile);
     testBrowser = privateWin.gBrowser.selectedBrowser;
     privateWin.gBrowser.tabContainer.addEventListener("TabOpen", onNewTabOpened, true);
   }
 
   function fetchResult() {
     return ContentTask.spawn(testBrowser, null, function() {
       return content.document.getElementById("result").textContent;
     });
@@ -72,17 +72,17 @@ function runPass(getterFile, finishedCal
 
     // Open a new private window, this time to set a cookie inside it.
     privateWin = OpenBrowserWindow({private: true});
       whenDelayedStartupFinished(privateWin, afterPrivateWindowOpened2);
   }
 
   function afterPrivateWindowOpened2() {
     // In the private window, open the setter file, and wait for it to load.
-    privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab(rootDir + "file_bug1108547-1.html");
+    privateWin.gBrowser.selectedTab = BrowserTestUtils.addTab(privateWin.gBrowser, rootDir + "file_bug1108547-1.html");
     BrowserTestUtils.browserLoaded(privateWin.gBrowser.selectedBrowser).then(afterOpenCookieSetter2);
   }
 
   function afterOpenCookieSetter2() {
     // We're done with the private window now, close it.
     privateWin.close();
 
     // Now try to read the cookie in a normal window, and wait for a new tab to be opened.
--- a/dom/indexedDB/test/browser_permissionsPromptDeny.js
+++ b/dom/indexedDB/test/browser_permissionsPromptDeny.js
@@ -44,17 +44,17 @@ add_task(async function test2() {
   registerPopupEventHandler("popupshown", function() {
     ok(false, "prompt shown");
   }, win);
   registerPopupEventHandler("popuphidden", function() {
     ok(false, "prompt hidden");
   }, win);
 
   info("creating private tab");
-  win.gBrowser.selectedTab = win.gBrowser.addTab();
+  win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser);
 
   info("loading test page: " + testPageURL);
   win.gBrowser.selectedBrowser.loadURI(testPageURL);
   await waitForMessage("InvalidStateError", win.gBrowser);
 
   is(getPermission(testPageURL, "indexedDB"),
      Ci.nsIPermissionManager.DENY_ACTION,
      "Correct permission set");
--- a/dom/indexedDB/test/browser_perwindow_privateBrowsing.js
+++ b/dom/indexedDB/test/browser_perwindow_privateBrowsing.js
@@ -21,15 +21,15 @@ add_task(async function test1() {
   gBrowser.removeCurrentTab();
 });
 
 add_task(async function test2() {
   info("creating private window");
   let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
 
   info("creating tab");
-  win.gBrowser.selectedTab = win.gBrowser.addTab();
+  win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser);
   win.gBrowser.selectedBrowser.loadURI(testPageURL);
   await waitForMessage("InvalidStateError", win.gBrowser);
   win.gBrowser.removeCurrentTab();
   await BrowserTestUtils.closeWindow(win);
   win = null;
 });
--- a/dom/quota/test/browser_permissionsPromptUnknown.js
+++ b/dom/quota/test/browser_permissionsPromptUnknown.js
@@ -17,17 +17,17 @@ add_task(async function testPermissionUn
   registerPopupEventHandler("popupshown", function () {
     ok(false, "Shouldn't show a popup this time");
   }, win);
   registerPopupEventHandler("popuphidden", function () {
     ok(false, "Shouldn't show a popup this time");
   }, win);
 
   info("Creating private tab");
-  win.gBrowser.selectedTab = win.gBrowser.addTab();
+  win.gBrowser.selectedTab = BrowserTestUtils.addTab(win.gBrowser);
 
   info("Loading test page: " + testPageURL);
   win.gBrowser.selectedBrowser.loadURI(testPageURL);
   await waitForMessage(false, win.gBrowser);
 
   is(getPermission(testPageURL, "persistent-storage"),
      Ci.nsIPermissionManager.UNKNOWN_ACTION,
      "Correct permission set");
--- a/dom/tests/browser/browser_localStorage_privatestorageevent.js
+++ b/dom/tests/browser/browser_localStorage_privatestorageevent.js
@@ -10,21 +10,21 @@ add_task(async function() {
   await new pubWin.Promise(resolve => {
     pubWin.addEventListener('load', function() {
       resolve();
     }, {once: true});
   });
 
   var URL = "http://mochi.test:8888/browser/dom/tests/browser/page_privatestorageevent.html";
 
-  var privTab = privWin.gBrowser.addTab(URL);
+  var privTab = BrowserTestUtils.addTab(privWin.gBrowser, URL);
   await BrowserTestUtils.browserLoaded(privWin.gBrowser.getBrowserForTab(privTab));
   var privBrowser = gBrowser.getBrowserForTab(privTab);
 
-  var pubTab = pubWin.gBrowser.addTab(URL);
+  var pubTab = BrowserTestUtils.addTab(pubWin.gBrowser, URL);
   await BrowserTestUtils.browserLoaded(pubWin.gBrowser.getBrowserForTab(pubTab));
   var pubBrowser = gBrowser.getBrowserForTab(pubTab);
 
   // Check if pubWin can see privWin's storage events
   await ContentTask.spawn(pubBrowser, null, function(opts) {
     content.window.gotStorageEvent = false;
     content.window.addEventListener('storage', ev => {
       content.window.gotStorageEvent = true;
--- a/dom/tests/browser/helper_largeAllocation.js
+++ b/dom/tests/browser/helper_largeAllocation.js
@@ -415,17 +415,18 @@ async function largeAllocSuccessTests() 
 
     let pid2 = await getPID(aBrowser);
 
     isnot(pid1, pid2, "PIDs 1 and 2 should not match");
     is(true, await getInLAProc(aBrowser));
 
     let newWindow = await BrowserTestUtils.openNewBrowserWindow();
 
-    newWindow.gBrowser.adoptTab(gBrowser.getTabForBrowser(aBrowser), 0);
+    newWindow.gBrowser.adoptTab(gBrowser.getTabForBrowser(aBrowser), 0, null,
+                                Services.scriptSecurityManager.getSystemPrincipal());
     let newTab = newWindow.gBrowser.tabs[0];
 
     is(newTab.linkedBrowser.currentURI.spec, TEST_URI);
     is(newTab.linkedBrowser.remoteType, "webLargeAllocation");
     let pid3 = await getPID(newTab.linkedBrowser);
 
     is(pid2, pid3, "PIDs 2 and 3 should match");
     is(true, await getInLAProc(newTab.linkedBrowser));
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
+++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
@@ -191,17 +191,17 @@ var BrowserTestUtils = {
       }
 
       promises = [
         BrowserTestUtils.switchTab(tabbrowser, function() {
           if (typeof opening == "function") {
             opening();
             tab = tabbrowser.selectedTab;
           } else {
-            tabbrowser.selectedTab = tab = tabbrowser.addTab(opening);
+            tabbrowser.selectedTab = tab = BrowserTestUtils.addTab(tabbrowser, opening);
           }
         })
       ];
 
       if (aWaitForLoad) {
         promises.push(BrowserTestUtils.browserLoaded(tab.linkedBrowser));
       }
       if (aWaitForStateStop) {
--- a/testing/mochitest/api.js
+++ b/testing/mochitest/api.js
@@ -90,17 +90,18 @@ var WindowListener = {
 function loadMochitest(e) {
   let flavor = e.detail[0];
   let url = e.detail[1];
 
   let win = Services.wm.getMostRecentWindow("navigator:browser");
   win.removeEventListener("mochitest-load", loadMochitest);
 
   // for mochitest-plain, navigating to the url is all we need
-  win.loadURI(url);
+  win.loadURI(url, null, null, null, null, null, null, null,
+    Services.scriptSecurityManager.getSystemPrincipal());
   if (flavor == "mochitest") {
     return;
   }
 
   WindowListener.setupWindow(win);
   Services.wm.addListener(WindowListener);
 
   loadChromeScripts(win);
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -571,17 +571,20 @@ Tester.prototype = {
           }));
         }
         gBrowser.removeTab(lastTab);
       }
     }
 
     // Replace the last tab with a fresh one
     if (window.gBrowser) {
-      gBrowser.addTab("about:blank", { skipAnimation: true });
+      gBrowser.addTab("about:blank", {
+        skipAnimation: true,
+        triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
+      });
       gBrowser.removeTab(gBrowser.selectedTab, { skipPermitUnload: true });
       gBrowser.stop();
     }
 
     // Remove stale windows
     this.structuredLogger.info("checking window state");
     let windowsEnum = Services.wm.getEnumerator(null);
     while (windowsEnum.hasMoreElements()) {
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_tab_separators.js
+++ b/toolkit/components/extensions/test/browser/browser_ext_themes_tab_separators.js
@@ -13,17 +13,17 @@ add_task(async function test_support_tab
         },
       },
     },
   });
   await extension.startup();
 
   info("Checking background tab separator color");
 
-  let tab = gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
 
   Assert.equal(window.getComputedStyle(tab, "::before").borderLeftColor,
                `rgb(${hexToRGB(TAB_SEPARATOR_COLOR).join(", ")})`,
                "Left separator has right color.");
 
   Assert.equal(window.getComputedStyle(tab, "::after").borderLeftColor,
                `rgb(${hexToRGB(TAB_SEPARATOR_COLOR).join(", ")})`,
                "Right separator has right color.");
--- a/toolkit/content/tests/browser/browser_block_autoplay_media.js
+++ b/toolkit/content/tests/browser/browser_block_autoplay_media.js
@@ -33,25 +33,25 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function block_autoplay_media() {
   info("- open new background tab1 -");
-  let tab1 = window.gBrowser.addTab("about:blank");
+  let tab1 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab1.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
 
   info("- should block autoplay media for non-visited tab1 -");
   await check_audio_suspended(tab1.linkedBrowser, SuspendedType.SUSPENDED_BLOCK);
 
   info("- open new background tab2 -");
-  let tab2 = window.gBrowser.addTab("about:blank");
+  let tab2 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab2.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
 
   info("- should block autoplay for non-visited tab2 -");
   await check_audio_suspended(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK);
 
   info("- select tab1 as foreground tab -");
   await BrowserTestUtils.switchTab(window.gBrowser, tab1);
@@ -85,17 +85,17 @@ add_task(async function block_autoplay_m
   // to satisfy the autoplay requirements on its own.
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.autoplay.default", SpecialPowers.Ci.nsIAutoplay.PROMPT],
     ["media.autoplay.enabled.user-gestures-needed", true],
     ["media.autoplay.ask-permission", true],
   ]});
 
   info("- open new background tab4 -");
-  let tab4 = window.gBrowser.addTab("about:blank");
+  let tab4 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab4.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab4.linkedBrowser);
   info("- should block autoplay for non-visited tab4 -");
   await check_audio_suspended(tab4.linkedBrowser, SuspendedType.SUSPENDED_BLOCK);
   await check_audio_paused(tab4.linkedBrowser, true);
   tab4.linkedBrowser.resumeMedia();
   info("- should not block media from tab4 -");
   await waitForTabPlayingEvent(tab4, true);
--- a/toolkit/content/tests/browser/browser_block_autoplay_media_pausedAfterPlay.js
+++ b/toolkit/content/tests/browser/browser_block_autoplay_media_pausedAfterPlay.js
@@ -32,27 +32,27 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function block_autoplay_media() {
   info("- open new background tab1, and check tab1's media suspend type -");
-  let tab1 = window.gBrowser.addTab("about:blank");
+  let tab1 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab1.linkedBrowser.loadURI(PAGE_SHOULD_NOT_PLAY);
   await BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
   await ContentTask.spawn(tab1.linkedBrowser, SuspendedType.NONE_SUSPENDED,
                           check_audio_suspended);
 
   info("- the tab1 should not be blocked -");
   await waitForTabBlockEvent(tab1, false);
 
   info("- open new background tab2, and check tab2's media suspend type -");
-  let tab2 = window.gBrowser.addTab("about:blank");
+  let tab2 = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab2.linkedBrowser.loadURI(PAGE_SHOULD_PLAY);
   await BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
   await ContentTask.spawn(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
                           check_audio_suspended);
 
   info("- the tab2 should be blocked -");
   await waitForTabBlockEvent(tab2, true);
 
--- a/toolkit/content/tests/browser/browser_block_autoplay_playAfterTabVisible.js
+++ b/toolkit/content/tests/browser/browser_block_autoplay_playAfterTabVisible.js
@@ -53,17 +53,17 @@ add_task(async function setup_test_prefe
 
 /**
  * This test is used for testing the visible tab which was not resumed yet.
  * If the tab doesn't have any media component, it won't be resumed even it
  * has already gone to foreground until we start audio.
  */
 add_task(async function media_should_be_able_to_play_in_visible_tab() {
   info("- open new background tab, and check tab's media pause state -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   await ContentTask.spawn(tab.linkedBrowser, true,
                           check_audio_pause_state);
 
   info("- select tab as foreground tab, and tab's media should still be paused -");
   await BrowserTestUtils.switchTab(window.gBrowser, tab);
   await ContentTask.spawn(tab.linkedBrowser, true,
--- a/toolkit/content/tests/browser/browser_block_multipleMedia.js
+++ b/toolkit/content/tests/browser/browser_block_multipleMedia.js
@@ -79,17 +79,17 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function block_multiple_media() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
   browser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(browser);
 
   info("- tab should be blocked -");
   await waitForTabBlockEvent(tab, true);
 
   info("- autoplay media should be blocked -");
--- a/toolkit/content/tests/browser/browser_block_notInTreeAudio.js
+++ b/toolkit/content/tests/browser/browser_block_notInTreeAudio.js
@@ -47,17 +47,17 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function block_not_in_tree_media() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("- tab should not be blocked -");
   await waitForTabBlockEvent(tab, false);
 
   info("- check audio's suspend state -");
   await ContentTask.spawn(tab.linkedBrowser, SuspendedType.NONE_SUSPENDED,
--- a/toolkit/content/tests/browser/browser_block_playMediaInMuteTab.js
+++ b/toolkit/content/tests/browser/browser_block_playMediaInMuteTab.js
@@ -58,17 +58,17 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function unblock_icon_should_disapear_after_resume_tab() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("- audio doesn't be started in beginning -");
   await ContentTask.spawn(tab.linkedBrowser, true,
                           check_audio_pause_state);
 
   info("- audio shouldn't be muted or blocked -");
--- a/toolkit/content/tests/browser/browser_block_plugIn.js
+++ b/toolkit/content/tests/browser/browser_block_plugIn.js
@@ -5,17 +5,17 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function block_plug_in() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("- tab should be blocked -");
   await waitForTabBlockEvent(tab, true);
 
   info("- switch tab -");
   await BrowserTestUtils.switchTab(window.gBrowser, tab);
--- a/toolkit/content/tests/browser/browser_block_silentAudioTrack_media.js
+++ b/toolkit/content/tests/browser/browser_block_silentAudioTrack_media.js
@@ -29,17 +29,17 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function unblock_icon_should_disapear_after_resume_tab() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("- the suspend state of tab should be suspend-block -");
   await ContentTask.spawn(tab.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
                           check_audio_suspended);
 
   info("- tab should display unblocking icon -");
@@ -59,17 +59,17 @@ add_task(async function unblock_icon_sho
   await waitForTabPlayingEvent(tab, false);
 
   info("- remove tab -");
   BrowserTestUtils.removeTab(tab);
 });
 
 add_task(async function should_not_show_sound_indicator_after_resume_tab() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("- the suspend state of tab should be suspend-block -");
   await ContentTask.spawn(tab.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
                           check_audio_suspended);
 
   info("- tab should display unblocking icon -");
--- a/toolkit/content/tests/browser/browser_block_webAudio.js
+++ b/toolkit/content/tests/browser/browser_block_webAudio.js
@@ -11,17 +11,17 @@ add_task(async function setup_test_prefe
   await SpecialPowers.pushPrefEnv({"set": [
     ["media.useAudioChannelService.testing", true],
     ["media.block-autoplay-until-in-foreground", true]
   ]});
 });
 
 add_task(async function block_web_audio() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   tab.linkedBrowser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   info("- tab should be blocked -");
   await waitForTabBlockEvent(tab, true);
 
   info("- switch tab -");
   await BrowserTestUtils.switchTab(window.gBrowser, tab);
--- a/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js
+++ b/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js
@@ -97,17 +97,17 @@ add_task(async function setup_test_prefe
 
 /**
  * TODO : add the following user-level tests after fixing bug1029451.
  * test1 - only affect the unselected tab
  * test2 - only affect the tab with suspended video
  */
 add_task(async function resume_and_suspend_background_video_decoding() {
   info("- open new background tab -");
-  let tab = window.gBrowser.addTab("about:blank");
+  let tab = BrowserTestUtils.addTab(window.gBrowser, "about:blank");
   let browser = tab.linkedBrowser;
 
   info("- before loading media, we shoudn't send the tab hover msg for tab -");
   await check_should_not_send_unselected_tab_hover_msg(browser);
   browser.loadURI(PAGE);
   await BrowserTestUtils.browserLoaded(browser);
 
   info("- should suspend background video decoding -");