Bug 1417639 move tests out of mochitest-chrome, r=rpl
authorShane Caraveo <scaraveo@mozilla.com>
Mon, 08 Jan 2018 14:50:43 -0800
changeset 452575 bf64f49f19aabfe55a90865fb69a7c9ae240912b
parent 452574 6e1f415d09e80e1914b649d5780c580f3e038423
child 452576 66429a3ae434ca926625fb2fcba7221843d5d00f
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1417639
milestone59.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 1417639 move tests out of mochitest-chrome, r=rpl MozReview-Commit-ID: CUYe2WNyzHj
toolkit/components/extensions/test/mochitest/chrome.ini
toolkit/components/extensions/test/mochitest/head_cookies.js
toolkit/components/extensions/test/mochitest/mochitest-common.ini
toolkit/components/extensions/test/mochitest/mochitest.ini
toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_errors.html
toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
toolkit/components/extensions/test/mochitest/test_ext_eventpage_warning.html
toolkit/components/extensions/test/mochitest/test_ext_idle.html
toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html
toolkit/components/extensions/test/mochitest/test_ext_schema.html
toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html
toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html
toolkit/components/extensions/test/xpcshell/test_ext_trustworthy_origin.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
--- a/toolkit/components/extensions/test/mochitest/chrome.ini
+++ b/toolkit/components/extensions/test/mochitest/chrome.ini
@@ -6,37 +6,27 @@ support-files =
   head_cookies.js
   file_image_great.png
   file_sample.html
   file_with_images.html
   webrequest_chromeworker.js
   webrequest_test.jsm
 tags = webextensions in-process-webextensions
 
+# NO NEW TESTS.  mochitest-chrome does not run under e10s, avoid adding new
+# tests here unless absolutely necessary.
+
 [test_chrome_ext_contentscript_data_uri.html]
 [test_chrome_ext_contentscript_telemetry.html]
 [test_chrome_ext_contentscript_unrecognizedprop_warning.html]
 [test_chrome_ext_downloads_open.html]
 [test_chrome_ext_downloads_saveAs.html]
 [test_chrome_ext_downloads_uniquify.html]
-[test_chrome_ext_eventpage_warning.html]
-[test_chrome_ext_idle.html]
 [test_chrome_ext_permissions.html]
 skip-if = os == 'android' # Bug 1350559
-[test_chrome_ext_storage_cleanup.html]
 [test_chrome_ext_trackingprotection.html]
-[test_chrome_ext_trustworthy_origin.html]
 [test_chrome_ext_webnavigation_resolved_urls.html]
 [test_chrome_ext_webrequest_background_events.html]
-[test_chrome_ext_webrequest_errors.html]
 [test_chrome_ext_webrequest_host_permissions.html]
 [test_chrome_ext_webrequest_mozextension.html]
 skip-if = true # Bug 1404172
 [test_chrome_native_messaging_paths.html]
 skip-if = os != "mac" && os != "linux"
-[test_ext_cookies_expiry.html]
-[test_ext_cookies_permissions_bad.html]
-[test_ext_cookies_permissions_good.html]
-[test_ext_cookies_containers.html]
-[test_ext_jsversion.html]
-[test_ext_schema.html]
-[test_ext_protocolHandlers.html]
-skip-if = (toolkit == 'android') # bug 1342577
--- a/toolkit/components/extensions/test/mochitest/head_cookies.js
+++ b/toolkit/components/extensions/test/mochitest/head_cookies.js
@@ -1,13 +1,14 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 /* exported testCookies */
+/* import-globals-from head.js */
 
 async function testCookies(options) {
   // Changing the options object is a bit of a hack, but it allows us to easily
   // pass an expiration date to the background script.
   options.expiry = Date.now() / 1000 + 3600;
 
   async function background(backgroundOptions) {
     // Ask the parent scope to change some cookies we may or may not have
@@ -20,17 +21,16 @@ async function testCookies(options) {
     });
 
     let changed = [];
     browser.cookies.onChanged.addListener(event => {
       changed.push(`${event.cookie.name}:${event.cause}`);
     });
     browser.test.sendMessage("change-cookies");
 
-
     // Try to access some cookies in various ways.
     let {url, domain, secure} = backgroundOptions;
 
     let failures = 0;
     let tallyFailure = error => {
       failures++;
     };
 
@@ -86,82 +86,109 @@ async function testCookies(options) {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": options.permissions,
     },
 
     background: `(${background})(${JSON.stringify(options)})`,
   });
 
