Bug 1514164 - Change urlbar tests to use the test path rather than hard-coding it. r=mak
authorMark Banner <standard8@mozilla.com>
Mon, 21 Jan 2019 16:57:48 +0000
changeset 514726 ba9f9c0ce2561b72c6dedd0bf5817ba452bb4638
parent 514725 565a04cfb0e443328f4b2c74e2ce439fc12eaa9f
child 514727 306a66424aad636fc9ec9010dd605f72fdc47b94
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1514164
milestone66.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 1514164 - Change urlbar tests to use the test path rather than hard-coding it. r=mak Differential Revision: https://phabricator.services.mozilla.com/D16995
browser/base/content/test/urlbar/browser_action_keyword.js
browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js
browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js
browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js
browser/base/content/test/urlbar/browser_bug1225194-remotetab.js
browser/base/content/test/urlbar/browser_bug304198.js
browser/base/content/test/urlbar/browser_bug556061.js
browser/base/content/test/urlbar/browser_bug623155.js
browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js
browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar_perwindowpb.js
browser/base/content/test/urlbar/browser_urlbarCopying.js
browser/base/content/test/urlbar/browser_urlbarHashChangeProxyState.js
browser/base/content/test/urlbar/browser_urlbarRaceWithTabs.js
browser/base/content/test/urlbar/browser_urlbar_blanking.js
browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js
browser/base/content/test/urlbar/browser_urlbar_stop_pending.js
browser/base/content/test/urlbar/browser_wyciwyg_urlbarCopying.js
--- a/browser/base/content/test/urlbar/browser_action_keyword.js
+++ b/browser/base/content/test/urlbar/browser_action_keyword.js
@@ -1,16 +1,18 @@
 async function promise_first_result(inputText) {
   await promiseAutocompleteResultPopup(inputText);
 
   let firstResult = gURLBar.popup.richlistbox.firstElementChild;
   return firstResult;
 }
 
