Bug 1202501 - [webext] Clean up WebExtension tests (r=gabor)
☠☠ backed out by f2e83a8b6b8e ☠ ☠
authorBill McCloskey <billm@mozilla.com>
Fri, 04 Sep 2015 16:12:46 -0700
changeset 263795 525227997274e65ad29ec5e7990c68e1f2baba58
parent 263794 da317cdb79d3ca5cf8941ef072e8b8ab3f94b5c9
child 263796 7e8c04ff6049464b74b3c2823747da516d323e3b
push id65446
push userwmccloskey@mozilla.com
push dateTue, 22 Sep 2015 23:09:36 +0000
treeherdermozilla-inbound@6503123e95dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1202501
milestone44.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 1202501 - [webext] Clean up WebExtension tests (r=gabor)
browser/components/extensions/test/browser/browser.ini
browser/components/extensions/test/browser/browser_ext_simple.js
browser/components/extensions/test/browser/browser_extensions_simple.js
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/ExtensionContent.jsm
toolkit/components/extensions/test/extensions/content_script/manifest.json
toolkit/components/extensions/test/mochitest/file_contentscript_page1.html
toolkit/components/extensions/test/mochitest/file_sample.html
toolkit/components/extensions/test/mochitest/mochitest.ini
toolkit/components/extensions/test/mochitest/test_ext_contentscript.html
toolkit/components/extensions/test/mochitest/test_ext_generate.html
toolkit/components/extensions/test/mochitest/test_ext_geturl.html
toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html
toolkit/components/extensions/test/mochitest/test_ext_simple.html
toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
toolkit/components/extensions/test/mochitest/test_extension_contentscript.html
toolkit/components/extensions/test/mochitest/test_extension_webrequest.html
toolkit/components/extensions/test/mochitest/test_generate_extension.html
toolkit/components/extensions/test/mochitest/test_sandbox_var.html
toolkit/components/extensions/test/mochitest/test_simple_extensions.html
--- a/browser/components/extensions/test/browser/browser.ini
+++ b/browser/components/extensions/test/browser/browser.ini
@@ -1,9 +1,9 @@
 [DEFAULT]
 skip-if = os == 'android' || buildapp == 'b2g' || os == 'mac'
 
-[browser_extensions_simple.js]
+[browser_ext_simple.js]
 [browser_ext_browserAction_simple.js]
 [browser_ext_tabs_executeScript.js]
 [browser_ext_tabs_query.js]
 [browser_ext_tabs_update.js]
 [browser_ext_windows_update.js]
rename from browser/components/extensions/test/browser/browser_extensions_simple.js
rename to browser/components/extensions/test/browser/browser_ext_simple.js
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -631,16 +631,30 @@ Extension.prototype = {
 
     let locale = Locale.findClosestLocale(locales);
     if (locale) {
       return this.readLocaleFile(locale.name).catch(() => {});
     }
     return {};
   },
 