-
-  let cookieSvc = SpecialPowers.Services.cookies;
-
-  let domain = options.domain.replace(/^\.?/, ".");
-
-  // This will be evicted after we add a fourth cookie.
-  cookieSvc.add(domain, "/", "evicted", "bar", options.secure, false, false, options.expiry);
-  // This will be modified by the background script.
-  cookieSvc.add(domain, "/", "foo", "bar", options.secure, false, false, options.expiry);
-  // This will be deleted by the background script.
-  cookieSvc.add(domain, "/", "deleted", "bar", options.secure, false, false, options.expiry);
-
+  let stepOne = loadChromeScript(() => {
+    const {addMessageListener, sendAsyncMessage} = this;
+    addMessageListener("options", options => {
+      let domain = options.domain.replace(/^\.?/, ".");
+      // This will be evicted after we add a fourth cookie.
+      Services.cookies.add(domain, "/", "evicted", "bar", options.secure, false, false, options.expiry);
+      // This will be modified by the background script.
+      Services.cookies.add(domain, "/", "foo", "bar", options.secure, false, false, options.expiry);
+      // This will be deleted by the background script.
+      Services.cookies.add(domain, "/", "deleted", "bar", options.secure, false, false, options.expiry);
+      sendAsyncMessage("done");
+    });
+  });
+  stepOne.sendAsyncMessage("options", options);
+  await stepOne.promiseOneMessage("done");
+  stepOne.destroy();
 
   await extension.startup();
 
   await extension.awaitMessage("change-cookies");
-  cookieSvc.add(domain, "/", "x", "y", options.secure, false, false, options.expiry);
-  cookieSvc.add(domain, "/", "x", "z", options.secure, false, false, options.expiry);
-  cookieSvc.remove(domain, "x", "/", false, {});
+
+  let stepTwo = loadChromeScript(() => {
+    const {addMessageListener, sendAsyncMessage} = this;
+    addMessageListener("options", options => {
+      let domain = options.domain.replace(/^\.?/, ".");
+
+      Services.cookies.add(domain, "/", "x", "y", options.secure, false, false, options.expiry);
+      Services.cookies.add(domain, "/", "x", "z", options.secure, false, false, options.expiry);
+      Services.cookies.remove(domain, "x", "/", false, {});
+      sendAsyncMessage("done");
+    });
+  });
+  stepTwo.sendAsyncMessage("options", options);
+  await stepTwo.promiseOneMessage("done");
+  stepTwo.destroy();
+
   extension.sendMessage("cookies-changed");
 
   await extension.awaitFinish("cookie-permissions");
   await extension.unload();
 
 
-  function getCookies(host) {
-    let cookies = [];
-    let enum_ = cookieSvc.getCookiesFromHost(host, {});
-    while (enum_.hasMoreElements()) {
-      cookies.push(enum_.getNext().QueryInterface(SpecialPowers.Ci.nsICookie2));
-    }
-    return cookies.sort((a, b) => a.name.localeCompare(b.name));
-  }
+  let stepThree = loadChromeScript(() => {
+    const {addMessageListener, sendAsyncMessage, assert} = this;
+    let cookieSvc = Services.cookies;
 
-  let cookies = getCookies(options.domain);
-  info(`Cookies: ${cookies.map(c => `${c.name}=${c.value}`)}`);
+    function getCookies(host) {
+      let cookies = [];
+      let enum_ = cookieSvc.getCookiesFromHost(host, {});
+      while (enum_.hasMoreElements()) {
+        cookies.push(enum_.getNext().QueryInterface(Components.interfaces.nsICookie2));
+      }
+      return cookies.sort((a, b) => a.name.localeCompare(b.name));
+    }
 
-  if (options.shouldPass) {
-    is(cookies.length, 2, "expected two cookies for host");
+    addMessageListener("options", options => {
+      let cookies = getCookies(options.domain);
 
-    is(cookies[0].name, "bar", "correct cookie name");
-    is(cookies[0].value, "quux", "correct cookie value");
+      if (options.shouldPass) {
+        assert.equal(cookies.length, 2, "expected two cookies for host");
+
+        assert.equal(cookies[0].name, "bar", "correct cookie name");
+        assert.equal(cookies[0].value, "quux", "correct cookie value");
 
-    is(cookies[1].name, "foo", "correct cookie name");
-    is(cookies[1].value, "baz", "correct cookie value");
-  } else if (options.shouldWrite) {
-    // Note: |shouldWrite| applies only when |shouldPass| is false.
-    // This is necessary because, unfortunately, websites (and therefore web
-    // extensions) are allowed to write some cookies which they're not allowed
-    // to read.
-    is(cookies.length, 3, "expected three cookies for host");
+        assert.equal(cookies[1].name, "foo", "correct cookie name");
+        assert.equal(cookies[1].value, "baz", "correct cookie value");
+      } else if (options.shouldWrite) {
+        // Note: |shouldWrite| applies only when |shouldPass| is false.
+        // This is necessary because, unfortunately, websites (and therefore web
+        // extensions) are allowed to write some cookies which they're not allowed
+        // to read.
+        assert.equal(cookies.length, 3, "expected three cookies for host");
 
-    is(cookies[0].name, "bar", "correct cookie name");
-    is(cookies[0].value, "quux", "correct cookie value");
+        assert.equal(cookies[0].name, "bar", "correct cookie name");
+        assert.equal(cookies[0].value, "quux", "correct cookie value");
+
+        assert.equal(cookies[1].name, "deleted", "correct cookie name");
 
-    is(cookies[1].name, "deleted", "correct cookie name");
+        assert.equal(cookies[2].name, "foo", "correct cookie name");
+        assert.equal(cookies[2].value, "baz", "correct cookie value");
+      } else {
+        assert.equal(cookies.length, 2, "expected two cookies for host");
 
-    is(cookies[2].name, "foo", "correct cookie name");
-    is(cookies[2].value, "baz", "correct cookie value");
-  } else {
-    is(cookies.length, 2, "expected two cookies for host");
+        assert.equal(cookies[0].name, "deleted", "correct second cookie name");
 
-    is(cookies[0].name, "deleted", "correct second cookie name");
+        assert.equal(cookies[1].name, "foo", "correct cookie name");
+        assert.equal(cookies[1].value, "bar", "correct cookie value");
+      }
 
-    is(cookies[1].name, "foo", "correct cookie name");
-    is(cookies[1].value, "bar", "correct cookie value");
-  }
-
-  for (let cookie of cookies) {
-    cookieSvc.remove(cookie.host, cookie.name, "/", false, {});
-  }
-  // Make sure we don't silently poison subsequent tests if something goes wrong.
-  is(getCookies(options.domain).length, 0, "cookies cleared");
+      for (let cookie of cookies) {
+        cookieSvc.remove(cookie.host, cookie.name, "/", false, {});
+      }
+      // Make sure we don't silently poison subsequent tests if something goes wrong.
+      assert.equal(getCookies(options.domain).length, 0, "cookies cleared");
+      sendAsyncMessage("done");
+    });
+  });
+  stepThree.sendAsyncMessage("options", options);
+  await stepThree.promiseOneMessage("done");
+  stepThree.destroy();
 }