-const TEST_URL = "http://mochi.test:8888/browser/browser/base/content/test/urlbar/print_postdata.sjs";
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://mochi.test:8888");
+const TEST_URL = `${TEST_PATH}print_postdata.sjs`;
 
 add_task(async function setup() {
   await PlacesUtils.keywords.insert({ keyword: "get",
                                       url: TEST_URL + "?q=%s" });
   await PlacesUtils.keywords.insert({ keyword: "post",
                                       url: TEST_URL,
                                       postData: "q=%s" });
   registerCleanupFunction(async function() {
--- a/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js
+++ b/browser/base/content/test/urlbar/browser_bug1003461-switchtab-override.js
@@ -1,17 +1,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-add_task(async function test_switchtab_override() {
-  let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.org/");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
 
+
+add_task(async function test_switchtab_override() {
   info("Opening first tab");
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testURL);
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
 
   info("Opening and selecting second tab");
   let secondTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(() => {
     try {
       gBrowser.removeTab(tab);
       gBrowser.removeTab(secondTab);
     } catch (ex) { /* tabs may have already been closed in case of failure */ }
--- a/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js
+++ b/browser/base/content/test/urlbar/browser_bug1024133-switchtab-override-keynav.js
@@ -1,17 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-add_task(async function test_switchtab_override_keynav() {
-  let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.org");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
 
+add_task(async function test_switchtab_override_keynav() {
   info("Opening first tab");
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, testURL);
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
 
   info("Opening and selecting second tab");
   let secondTab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
   registerCleanupFunction(() => {
     try {
       gBrowser.removeTab(tab);
       gBrowser.removeTab(secondTab);
     } catch (ex) { /* tabs may have already been closed in case of failure */ }
--- a/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js
+++ b/browser/base/content/test/urlbar/browser_bug1104165-switchtab-decodeuri.js
@@ -1,11 +1,14 @@
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.org");
+const TEST_URL = `${TEST_PATH}dummy_page.html#test%7C1`;
+
 add_task(async function test_switchtab_decodeuri() {
   info("Opening first tab");
-  const TEST_URL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#test%7C1";
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
 
   info("Opening and selecting second tab");
   gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   info("Wait for autocomplete");
   await promiseAutocompleteResultPopup("dummy_page");
 
--- a/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js
+++ b/browser/base/content/test/urlbar/browser_bug1225194-remotetab.js
@@ -1,16 +1,19 @@
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.org");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
+
 add_task(async function test_remotetab_opens() {
-  const url = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
   await BrowserTestUtils.withNewTab({url: "about:robots", gBrowser}, async function() {
     // Set the urlbar to include the moz-action
-    gURLBar.value = "moz-action:remotetab," + JSON.stringify({ url });
+    gURLBar.value = "moz-action:remotetab," + JSON.stringify({ url: TEST_URL });
     // Focus the urlbar so we can press enter
     gURLBar.focus();
 
     // The URL is going to open in the current tab as it is currently about:blank
     let promiseTabLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
     EventUtils.synthesizeKey("KEY_Enter");
     await promiseTabLoaded;
 
-    Assert.equal(gBrowser.selectedTab.linkedBrowser.currentURI.spec, url, "correct URL loaded");
+    Assert.equal(gBrowser.selectedTab.linkedBrowser.currentURI.spec, TEST_URL, "correct URL loaded");
   });
 });
--- a/browser/base/content/test/urlbar/browser_bug304198.js
+++ b/browser/base/content/test/urlbar/browser_bug304198.js
@@ -1,20 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.com");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
+
 add_task(async function() {
   let charsToDelete, deletedURLTab, fullURLTab, partialURLTab, testPartialURL, testURL;
 
   charsToDelete = 5;
   deletedURLTab = BrowserTestUtils.addTab(gBrowser);
   fullURLTab = BrowserTestUtils.addTab(gBrowser);
   partialURLTab = BrowserTestUtils.addTab(gBrowser);
-  testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
+  testURL = TEST_URL;
 
   let loaded1 = BrowserTestUtils.browserLoaded(deletedURLTab.linkedBrowser, false, testURL);
   let loaded2 = BrowserTestUtils.browserLoaded(fullURLTab.linkedBrowser, false, testURL);
   let loaded3 = BrowserTestUtils.browserLoaded(partialURLTab.linkedBrowser, false, testURL);
   BrowserTestUtils.loadURI(deletedURLTab.linkedBrowser, testURL);
   BrowserTestUtils.loadURI(fullURLTab.linkedBrowser, testURL);
   BrowserTestUtils.loadURI(partialURLTab.linkedBrowser, testURL);
   await Promise.all([loaded1, loaded2, loaded3]);
--- a/browser/base/content/test/urlbar/browser_bug556061.js
+++ b/browser/base/content/test/urlbar/browser_bug556061.js
@@ -1,15 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-var testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
-var testActionURL = "moz-action:switchtab," + JSON.stringify({url: testURL});
-testURL = gURLBar.trimValue(testURL);
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.com");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
+var testActionURL = "moz-action:switchtab," + JSON.stringify({url: TEST_URL});
+const testURL = gURLBar.trimValue(TEST_URL);
 var testTab;
 
 function runNextTest() {
   if (tests.length) {
     let t = tests.shift();
     waitForClipboard(t.expected, t.setup, function() {
       t.success();
       runNextTest();
--- a/browser/base/content/test/urlbar/browser_bug623155.js
+++ b/browser/base/content/test/urlbar/browser_bug623155.js
@@ -1,43 +1,40 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-const REDIRECT_FROM = "https://example.com/browser/browser/base/content/test/urlbar/" +
-                      "redirect_bug623155.sjs";
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.com");
+const REDIRECT_FROM = `${TEST_PATH}redirect_bug623155.sjs`;
 
 const REDIRECT_TO = "https://www.bank1.com/"; // Bad-cert host.
 
 function isRedirectedURISpec(aURISpec) {
   return isRedirectedURI(Services.io.newURI(aURISpec));
 }
 
 function isRedirectedURI(aURI) {
   // Compare only their before-hash portion.
   return Services.io.newURI(REDIRECT_TO)
                  .equalsExceptRef(aURI);
 }
 
 /*
    Test.
 
-1. Load
-https://example.com/browser/browser/base/content/test/urlbar/redirect_bug623155.sjs#BG
-   in a background tab.
+1. Load redirect_bug623155.sjs#BG in a background tab.
 
 2. The redirected URI is <https://www.bank1.com/#BG>, which displayes a cert
    error page.
 
 3. Switch the tab to foreground.
 
 4. Check the URLbar's value, expecting <https://www.bank1.com/#BG>
 
-5. Load
-https://example.com/browser/browser/base/content/test/urlbar/redirect_bug623155.sjs#FG
-   in the foreground tab.
+5. Load redirect_bug623155.sjs#FG in the foreground tab.
 
 6. The redirected URI is <https://www.bank1.com/#FG>. And this is also
    a cert-error page.
 
 7. Check the URLbar's value, expecting <https://www.bank1.com/#FG>
 
 8. End.
 
--- a/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js
+++ b/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar.js
@@ -1,19 +1,21 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * vim:set ts=2 sw=2 sts=2 et:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 requestLongerTimeout(2);
 
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.com");
 const TEST_URL_BASES = [
-  "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#tabmatch",
-  "http://example.org/browser/browser/base/content/test/urlbar/moz.png#tabmatch",
+  `${TEST_PATH}dummy_page.html#tabmatch`,
+  `${TEST_PATH}moz.png#tabmatch`,
 ];
 
 const RESTRICT_TOKEN_OPENPAGE = "%";
 
 var gController = Cc["@mozilla.org/autocomplete/controller;1"].
                   getService(Ci.nsIAutoCompleteController);
 
 var gTabCounter = 0;
@@ -132,17 +134,17 @@ function loadTab(tab, url) {
   });
 
   info("Loading page: " + url);
   BrowserTestUtils.loadURI(tab.linkedBrowser, url);
   return Promise.all([ loaded, visited ]);
 }
 
 function ensure_opentabs_match_db() {
-  var tabs = {};
+  let tabs = {};
 
   for (let browserWin of Services.wm.getEnumerator("navigator:browser")) {
     // skip closed-but-not-destroyed windows
     if (browserWin.closed)
       continue;
 
     for (let i = 0; i < browserWin.gBrowser.tabContainer.childElementCount; i++) {
       let browser = browserWin.gBrowser.getBrowserAtIndex(i);
--- a/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar_perwindowpb.js
+++ b/browser/base/content/test/urlbar/browser_tabMatchesInAwesomebar_perwindowpb.js
@@ -1,9 +1,11 @@
-let testURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.com");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
 
 add_task(async function() {
   let normalWindow = await BrowserTestUtils.openNewBrowserWindow();
   let privateWindow = await BrowserTestUtils.openNewBrowserWindow({private: true});
   await runTest(normalWindow, privateWindow, false);
   await BrowserTestUtils.closeWindow(normalWindow);
   await BrowserTestUtils.closeWindow(privateWindow);
 
@@ -18,17 +20,17 @@ add_task(async function() {
   await BrowserTestUtils.closeWindow(privateWindow);
 
   normalWindow = await BrowserTestUtils.openNewBrowserWindow();
   await runTest(normalWindow, normalWindow, true);
   await BrowserTestUtils.closeWindow(normalWindow);
 });
 
 async function runTest(aSourceWindow, aDestWindow, aExpectSwitch, aCallback) {
-  await BrowserTestUtils.openNewForegroundTab(aSourceWindow.gBrowser, testURL);
+  await BrowserTestUtils.openNewForegroundTab(aSourceWindow.gBrowser, TEST_URL);
   let testTab = await BrowserTestUtils.openNewForegroundTab(aDestWindow.gBrowser);
 
   info("waiting for focus on the window");
   await SimpleTest.promiseFocus(aDestWindow);
   info("got focus on the window");
 
   // Select the testTab
   aDestWindow.gBrowser.selectedTab = testTab;
@@ -49,17 +51,17 @@ async function runTest(aSourceWindow, aD
   await ContentTask.spawn(testTab.linkedBrowser, null, async function() {
     ok(!content.document.body.hasChildNodes(),
        "The test tab has no child nodes");
   });
   ok(!testTab.hasAttribute("busy"),
      "The test tab doesn't have the busy attribute");
 
   // Wait for the Awesomebar popup to appear.
-  await promiseAutocompleteResultPopup(testURL, aDestWindow);
+  await promiseAutocompleteResultPopup(TEST_URL, aDestWindow);
 
   info(`awesomebar popup appeared. aExpectSwitch: ${aExpectSwitch}`);
   // Make sure the last match is selected.
   let {controller, popup} = aDestWindow.gURLBar;
   while (popup.selectedIndex < controller.matchCount - 1) {
     info("handling key navigation for DOM_VK_DOWN key");
     controller.handleKeyNavigation(KeyEvent.DOM_VK_DOWN);
   }
--- a/browser/base/content/test/urlbar/browser_urlbarCopying.js
+++ b/browser/base/content/test/urlbar/browser_urlbarCopying.js
@@ -1,17 +1,21 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const trimPref = "browser.urlbar.trimURLs";
 const phishyUserPassPref = "network.http.phishy-userpass-length";
 const decodeURLpref = "browser.urlbar.decodeURLsOnCopy";
 
+function getUrl(hostname, file) {
+  return getRootDirectory(gTestPath)
+    .replace("chrome://mochitests/content", hostname) + file;
+}
+
 function test() {
-
   let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
 
   registerCleanupFunction(function() {
     gBrowser.removeTab(tab);
     Services.prefs.clearUserPref(trimPref);
     Services.prefs.clearUserPref(phishyUserPassPref);
     Services.prefs.clearUserPref(decodeURLpref);
     URLBarSetURI();
@@ -91,19 +95,19 @@ var tests = [
   },
   {
     copyVal: "<example>.com/foo",
     copyExpected: "example",
   },
 
   // Test that userPass is stripped out
   {
-    loadURL: "http://user:pass@mochi.test:8888/browser/browser/base/content/test/urlbar/authenticate.sjs?user=user&pass=pass",
-    expectedURL: "mochi.test:8888/browser/browser/base/content/test/urlbar/authenticate.sjs?user=user&pass=pass",
-    copyExpected: "http://mochi.test:8888/browser/browser/base/content/test/urlbar/authenticate.sjs?user=user&pass=pass",
+    loadURL: getUrl("http://user:pass@mochi.test:8888", "authenticate.sjs?user=user&pass=pass"),
+    expectedURL: getUrl("mochi.test:8888", "authenticate.sjs?user=user&pass=pass"),
+    copyExpected: getUrl("http://mochi.test:8888", "authenticate.sjs?user=user&pass=pass"),
   },
 
   // Test escaping
   {
     loadURL: "http://example.com/()%28%29%C3%A9",
     expectedURL: "example.com/()()\xe9",
     copyExpected: "http://example.com/()%28%29%C3%A9",
   },
--- a/browser/base/content/test/urlbar/browser_urlbarHashChangeProxyState.js
+++ b/browser/base/content/test/urlbar/browser_urlbarHashChangeProxyState.js
@@ -1,16 +1,19 @@
 "use strict";
 
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "https://example.org");
+
 /**
  * Check that navigating through both the URL bar and using in-page hash- or ref-
  * based links and back or forward navigation updates the URL bar and identity block correctly.
  */
 add_task(async function() {
-  let baseURL = "https://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
+  let baseURL = `${TEST_PATH}dummy_page.html`;
   let url = baseURL + "#foo";
   await BrowserTestUtils.withNewTab({ gBrowser, url }, async function(browser) {
     let identityBox = document.getElementById("identity-box");
     let expectedURL = url;
 
     let verifyURLBarState = testType => {
       is(gURLBar.textValue, expectedURL, "URL bar visible value should be correct " + testType);
       is(gURLBar.value, expectedURL, "URL bar value should be correct " + testType);
@@ -87,24 +90,23 @@ add_task(async function() {
 /**
  * Check that initial secure loads that swap remoteness
  * get the correct page icon when finished.
  */
 add_task(async function() {
   // Ensure there's no preloaded newtab browser, since that'll not fire a load event.
   gBrowser.removePreloadedBrowser();
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:newtab");
-  let url = "https://example.org/browser/browser/base/content/test/urlbar/dummy_page.html#foo";
+  let url = `${TEST_PATH}dummy_page.html#foo`;
   gURLBar.value = url;
   gURLBar.select();
   EventUtils.sendKey("return");
   await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
 
   is(gURLBar.textValue, url, "URL bar visible value should be correct when the page loads from about:newtab");
   is(gURLBar.value, url, "URL bar value should be correct when the page loads from about:newtab");
   let identityBox = document.getElementById("identity-box");
   ok(identityBox.classList.contains("verifiedDomain"),
      "Identity box should know we're doing SSL when the page loads from about:newtab");
   is(gURLBar.getAttribute("pageproxystate"), "valid",
      "URL bar is in valid page proxy state when SSL page with hash loads from about:newtab");
   BrowserTestUtils.removeTab(tab);
 });
-
--- a/browser/base/content/test/urlbar/browser_urlbarRaceWithTabs.js
+++ b/browser/base/content/test/urlbar/browser_urlbarRaceWithTabs.js
@@ -1,9 +1,11 @@
-const kURL = "http://example.org/browser/browser/base/content/test/urlbar/dummy_page.html";
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://example.com");
+const TEST_URL = `${TEST_PATH}dummy_page.html`;
 
 async function addBookmark(bookmark) {
   if (bookmark.keyword) {
     await PlacesUtils.keywords.insert({
       keyword: bookmark.keyword,
       url: bookmark.url,
     });
   }
@@ -25,33 +27,33 @@ async function addBookmark(bookmark) {
 /**
  * Check that if the user hits enter and ctrl-t at the same time, we open the URL in the right tab.
  */
 add_task(async function hitEnterLoadInRightTab() {
   info("Opening new tab");
   let oldTabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen");
   BrowserOpenTab();
   let oldTab = (await oldTabCreatedPromise).target;
-  let oldTabLoadedPromise = BrowserTestUtils.browserLoaded(oldTab.linkedBrowser, false, kURL);
+  let oldTabLoadedPromise = BrowserTestUtils.browserLoaded(oldTab.linkedBrowser, false, TEST_URL);
   oldTabLoadedPromise.then(() => info("Old tab loaded"));
   let newTabCreatedPromise = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "TabOpen");
 
   info("Creating bookmark and keyword");
-  await addBookmark({title: "Test for keyword bookmark and URL", url: kURL, keyword: "urlbarkeyword"});
+  await addBookmark({title: "Test for keyword bookmark and URL", url: TEST_URL, keyword: "urlbarkeyword"});
   info("Filling URL bar, sending <return> and opening a tab");
   gURLBar.value = "urlbarkeyword";
   gURLBar.select();
   EventUtils.sendKey("return");
   BrowserOpenTab();
   info("Waiting for new tab");
   let newTab = (await newTabCreatedPromise).target;
   info("Created new tab; waiting for either tab to load");
-  let newTabLoadedPromise = BrowserTestUtils.browserLoaded(newTab.linkedBrowser, false, kURL);
+  let newTabLoadedPromise = BrowserTestUtils.browserLoaded(newTab.linkedBrowser, false, TEST_URL);
   newTabLoadedPromise.then(() => info("New tab loaded"));
   await Promise.race([newTabLoadedPromise, oldTabLoadedPromise]);
   is(newTab.linkedBrowser.currentURI.spec, "about:newtab", "New tab still has about:newtab");
-  is(oldTab.linkedBrowser.currentURI.spec, kURL, "Old tab loaded URL");
+  is(oldTab.linkedBrowser.currentURI.spec, TEST_URL, "Old tab loaded URL");
   info("Closing new tab");
   BrowserTestUtils.removeTab(newTab);
   info("Closing old tab");
   BrowserTestUtils.removeTab(oldTab);
   info("Finished");
 });
--- a/browser/base/content/test/urlbar/browser_urlbar_blanking.js
+++ b/browser/base/content/test/urlbar/browser_urlbar_blanking.js
@@ -1,26 +1,29 @@
 "use strict";
 
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://www.example.com");
+const TEST_URL = `${TEST_PATH}file_blank_but_not_blank.html`;
+
 add_task(async function() {
   for (let page of gInitialPages) {
     if (page == "about:newtab") {
       // New tab preloading makes this a pain to test, so skip
       continue;
     }
     let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, page);
     ok(!gURLBar.value, "The URL bar should be empty if we load a plain " + page + " page.");
     BrowserTestUtils.removeTab(tab);
   }
 });
 
 add_task(async function() {
-  const URI = "http://www.example.com/browser/browser/base/content/test/urlbar/file_blank_but_not_blank.html";
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URI);
-  is(gURLBar.value, URI, "The URL bar should match the URI");
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
+  is(gURLBar.value, TEST_URL, "The URL bar should match the URI");
   let browserLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
   ContentTask.spawn(tab.linkedBrowser, null, function() {
     content.document.querySelector("a").click();
   });
   await browserLoaded;
   ok(gURLBar.value.startsWith("javascript"), "The URL bar should have the JS URI");
   // When reloading, the javascript: uri we're using will throw an exception.
   // That's deliberate, so we need to tell mochitest to ignore it:
--- a/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js
+++ b/browser/base/content/test/urlbar/browser_urlbar_locationchange_urlbar_edit_dos.js
@@ -1,10 +1,14 @@
 "use strict";
 
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://www.example.com");
+const TEST_URL = `${TEST_PATH}file_urlbar_edit_dos.html`;
+
 async function checkURLBarValueStays(browser) {
   gURLBar.select();
   EventUtils.sendString("a");
   is(gURLBar.value, "a", "URL bar value should match after sending a key");
   await new Promise(resolve => {
     let listener = {
       onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
         ok(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT,
@@ -20,22 +24,21 @@ async function checkURLBarValueStays(bro
     gBrowser.selectedBrowser.addProgressListener(filter);
   });
   is(gURLBar.value, "a", "URL bar should not have been changed by location changes.");
 }
 
 add_task(async function() {
   await BrowserTestUtils.withNewTab({
     gBrowser,
-    url: "http://example.com/browser/browser/base/content/test/urlbar/file_urlbar_edit_dos.html",
+    url: TEST_URL,
   }, async function(browser) {
     await ContentTask.spawn(browser, "", function() {
       content.wrappedJSObject.dos_hash();
     });
     await checkURLBarValueStays(browser);
     await ContentTask.spawn(browser, "", function() {
       content.clearTimeout(content.wrappedJSObject.dos_timeout);
       content.wrappedJSObject.dos_pushState();
     });
     await checkURLBarValueStays(browser);
   });
 });
-
--- a/browser/base/content/test/urlbar/browser_urlbar_stop_pending.js
+++ b/browser/base/content/test/urlbar/browser_urlbar_stop_pending.js
@@ -1,13 +1,15 @@
 /* eslint-disable mozilla/no-arbitrary-setTimeout */
 "use strict";
 
-const SLOW_PAGE = "http://www.example.com/browser/browser/base/content/test/urlbar/slow-page.sjs";
-const SLOW_PAGE2 = "http://mochi.test:8888/browser/browser/base/content/test/urlbar/slow-page.sjs?faster";
+const SLOW_PAGE = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://www.example.com") + "slow-page.sjs";
+const SLOW_PAGE2 = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://mochi.test:8888") + "slow-page.sjs?faster";
 
 /**
  * Check that if we:
  * 1) have a loaded page
  * 2) load a separate URL
  * 3) before the URL for step 2 has finished loading, load a third URL
  * we don't revert to the URL from (1).
  */
@@ -131,9 +133,8 @@ add_task(async function() {
   browserStoppedPromise = BrowserTestUtils.browserStopped(newTab.linkedBrowser, null, true);
   BrowserStop();
   await browserStoppedPromise;
 
   is(gURLBar.value, SLOW_HOST2, "Should still have second slow page in URL bar after stop");
   BrowserTestUtils.removeTab(newTab);
   BrowserTestUtils.removeTab(tab);
 });
-
--- a/browser/base/content/test/urlbar/browser_wyciwyg_urlbarCopying.js
+++ b/browser/base/content/test/urlbar/browser_wyciwyg_urlbarCopying.js
@@ -1,31 +1,34 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+const TEST_PATH = getRootDirectory(gTestPath)
+  .replace("chrome://mochitests/content", "http://mochi.test:8888");
+const TEST_URL = `${TEST_PATH}test_wyciwyg_copying.html`;
+
 function testURLBarCopy(targetValue) {
   return new Promise((resolve, reject) => {
     info("Expecting copy of: " + targetValue);
     waitForClipboard(targetValue, function() {
       gURLBar.focus();
       gURLBar.select();
 
       goDoCommand("cmd_copy");
     }, resolve, () => {
       ok(false, "Clipboard copy failed");
       reject();
     });
   });
 }
 
 add_task(async function() {
-  const url = "http://mochi.test:8888/browser/browser/base/content/test/urlbar/test_wyciwyg_copying.html";
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
 
   await BrowserTestUtils.synthesizeMouseAtCenter("#btn", {}, tab.linkedBrowser);
   let currentURL = gBrowser.currentURI.spec;
   ok(/^wyciwyg:\/\//i.test(currentURL), currentURL + " is a wyciwyg URI");
 
-  await testURLBarCopy(url);
+  await testURLBarCopy(TEST_URL);
 
   while (gBrowser.tabs.length > 1)
     gBrowser.removeCurrentTab();
 });