Bug 1234755: [webext] Make JS in HTML files pass ESLint. r=billm
authorKris Maglione <maglione.k@gmail.com>
Tue, 22 Dec 2015 23:43:23 -0500
changeset 278004 2eb35642f31d462c3978b62e369679fd3a45203f
parent 278003 e1273a6122e56df24bdaac52efe73b0d5556bc1c
child 278005 8338cdb566e28bd2dcaf7ef726cdd49529ae431d
push id29840
push userryanvm@gmail.com
push dateFri, 01 Jan 2016 23:13:05 +0000
treeherderautoland@5933251c8c98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1234755
milestone46.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 1234755: [webext] Make JS in HTML files pass ESLint. r=billm This also changes the `type` attribute in our script tags to text/javascript, since that's currently all the eslint-html plugin supports.
toolkit/components/extensions/test/mochitest/.eslintrc
toolkit/components/extensions/test/mochitest/file_permission_xhr.html
toolkit/components/extensions/test/mochitest/file_privilege_escalation.html
toolkit/components/extensions/test/mochitest/test_ext_alarms.html
toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html
toolkit/components/extensions/test/mochitest/test_ext_background_runtime_connect_params.html
toolkit/components/extensions/test/mochitest/test_ext_background_sub_windows.html
toolkit/components/extensions/test/mochitest/test_ext_background_window_properties.html
toolkit/components/extensions/test/mochitest/test_ext_bookmarks.html
toolkit/components/extensions/test/mochitest/test_ext_contentscript.html
toolkit/components/extensions/test/mochitest/test_ext_cookies.html
toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.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_i18n.html
toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
toolkit/components/extensions/test/mochitest/test_ext_localStorage.html
toolkit/components/extensions/test/mochitest/test_ext_notifications.html
toolkit/components/extensions/test/mochitest/test_ext_onmessage_removelistener.html
toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html
toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html
toolkit/components/extensions/test/mochitest/test_ext_runtime_getPlatformInfo.html
toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html
toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html
toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html
toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html
toolkit/components/extensions/test/mochitest/test_ext_simple.html
toolkit/components/extensions/test/mochitest/test_ext_storage.html
toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html
toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
--- a/toolkit/components/extensions/test/mochitest/.eslintrc
+++ b/toolkit/components/extensions/test/mochitest/.eslintrc
@@ -1,19 +1,26 @@
 {
   "extends": "../../.eslintrc",
 
   "globals": {
-    // DOM window globals
-    "window": false,
-    "XMLHttpRequest": false,
-
     "sendAsyncMessage": false,
 
+    "ExtensionTestUtils": false,
     "NetUtil": true,
     "XPCOMUtils": true,
 
+    "waitForLoad": true,
+
     // Test harness globals
     "add_task": false,
+    "info": false,
+    "is": false,
     "ok": false,
     "SimpleTest": false,
+    "SpecialPowers": true,
+  },
+
+  "env": {
+    "browser": true,
+    "webextensions": true,
   }
 }
--- a/toolkit/components/extensions/test/mochitest/file_permission_xhr.html
+++ b/toolkit/components/extensions/test/mochitest/file_permission_xhr.html
@@ -2,39 +2,44 @@
 
 <html>
 <head>
 <meta charset="utf-8">
 </head>
 <body>
 
 <script>
+"use strict";
+
+/* globals privilegedXHR */
+/* eslint-disable mozilla/balanced-listeners */
+
 addEventListener("message", function rcv(event) {
   removeEventListener("message", rcv, false);
 
   function passListener() {
     postMessage(true, "*");
   }
 
   function failListener() {
     postMessage(false, "*");
   }
 
-  var exc = null;
+  let exc = null;
   try {
     new privilegedXHR();
   } catch (e) {
     exc = e;
   }
   if (!/Permission denied to access object/.exec(exc)) {
     postMessage(false, "*");
     return;
   }
 
-  var req = new XMLHttpRequest();
+  let req = new XMLHttpRequest();
   req.addEventListener("load", failListener);
   req.addEventListener("error", passListener);
   req.open("GET", "http://example.org/example.txt");
   req.send();
 }, false);
 </script>
 
 </body>
--- a/toolkit/components/extensions/test/mochitest/file_privilege_escalation.html
+++ b/toolkit/components/extensions/test/mochitest/file_privilege_escalation.html
@@ -1,12 +1,13 @@
 <!DOCTYPE HTML>
 
 <html>
 <head>
 <meta charset="utf-8">
 </head>
 <body>
-  <script type="application/javascript">
+  <script type="text/javascript">
+    "use strict";
     throw new Error(`WebExt Privilege Escalation: typeof(browser) = ${typeof(browser)}`);
   </script>
 </body>
 </html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_alarms.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_alarms.html