--- a/toolkit/components/extensions/test/mochitest/mochitest-common.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest-common.ini
@@ -1,162 +1,174 @@
 [DEFAULT]
 support-files =
   chrome_cleanup_script.js
-  head.js
-  head_unlimitedStorage.js
-  head_webrequest.js
-  mochitest_console.js
-  hsts.sjs
-  file_mixed.html
+  file_WebNavigation_page1.html
+  file_WebNavigation_page2.html
+  file_WebNavigation_page3.html
+  file_WebRequest_page3.html
+  file_WebRequest_permission_original.html
+  file_WebRequest_permission_original.js
+  file_WebRequest_permission_redirected.html
+  file_WebRequest_permission_redirected.js
   file_csp.html
   file_csp.html^headers^
+  file_ext_test_api_injection.js
+  file_image_bad.png
+  file_image_good.png
+  file_image_great.png
+  file_image_redirect.png
+  file_mixed.html
   file_page_xhr.html
+  file_permission_xhr.html
+  file_privilege_escalation.html
+  file_remote_frame.html
+  file_sample.html
+  file_script_bad.js
+  file_script_good.js
+  file_script_redirect.js
+  file_script_xhr.js
+  file_simple_sandboxed_frame.html
+  file_simple_sandboxed_subframe.html
+  file_simple_xhr.html
+  file_simple_xhr_frame.html
+  file_simple_xhr_frame2.html
+  file_style_bad.css
+  file_style_good.css
+  file_style_redirect.css
+  file_teardown_test.js
   file_to_drawWindow.html
-  file_WebRequest_page3.html
-  file_WebRequest_permission_original.html
-  file_WebRequest_permission_redirected.html
-  file_WebRequest_permission_original.js
-  file_WebRequest_permission_redirected.js
   file_webNavigation_clientRedirect.html
   file_webNavigation_clientRedirect_httpHeaders.html
   file_webNavigation_clientRedirect_httpHeaders.html^headers^
-  file_webrequestblocking_set_cookie.html
-  file_webrequestblocking_set_cookie.html^headers^
   file_webNavigation_frameClientRedirect.html
   file_webNavigation_frameRedirect.html
   file_webNavigation_manualSubframe.html
   file_webNavigation_manualSubframe_page1.html
   file_webNavigation_manualSubframe_page2.html
-  file_WebNavigation_page1.html
-  file_WebNavigation_page2.html
-  file_WebNavigation_page3.html
+  file_webrequestblocking_set_cookie.html
+  file_webrequestblocking_set_cookie.html^headers^
   file_with_about_blank.html
-  file_image_good.png
-  file_image_great.png
-  file_image_bad.png
-  file_image_redirect.png
-  file_style_good.css
-  file_style_bad.css
-  file_style_redirect.css
-  file_script_good.js
-  file_script_bad.js
-  file_script_redirect.js
-  file_script_xhr.js
-  file_remote_frame.html
-  file_sample.html
-  file_simple_sandboxed_frame.html
-  file_simple_sandboxed_subframe.html
-  file_simple_xhr.html
-  file_simple_xhr_frame.html
-  file_simple_xhr_frame2.html
+  head.js
+  head_cookies.js
+  head_unlimitedStorage.js
+  head_webrequest.js
+  hsts.sjs
+  lorem.html.gz
+  lorem.html.gz^headers^
+  mochitest_console.js
+  oauth.html
   redirect_auto.sjs
   redirection.sjs