+  broadcast(msg, data) {
+    return new Promise(resolve => {
+      let count = Services.ppmm.childCount;
+      Services.ppmm.addMessageListener(msg + "Complete", function listener() {
+        count--;
+        if (count == 0) {
+          Services.ppmm.removeMessageListener(msg + "Complete", listener);
+          resolve();
+        }
+      });
+      Services.ppmm.broadcastAsyncMessage(msg, data);
+    });
+  },
+
   runManifest(manifest) {
     let permissions = manifest.permissions || [];
     let webAccessibleResources = manifest.web_accessible_resources || [];
 
     let whitelist = [];
     for (let perm of permissions) {
       if (perm.match(/:\/\//)) {
         whitelist.push(perm);
@@ -661,17 +675,18 @@ Extension.prototype = {
     }
 
     let data = Services.ppmm.initialProcessData;
     if (!data["Extension:Extensions"]) {
       data["Extension:Extensions"] = [];
     }
     let serial = this.serialize();
     data["Extension:Extensions"].push(serial);
-    Services.ppmm.broadcastAsyncMessage("Extension:Startup", serial);
+
+    return this.broadcast("Extension:Startup", serial);
   },
 
   callOnClose(obj) {
     this.onShutdown.add(obj);
   },
 
   forgetOnClose(obj) {
     this.onShutdown.delete(obj);
@@ -691,17 +706,17 @@ Extension.prototype = {
 
       GlobalManager.init(this);
 
       this.manifest = manifest;
       this.localeMessages = messages;
 
       Management.emit("startup", this);
 
-      this.runManifest(manifest);
+      return this.runManifest(manifest);
     }).catch(e => {
       dump(`Extension error: ${e} ${e.fileName}:${e.lineNumber}\n`);
       Cu.reportError(e);
       throw e;
     });
   },
 
   cleanupGeneratedFile() {
@@ -709,29 +724,23 @@ Extension.prototype = {
       return;
     }
 
     let file = this.cleanupFile;
     this.cleanupFile = null;
 
     Services.obs.removeObserver(this, "xpcom-shutdown");
 
-    let count = Services.ppmm.childCount;
-
-    Services.ppmm.addMessageListener("Extension:FlushJarCacheComplete", function listener() {
-      count--;
-      if (count == 0) {
-        // We can't delete this file until everyone using it has
-        // closed it (because Windows is dumb). So we wait for all the
-        // child processes (including the parent) to flush their JAR
-        // caches. These caches may keep the file open.
-        file.remove(false);
-      }
+    this.broadcast("Extension:FlushJarCache", {path: file.path}).then(() => {
+      // We can't delete this file until everyone using it has
+      // closed it (because Windows is dumb). So we wait for all the
+      // child processes (including the parent) to flush their JAR
+      // caches. These caches may keep the file open.
+      file.remove(false);
     });
-    Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path});
   },
 
   shutdown() {
     this.hasShutdown = true;
     if (!this.manifest) {
       return;
     }
 
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -478,16 +478,17 @@ var ExtensionManager = {
 
   receiveMessage({name, data}) {
     let extension;
     switch (name) {
       case "Extension:Startup": {
         extension = new BrowserExtensionContent(data);
         this.extensions.set(data.id, extension);
         DocumentManager.startupExtension(data.id);
+        Services.cpmm.sendAsyncMessage("Extension:StartupComplete");
         break;
       }
 
       case "Extension:Shutdown": {
         extension = this.extensions.get(data.id);
         extension.shutdown();
         DocumentManager.shutdownExtension(data.id);
         this.extensions.delete(data.id);
--- a/toolkit/components/extensions/test/extensions/content_script/manifest.json
+++ b/toolkit/components/extensions/test/extensions/content_script/manifest.json
@@ -1,32 +1,32 @@
 {
   "name": "Content script extension test",
   "version": "1.0",
   "manifest_version": 2,
   "description": "",
 
   "content_scripts": [
     {
-      "matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
+      "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script_start.js"],
       "run_at": "document_start"
     },
     {
-      "matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
+      "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script_end.js"],
       "run_at": "document_end"
     },
     {
-      "matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
+      "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script_idle.js"],
       "run_at": "document_idle"
     },
     {
-      "matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
+      "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
       "run_at": "document_idle"
     }
   ],
 
   "background": {
     "scripts": ["background.js"]
   }
rename from toolkit/components/extensions/test/mochitest/file_contentscript_page1.html
rename to toolkit/components/extensions/test/mochitest/file_sample.html
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest.ini
@@ -9,16 +9,16 @@ support-files =
   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_contentscript_page1.html
+  file_sample.html
 
-[test_simple_extensions.html]
+[test_ext_simple.html]
 [test_ext_geturl.html]
-[test_extension_contentscript.html]
-[test_extension_webrequest.html]
-[test_generate_extension.html]
-[test_sandbox_var.html]
+[test_ext_contentscript.html]
+[test_ext_webrequest.html]
+[test_ext_generate.html]
+[test_ext_sandbox_var.html]
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for content script</title>
+  <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="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type="application/javascript;version=1.8">
+"use strict";
+
+add_task(function* test_contentscript()
+{
+  let extension = ExtensionTestUtils.loadExtension("content_script");
+  yield extension.startup();
+  info("extension loaded");
+
+  let loadingCount = 0;
+  let interactiveCount = 0;
+  let completeCount = 0;
+  extension.onMessage("script-run-loading", () => { loadingCount++; });
+  extension.onMessage("script-run-interactive", () => { interactiveCount++; });
+
+  let completePromise = new Promise(resolve => {
+    extension.onMessage("script-run-complete", () => { completeCount++; resolve(); });
+  });
+
+  let chromeNamespacePromise = extension.awaitMessage("chrome-namespace-ok");
+
+  let win = window.open("file_sample.html");
+
+  yield Promise.all([waitForLoad(win), completePromise, chromeNamespacePromise]);
+  info("test page loaded");
+
+  win.close();
+
+  is(loadingCount, 1, "document_start script ran exactly once");
+  is(interactiveCount, 1, "document_end script ran exactly once");
+  is(completeCount, 1, "document_idle script ran exactly once");
+
+  yield extension.unload();
+  info("extension unloaded");
+});
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_ext_generate.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for generating WebExtensions</title>
+  <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="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type="application/javascript;version=1.8">
+
+function backgroundScript() {
+  browser.test.log("running background script");
+
+  browser.test.onMessage.addListener((x, y) => {
+    browser.test.assertEq(x, 10, "x is 10");
+    browser.test.assertEq(y, 20, "y is 20");
+
+    browser.test.notifyPass("background test passed");
+  });
+
+  browser.test.sendMessage("running", 1);
+}
+
+let extensionData = {
+  background: "(" + backgroundScript.toString() + ")()"
+};
+
+add_task(function* test_background() {
+  let extension = ExtensionTestUtils.loadExtension(extensionData);
+  info("load complete");
+  yield extension.startup();
+  let x = yield extension.awaitMessage("running");
+  is(x, 1, "got correct value from extension");
+  info("startup complete");
+  extension.sendMessage(10, 20);
+  yield extension.awaitFinish();
+  info("test complete");
+  yield extension.unload();
+  info("extension unloaded successfully");
+});
+
+</script>
+
+</body>
+</html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_geturl.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_geturl.html
@@ -35,37 +35,33 @@ function contentScript() {
   var url2 = browser.extension.getURL("test_file.html");
   browser.runtime.sendMessage([url1, url2]);
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "content_scripts": [{
-      "matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
+      "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
       "run_at": "document_start"
     }]
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
   info("extension loaded");
 
-  yield new Promise(resolve => { setTimeout(resolve, 0); });
-
-  let win = window.open();
-
-  win.location = "file_contentscript_page1.html";
+  let win = window.open("file_sample.html");
 
   yield Promise.all([waitForLoad(win), extension.awaitFinish("geturl")]);
 
   win.close();
 
   yield extension.unload();
   info("extension unloaded");
 });
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for content script</title>
+  <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="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type="application/javascript;version=1.8">
+"use strict";
+
+function backgroundScript() {
+  browser.runtime.onMessage.addListener(result => {
+    browser.test.assertEq(result, 12, "x is 12");
+    browser.test.notifyPass("background test passed");
+  });
+}
+
+function contentScript() {
+  window.x = 12;
+  browser.runtime.onMessage.addListener(function() {});
+  browser.runtime.sendMessage(window.x);
+}
+
+let extensionData = {
+  background: "(" + backgroundScript.toString() + ")()",
+  manifest: {
+    "content_scripts": [{
+      "matches": ["http://mochi.test/*/file_sample.html"],
+      "js": ["content_script.js"],
+      "run_at": "document_start"
+    }]
+  },
+
+  files: {
+    "content_script.js": "(" + contentScript.toString() + ")()",
+  },
+};
+
+add_task(function* test_contentscript() {
+  let extension = ExtensionTestUtils.loadExtension(extensionData);
+  yield extension.startup();
+  info("extension loaded");
+
+  let win = window.open("file_sample.html");
+
+  yield Promise.all([waitForLoad(win), extension.awaitFinish()]);
+
+  win.close();
+
+  yield extension.unload();
+  info("extension unloaded");
+});
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_ext_simple.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for simple WebExtension</title>
+  <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="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type="application/javascript;version=1.8">
+
+add_task(function* test_simple() {
+  let extension = ExtensionTestUtils.loadExtension("simple");
+  info("load complete");
+  yield extension.startup();
+  info("startup complete");
+  yield extension.unload();
+  info("extension unloaded successfully");
+});
+
+add_task(function* test_background() {
+  let extension = ExtensionTestUtils.loadExtension("background");
+  info("load complete");
+  yield extension.startup();
+  let x = yield extension.awaitMessage("running");
+  is(x, 1, "got correct value from extension");
+  info("startup complete");
+  extension.sendMessage(10, 20);
+  yield extension.awaitFinish();
+  info("test complete");
+  yield extension.unload();
+  info("extension unloaded successfully");
+});
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
@@ -0,0 +1,126 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test for simple WebExtension</title>
+  <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="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+
+<script type="application/javascript;version=1.8">
+"use strict";
+
+const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest";
+
+const expected_requested = [BASE + "/file_WebRequest_page1.html",
+                            BASE + "/file_style_good.css",
+                            BASE + "/file_style_bad.css",
+                            BASE + "/file_style_redirect.css",
+                            BASE + "/file_image_good.png",
+                            BASE + "/file_image_bad.png",
+                            BASE + "/file_image_redirect.png",
+                            BASE + "/file_script_good.js",
+                            BASE + "/file_script_bad.js",
+                            BASE + "/file_script_redirect.js",
+                            BASE + "/file_script_xhr.js",
+                            BASE + "/file_WebRequest_page2.html",
+                            BASE + "/nonexistent_script_url.js",
+                            BASE + "/xhr_resource"];
+
+const expected_sendHeaders = [BASE + "/file_WebRequest_page1.html",
+                              BASE + "/file_style_good.css",
+                              BASE + "/file_style_redirect.css",
+                              BASE + "/file_image_good.png",
+                              BASE + "/file_image_redirect.png",
+                              BASE + "/file_script_good.js",
+                              BASE + "/file_script_redirect.js",
+                              BASE + "/file_script_xhr.js",
+                              BASE + "/file_WebRequest_page2.html",
+                              BASE + "/nonexistent_script_url.js",
+                              BASE + "/xhr_resource"];
+
+const expected_headersReceived = [BASE + "/file_WebRequest_page1.html",
+                                  BASE + "/file_style_good.css",
+                                  BASE + "/file_image_good.png",
+                                  BASE + "/file_script_good.js",
+                                  BASE + "/file_script_xhr.js",
+                                  BASE + "/file_WebRequest_page2.html",
+                                  BASE + "/nonexistent_script_url.js",
+                                  BASE + "/xhr_resource"];
+
+function removeDupes(list)
+{
+  let j = 0;
+  for (let i = 1; i < list.length; i++) {
+    if (list[i] != list[j]) {
+      j++;
+      if (i != j) {
+        list[j] = list[i];
+      }
+    }
+  }
+  list.length = j + 1;
+}
+
+function compareLists(list1, list2, kind)
+{
+  list1.sort();
+  removeDupes(list1);
+  list2.sort();
+  removeDupes(list2);
+  is(String(list1), String(list2), `${kind} URLs correct`);
+}
+
+function* test_once()
+{
+  let extension = ExtensionTestUtils.loadExtension("webrequest");
+  yield extension.startup();
+  yield extension.awaitMessage("ready");
+  info("webrequest extension loaded");
+
+  yield new Promise(resolve => { setTimeout(resolve, 0); });
+
+  let win = window.open();
+
+  // Clear the image cache, since it gets in the way otherwise.
+  var imgTools = SpecialPowers.Cc["@mozilla.org/image/tools;1"].getService(SpecialPowers.Ci.imgITools);
+  var cache = imgTools.getImgCacheForDocument(win.document);
+  cache.clearCache(false);
+
+  //yield waitForLoad(win);
+  info("about:blank loaded");
+
+  win.location = "file_WebRequest_page1.html";
+
+  yield waitForLoad(win);
+  info("test page loaded");
+
+  is(win.success, 2, "Good script ran");
+  is(win.failure, undefined, "Failure script didn't run");
+
+  let style = win.getComputedStyle(win.document.getElementById("test"), null);
+  is(style.getPropertyValue("color"), "rgb(255, 0, 0)", "Good CSS loaded");
+
+  win.close();
+
+  extension.sendMessage("getResults");
+  let [requested, sendHeaders, headersReceived] = yield extension.awaitMessage("results");
+
+  compareLists(requested, expected_requested, "requested");
+  compareLists(sendHeaders, expected_sendHeaders, "sendHeaders");
+  compareLists(headersReceived, expected_headersReceived, "headersReceived");
+
+  yield extension.unload();
+  info("webrequest extension unloaded");
+}
+
+// Run the test twice to make sure it works with caching.
+add_task(test_once);
+add_task(test_once);
+</script>
+
+</body>
+</html>
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_extension_contentscript.html
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for content script</title>
-  <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>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.8">
-"use strict";
-
-add_task(function* test_contentscript()
-{
-  let extension = ExtensionTestUtils.loadExtension("content_script");
-  yield extension.startup();
-  info("extension loaded");
-
-  let loadingCount = 0;
-  let interactiveCount = 0;
-  let completeCount = 0;
-  extension.onMessage("script-run-loading", () => { loadingCount++; });
-  extension.onMessage("script-run-interactive", () => { interactiveCount++; });
-
-  let completePromise = new Promise(resolve => {
-    extension.onMessage("script-run-complete", () => { completeCount++; resolve(); });
-  });
-
-  let chromeNamespacePromise = extension.awaitMessage("chrome-namespace-ok");
-
-  yield new Promise(resolve => { setTimeout(resolve, 0); });
-
-  let win = window.open();
-
-  win.location = "file_contentscript_page1.html";
-
-  ok(true, "page loaded");
-
-  yield Promise.all([waitForLoad(win), completePromise, chromeNamespacePromise]);
-  info("test page loaded");
-
-  win.close();
-
-  is(loadingCount, 1, "document_start script ran exactly once");
-  is(interactiveCount, 1, "document_end script ran exactly once");
-  is(completeCount, 1, "document_idle script ran exactly once");
-
-  yield extension.unload();
-  info("extension unloaded");
-});
-
-function waitForLoad(win) {
-  return new Promise(resolve => {
-    win.addEventListener("load", function listener() {
-      win.removeEventListener("load", listener, true);
-      resolve();
-    }, true);
-  });
-}
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_extension_webrequest.html
+++ /dev/null
@@ -1,134 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for simple WebExtension</title>
-  <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>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.8">
-"use strict";
-
-const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest";
-
-const expected_requested = [BASE + "/file_WebRequest_page1.html",
-                            BASE + "/file_style_good.css",
-                            BASE + "/file_style_bad.css",
-                            BASE + "/file_style_redirect.css",
-                            BASE + "/file_image_good.png",
-                            BASE + "/file_image_bad.png",
-                            BASE + "/file_image_redirect.png",
-                            BASE + "/file_script_good.js",
-                            BASE + "/file_script_bad.js",
-                            BASE + "/file_script_redirect.js",
-                            BASE + "/file_script_xhr.js",
-                            BASE + "/file_WebRequest_page2.html",
-                            BASE + "/nonexistent_script_url.js",
-                            BASE + "/xhr_resource"];
-
-const expected_sendHeaders = [BASE + "/file_WebRequest_page1.html",
-                              BASE + "/file_style_good.css",
-                              BASE + "/file_style_redirect.css",
-                              BASE + "/file_image_good.png",
-                              BASE + "/file_image_redirect.png",
-                              BASE + "/file_script_good.js",
-                              BASE + "/file_script_redirect.js",
-                              BASE + "/file_script_xhr.js",
-                              BASE + "/file_WebRequest_page2.html",
-                              BASE + "/nonexistent_script_url.js",
-                              BASE + "/xhr_resource"];
-
-const expected_headersReceived = [BASE + "/file_WebRequest_page1.html",
-                                  BASE + "/file_style_good.css",
-                                  BASE + "/file_image_good.png",
-                                  BASE + "/file_script_good.js",
-                                  BASE + "/file_script_xhr.js",
-                                  BASE + "/file_WebRequest_page2.html",
-                                  BASE + "/nonexistent_script_url.js",
-                                  BASE + "/xhr_resource"];
-
-function removeDupes(list)
-{
-  let j = 0;
-  for (let i = 1; i < list.length; i++) {
-    if (list[i] != list[j]) {
-      j++;
-      if (i != j) {
-        list[j] = list[i];
-      }
-    }
-  }
-  list.length = j + 1;
-}
-
-function compareLists(list1, list2, kind)
-{
-  list1.sort();
-  removeDupes(list1);
-  list2.sort();
-  removeDupes(list2);
-  is(String(list1), String(list2), `${kind} URLs correct`);
-}
-
-function* test_once()
-{
-  let extension = ExtensionTestUtils.loadExtension("webrequest");
-  yield extension.startup();
-  yield extension.awaitMessage("ready");
-  info("webrequest extension loaded");
-
-  yield new Promise(resolve => { setTimeout(resolve, 0); });
-
-  let win = window.open();
-
-  // Clear the image cache, since it gets in the way otherwise.
-  var imgTools = SpecialPowers.Cc["@mozilla.org/image/tools;1"].getService(SpecialPowers.Ci.imgITools);
-  var cache = imgTools.getImgCacheForDocument(win.document);
-  cache.clearCache(false);
-
-  //yield waitForLoad(win);
-  info("about:blank loaded");
-
-  win.location = "file_WebRequest_page1.html";
-
-  yield waitForLoad(win);
-  info("test page loaded");
-
-  is(win.success, 2, "Good script ran");
-  is(win.failure, undefined, "Failure script didn't run");
-
-  let style = win.getComputedStyle(win.document.getElementById("test"), null);
-  is(style.getPropertyValue("color"), "rgb(255, 0, 0)", "Good CSS loaded");
-
-  win.close();
-
-  extension.sendMessage("getResults");
-  let [requested, sendHeaders, headersReceived] = yield extension.awaitMessage("results");
-
-  compareLists(requested, expected_requested, "requested");
-  compareLists(sendHeaders, expected_sendHeaders, "sendHeaders");
-  compareLists(headersReceived, expected_headersReceived, "headersReceived");
-
-  yield extension.unload();
-  info("webrequest extension unloaded");
-}
-
-// Run the test twice to make sure it works with caching.
-add_task(test_once);
-add_task(test_once);
-
-function waitForLoad(win) {
-  return new Promise(resolve => {
-    win.addEventListener("load", function listener() {
-      win.removeEventListener("load", listener, true);
-      resolve();
-    }, true);
-  });
-}
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_generate_extension.html
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for generating WebExtensions</title>
-  <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>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.8">
-
-function backgroundScript() {
-  browser.test.log("running background script");
-
-  browser.test.onMessage.addListener((x, y) => {
-    browser.test.assertEq(x, 10, "x is 10");
-    browser.test.assertEq(y, 20, "y is 20");
-
-    browser.test.notifyPass("background test passed");
-  });
-
-  browser.test.sendMessage("running", 1);
-}
-
-let extensionData = {
-  background: "(" + backgroundScript.toString() + ")()"
-};
-
-add_task(function* test_background() {
-  let extension = ExtensionTestUtils.loadExtension(extensionData);
-  info("load complete");
-  yield extension.startup();
-  let x = yield extension.awaitMessage("running");
-  is(x, 1, "got correct value from extension");
-  info("startup complete");
-  extension.sendMessage(10, 20);
-  yield extension.awaitFinish();
-  info("test complete");
-  yield extension.unload();
-  info("extension unloaded successfully");
-});
-
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_sandbox_var.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for content script</title>
-  <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>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.8">
-"use strict";
-
-function backgroundScript() {
-  browser.runtime.onMessage.addListener(result => {
-    browser.test.assertEq(result, 12, "x is 12");
-    browser.test.notifyPass("background test passed");
-  });
-}
-
-function contentScript() {
-  window.x = 12;
-  browser.runtime.onMessage.addListener(function() {});
-  browser.runtime.sendMessage(window.x);
-}
-
-let extensionData = {
-  background: "(" + backgroundScript.toString() + ")()",
-  manifest: {
-    "content_scripts": [{
-      "matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
-      "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
-  },
-
-  files: {
-    "content_script.js": "(" + contentScript.toString() + ")()",
-  },
-};
-
-add_task(function* test_contentscript() {
-  let extension = ExtensionTestUtils.loadExtension(extensionData);
-  yield extension.startup();
-  info("extension loaded");
-
-  yield new Promise(resolve => { setTimeout(resolve, 0); });
-
-  let win = window.open();
-
-  win.location = "file_contentscript_page1.html";
-
-  yield Promise.all([waitForLoad(win), extension.awaitFinish()]);
-
-  win.close();
-
-  yield extension.unload();
-  info("extension unloaded");
-});
-
-function waitForLoad(win) {
-  return new Promise(resolve => {
-    win.addEventListener("load", function listener() {
-      win.removeEventListener("load", listener, true);
-      resolve();
-    }, true);
-  });
-}
-</script>
-
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/extensions/test/mochitest/test_simple_extensions.html
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Test for simple WebExtension</title>
-  <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>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript;version=1.8">
-
-add_task(function* test_simple() {
-  let extension = ExtensionTestUtils.loadExtension("simple");
-  info("load complete");
-  yield extension.startup();
-  info("startup complete");
-  yield extension.unload();
-  info("extension unloaded successfully");
-});
-
-add_task(function* test_background() {
-  let extension = ExtensionTestUtils.loadExtension("background");
-  info("load complete");
-  yield extension.startup();
-  let x = yield extension.awaitMessage("running");
-  is(x, 1, "got correct value from extension");
-  info("startup complete");
-  extension.sendMessage(10, 20);
-  yield extension.awaitFinish();
-  info("test complete");
-  yield extension.unload();
-  info("extension unloaded successfully");
-});
-
-</script>
-
-</body>
-</html>