@@ -5,56 +5,57 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* test_alarm_fires() {
   function backgroundScript() {
-    var ALARM_NAME = "test_ext_alarms";
+    let ALARM_NAME = "test_ext_alarms";
     browser.test.log("running alarm script");
 
-    chrome.alarms.onAlarm.addListener(function (alarm) {
+    chrome.alarms.onAlarm.addListener(function(alarm) {
       browser.test.assertEq(alarm.name, ALARM_NAME, "alarm should have the correct name");
       browser.test.notifyPass("alarms");
     });
     chrome.alarms.create(ALARM_NAME, {delayInMinutes: 0.02});
     setTimeout(() => {
       browser.test.notifyFail("alarms test failed, took too long");
     }, 10000);
   }
 
   let extensionData = {
     background: "(" + backgroundScript.toString() + ")()",
     manifest: {
-      permissions: ["alarms"]
+      permissions: ["alarms"],
     },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
   info("extension loaded");
   yield extension.awaitFinish("alarms");
   yield extension.unload();
   info("extension unloaded");
 });
 
 
 add_task(function* test_periodic_alarm_fires() {
   function backgroundScript() {
-    var ALARM_NAME = "test_ext_alarms";
+    const ALARM_NAME = "test_ext_alarms";
     browser.test.log("running alarm script");
 
-    var count = 0;
-    chrome.alarms.onAlarm.addListener(function (alarm) {
+    let count = 0;
+    chrome.alarms.onAlarm.addListener(function(alarm) {
       browser.test.assertEq(alarm.name, ALARM_NAME, "alarm should have the correct name");
       if (count++ === 3) {
         chrome.alarms.clear(ALARM_NAME, (wasCleared) => {
           browser.test.assertTrue(wasCleared, "alarm should be cleared");
           browser.test.notifyPass("alarms");
         });
       }
     });
@@ -65,17 +66,17 @@ add_task(function* test_periodic_alarm_f
         browser.test.assertTrue(wasCleared, "alarm should be cleared");
       });
     }, 30000);
   }
 
   let extensionData = {
     background: "(" + backgroundScript.toString() + ")()",
     manifest: {
-      permissions: ["alarms"]
+      permissions: ["alarms"],
     },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
   info("extension loaded");
   yield extension.awaitFinish("alarms");
   yield extension.unload();
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 add_task(function* testBackgroundWindow() {
   let extension = ExtensionTestUtils.loadExtension({
     background: "new " + function() {
       const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest";
 
       browser.test.log("background script executed");
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_runtime_connect_params.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_background_runtime_connect_params.html
@@ -5,59 +5,59 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
-  var detected_invalid_connect_params = 0,
-      received_ports_number = 0;
+  let detected_invalid_connect_params = 0;
+  let received_ports_number = 0;
 
   const invalid_connect_params = [
     // too many params
     ["fake-extensions-id", { name: "fake-conn-name" }, "unexpected third params"],
     // invalid params format
     [{}, {}],
-    ["fake-extensions-id", "invalid-connect-info-format"]
+    ["fake-extensions-id", "invalid-connect-info-format"],
   ];
 
   const expected_detected_invalid_connect_params = invalid_connect_params.length;
   const expected_received_ports_number = 1;
 
-  function assertInvalidConnectParamsException(e) {
+  function assertInvalidConnectParamsException(params) {
     try {
       browser.runtime.connect(...params);
-    } catch(e) {
+    } catch (e) {
       detected_invalid_connect_params++;
       browser.test.assertTrue(e.toString().indexOf("Incorrect argument types for runtime.connect.") >= 0, "exception message is correct");
     }
   }
 
   function countReceivedPorts(port) {
     received_ports_number++;
 
     if (port.name == "check-results") {
       browser.runtime.onConnect.removeListener(countReceivedPorts);
 
       browser.test.assertEq(expected_detected_invalid_connect_params, detected_invalid_connect_params, "all invalid runtime.connect params detected");
       browser.test.assertEq(expected_received_ports_number, received_ports_number, "invalid connect should not create a port");
 
       browser.test.notifyPass("runtime.connect invalid params");
     }
-  };
+  }
 
   browser.runtime.onConnect.addListener(countReceivedPorts);
 
-  for (var params of invalid_connect_params) {
+  for (let params of invalid_connect_params) {
     assertInvalidConnectParamsException(params);
   }
 
   browser.runtime.connect(browser.runtime.id, { name: "check-results"});
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_sub_windows.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_background_sub_windows.html
@@ -5,17 +5,18 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* testBackgroundWindow() {
   let extension = ExtensionTestUtils.loadExtension({
     background: "new " + function() {
       browser.test.log("background script executed");
 
       browser.test.sendMessage("background-script-load");
 
@@ -46,17 +47,17 @@ add_task(function* testBackgroundWindow(
   extension.onMessage("background-script-load", () => {
     loadCount++;
   });
 
   yield extension.startup();
 
   info("startup complete loaded");
 
-  yield extension.awaitFinish("background sub-window test done")
+  yield extension.awaitFinish("background sub-window test done");
 
   is(loadCount, 1, "background script loaded only once");
 
   yield extension.unload();
 });
 
 </script>
 
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_window_properties.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_background_window_properties.html
@@ -5,48 +5,49 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* testBackgroundWindowProperties() {
   let extension = ExtensionTestUtils.loadExtension({
     background: "(" + function() {
-      var expectedValues = {
+      let expectedValues = {
         screenX: 0,
         screenY: 0,
         outerWidth: 0,
-        outerHeight: 0
+        outerHeight: 0,
       };
 
-      for (var k in window) {
+      for (let k in window) {
         try {
           if (k in expectedValues) {
             browser.test.assertEq(expectedValues[k], window[k],
-                                  `should return the expected value for window property: ${k}`)
+                                  `should return the expected value for window property: ${k}`);
           } else {
-            window[k];
+            void window[k];
           }
-        } catch(e) {
-          browser.test.assertEq(null, e, `unexpected exception accessing window property: ${k}`)
+        } catch (e) {
+          browser.test.assertEq(null, e, `unexpected exception accessing window property: ${k}`);
         }
       }
 
-      browser.test.notifyPass("background.testWindowProperties.done")
-    } + ")();"
+      browser.test.notifyPass("background.testWindowProperties.done");
+    } + ")();",
   });
   info("load complete");
   yield extension.startup();
   info("startup complete");
-  yield extension.awaitFinish("background.testWindowProperties.done")
+  yield extension.awaitFinish("background.testWindowProperties.done");
   yield extension.unload();
   info("extension unloaded successfully");
 });
 
 </script>
 
 </body>
 </html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_bookmarks.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_bookmarks.html
@@ -5,78 +5,72 @@
   <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">
+<script type="text/javascript">
+"use strict";
+
 function backgroundScript() {
   function get(idOrIdList) {
     return new Promise(resolve => {
       browser.bookmarks.get(idOrIdList, resolve);
     });
   }
 
   function create(bookmark) {
     return new Promise(resolve => {
       browser.bookmarks.create(bookmark, resolve);
     });
   }
 
   function getChildren(id) {
     return new Promise(resolve => {
       browser.bookmarks.getChildren(id, resolve);
-    })
+    });
   }
 
   function update(id, changes) {
     return new Promise(resolve => {
       browser.bookmarks.update(id, changes, resolve);
     });
   }
 
   function getTree(id) {
     return new Promise(resolve => {
       browser.bookmarks.getTree(resolve);
-    })
+    });
   }
 
   function remove(idOrIdList) {
     return new Promise(resolve => {
       browser.bookmarks.remove(idOrIdList, resolve);
     });
   }
 
-  function assertExpected(cookie, expected) {
-    for (var key of Object.keys(cookie)) {
-      browser.test.assertTrue(key in expected, "found property " + key);
-      browser.test.assertEq(cookie[key], expected[key], "property value for " + key + " is wrong");
-    }
-    browser.test.assertEq(Object.keys(cookie).length, Object.keys(expected).length, "all expected properties found");
-  }
-
-  var unsortedId, ourId;
+  let unsortedId, ourId;
 
   function checkOurBookmark(bookmark) {
     browser.test.assertEq(bookmark.id, ourId);
     browser.test.assertTrue("parentId" in bookmark);
     browser.test.assertEq(bookmark.index, 0); // We assume there are no other bookmarks.
     browser.test.assertEq(bookmark.url, "http://example.org/");
     browser.test.assertEq(bookmark.title, "test bookmark");
     browser.test.assertTrue("dateAdded" in bookmark);
     browser.test.assertFalse("dateGroupModified" in bookmark);
     browser.test.assertFalse("unmodifiable" in bookmark);
   }
 
   get(["not-a-bookmark-guid"]).then(result => {
     // TODO: check lastError
-    browser.test.assertEq(result.length, 0, "invalid bookmark guid returned nothing")
+    browser.test.assertEq(result.length, 0, "invalid bookmark guid returned nothing");
     return get(["000000000000"]);
   }).then(results => {
     // TODO: check lastError
     browser.test.assertEq(results.length, 0, "correctly did not find bookmark");
     return create({title: "test bookmark", url: "http://example.org"});
   }).then(result => {
     ourId = result.id;
     checkOurBookmark(result);
@@ -84,17 +78,17 @@ function backgroundScript() {
     return get(ourId);
   }).then(results => {
     browser.test.assertEq(results.length, 1);
     checkOurBookmark(results[0]);
 
     unsortedId = results[0].parentId;
     return get(unsortedId);
   }).then(results => {
-    var folder = results[0];
+    let folder = results[0];
     browser.test.assertEq(results.length, 1);
 
     browser.test.assertEq(folder.id, unsortedId);
     browser.test.assertTrue("parentId" in folder);
     browser.test.assertTrue("index" in folder);
     browser.test.assertFalse("url" in folder);
     browser.test.assertEq(folder.title, "Unsorted Bookmarks");
     browser.test.assertTrue("dateAdded" in folder);
@@ -109,17 +103,17 @@ function backgroundScript() {
     return update(ourId, {title: "new test title"});
   }).then(result => {
     browser.test.assertEq(result.title, "new test title");
     browser.test.assertEq(result.id, ourId);
 
     return getTree();
   }).then(results => {
     browser.test.assertEq(results.length, 1);
-    var bookmark = results[0].children.find(bookmark => bookmark.id == unsortedId);
+    let bookmark = results[0].children.find(bookmark => bookmark.id == unsortedId);
     browser.test.assertEq(bookmark.title, "Unsorted Bookmarks");
 
     return create({parentId: "invalid"});
   }).then(result => {
     // TODO: Check lastError
     browser.test.assertEq(result, null);
 
     return remove(ourId);
@@ -135,17 +129,17 @@ function backgroundScript() {
   }).then(() => {
     browser.test.notifyPass("bookmarks");
   });
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
-    permissions: ["bookmarks"]
+    permissions: ["bookmarks"],
   },
 };
 
 add_task(function* test_contentscript() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
   info("extension loaded");
   yield extension.awaitFinish("bookmarks");
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html
@@ -5,21 +5,20 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
-add_task(function* test_contentscript()
-{
+add_task(function* test_contentscript() {
   function backgroundScript() {
     browser.runtime.onMessage.addListener(([msg, expectedState, readyState], sender) => {
       if (msg == "chrome-namespace-ok") {
         browser.test.sendMessage(msg);
         return;
       }
 
       browser.test.assertEq(msg, "script-run", "message type is correct");
@@ -34,44 +33,44 @@ add_task(function* test_contentscript()
   function contentScriptEnd() {
     browser.runtime.sendMessage(["script-run", "interactive", document.readyState]);
   }
   function contentScriptIdle() {
     browser.runtime.sendMessage(["script-run", "complete", document.readyState]);
   }
 
   function contentScript() {
-    var manifest = browser.runtime.getManifest();
-    manifest.applications.gecko.id;
+    let manifest = browser.runtime.getManifest();
+    void manifest.applications.gecko.id;
     chrome.runtime.sendMessage(["chrome-namespace-ok"]);
   }
 
   let extensionData = {
     manifest: {
       content_scripts: [
         {
           "matches": ["http://mochi.test/*/file_sample.html"],
           "js": ["content_script_start.js"],
-          "run_at": "document_start"
+          "run_at": "document_start",
         },
         {
           "matches": ["http://mochi.test/*/file_sample.html"],
           "js": ["content_script_end.js"],
-          "run_at": "document_end"
+          "run_at": "document_end",
         },
         {
           "matches": ["http://mochi.test/*/file_sample.html"],
           "js": ["content_script_idle.js"],
-          "run_at": "document_idle"
+          "run_at": "document_idle",
         },
         {
           "matches": ["http://mochi.test/*/file_sample.html"],
           "js": ["content_script.js"],
-          "run_at": "document_idle"
-        }
+          "run_at": "document_idle",
+        },
       ],
     },
     background: "(" + backgroundScript.toString() + ")()",
 
     files: {
       "content_script_start.js": "(" + contentScriptStart.toString() + ")()",
       "content_script_end.js": "(" + contentScriptEnd.toString() + ")()",
       "content_script_idle.js": "(" + contentScriptIdle.toString() + ")()",
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies.html
@@ -5,17 +5,19 @@
   <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">
+<script type="text/javascript">
+"use strict";
+
 function backgroundScript() {
   function get(details) {
     return new Promise(resolve => {
       browser.cookies.get(details, resolve);
     });
   }
 
   function getAll(details) {
@@ -38,45 +40,45 @@ function backgroundScript() {
 
   function getAllCookieStores() {
     return new Promise(resolve => {
       browser.cookies.getAllCookieStores(resolve);
     });
   }
 
   function assertExpected(cookie, expected) {
-    for (var key of Object.keys(cookie)) {
+    for (let key of Object.keys(cookie)) {
       browser.test.assertTrue(key in expected, "found property " + key);
       browser.test.assertEq(cookie[key], expected[key], "property value for " + key + " is wrong");
     }
     browser.test.assertEq(Object.keys(cookie).length, Object.keys(expected).length, "all expected properties found");
   }
 
-  var TEST_URL = "http://example.org/";
-  var THE_FUTURE = Date.now() + 5 * 60;
+  let TEST_URL = "http://example.org/";
+  let THE_FUTURE = Date.now() + 5 * 60;
 
-  var expected = {
+  let expected = {
     name: "name1",
     value: "value1",
     domain: "example.org",
     hostOnly: true,
     path: "/",
     secure: false,
     httpOnly: false,
     session: false,
     expirationDate: THE_FUTURE,
-    storeId: "firefox-default"
+    storeId: "firefox-default",
   };
 
   set({url: TEST_URL, name: "name1", value: "value1", expirationDate: THE_FUTURE}).then(cookie => {
     assertExpected(cookie, expected);
     return get({url: TEST_URL, name: "name1"});
   }).then(cookie => {
     assertExpected(cookie, expected);
-    return getAll({domain: "example.org"})
+    return getAll({domain: "example.org"});
   }).then(cookies => {
     browser.test.assertEq(cookies.length, 1, "only found one cookie for example.org");
     assertExpected(cookies[0], expected);
     return remove({url: TEST_URL, name: "name1"});
   }).then(details => {
     assertExpected(details, {url: TEST_URL, name: "name1", storeId: "firefox-default"});
     return get({url: TEST_URL, name: "name1"});
   }).then(cookie => {
@@ -89,17 +91,17 @@ function backgroundScript() {
   }).then(() => {
     browser.test.notifyPass("cookies");
   });
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
-    permissions: ["cookies", "*://example.org/"]
+    permissions: ["cookies", "*://example.org/"],
   },
 };
 
 add_task(function* test_cookies() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield extension.startup();
   info("extension loaded");
   yield extension.awaitFinish("cookies");
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 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;
 
   function background(options) {
@@ -189,123 +189,123 @@ add_task(function* init() {
   // observer.
   SpecialPowers.setIntPref("network.cookie.maxPerHost", 3);
   SimpleTest.registerCleanupFunction(() => {
     SpecialPowers.clearUserPref("network.cookie.maxPerHost");
   });
 });
 
 add_task(function* test_good_cookie_permissions() {
-  info('Test matching, non-secure domain with non-secure cookie');
+  info("Test matching, non-secure domain with non-secure cookie");
   yield testCookies({
     permissions: ["http://example.com/", "cookies"],
     url: "http://example.com/",
     domain: "example.com",
     secure: false,
     shouldPass: true,
   });
 
-  info('Test matching, secure domain with non-secure cookie');
+  info("Test matching, secure domain with non-secure cookie");
   yield testCookies({
     permissions: ["https://example.com/", "cookies"],
     url: "https://example.com/",
     domain: "example.com",
     secure: false,
     shouldPass: true,
   });
 
-  info('Test matching, secure domain with secure cookie');
+  info("Test matching, secure domain with secure cookie");
   yield testCookies({
     permissions: ["https://example.com/", "cookies"],
     url: "https://example.com/",
     domain: "example.com",
     secure: true,
     shouldPass: true,
   });
 
-  info('Test matching subdomain with superdomain privileges, secure cookie (https)');
+  info("Test matching subdomain with superdomain privileges, secure cookie (https)");
   yield testCookies({
     permissions: ["https://foo.bar.example.com/", "cookies"],
     url: "https://foo.bar.example.com/",
     domain: ".example.com",
     secure: true,
     shouldPass: true,
   });
 
-  info('Test matching subdomain with superdomain privileges, non-secure cookie (https)');
+  info("Test matching subdomain with superdomain privileges, non-secure cookie (https)");
   yield testCookies({
     permissions: ["https://foo.bar.example.com/", "cookies"],
     url: "https://foo.bar.example.com/",
     domain: ".example.com",
     secure: false,
     shouldPass: true,
   });
 
-  info('Test matching subdomain with superdomain privileges, non-secure cookie  (http)');
+  info("Test matching subdomain with superdomain privileges, non-secure cookie  (http)");
   yield testCookies({
     permissions: ["http://foo.bar.example.com/", "cookies"],
     url: "http://foo.bar.example.com/",
     domain: ".example.com",
     secure: false,
     shouldPass: true,
   });
 });
 
 add_task(function* test_bad_cookie_permissions() {
-  info('Test non-matching, non-secure domain with non-secure cookie');
+  info("Test non-matching, non-secure domain with non-secure cookie");
   yield testCookies({
     permissions: ["http://example.com/", "cookies"],
     url: "http://example.net/",
     domain: "example.net",
     secure: false,
     shouldPass: false,
     shouldWrite: false,
   });
 
-  info('Test non-matching, secure domain with non-secure cookie');
+  info("Test non-matching, secure domain with non-secure cookie");
   yield testCookies({
     permissions: ["https://example.com/", "cookies"],
     url: "https://example.net/",
     domain: "example.net",
     secure: false,
     shouldPass: false,
     shouldWrite: false,
   });
 
-  info('Test non-matching, secure domain with secure cookie');
+  info("Test non-matching, secure domain with secure cookie");
   yield testCookies({
     permissions: ["https://example.com/", "cookies"],
     url: "https://example.net/",
     domain: "example.net",
     secure: false,
     shouldPass: false,
     shouldWrite: false,
   });
 
-  info('Test matching subdomain with superdomain privileges, secure cookie (http)');
+  info("Test matching subdomain with superdomain privileges, secure cookie (http)");
   yield testCookies({
     permissions: ["http://foo.bar.example.com/", "cookies"],
     url: "http://foo.bar.example.com/",
     domain: ".example.com",
     secure: true,
     shouldPass: false,
     shouldWrite: true,
   });
 
-  info('Test matching, non-secure domain with secure cookie');
+  info("Test matching, non-secure domain with secure cookie");
   yield testCookies({
     permissions: ["http://example.com/", "cookies"],
     url: "http://example.com/",
     domain: "example.com",
     secure: true,
     shouldPass: false,
     shouldWrite: true,
   });
 
-  info('Test matching, non-secure host, secure URL');
+  info("Test matching, non-secure host, secure URL");
   yield testCookies({
     permissions: ["http://example.com/", "cookies"],
     url: "https://example.com/",
     domain: "example.com",
     secure: true,
     shouldPass: false,
     shouldWrite: false,
   });
--- a/toolkit/components/extensions/test/mochitest/test_ext_generate.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_generate.html
@@ -5,33 +5,34 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 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() + ")()"
+  background: "(" + backgroundScript.toString() + ")()",
 };
 
 add_task(function* test_background() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   let [, x] = yield Promise.all([extension.startup(), extension.awaitMessage("running")]);
   is(x, 1, "got correct value from extension");
   info("startup complete");
--- a/toolkit/components/extensions/test/mochitest/test_ext_geturl.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_geturl.html
@@ -5,50 +5,51 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 function backgroundScript() {
   browser.runtime.onMessage.addListener(([url1, url2]) => {
-    var url3 = browser.runtime.getURL("test_file.html");
-    var url4 = browser.extension.getURL("test_file.html");
+    let url3 = browser.runtime.getURL("test_file.html");
+    let url4 = browser.extension.getURL("test_file.html");
 
     browser.test.assertTrue(url1 !== undefined, "url1 defined");
 
     browser.test.assertTrue(url1.startsWith("moz-extension://"), "url1 has correct scheme");
     browser.test.assertTrue(url1.endsWith("test_file.html"), "url1 has correct leaf name");
 
     browser.test.assertEq(url1, url2, "url2 matches");
     browser.test.assertEq(url1, url3, "url3 matches");
     browser.test.assertEq(url1, url4, "url4 matches");
 
     browser.test.notifyPass("geturl");
   });
 }
 
 function contentScript() {
-  var url1 = browser.runtime.getURL("test_file.html");
-  var url2 = browser.extension.getURL("test_file.html");
+  let url1 = browser.runtime.getURL("test_file.html");
+  let url2 = browser.extension.getURL("test_file.html");
   browser.runtime.sendMessage([url1, url2]);
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "content_scripts": [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
+      "run_at": "document_start",
+    }],
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
@@ -5,17 +5,18 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* test_i18n() {
   function runTests(assertEq) {
     let _ = browser.i18n.getMessage.bind(browser.i18n);
 
     assertEq("Foo.", _("Foo"), "Simple message in selected locale.");
 
     assertEq("(bar)", _("bar"), "Simple message fallback in default locale.");
@@ -38,17 +39,17 @@ add_task(function* test_i18n() {
 
     assertEq("$bad name$", values[2], "Named placeholder with invalid key");
 
     assertEq("", values[3], "Named placeholder with an invalid value");
 
     assertEq("Accepted, but shouldn't break.", values[4], "Named placeholder with a strange content value");
 
     assertEq("$foo", values[5], "Non-placeholder token that should be ignored");
-  };
+  }
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "default_locale": "jp",
 
       content_scripts: [
         { "matches": ["http://mochi.test/*/file_sample.html"],
           "js": ["content.js"] },
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
@@ -5,34 +5,33 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 add_task(function* test_i18n_css() {
   let extension = ExtensionTestUtils.loadExtension({
     background: "new " + function() {
       function fetch(url) {
         return new Promise((resolve, reject) => {
-          let xhr = new XMLHttpRequest;
+          let xhr = new XMLHttpRequest();
           xhr.open("GET", url);
-          xhr.onload = () => { resolve(xhr.responseText) };
+          xhr.onload = () => { resolve(xhr.responseText); };
           xhr.onerror = reject;
           xhr.send();
         });
       }
 
       Promise.all([fetch("foo.css"), fetch("bar.CsS?x#y"), fetch("foo.txt")]).then(results => {
-
         browser.test.assertEq("body { max-width: 42px; }", results[0], "CSS file localized");
         browser.test.assertEq("body { max-width: 42px; }", results[1], "CSS file localized");
 
         browser.test.assertEq("body { __MSG_foo__; }", results[2], "Text file not localized");
 
         browser.test.notifyPass("i18n-css");
       });
 
@@ -65,19 +64,19 @@ add_task(function* test_i18n_css() {
     },
   });
 
   yield extension.startup();
   let cssURL = yield extension.awaitMessage("ready");
 
   function fetch(url) {
     return new Promise((resolve, reject) => {
-      let xhr = new XMLHttpRequest;
+      let xhr = new XMLHttpRequest();
       xhr.open("GET", url);
-      xhr.onload = () => { resolve(xhr.responseText) };
+      xhr.onload = () => { resolve(xhr.responseText); };
       xhr.onerror = reject;
       xhr.send();
     });
   }
 
   let css = yield fetch(cssURL);
 
   is(css, "body { max-width: 42px; }", "CSS file localized in mochitest scope");
--- a/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html
@@ -6,54 +6,55 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* test_versioned_js() {
   // We need to deal with escaping the close script tags.
   // May as well consolidate it into one place.
-  let script = attrs => `<script ${attrs}></${'script'}>`;
+  let script = attrs => `<script ${attrs}></${"script"}>`;
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "background": {"page": "background.html"}
+      "background": {"page": "background.html"},
     },
 
     files: {
       "background.html": `
         <meta charset="utf-8">
         ${script('src="background.js" type="application/javascript"')}
         ${script('src="background-1.js" type="application/javascript;version=1.8"')}
         ${script('src="background-2.js" type="application/javascript;version=latest"')}
         ${script('src="background-3.js" type="application/javascript"')}
       `,
 
-      "background.js": "new " + function () {
+      "background.js": "new " + function() {
         browser.runtime.onMessage.addListener(msg => {
           browser.test.assertEq(
             msg, "background-script-3",
             "Expected a message only from the unversioned background script.");
 
           browser.test.sendMessage("finished");
         });
       },
 
-      "background-1.js": "new " + function () {
+      "background-1.js": "new " + function() {
         browser.runtime.sendMessage("background-script-1");
       },
-      "background-2.js": "new " + function () {
+      "background-2.js": "new " + function() {
         browser.runtime.sendMessage("background-script-2");
       },
-      "background-3.js": "new " + function () {
+      "background-3.js": "new " + function() {
         browser.runtime.sendMessage("background-script-3");
       },
     },
   });
 
   let messages = [/Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/,
                   /Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/];
 
--- a/toolkit/components/extensions/test/mochitest/test_ext_localStorage.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_localStorage.html
@@ -5,28 +5,28 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
-  var hasRun = localStorage.getItem("has-run");
-  var result;
+  let hasRun = localStorage.getItem("has-run");
+  let result;
   if (!hasRun) {
     localStorage.setItem("has-run", "yup");
     localStorage.setItem("test-item", "item1");
     result = "item1";
   } else {
-    var data = localStorage.getItem("test-item");
+    let data = localStorage.getItem("test-item");
     if (data == "item1") {
       localStorage.setItem("test-item", "item2");
       result = "item2";
     } else if (data == "item2") {
       localStorage.removeItem("test-item");
       result = "deleted";
     } else if (!data) {
       localStorage.clear();
--- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
@@ -4,38 +4,39 @@
   <title>Test for notifications</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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* test_notifications() {
   function backgroundScript() {
     browser.test.log("running background script");
 
-    var opts = {title: "Testing Notification", message: "Carry on"};
+    let opts = {title: "Testing Notification", message: "Carry on"};
 
     // Test an unimplemented listener.
     browser.notifications.onClicked.addListener(function() {});
 
     browser.notifications.create("5", opts, function(id) {
       browser.test.sendMessage("running", id);
       browser.test.notifyPass("background test passed");
     });
   }
 
   let extensionData = {
     manifest: {
-      permissions: ["notifications"]
+      permissions: ["notifications"],
     },
-    background: "(" + backgroundScript.toString() + ")()"
+    background: "(" + backgroundScript.toString() + ")()",
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   yield extension.startup();
   info("startup complete");
   let x = yield extension.awaitMessage("running");
   is(x, "5", "got correct value from extension");
@@ -54,36 +55,36 @@ add_task(function* test_notifications_em
         "getAll() returned an array");
       browser.test.assertEq(notifications.length, 0, "the array was empty");
       browser.test.notifyPass("getAll empty");
     });
   }
 
   let extensionData = {
     manifest: {
-      permissions: ["notifications"]
+      permissions: ["notifications"],
     },
-    background: "(" + backgroundScript.toString() + ")()"
+    background: "(" + backgroundScript.toString() + ")()",
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   yield extension.startup();
   info("startup complete");
   yield extension.awaitFinish("getAll empty");
   info("test complete");
   yield extension.unload();
   info("extension unloaded successfully");
 });
 
 add_task(function* test_notifications_populated_getAll() {
   function backgroundScript() {
     browser.test.log("running background script");
 
-    var opts = {title: "Testing Notification", message: "Carry on"};
+    let opts = {title: "Testing Notification", message: "Carry on"};
     browser.notifications.create("p1", opts, () => {
       browser.notifications.create("p2", opts, () => {
         browser.notifications.getAll(notifications => {
           browser.test.assertTrue(Array.isArray(notifications),
             "getAll() returned an array");
           browser.test.assertEq(notifications.length, 2,
             "the array contained two notification ids");
           browser.test.assertTrue(notifications.includes("p1"),
@@ -93,19 +94,19 @@ add_task(function* test_notifications_po
           browser.test.notifyPass("getAll populated");
         });
       });
     });
   }
 
   let extensionData = {
     manifest: {
-      permissions: ["notifications"]
+      permissions: ["notifications"],
     },
-    background: "(" + backgroundScript.toString() + ")()"
+    background: "(" + backgroundScript.toString() + ")()",
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   yield extension.startup();
   info("startup complete");
   yield extension.awaitFinish("getAll populated");
   info("test complete");
--- a/toolkit/components/extensions/test/mochitest/test_ext_onmessage_removelistener.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_onmessage_removelistener.html
@@ -5,21 +5,20 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
-  var count = 0;
   function listener() {
     browser.test.notifyFail("listener should not be invoked");
   }
 
   browser.runtime.onMessage.addListener(listener);
   browser.runtime.onMessage.removeListener(listener);
   browser.runtime.sendMessage("hello");
 
--- a/toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_permission_xhr.html
@@ -5,32 +5,35 @@
   <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">
+<script type="text/javascript">
+"use strict";
+
+/* eslint-disable mozilla/balanced-listeners */
 
 add_task(function* test_simple() {
   function runTests(cx, assertTrue, finish) {
     function run(shouldFail, finish) {
       function passListener() {
         assertTrue(true, `${cx} pass listener`);
         finish();
       }
 
       function failListener() {
         assertTrue(false, `${cx} fail listener`);
         finish();
       }
 
-      var req = new XMLHttpRequest();
+      let req = new XMLHttpRequest();
       if (shouldFail) {
         req.addEventListener("load", failListener);
         req.addEventListener("error", passListener);
         req.open("GET", "http://example.org/example.txt");
       } else {
         req.addEventListener("load", passListener);
         req.addEventListener("error", failListener);
         req.open("GET", "http://example.com/example.txt");
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
@@ -5,26 +5,26 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   browser.runtime.onConnect.addListener(port => {
     browser.test.assertEq(port.name, "ernie", "port name correct");
     browser.test.assertTrue(port.sender.url.endsWith("file_sample.html"), "URL correct");
     browser.test.assertTrue(port.sender.tab.url.endsWith("file_sample.html"), "tab URL correct");
 
-    var expected = "message 1";
+    let expected = "message 1";
     port.onMessage.addListener(msg => {
       browser.test.assertEq(msg, expected, "message is expected");
       if (expected == "message 1") {
         port.postMessage("message 2");
         expected = "message 3";
       } else if (expected == "message 3") {
         expected = "disconnect";
         browser.test.notifyPass("runtime.connect");
@@ -32,35 +32,35 @@ function backgroundScript() {
     });
     port.onDisconnect.addListener(() => {
       browser.test.assertEq(expected, "disconnect", "got disconnection at right time");
     });
   });
 }
 
 function contentScript() {
-  var port = browser.runtime.connect({name: "ernie"});
+  let port = browser.runtime.connect({name: "ernie"});
   port.postMessage("message 1");
   port.onMessage.addListener(msg => {
     if (msg == "message 2") {
       port.postMessage("message 3");
       port.disconnect();
     }
   });
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "permissions": ["tabs"],
     "content_scripts": [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
+      "run_at": "document_start",
+    }],
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript(token) {
   browser.runtime.onMessage.addListener(msg => {
     browser.test.assertEq(msg, "done");
     browser.test.notifyPass("sendmessage_reply");
   });
 
@@ -38,17 +38,17 @@ function contentScript(token) {
     if (port.name == token) {
       gotTabMessage = true;
     } else {
       badTabMessage = true;
     }
     port.disconnect();
   });
 
-  var port = browser.runtime.connect(null, {name: token});
+  let port = browser.runtime.connect(null, {name: token});
   port.onMessage.addListener(function(msg) {
     if (msg != token + "-done" || !gotTabMessage || badTabMessage) {
       return; // test failed
     }
 
     // FIXME: Removing this line causes the test to fail:
     // resource://gre/modules/ExtensionUtils.jsm, line 651: NS_ERROR_NOT_INITIALIZED
     port.disconnect();
@@ -60,26 +60,26 @@ function makeExtension() {
   let token = Math.random();
   let extensionData = {
     background: `(${backgroundScript})("${token}")`,
     manifest: {
       "permissions": ["tabs"],
       "content_scripts": [{
         "matches": ["http://mochi.test/*/file_sample.html"],
         "js": ["content_script.js"],
-        "run_at": "document_start"
-      }]
+        "run_at": "document_start",
+      }],
     },
 
     files: {
       "content_script.js": `(${contentScript})("${token}")`,
     },
   };
   return extensionData;
-};
+}
 
 add_task(function* test_contentscript() {
   let extension1 = ExtensionTestUtils.loadExtension(makeExtension());
   let extension2 = ExtensionTestUtils.loadExtension(makeExtension());
   yield Promise.all([extension1.startup(), extension2.startup()]);
   info("extensions loaded");
 
   let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   browser.runtime.onConnect.addListener(port => {
     browser.test.assertEq(port.name, "ernie", "port name correct");
     port.onDisconnect.addListener(() => {
       browser.test.sendMessage("disconnected");
     });
@@ -29,18 +29,18 @@ function contentScript() {
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "permissions": ["tabs"],
     "content_scripts": [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
+      "run_at": "document_start",
+    }],
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
@@ -55,17 +55,17 @@ add_task(function* test_contentscript() 
 
   info("win.close() succeeded");
 
   win = window.open("file_sample.html");
   yield Promise.all([waitForLoad(win), extension.awaitMessage("connected")]);
 
   // Add an "unload" listener so that we don't put the window in the
   // bfcache. This way it gets destroyed immediately upon navigation.
-  win.addEventListener("unload", function() {});
+  win.addEventListener("unload", function() {});  // eslint-disable-line mozilla/balanced-listeners
 
   win.location = "http://example.com";
   yield extension.awaitMessage("disconnected");
   win.close();
 
   yield extension.unload();
   info("extension unloaded");
 });
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_getPlatformInfo.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_getPlatformInfo.html
@@ -5,23 +5,23 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   browser.runtime.getPlatformInfo(info => {
-    var validOSs = ["mac", "win", "android", "cros", "linux", "openbsd"];
-    var validArchs = ["arm", "x86-32", "x86-64"];
+    let validOSs = ["mac", "win", "android", "cros", "linux", "openbsd"];
+    let validArchs = ["arm", "x86-32", "x86-64"];
 
     browser.test.assertTrue(validOSs.indexOf(info.os) != -1, "OS is valid");
     browser.test.assertTrue(validArchs.indexOf(info.arch) != -1, "Architecture is valid");
     browser.test.notifyPass("runtime.getPlatformInfo");
   });
 }
 
 let extensionData = {
--- a/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   browser.runtime.onMessage.addListener(result => {
     browser.test.assertEq(result, 12, "x is 12");
     browser.test.notifyPass("background test passed");
   });
 }
@@ -27,18 +27,18 @@ function contentScript() {
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "content_scripts": [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
+      "run_at": "document_start",
+    }],
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   // Add two listeners that both send replies. We're supposed to ignore all but one
   // of them. Which one is chosen is non-deterministic.
 
   browser.runtime.onMessage.addListener((msg, sender, sendReply) => {
     browser.test.assertTrue(sender.tab.url.endsWith("file_sample.html"), "sender url correct");
@@ -36,17 +36,17 @@ function backgroundScript() {
   function sleep(callback, n = 10) {
     if (n == 0) {
       callback();
     } else {
       setTimeout(function() { sleep(callback, n - 1); }, 0);
     }
   }
 
-  var done_count = 0;
+  let done_count = 0;
   browser.runtime.onMessage.addListener((msg, sender, sendReply) => {
     browser.test.assertTrue(sender.tab.url.endsWith("file_sample.html"), "sender url correct");
 
     if (msg == "done") {
       done_count++;
       browser.test.assertEq(done_count, 1, "got exactly one reply");
 
       // Go through the event loop a few times to make sure we don't get multiple replies.
@@ -68,18 +68,18 @@ function contentScript() {
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "permissions": ["tabs"],
     "content_scripts": [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
+      "run_at": "document_start",
+    }],
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   browser.runtime.onMessage.addListener((msg, sender, sendReply) => {
     browser.test.assertTrue(sender.tab.url.endsWith("file_sample.html"), "sender url correct");
 
     if (msg == 0) {
       sendReply("reply1");
@@ -46,18 +46,18 @@ function contentScript() {
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
     "permissions": ["tabs"],
     "content_scripts": [{
       "matches": ["http://mochi.test/*/file_sample.html"],
       "js": ["content_script.js"],
-      "run_at": "document_start"
-    }]
+      "run_at": "document_start",
+    }],
   },
 
   files: {
     "content_script.js": "(" + contentScript.toString() + ")()",
   },
 };
 
 add_task(function* test_contentscript() {
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript(token) {
   browser.runtime.onMessage.addListener((msg, sender, sendReply) => {
     browser.test.assertTrue(sender.tab.url.endsWith("file_sample.html"), "sender url correct");
 
     if (msg == "done") {
       browser.test.notifyPass("sendmessage_reply");
@@ -53,26 +53,26 @@ function makeExtension() {
   let token = Math.random();
   let extensionData = {
     background: `(${backgroundScript})(${token})`,
     manifest: {
       "permissions": ["tabs"],
       "content_scripts": [{
         "matches": ["http://mochi.test/*/file_sample.html"],
         "js": ["content_script.js"],
-        "run_at": "document_start"
-      }]
+        "run_at": "document_start",
+      }],
     },
 
     files: {
       "content_script.js": `(${contentScript})(${token})`,
     },
   };
   return extensionData;
-};
+}
 
 add_task(function* test_contentscript() {
   let extension1 = ExtensionTestUtils.loadExtension(makeExtension());
   let extension2 = ExtensionTestUtils.loadExtension(makeExtension());
   yield Promise.all([extension1.startup(), extension2.startup()]);
   info("extensions loaded");
 
   let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_simple.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_simple.html
@@ -5,26 +5,27 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 add_task(function* test_simple() {
   let extensionData = {
     manifest: {
       "name": "Simple extension test",
       "version": "1.0",
       "manifest_version": 2,
-      "description": ""
-    }
+      "description": "",
+    },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   yield extension.startup();
   info("startup complete");
   yield extension.unload();
   info("extension unloaded successfully");
@@ -45,18 +46,18 @@ add_task(function* test_background() {
   }
 
   let extensionData = {
     background: "(" + backgroundScript.toString() + ")()",
     manifest: {
       "name": "Simple extension test",
       "version": "1.0",
       "manifest_version": 2,
-      "description": ""
-    }
+      "description": "",
+    },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   let [, x] = yield Promise.all([extension.startup(), extension.awaitMessage("running")]);
   is(x, 1, "got correct value from extension");
   info("startup complete");
   extension.sendMessage(10, 20);
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_storage.html
@@ -5,17 +5,18 @@
   <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">
+<script type="text/javascript">
+"use strict";
 
 function backgroundScript() {
   function set(items) {
     return new Promise(resolve => {
       browser.storage.local.set(items, resolve);
     });
   }
 
@@ -47,36 +48,38 @@ function backgroundScript() {
     }).then(data => {
       browser.test.assertEq(data[prop], value, "array getter worked for " + prop);
       return get({[prop]: undefined});
     }).then(data => {
       browser.test.assertEq(data[prop], value, "object getter worked for " + prop);
     });
   }
 
-  var globalChanges = {};
+  let globalChanges = {};
 
   browser.storage.onChanged.addListener((changes, storage) => {
     browser.test.assertEq(storage, "local", "storage is local");
     Object.assign(globalChanges, changes);
   });
 
   function checkChanges(changes) {
     function checkSub(obj1, obj2) {
-      for (var prop in obj1) {
+      for (let prop in obj1) {
         browser.test.assertEq(obj1[prop].oldValue, obj2[prop].oldValue);
         browser.test.assertEq(obj1[prop].newValue, obj2[prop].newValue);
       }
     }
 
     checkSub(changes, globalChanges);
     checkSub(globalChanges, changes);
     globalChanges = {};
   }
 
+  /* eslint-disable dot-notation */
+
   // Set some data and then test getters.
   set({"test-prop1": "value1", "test-prop2": "value2"}).then(() => {
     checkChanges({"test-prop1": {newValue: "value1"}, "test-prop2": {newValue: "value2"}});
     return check("test-prop1", "value1");
   }).then(() => {
     return check("test-prop2", "value2");
   }).then(() => {
     return get({"test-prop1": undefined, "test-prop2": undefined, "other": "default"});
@@ -144,36 +147,35 @@ function backgroundScript() {
   }).then(() => {
     return set({"test-prop1": {str: "hello", bool: true, undef: undefined, obj: {}, arr: [1, 2]}});
   }).then(() => {
     browser.test.assertEq(globalChanges["test-prop1"].oldValue, "value1", "oldValue correct");
     browser.test.assertEq(typeof(globalChanges["test-prop1"].newValue), "object", "newValue is obj");
     globalChanges = {};
     return get({"test-prop1": undefined});
   }).then(data => {
-    var obj = data["test-prop1"];
+    let obj = data["test-prop1"];
 
     browser.test.assertEq(obj.str, "hello", "string part correct");
     browser.test.assertEq(obj.bool, true, "bool part correct");
     browser.test.assertEq(obj.undef, undefined, "undefined part correct");
     browser.test.assertEq(typeof(obj.obj), "object", "object part correct");
     browser.test.assertTrue(Array.isArray(obj.arr), "array part present");
     browser.test.assertEq(obj.arr[0], 1, "arr[0] part correct");
     browser.test.assertEq(obj.arr[1], 2, "arr[1] part correct");
     browser.test.assertEq(obj.arr.length, 2, "arr.length part correct");
-
   }).then(() => {
     browser.test.notifyPass("storage");
   });
 }
 
 let extensionData = {
   background: "(" + backgroundScript.toString() + ")()",
   manifest: {
-    permissions: ["storage"]
+    permissions: ["storage"],
   },
 };
 
 add_task(function* test_contentscript() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   yield Promise.all([extension.startup(), extension.awaitMessage("invalidate")]);
   SpecialPowers.invalidateExtensionStorageCache();
   extension.sendMessage("invalidated");
--- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html
@@ -5,36 +5,35 @@
   <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">
+<script type="text/javascript">
 "use strict";
 
 function backgroundScript() {
   const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest";
   const URL = BASE + "/file_WebNavigation_page1.html";
 
   const EVENTS = [
     "onBeforeNavigate",
     "onCommitted",
     "onDOMContentLoaded",
     "onCompleted",
     "onErrorOccurred",
     "onReferenceFragmentUpdated",
   ];
 
-  var expectedTabId = -1;
+  let expectedTabId = -1;
 
-  function gotEvent(event, details)
-  {
+  function gotEvent(event, details) {
     if (!details.url.startsWith(BASE)) {
       return;
     }
     browser.test.log(`Got ${event} ${details.url} ${details.frameId} ${details.parentFrameId}`);
 
     if (expectedTabId == -1) {
       browser.test.assertTrue(details.tabId !== undefined, "tab ID defined");
       expectedTabId = details.tabId;
@@ -51,18 +50,18 @@ function backgroundScript() {
       browser.test.assertEq(details.parentFrameId, 0, "parent frame ID correct");
       browser.test.assertTrue(details.frameId != 0, "frame ID probably okay");
     }
 
     browser.test.assertTrue(details.frameId !== undefined);
     browser.test.assertTrue(details.parentFrameId !== undefined);
   }
 
-  var listeners = {};
-  for (var event of EVENTS) {
+  let listeners = {};
+  for (let event of EVENTS) {
     listeners[event] = gotEvent.bind(null, event);
     browser.webNavigation[event].addListener(listeners[event]);
   }
 
   browser.test.sendMessage("ready", browser.webRequest.ResourceType);
 }
 
 const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest";
@@ -76,23 +75,22 @@ const REQUIRED = [
   "onDOMContentLoaded",
   "onCompleted",
 ];
 
 var received = [];
 var completedResolve;
 var waitingURL, waitingEvent;
 
-function loadAndWait(win, event, url, script)
-{
+function loadAndWait(win, event, url, script) {
   received = [];
   waitingEvent = event;
   waitingURL = url;
   dump(`RUN ${script}\n`);
-  eval(script);
+  script();
   return new Promise(resolve => { completedResolve = resolve; });
 }
 
 add_task(function* webnav_ordering() {
   let extensionData = {
     manifest: {
       permissions: [
         "webNavigation",
@@ -111,17 +109,17 @@ add_task(function* webnav_ordering() {
     }
   });
 
   yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
   info("webnavigation extension loaded");
 
   let win = window.open();
 
-  yield loadAndWait(win, "onCompleted", URL, `win.location = "${URL}";`);
+  yield loadAndWait(win, "onCompleted", URL, () => { win.location = URL; });
 
   function checkRequired(url) {
     for (let event of REQUIRED) {
       let found = false;
       for (let r of received) {
         if (r.url == url && r.event == event) {
           found = true;
         }
@@ -148,22 +146,22 @@ add_task(function* webnav_ordering() {
     ok(index1 != -1, `Action ${JSON.stringify(action1)} happened`);
     ok(index2 != -1, `Action ${JSON.stringify(action2)} happened`);
     ok(index1 < index2, `Action ${JSON.stringify(action1)} happened before ${JSON.stringify(action2)}`);
   }
 
   checkBefore({url: URL, event: "onCommitted"}, {url: FRAME, event: "onBeforeNavigate"});
   checkBefore({url: FRAME, event: "onCompleted"}, {url: URL, event: "onCompleted"});
 
-  yield loadAndWait(win, "onCompleted", FRAME2, `win.frames[0].location = "${FRAME2}";`);
+  yield loadAndWait(win, "onCompleted", FRAME2, () => { win.frames[0].location = FRAME2; });
 
   checkRequired(FRAME2);
 
   yield loadAndWait(win, "onReferenceFragmentUpdated", FRAME2 + "#ref",
-                    "win.frames[0].document.getElementById('elt').click();");
+                    () => { win.frames[0].document.getElementById("elt").click(); });
 
   info("Received onReferenceFragmentUpdated from FRAME2");
 
   win.close();
 
   yield extension.unload();
   info("webnavigation extension unloaded");
 });
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest.html
@@ -5,17 +5,17 @@
   <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">
+<script type="text/javascript">
 "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",
@@ -56,81 +56,75 @@ const expected_complete = [BASE + "/file
                            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 + "/dummy_page.html",
                            BASE + "/xhr_resource"];
 
-function removeDupes(list)
-{
+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)
-{
+function compareLists(list1, list2, kind) {
   list1.sort();
   removeDupes(list1);
   list2.sort();
   removeDupes(list2);
   is(String(list1), String(list2), `${kind} URLs correct`);
 }
 
-function backgroundScript()
-{
+function backgroundScript() {
   const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest";
 
-  var savedTabId = -1;
+  let savedTabId = -1;
 
-  function checkType(details)
-  {
-    var expected_type = "???";
+  function checkType(details) {
+    let expected_type = "???";
     if (details.url.indexOf("style") != -1) {
       expected_type = "stylesheet";
     } else if (details.url.indexOf("image") != -1) {
       expected_type = "image";
     } else if (details.url.indexOf("script") != -1) {
       expected_type = "script";
     } else if (details.url.indexOf("page1") != -1) {
       expected_type = "main_frame";
     } else if (/page2|redirection|dummy_page/.test(details.url)) {
       expected_type = "sub_frame";
     } else if (details.url.indexOf("xhr") != -1) {
       expected_type = "xmlhttprequest";
     }
     browser.test.assertEq(details.type, expected_type, "resource type is correct");
   }
 
-  var frameIDs = new Map();
+  let frameIDs = new Map();
 
-  var recorded = {requested: [],
+  let recorded = {requested: [],
                   beforeSendHeaders: [],
                   beforeRedirect: [],
                   sendHeaders: [],
                   responseStarted: [],
                   completed: []};
 
-  function checkResourceType(type)
-  {
-    var key = type.toUpperCase();
+  function checkResourceType(type) {
+    let key = type.toUpperCase();
     browser.test.assertTrue(key in browser.webRequest.ResourceType);
   }
 
-  function onBeforeRequest(details)
-  {
+  function onBeforeRequest(details) {
     browser.test.log(`onBeforeRequest ${details.url}`);
     checkResourceType(details.type);
     if (details.url.startsWith(BASE)) {
       recorded.requested.push(details.url);
 
       if (savedTabId == -1) {
         browser.test.assertTrue(details.tabId !== undefined, "tab ID defined");
         savedTabId = details.tabId;
@@ -151,117 +145,112 @@ function backgroundScript()
       }
     }
     if (details.url.indexOf("_bad.") != -1) {
       return {cancel: true};
     }
     return {};
   }
 
-  function onBeforeSendHeaders(details)
-  {
+  function onBeforeSendHeaders(details) {
     browser.test.log(`onBeforeSendHeaders ${details.url}`);
     checkResourceType(details.type);
     if (details.url.startsWith(BASE)) {
       recorded.beforeSendHeaders.push(details.url);
 
       browser.test.assertEq(details.tabId, savedTabId, "correct tab ID");
       checkType(details);
 
-      var id = frameIDs.get(details.url);
+      let id = frameIDs.get(details.url);
       browser.test.assertEq(id, details.frameId, "frame ID same in onBeforeSendHeaders as onBeforeRequest");
     }
     if (details.url.indexOf("_redirect.") != -1) {
       return {redirectUrl: details.url.replace("_redirect.", "_good.")};
     }
     return {};
   }
 
-  function onBeforeRedirect(details)
-  {
+  function onBeforeRedirect(details) {
     browser.test.log(`onBeforeRedirect ${details.url} -> ${details.redirectUrl}`);
     checkResourceType(details.type);
     if (details.url.startsWith(BASE)) {
       recorded.beforeRedirect.push(details.url);
 
       browser.test.assertEq(details.tabId, savedTabId, "correct tab ID");
       checkType(details);
 
-      var id = frameIDs.get(details.url);
+      let id = frameIDs.get(details.url);
       browser.test.assertEq(id, details.frameId, "frame ID same in onBeforeRedirect as onBeforeRequest");
       frameIDs.set(details.redirectUrl, details.frameId);
     }
     if (details.url.indexOf("_redirect.") != -1) {
       let expectedUrl = details.url.replace("_redirect.", "_good.");
       browser.test.assertEq(details.redirectUrl, expectedUrl, "correct redirectUrl value");
     }
     return {};
   }
 
-  function onRecord(kind, details)
-  {
+  function onRecord(kind, details) {
     checkResourceType(details.type);
     if (details.url.startsWith(BASE)) {
       recorded[kind].push(details.url);
     }
   }
 
   browser.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["<all_urls>"]}, ["blocking"]);
   browser.webRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, {urls: ["<all_urls>"]}, ["blocking"]);
   browser.webRequest.onSendHeaders.addListener(onRecord.bind(null, "sendHeaders"), {urls: ["<all_urls>"]});
   browser.webRequest.onBeforeRedirect.addListener(onBeforeRedirect, {urls: ["<all_urls>"]});
   browser.webRequest.onResponseStarted.addListener(onRecord.bind(null, "responseStarted"), {urls: ["<all_urls>"]});
   browser.webRequest.onCompleted.addListener(onRecord.bind(null, "completed"), {urls: ["<all_urls>"]});
 
-  function onTestMessage()
-  {
+  function onTestMessage() {
     browser.test.sendMessage("results", recorded);
   }
 
   browser.test.onMessage.addListener(onTestMessage);
 
   browser.test.sendMessage("ready", browser.webRequest.ResourceType);
 }
 
-function* test_once()
-{
+function* test_once() {
   let extensionData = {
     manifest: {
       permissions: [
         "webRequest",
-        "webRequestBlocking"
+        "webRequestBlocking",
       ],
     },
     background: "(" + backgroundScript.toString() + ")()",
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   let [, resourceTypes] = yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
   info("webrequest extension loaded");
 
-  for (var key in resourceTypes) {
-    var value = resourceTypes[key];
+  for (let key in resourceTypes) {
+    let value = resourceTypes[key];
     is(key, value.toUpperCase());
   }
 
   // Check a few Firefox-specific types.
   is(resourceTypes.XBL, "xbl", "XBL resource type supported");
   is(resourceTypes.FONT, "font", "Font resource type supported");
   is(resourceTypes.WEBSOCKET, "websocket", "Websocket resource type supported");
 
   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);
+  let imgTools = SpecialPowers.Cc["@mozilla.org/image/tools;1"].getService(SpecialPowers.Ci.imgITools);
+  let cache = imgTools.getImgCacheForDocument(win.document);
   cache.clearCache(false);
 
-  //yield waitForLoad(win);
+  // 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");