-  file_privilege_escalation.html
-  file_ext_test_api_injection.js
-  file_permission_xhr.html
-  file_teardown_test.js
-  lorem.html.gz
-  lorem.html.gz^headers^
   return_headers.sjs
   slow_response.sjs
   webrequest_worker.js
-  oauth.html
+  !/dom/tests/mochitest/geolocation/network_geolocation.sjs
   !/toolkit/components/passwordmgr/test/authenticate.sjs
-  !/dom/tests/mochitest/geolocation/network_geolocation.sjs
 
+[test_ext_background_api_injection.html]
+[test_ext_background_generated_url.html]
+[test_ext_background_canvas.html]
 [test_ext_background_page.html]
 skip-if = (toolkit == 'android') # android doesn't have devtools
+[test_ext_background_teardown.html]
 [test_ext_clipboard.html]
 [test_ext_clipboard_image.html]
 skip-if = headless # disabled test case with_permission_allow_copy, see inline comment. Headless: Bug 1405872
-[test_ext_inIncognitoContext_window.html]
-skip-if = os == 'android' # Android does not support multiple windows.
-[test_ext_geturl.html]
-[test_ext_background_canvas.html]
 [test_ext_content_security_policy.html]
+[test_ext_contentscript_about_blank.html]
+skip-if = os == 'android' # bug 1369440
 [test_ext_contentscript_api_injection.html]
 [test_ext_contentscript_async_loading.html]
 skip-if = os == 'android' && debug # The generated script takes too long to load on Android debug
 [test_ext_contentscript_cache.html]
 skip-if = (os == 'linux' && debug) || (toolkit == 'android' && debug) # bug 1348241
 [test_ext_contentscript_canvas.html]
 [test_ext_contentscript_context.html]
 [test_ext_contentscript_create_iframe.html]
+[test_ext_contentscript_css.html]
 [test_ext_contentscript_devtools_metadata.html]
 [test_ext_contentscript_exporthelpers.html]
 [test_ext_contentscript_incognito.html]
 skip-if = os == 'android' # Android does not support multiple windows.
-[test_ext_contentscript_css.html]
-[test_ext_contentscript_about_blank.html]
-skip-if = os == 'android' # bug 1369440
-[test_ext_webrequestblocking_set_cookie.html]
 [test_ext_contentscript_permission.html]
 [test_ext_contentscript_teardown.html]
+[test_ext_cookies.html]
+[test_ext_cookies_containers.html]
+[test_ext_cookies_expiry.html]
+[test_ext_cookies_first_party.html]
+[test_ext_cookies_permissions_bad.html]
+[test_ext_cookies_permissions_good.html]
+[test_ext_eventpage_warning.html]
 [test_ext_exclude_include_globs.html]
 [test_ext_external_messaging.html]
 [test_ext_generate.html]
 [test_ext_geolocation.html]
 skip-if = os == 'android' # Android support Bug 1336194
+[test_ext_geturl.html]
 [test_ext_identity.html]
 skip-if = os == 'android' # unsupported.
+[test_ext_idle.html]
+[test_ext_inIncognitoContext_window.html]
+skip-if = os == 'android' # Android does not support multiple windows.
+[test_ext_jsversion.html]
+[test_ext_listener_proxies.html]
 [test_ext_new_tab_processType.html]
 [test_ext_notifications.html]
 skip-if = os == "win" # Bug 1398518
 [test_ext_permission_xhr.html]
+[test_ext_protocolHandlers.html]
+skip-if = (toolkit == 'android') # bug 1342577
 [test_ext_redirect_jar.html]
 [test_ext_runtime_connect.html]
 [test_ext_runtime_connect_twoway.html]
 [test_ext_runtime_connect2.html]
 [test_ext_runtime_disconnect.html]
 [test_ext_runtime_id.html]
 [test_ext_sandbox_var.html]
+[test_ext_schema.html]
 [test_ext_sendmessage_doublereply.html]
 [test_ext_sendmessage_frameId.html]
 [test_ext_sendmessage_no_receiver.html]
 [test_ext_sendmessage_reply.html]
 [test_ext_sendmessage_reply2.html]
 skip-if = true # Bug 1258897
 [test_ext_storage_content.html]
 [test_ext_storage_tab.html]
 [test_ext_storage_manager_capabilities.html]
 scheme=https
-[test_ext_test.html]
-[test_ext_cookies.html]
-[test_ext_cookies_first_party.html]
-[test_ext_background_api_injection.html]
-[test_ext_background_generated_url.html]
-[test_ext_background_teardown.html]
+[test_ext_subframes_privileges.html]
 [test_ext_tab_teardown.html]
 skip-if = os == 'android' # Bug 1258975 on android.
+[test_ext_test.html]
 [test_ext_unlimitedStorage.html]
 [test_ext_unlimitedStorage_legacy_persistent_indexedDB.html]
 # IndexedDB persistent storage mode is not allowed on Fennec from a non-chrome privileged code
 # (it has only been enabled for apps and privileged code). See Bug 1119462 for additional info.
 skip-if = os == 'android'
 [test_ext_unload_frame.html]
 skip-if = webrender # bug 1424752
-[test_ext_listener_proxies.html]
 [test_ext_web_accessible_resources.html]
 skip-if = os == 'android' && debug # bug 1397615
+[test_ext_webnavigation.html]
+skip-if = os == 'android' && debug # bug 1397615
+[test_ext_webnavigation_filters.html]
+skip-if = os == 'android' && debug # bug 1397615
 [test_ext_webrequest_auth.html]
 skip-if = os == 'android'
 [test_ext_webrequest_background_events.html]
-[test_ext_webrequest_hsts.html]
+[test_ext_webrequestblocking_set_cookie.html]
 [test_ext_webrequest_basic.html]
 skip-if = os == 'android' && debug # bug 1397615
+[test_ext_webrequest_errors.html]
 [test_ext_webrequest_filter.html]
 [test_ext_webrequest_frameId.html]
+[test_ext_webrequest_hsts.html]
+[test_ext_webrequest_permission.html]
 [test_ext_webrequest_responseBody.html]
 skip-if = os == 'android' || os == 'linux' # linux, bug 1398120
 [test_ext_webrequest_suspend.html]
 [test_ext_webrequest_upgrade.html]
 [test_ext_webrequest_upload.html]
 skip-if = os == 'android' # Currently fails in emulator tests
-[test_ext_webrequest_permission.html]
 [test_ext_webrequest_websocket.html]
-[test_ext_webnavigation.html]
-skip-if = os == 'android' && debug # bug 1397615
-[test_ext_webnavigation_filters.html]
-skip-if = os == 'android' && debug # bug 1397615
 [test_ext_window_postMessage.html]
-[test_ext_subframes_privileges.html]
 [test_ext_xhr_capabilities.html]
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest.ini
@@ -1,4 +1,7 @@
 [DEFAULT]
 tags = webextensions in-process-webextensions
 
+[test_ext_storage_cleanup.html]
+# Bug 1426514 storage_cleanup: clearing localStorage fails with oop
+
 [include:mochitest-common.ini]
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html
@@ -96,16 +96,17 @@ add_task(async function test_webRequest_
     browser.test.sendMessage("extensionUrl", browser.extension.getURL("*"));
   }
 
   // Use webrequest to monitor moz-extension:// requests
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       permissions: [
         "webRequest",
+        "webRequestBlocking",
         "tabs",
         "<all_urls>",
       ],
     },
     files: {
       "fetched.html": `
         <!DOCTYPE html>
         <html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html
@@ -1,33 +1,36 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>WebExtension test</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <meta charset="utf-8">
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(async function setup() {
   // make sure userContext is enabled.
-  return SpecialPowers.pushPrefEnv({"set": [
+  await SpecialPowers.pushPrefEnv({"set": [
     ["privacy.userContext.enabled", true],
   ]});
 });
 
 add_task(async function test_cookie_containers() {
   async function background() {
+    // Sometimes there is a cookie without name/value when running tests.
+    let cookiesAtStart = await browser.cookies.getAll({storeId: "firefox-default"});
+
     function assertExpected(expected, cookie) {
       for (let key of Object.keys(cookie)) {
         browser.test.assertTrue(key in expected, `found property ${key}`);
         browser.test.assertEq(expected[key], cookie[key], `property value for ${key} is correct`);
       }
       browser.test.assertEq(Object.keys(expected).length, Object.keys(cookie).length, "all expected properties found");
     }
 
@@ -56,17 +59,17 @@ add_task(async function test_cookie_cont
 
     cookie = await browser.cookies.get({url: TEST_URL, name: "name1"});
     browser.test.assertEq(null, cookie, "get() without storeId returns null");
 
     cookie = await browser.cookies.get({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
     assertExpected(expected, cookie);
 
     let cookies = await browser.cookies.getAll({storeId: "firefox-default"});
-    browser.test.assertEq(0, cookies.length, "getAll() with default storeId returns an empty array");
+    browser.test.assertEq(0, cookiesAtStart.length - cookies.length, "getAll() with default storeId hasn't added cookies");
 
     cookies = await browser.cookies.getAll({storeId: "firefox-container-1"});
     browser.test.assertEq(1, cookies.length, "one cookie found for matching domain");
     assertExpected(expected, cookies[0]);
 
     let details = await browser.cookies.remove({url: TEST_URL, name: "name1", storeId: "firefox-container-1"});
     assertExpected({url: TEST_URL, name: "name1", storeId: "firefox-container-1", firstPartyDomain: ""}, details);
 
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html
@@ -1,18 +1,18 @@
 <!DOCTYPE HTML>
 <html>
 <head>
-  <title>WebExtension test</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <title>WebExtension cookies test</title>
+  <meta charset="utf-8">
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(async function test_cookies_expiry() {
   function background() {
@@ -32,40 +32,41 @@ add_task(async function test_cookies_exp
       }
     });
 
     setTimeout(() => {
       browser.test.sendMessage("change-cookies");
     }, 1000);
   }
 
-  let domain = ".example.com";
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["http://example.com/", "cookies"],
     },
     background,
   });
 
-  let cookieSvc = SpecialPowers.Services.cookies;
-
-  let cookie = {
-    host: domain,
-    name: "first",
-    path: "/",
-  };
-
-  do {
-    cookieSvc.add(cookie.host, cookie.path, cookie.name, "one", false, false, false, Date.now() / 1000 + 1);
-  } while (!cookieSvc.cookieExists(cookie));
+  let chromeScript = loadChromeScript(() => {
+    const {sendAsyncMessage} = this;
+    Services.cookies.add(".example.com", "/", "first", "one", false, false, false, Date.now() / 1000 + 1);
+    sendAsyncMessage("done");
+  });
+  await chromeScript.promiseOneMessage("done");
+  chromeScript.destroy();
 
   await extension.startup();
   await extension.awaitMessage("change-cookies");
 
-  cookieSvc.add(cookie.host, cookie.path, cookie.name, "one-again", false, false, false, Date.now() / 1000 + 10);
+  chromeScript = loadChromeScript(() => {
+    const {sendAsyncMessage} = this;
+    Services.cookies.add(".example.com", "/", "first", "one-again", false, false, false, Date.now() / 1000 + 10);
+    sendAsyncMessage("done");
+  });
+  await chromeScript.promiseOneMessage("done");
+  chromeScript.destroy();
 
   await extension.awaitFinish("cookie-expiry");
   await extension.unload();
 });
 
 </script>
 
 </body>
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_bad.html
@@ -1,19 +1,18 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>WebExtension test</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
   <script type="text/javascript" src="head_cookies.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(async function init() {
   // We need to trigger a cookie eviction in order to test our batch delete
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html
@@ -1,19 +1,18 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>WebExtension test</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
   <script type="text/javascript" src="head_cookies.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(async function init() {
   // We need to trigger a cookie eviction in order to test our batch delete
rename from toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
rename to toolkit/components/extensions/test/mochitest/test_ext_eventpage_warning.html
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_eventpage_warning.html
@@ -1,18 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for WebExtension EventPage Warning</title>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 function createEventPageExtension(eventPage) {
   function eventPageScript() {
@@ -30,77 +29,51 @@ function createEventPageExtension(eventP
         <meta charset="utf-8">
         <script src="event-page-script.js"><\/script>
       </head></html>`,
     },
   });
 }
 
 add_task(async function test_eventpages() {
-  // Used in other tests to prevent the monitorConsole to grip.
-  SimpleTest.waitForExplicitFinish();
-
   let testCases = [
     {
       message: "testing event page running as a background page",
       eventPage: {
         "page": "event-page.html",
         "persistent": false,
       },
     },
     {
       message: "testing event page scripts running as a background page",
       eventPage: {
         "scripts": ["event-page-script.js"],
         "persistent": false,
       },
     },
+    {
+      message: "testing additional unrecognized properties on background page",
+      eventPage: {
+        "scripts": ["event-page-script.js"],
+        "nonExistentProp": true,
+      },
+    },
   ];
 
-  for (let {message, eventPage} of testCases) {
-    info(message);
+  // Wait for the expected logged warnings from the manifest validation.
+  consoleMonitor.start([{message: /Event pages are not currently supported./},
+                        {message: /Event pages are not currently supported./},
+                        {message: /Reading manifest: Error processing background.nonExistentProp: An unexpected property was found/}]);
+  for (let test of testCases) {
+    info(test.message);
 
-    // Wait for the expected logged warnings from the manifest validation.
-    let waitForConsole = new Promise(resolve => {
-      SimpleTest.monitorConsole(resolve, [{message: /Event pages are not currently supported./}]);
-    });
-
-    let extension = createEventPageExtension(eventPage);
-
-    info("load complete");
+    let extension = createEventPageExtension(test.eventPage);
     let [, x] = await Promise.all([extension.startup(), extension.awaitMessage("running")]);
     is(x, 1, "got correct value from extension");
-    info("test complete");
     await extension.unload();
-    info("extension unloaded successfully");
-
-    SimpleTest.endMonitorConsole();
-    await waitForConsole;
-
-    waitForConsole = new Promise(resolve => {
-      SimpleTest.monitorConsole(resolve, [{
-        message: /Reading manifest: Error processing background.nonExistentProp: An unexpected property was found/,
-      }]);
-    });
-
-    info("testing additional unrecognized properties on background page");
-
-    extension = createEventPageExtension({
-      "scripts": ["event-page-script.js"],
-      "nonExistentProp": true,
-    });
-
-    info("load complete");
-    [, x] = await Promise.all([extension.startup(), extension.awaitMessage("running")]);
-    is(x, 1, "got correct value from extension");
-    info("test complete");
-    await extension.unload();
-    info("extension unloaded successfully");
-
-    SimpleTest.endMonitorConsole();
-    await waitForConsole;
   }
+  await consoleMonitor.finished();
 });
 
 </script>
 
 </body>
 </html>
rename from toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
rename to toolkit/components/extensions/test/mochitest/test_ext_idle.html
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_idle.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_idle.html
@@ -1,63 +1,66 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>WebExtension test</title>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
-const idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService);
-
 add_task(async function testWithRealIdleService() {
   function background() {
-    browser.test.onMessage.addListener((msg, ...args) => {
+    browser.test.onMessage.addListener(async (msg, ...args) => {
       let detectionInterval = args[0];
       if (msg == "addListener") {
-        browser.idle.queryState(detectionInterval).then(status => {
-          browser.test.assertEq("active", status, "Idle status is active");
-        });
+        let status = await browser.idle.queryState(detectionInterval);
+        browser.test.assertEq("active", status, "Idle status is active");
         browser.idle.setDetectionInterval(detectionInterval);
         browser.idle.onStateChanged.addListener(newState => {
           browser.test.assertEq("idle", newState, "listener fired with the expected state");
           browser.test.sendMessage("listenerFired");
         });
         browser.test.sendMessage("listenerAdded");
       } else if (msg == "checkState") {
-        browser.idle.queryState(detectionInterval).then(status => {
-          browser.test.assertEq("idle", status, "Idle status is idle");
-          browser.test.notifyPass("idle");
-        });
+        let status = await browser.idle.queryState(detectionInterval);
+        browser.test.assertEq("idle", status, "Idle status is idle");
+        browser.test.notifyPass("idle");
       }
     });
   }
 
   let extension = ExtensionTestUtils.loadExtension({
     background,
     manifest: {
       permissions: ["idle"],
     },
   });
 
   await extension.startup();
-  let idleTime = idleService.idleTime;
-  let detectionInterval = Math.max(Math.ceil(idleTime / 1000) + 10, 15);
-  info(`idleTime: ${idleTime}, detectionInterval: ${detectionInterval}`);
+
+  let chromeScript = loadChromeScript(() => {
+    const {sendAsyncMessage} = this;
+    const idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService);
+    let idleTime = idleService.idleTime;
+    sendAsyncMessage("detectionInterval", Math.max(Math.ceil(idleTime / 1000) + 10, 15));
+  });
+  let detectionInterval = await chromeScript.promiseOneMessage("detectionInterval");
+  chromeScript.destroy();
+
+  info(`Setting interval to ${detectionInterval}`);
   extension.sendMessage("addListener", detectionInterval);
   await extension.awaitMessage("listenerAdded");
-  info(`Listener added. idleTime: ${idleService.idleTime}`);
+  info("Listener added");
   await extension.awaitMessage("listenerFired");
   info("Listener fired");
   extension.sendMessage("checkState", detectionInterval);
   await extension.awaitFinish("idle");
   await extension.unload();
 });
 
 </script>
--- a/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
@@ -1,19 +1,18 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for simple WebExtension</title>
   <meta charset="utf-8">
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(async function test_versioned_js() {
   // We need to deal with escaping the close script tags.
@@ -51,36 +50,22 @@ add_task(async function test_versioned_j
         window.reportResult("background-script-2");
       },
       "background-3.js": function() {
         window.reportResult("background-script-3");
       },
     },
   });
 
-  let messages = [/Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/,
-                  /Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/];
-
-  let waitForConsole = new Promise(resolve => {
-    SimpleTest.monitorConsole(resolve, messages);
-  });
-
-  info("loading extension");
+  consoleMonitor.start([{message: /Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/},
+                        {message: /Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/}]);
 
   await Promise.all([extension.startup(),
                      extension.awaitMessage("finished")]);
 
-  info("waiting for console");
-
-  SimpleTest.endMonitorConsole();
-  await waitForConsole;
-
-  info("unloading extension");
-
+  await consoleMonitor.finished();
   await extension.unload();
-
-  info("test complete");
 });
 
 </script>
 
 </body>
 </html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html
@@ -1,18 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for protocol handlers</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 /* eslint-disable mozilla/balanced-listeners */
 /* global addMessageListener, sendAsyncMessage */
@@ -167,49 +166,43 @@ add_task(async function test_protocolHan
           "protocol": "http",
           "name": "take over the http protocol",
           "uriTemplate": "http.html?val=%s",
         },
       ],
     },
   };
 
-  let waitForConsole = new Promise(resolve => {
-    SimpleTest.monitorConsole(resolve, [{message: /processing protocol_handlers\.0\.protocol/}]);
-  });
+  consoleMonitor.start([{message: /processing protocol_handlers\.0\.protocol/}]);
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   await Assert.rejects(extension.startup(), "unable to register restricted handler protocol");
 
-  SimpleTest.endMonitorConsole();
-  await waitForConsole;
+  await consoleMonitor.finished();
 });
 
 add_task(async function test_protocolHandler_restricted_uriTemplate() {
   let extensionData = {
     manifest: {
       "protocol_handlers": [
         {
           "protocol": "ext+foo",
           "name": "take over the http protocol",
           "uriTemplate": "ftp://example.com/file.txt",
         },
       ],
     },
   };
 
-  let waitForConsole = new Promise(resolve => {
-    SimpleTest.monitorConsole(resolve, [{message: /processing protocol_handlers\.0\.uriTemplate/}]);
-  });
+  consoleMonitor.start([{message: /processing protocol_handlers\.0\.uriTemplate/}]);
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   await Assert.rejects(extension.startup(), "unable to register restricted handler uriTemplate");
 
-  SimpleTest.endMonitorConsole();
-  await waitForConsole;
+  await consoleMonitor.finished();
 });
 
 add_task(async function test_protocolHandler_duplicate() {
   let extensionData = {
     manifest: {
       "protocol_handlers": [
         {
           "protocol": "ext+foo",
--- a/toolkit/components/extensions/test/mochitest/test_ext_schema.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_schema.html
@@ -1,18 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for schema API creation</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(async function testEmptySchema() {
   function background() {
@@ -44,30 +43,23 @@ add_task(async function testUnknownPrope
       permissions: ["unknownPermission"],
 
       unknown_property: {},
     },
 
     background,
   });
 
-  let messages = [
+  consoleMonitor.start([
     {message: /processing permissions\.0: Value "unknownPermission"/},
     {message: /processing unknown_property: An unexpected property was found in the WebExtension manifest/},
-  ];
-
-  let waitForConsole = new Promise(resolve => {
-    SimpleTest.monitorConsole(resolve, messages);
-  });
+  ]);
 
   await extension.startup();
-
   await extension.awaitFinish("loaded");
 
+  await consoleMonitor.finished();
   await extension.unload();
-
-  SimpleTest.endMonitorConsole();
-  await waitForConsole;
 });
 </script>
 
 </body>
 </html>
rename from toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html
rename to toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html
@@ -1,17 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>WebExtension test</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 // Test that storage used by a webextension (through localStorage,
 // indexedDB, and browser.storage.local) gets cleaned up when the
rename from toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_errors.html
rename to toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_errors.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html
@@ -1,18 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <title>Test for WebRequest errors</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
   <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <script type="text/javascript">
 "use strict";
 
 async function test_connection_refused(url, expectedError) {
   async function background(url, expectedError) {
     browser.test.log(`background url is ${url}`);
rename from toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html
rename to toolkit/components/extensions/test/xpcshell/test_ext_trustworthy_origin.js
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_trustworthy_origin.js
@@ -1,55 +1,13 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>WebExtension test</title>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
-  <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="chrome_head.js"></script>
-  <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="text/javascript">
 "use strict";
 
-/* import-globals-from chrome_head.js */
-
 /**
  * This test is asserting that moz-extension: URLs are recognized as trustworthy local origins
  */
 
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gContentSecurityManager",
-                                   "@mozilla.org/contentsecuritymanager;1",
-                                   "nsIContentSecurityManager");
-
-add_task(async function() {
-  function background() {
-    browser.test.sendMessage("ready", browser.runtime.getURL("/test.html"));
-  }
-
-  let extensionData = {
-    background,
-    files: {
-      "test.html": `<html><head></head><body></body></html>`,
-    },
-  };
-
-  let extension = ExtensionTestUtils.loadExtension(extensionData);
-  await extension.startup();
-
-  let url = await extension.awaitMessage("ready");
-
-  let uri = NetUtil.newURI(url);
+add_task(function test_isOriginPotentiallyTrustworthnsIContentSecurityManagery() {
+  let contentSecManager = Cc["@mozilla.org/contentsecuritymanager;1"]
+                          .getService(Ci.nsIContentSecurityManager);
+  let uri = NetUtil.newURI("moz-extension://foobar/something.html");
   let principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
-  is(gContentSecurityManager.isOriginPotentiallyTrustworthy(principal), true);
-
-  await extension.unload();
+  Assert.equal(contentSecManager.isOriginPotentiallyTrustworthy(principal), true, "it is potentially trustworthy");
 });
-</script>
-
-</body>
-</html>
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -69,16 +69,17 @@ skip-if = os == "android"
 skip-if = os == "android"
 [test_ext_storage_sync.js]
 head = head.js head_sync.js
 skip-if = os == "android"
 [test_ext_storage_sync_crypto.js]
 skip-if = os == "android"
 [test_ext_storage_telemetry.js]
 skip-if = os == "android" # checking for telemetry needs to be updated: 1384923
+[test_ext_trustworthy_origin.js]
 [test_ext_topSites.js]
 skip-if = os == "android"
 [test_native_manifests.js]
 subprocess = true
 skip-if = os == "android"
 [test_ext_permissions.js]
 skip-if = os == "android" # Bug 1350559
 [test_proxy_scripts.js]