Merge mozilla-central to inbound. a=merge CLOSED TREE
authorBogdan Tara <btara@mozilla.com>
Fri, 18 May 2018 01:08:52 +0300
changeset 418784 5428125d8636
parent 418783 c6b1884407a7 (current diff)
parent 418746 54063deb2f1c (diff)
child 418785 8fe97d20da6f
push id34013
push userdluca@mozilla.com
push date2018-05-18 09:56 +0000
treeherdermozilla-central@11ee70f24ea5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone62.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
Merge mozilla-central to inbound. a=merge CLOSED TREE
testing/mozharness/external_tools/virtualenv/AUTHORS.txt
testing/mozharness/external_tools/virtualenv/LICENSE.txt
testing/mozharness/external_tools/virtualenv/MANIFEST.in
testing/mozharness/external_tools/virtualenv/PKG-INFO
testing/mozharness/external_tools/virtualenv/README.rst
testing/mozharness/external_tools/virtualenv/bin/rebuild-script.py
testing/mozharness/external_tools/virtualenv/docs/Makefile
testing/mozharness/external_tools/virtualenv/docs/changes.rst
testing/mozharness/external_tools/virtualenv/docs/conf.py
testing/mozharness/external_tools/virtualenv/docs/development.rst
testing/mozharness/external_tools/virtualenv/docs/index.rst
testing/mozharness/external_tools/virtualenv/docs/installation.rst
testing/mozharness/external_tools/virtualenv/docs/make.bat
testing/mozharness/external_tools/virtualenv/docs/reference.rst
testing/mozharness/external_tools/virtualenv/docs/userguide.rst
testing/mozharness/external_tools/virtualenv/scripts/virtualenv
testing/mozharness/external_tools/virtualenv/setup.cfg
testing/mozharness/external_tools/virtualenv/setup.py
testing/mozharness/external_tools/virtualenv/site.py
testing/mozharness/external_tools/virtualenv/tests/__init__.py
testing/mozharness/external_tools/virtualenv/tests/test_activate.sh
testing/mozharness/external_tools/virtualenv/tests/test_activate_output.expected
testing/mozharness/external_tools/virtualenv/tests/test_cmdline.py
testing/mozharness/external_tools/virtualenv/tests/test_virtualenv.py
testing/mozharness/external_tools/virtualenv/virtualenv.py
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/activate.bat
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/activate.csh
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/activate.fish
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/activate.ps1
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/activate.sh
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/activate_this.py
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/deactivate.bat
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/distutils-init.py
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/distutils.cfg
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/python-config
testing/mozharness/external_tools/virtualenv/virtualenv_embedded/site.py
testing/mozharness/external_tools/virtualenv/virtualenv_support/__init__.py
testing/mozharness/external_tools/virtualenv/virtualenv_support/argparse-1.4.0-py2.py3-none-any.whl
testing/mozharness/external_tools/virtualenv/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl
testing/mozharness/external_tools/virtualenv/virtualenv_support/setuptools-25.2.0-py2.py3-none-any.whl
testing/mozharness/external_tools/virtualenv/virtualenv_support/wheel-0.29.0-py2.py3-none-any.whl
--- a/.cron.yml
+++ b/.cron.yml
@@ -10,17 +10,16 @@ jobs:
           type: decision-task
           treeherder-symbol: Nd
           target-tasks-method: nightly_desktop
       run-on-projects:
           - mozilla-central
       when:
           by-project:
               # Match buildbot starts for now
-              date: [{hour: 15, minute: 0}]
               mozilla-central: [{hour: 10, minute: 0}, {hour: 22, minute: 0}]
               # No default
 
     - name: nightly-desktop-linux
       job:
           type: decision-task
           treeherder-symbol: Nd-Ln
           target-tasks-method: nightly_linux
@@ -60,17 +59,16 @@ jobs:
           type: decision-task
           treeherder-symbol: Na
           target-tasks-method: nightly_fennec
       run-on-projects:
           - mozilla-central
       when:
           by-project:
               # Match buildbot starts for now
-              date: [{hour: 15, minute: 0}]
               mozilla-central: [{hour: 10, minute: 0}]
               # No default
 
     - name: nightly-mochitest-valgrind
       job:
           type: decision-task
           treeherder-symbol: Vg
           target-tasks-method: mochitest_valgrind
--- a/.eslintignore
+++ b/.eslintignore
@@ -213,18 +213,20 @@ dom/html/**
 dom/imptests/**
 dom/interfaces/**
 dom/ipc/**
 dom/json/**
 dom/jsurl/**
 dom/locales/**
 dom/manifest/**
 dom/mathml/**
-dom/media/**
-!dom/media/*.js*
+dom/media/test/**
+dom/media/tests/**
+dom/media/webaudio/**
+dom/media/webspeech/**
 dom/messagechannel/**
 dom/midi/**
 dom/network/**
 dom/notification/Notification*.*
 dom/notification/test/browser/**
 dom/notification/test/unit/**
 dom/notification/test/mochitest/**
 dom/offline/**
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -1614,17 +1614,17 @@ window._gBrowser = {
 
     // Make sure to restore the original droppedLinkHandler and
     // sameProcessAsFrameLoader.
     let droppedLinkHandler = aBrowser.droppedLinkHandler;
     let sameProcessAsFrameLoader = aBrowser.sameProcessAsFrameLoader;
 
     // Change the "remote" attribute.
     let parent = aBrowser.parentNode;
-    parent.removeChild(aBrowser);
+    aBrowser.remove();
     if (aShouldBeRemote) {
       aBrowser.setAttribute("remote", "true");
       aBrowser.setAttribute("remoteType", aOptions.remoteType);
     } else {
       aBrowser.setAttribute("remote", "false");
       aBrowser.removeAttribute("remoteType");
     }
 
@@ -2125,19 +2125,17 @@ window._gBrowser = {
     // Reset the findbar and remove it if it is attached to the tab.
     if (tab._findBar) {
       tab._findBar.close(true);
       tab._findBar.remove();
       delete tab._findBar;
     }
 
     aBrowser.destroy();
-
-    let notificationbox = this.getNotificationBox(aBrowser);
-    this.tabpanels.removeChild(notificationbox);
+    this.getNotificationBox(aBrowser).remove();
     tab.removeAttribute("linkedpanel");
 
     this._createLazyBrowser(tab);
 
     let evt = new CustomEvent("TabBrowserDiscarded", { bubbles: true });
     tab.dispatchEvent(evt);
   },
 
@@ -2921,17 +2919,17 @@ window._gBrowser = {
       // This has to happen before we remove the child so that the
       // XBL implementation of nsIObserver still works.
       browser.destroy();
     }
 
     var wasPinned = aTab.pinned;
 
     // Remove the tab ...
-    this.tabContainer.removeChild(aTab);
+    aTab.remove();
 
     // Update hashiddentabs if this tab was hidden.
     if (aTab.hidden)
       this.tabContainer._updateHiddenTabsStatus();
 
     // ... and fix up the _tPos properties immediately.
     for (let i = aTab._tPos; i < this.tabs.length; i++)
       this.tabs[i]._tPos = i;
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -774,20 +774,25 @@ function setDefaultPref(prefName, prefVa
  * @param {array} blockList
  *        The list of URLs to be set as DENY_ACTION for the chosen permission.
  */
 function addAllowDenyPermissions(permissionName, allowList, blockList) {
   allowList = allowList || [];
   blockList = blockList || [];
 
   for (let origin of allowList) {
-    Services.perms.add(origin,
-                       permissionName,
-                       Ci.nsIPermissionManager.ALLOW_ACTION,
-                       Ci.nsIPermissionManager.EXPIRE_POLICY);
+    try {
+      Services.perms.add(origin,
+                         permissionName,
+                         Ci.nsIPermissionManager.ALLOW_ACTION,
+                         Ci.nsIPermissionManager.EXPIRE_POLICY);
+    } catch (ex) {
+      log.error(`Added by default for ${permissionName} permission in the permission
+      manager - ${origin.spec}`);
+    }
   }
 
   for (let origin of blockList) {
     Services.perms.add(origin,
                        permissionName,
                        Ci.nsIPermissionManager.DENY_ACTION,
                        Ci.nsIPermissionManager.EXPIRE_POLICY);
   }
--- a/config/check_vanilla_allocations.py
+++ b/config/check_vanilla_allocations.py
@@ -37,16 +37,17 @@
 #----------------------------------------------------------------------------
 
 from __future__ import print_function
 
 import argparse
 import re
 import subprocess
 import sys
+import buildconfig
 
 # The obvious way to implement this script is to search for occurrences of
 # malloc et al, succeed if none are found, and fail is some are found.
 # However, "none are found" does not necessarily mean "none are present" --
 # this script could be buggy.  (Or the output format of |nm| might change in
 # the future.)
 #
 # So jsutil.cpp deliberately contains a (never-called) function that contains a
@@ -71,17 +72,18 @@ def main():
     parser.add_argument('file', type=str,
                         help='name of the file to check')
     args = parser.parse_args()
 
     # Run |nm|.  Options:
     # -u: show only undefined symbols
     # -C: demangle symbol names
     # -A: show an object filename for each undefined symbol
-    cmd = ['nm', '-u', '-C', '-A', args.file]
+    nm = buildconfig.substs.get('NM') or 'nm'
+    cmd = [nm, '-u', '-C', '-A', args.file]
     lines = subprocess.check_output(cmd, universal_newlines=True,
                                     stderr=subprocess.PIPE).split('\n')
 
     # alloc_fns contains all the vanilla allocation/free functions that we look
     # for. Regexp chars are escaped appropriately.
 
     alloc_fns = [
         # Matches |operator new(unsigned T)|, where |T| is |int| or |long|.
--- a/devtools/client/preferences/devtools-client.js
+++ b/devtools/client/preferences/devtools-client.js
@@ -287,18 +287,22 @@ pref("devtools.netmonitor.persistlog", f
 // in the Web Console to display a timestamp, or |false| to not display
 // any timestamps.
 pref("devtools.webconsole.timestampMessages", false);
 
 // Web Console automatic multiline mode: |true| if you want incomplete statements
 // to automatically trigger multiline editing (equivalent to shift + enter).
 pref("devtools.webconsole.autoMultiline", true);
 
-// Enable the webconsole sidebar toggle
+// Enable the webconsole sidebar toggle in Nightly builds.
+#if defined(NIGHTLY_BUILD)
+pref("devtools.webconsole.sidebarToggle", true);
+#else
 pref("devtools.webconsole.sidebarToggle", false);
+#endif
 
 // Disable the new performance recording panel by default
 pref("devtools.performance.new-panel-enabled", false);
 
 // Enable client-side mapping service for source maps
 pref("devtools.source-map.client-service.enabled", true);
 
 // The number of lines that are displayed in the web console.
--- a/devtools/client/webconsole/test/mochitest/browser_console_context_menu_entries.js
+++ b/devtools/client/webconsole/test/mochitest/browser_console_context_menu_entries.js
@@ -21,49 +21,57 @@ add_task(async function() {
     content.wrappedJSObject.location.reload();
   });
   const networkMessage = await onNetworkMessage;
 
   info("Open and check the context menu for the network message");
   let menuPopup = await openContextMenu(hud, networkMessage.node);
   ok(menuPopup, "The context menu is displayed on a network message");
 
-  let expectedContextMenu = [
+  let expectedContextMenu = addPrefBasedEntries([
     "#console-menu-copy-url (a)",
     "#console-menu-open-url (T)",
     "#console-menu-store (S) [disabled]",
     "#console-menu-copy (C)",
     "#console-menu-copy-object (o) [disabled]",
-    "#console-menu-select (A)"
-  ];
+    "#console-menu-select (A)",
+  ]);
   is(getSimplifiedContextMenu(menuPopup).join("\n"), expectedContextMenu.join("\n"),
     "The context menu has the expected entries for a network message");
 
   info("Logging a text message in the content window");
   const onLogMessage = waitForMessage(hud, "simple text message");
   ContentTask.spawn(gBrowser.selectedBrowser, null, () => {
     content.wrappedJSObject.console.log("simple text message");
   });
 
   const logMessage = await onLogMessage;
   menuPopup = await openContextMenu(hud, logMessage.node);
   ok(menuPopup, "The context menu is displayed on a log message");
 
-  expectedContextMenu = [
+  expectedContextMenu = addPrefBasedEntries([
     "#console-menu-store (S) [disabled]",
     "#console-menu-copy (C)",
     "#console-menu-copy-object (o) [disabled]",
-    "#console-menu-select (A)"
-  ];
+    "#console-menu-select (A)",
+  ]);
   is(getSimplifiedContextMenu(menuPopup).join("\n"), expectedContextMenu.join("\n"),
     "The context menu has the expected entries for a simple log message");
 
   await hideContextMenu(hud);
 });
 
+function addPrefBasedEntries(expectedEntries) {
+  if (Services.prefs.getBoolPref("devtools.webconsole.sidebarToggle", false)) {
+    expectedEntries.push("#console-menu-open-sidebar (V) [disabled]");
+  }
+
+  return expectedEntries;
+}
+
 function getSimplifiedContextMenu(popupElement) {
   return [...popupElement.querySelectorAll("menuitem")]
     .map(entry => {
       const key = entry.getAttribute("accesskey");
       const disabled = entry.hasAttribute("disabled");
       return `#${entry.id} (${key})${disabled ? " [disabled]" : ""}`;
     });
 }
new file mode 100644
--- /dev/null
+++ b/devtools/server/actors/addon-console.js
@@ -0,0 +1,101 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+var { ConsoleAPIListener } = require("devtools/server/actors/webconsole/listeners");
+var { update } = require("devtools/shared/DevToolsUtils");
+
+loader.lazyRequireGetter(this, "WebConsoleActor", "devtools/server/actors/webconsole", true);
+
+const { extend } = require("devtools/shared/extend");
+const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
+const { webconsoleSpec } = require("devtools/shared/specs/webconsole");
+
+/**
+ * Protocol.js expects only the prototype object, and does not maintain the prototype
+ * chain when it constructs the ActorClass. For this reason we are using `extend` to
+ * maintain the properties of TabActor.prototype
+ * */
+const addonConsolePrototype = extend({}, WebConsoleActor.prototype);
+
+/**
+ * The AddonConsoleActor implements capabilities needed for the add-on web
+ * console feature.
+ *
+ * @constructor
+ * @param object addon
+ *        The add-on that this console watches.
+ * @param object connection
+ *        The connection to the client, DebuggerServerConnection.
+ * @param object parentActor
+ *        The parent BrowserAddonActor actor.
+ */
+addonConsolePrototype.initialize = function(addon, connection, parentActor) {
+  this.addon = addon;
+  Actor.prototype.initialize.call(this, connection);
+  WebConsoleActor.call(this, connection, parentActor);
+};
+
+update(addonConsolePrototype, {
+  // TODO: remove once webconsole is updated to protocol.js, Bug #1450946
+  actorPrefix: "addonConsole",
+
+  /**
+   * The add-on that this console watches.
+   */
+  addon: null,
+
+  /**
+   * The main add-on JS global
+   */
+  get window() {
+    return this.parentActor.global;
+  },
+
+  /**
+   * Destroy the current AddonConsoleActor instance.
+   */
+  destroy() {
+    Actor.prototype.destroy.call(this);
+    WebConsoleActor.prototype.destroy.call(this);
+    this.addon = null;
+  },
+
+  /**
+   * Handler for the "startListeners" request.
+   *
+   * @param object request
+   *        The JSON request object received from the Web Console client.
+   * @return object
+   *         The response object which holds the startedListeners array.
+   */
+  startListeners: function ACAOnStartListeners(request) {
+    let startedListeners = [];
+
+    while (request.listeners.length > 0) {
+      let listener = request.listeners.shift();
+      switch (listener) {
+        case "ConsoleAPI":
+          if (!this.consoleAPIListener) {
+            this.consoleAPIListener =
+              new ConsoleAPIListener(null, this, { addonId: this.addon.id });
+            this.consoleAPIListener.init();
+          }
+          startedListeners.push(listener);
+          break;
+      }
+    }
+    return {
+      startedListeners: startedListeners,
+      nativeConsoleAPI: true,
+      traits: this.traits,
+    };
+  },
+});
+
+exports.AddonConsoleActor = ActorClassWithSpec(webconsoleSpec, addonConsolePrototype);
+
+// TODO: remove once protocol.js can handle inheritance. Bug #1450960
+exports.AddonConsoleActor.prototype.typeName = "addonConsole";
--- a/devtools/server/actors/addon.js
+++ b/devtools/server/actors/addon.js
@@ -4,23 +4,22 @@
 
 "use strict";
 
 var { Ci, Cu } = require("chrome");
 var Services = require("Services");
 var { ActorPool } = require("devtools/server/actors/common");
 var { TabSources } = require("./utils/TabSources");
 var makeDebugger = require("./utils/make-debugger");
-var { ConsoleAPIListener } = require("devtools/server/actors/webconsole/listeners");
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
-var { assert, update } = DevToolsUtils;
+var { assert } = DevToolsUtils;
 
 loader.lazyRequireGetter(this, "AddonThreadActor", "devtools/server/actors/thread", true);
 loader.lazyRequireGetter(this, "unwrapDebuggerObjectGlobal", "devtools/server/actors/thread", true);
-loader.lazyRequireGetter(this, "WebConsoleActor", "devtools/server/actors/webconsole", true);
+loader.lazyRequireGetter(this, "AddonConsoleActor", "devtools/server/actors/addon-console", true);
 
 loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
 
 function BrowserAddonActor(connection, addon) {
   this.conn = connection;
   this._addon = addon;
   this._contextPool = new ActorPool(this.conn);
   this.conn.addActorPool(this._contextPool);
@@ -247,89 +246,8 @@ BrowserAddonActor.prototype = {
 };
 
 BrowserAddonActor.prototype.requestTypes = {
   "attach": BrowserAddonActor.prototype.onAttach,
   "detach": BrowserAddonActor.prototype.onDetach,
   "reload": BrowserAddonActor.prototype.onReload
 };
 
-/**
- * The AddonConsoleActor implements capabilities needed for the add-on web
- * console feature.
- *
- * @constructor
- * @param object addon
- *        The add-on that this console watches.
- * @param object connection
- *        The connection to the client, DebuggerServerConnection.
- * @param object parentActor
- *        The parent BrowserAddonActor actor.
- */
-function AddonConsoleActor(addon, connection, parentActor) {
-  this.addon = addon;
-  WebConsoleActor.call(this, connection, parentActor);
-}
-
-AddonConsoleActor.prototype = Object.create(WebConsoleActor.prototype);
-
-update(AddonConsoleActor.prototype, {
-  constructor: AddonConsoleActor,
-
-  actorPrefix: "addonConsole",
-
-  /**
-   * The add-on that this console watches.
-   */
-  addon: null,
-
-  /**
-   * The main add-on JS global
-   */
-  get window() {
-    return this.parentActor.global;
-  },
-
-  /**
-   * Destroy the current AddonConsoleActor instance.
-   */
-  destroy() {
-    WebConsoleActor.prototype.destroy.call(this);
-    this.addon = null;
-  },
-
-  /**
-   * Handler for the "startListeners" request.
-   *
-   * @param object request
-   *        The JSON request object received from the Web Console client.
-   * @return object
-   *         The response object which holds the startedListeners array.
-   */
-  onStartListeners: function ACAOnStartListeners(request) {
-    let startedListeners = [];
-
-    while (request.listeners.length > 0) {
-      let listener = request.listeners.shift();
-      switch (listener) {
-        case "ConsoleAPI":
-          if (!this.consoleAPIListener) {
-            this.consoleAPIListener =
-              new ConsoleAPIListener(null, this, { addonId: this.addon.id });
-            this.consoleAPIListener.init();
-          }
-          startedListeners.push(listener);
-          break;
-      }
-    }
-    return {
-      startedListeners: startedListeners,
-      nativeConsoleAPI: true,
-      traits: this.traits,
-    };
-  },
-});
-
-AddonConsoleActor.prototype.requestTypes = Object.create(
-  WebConsoleActor.prototype.requestTypes
-);
-AddonConsoleActor.prototype.requestTypes.startListeners =
-  AddonConsoleActor.prototype.onStartListeners;
--- a/devtools/server/actors/emulation.js
+++ b/devtools/server/actors/emulation.js
@@ -121,20 +121,20 @@ let EmulationActor = protocol.ActorClass
     if (this._previousNetworkThrottling === undefined) {
       this._previousNetworkThrottling = current;
     }
 
     let consoleActor = this._consoleActor;
     if (!consoleActor) {
       return false;
     }
-    consoleActor.onStartListeners({
+    consoleActor.startListeners({
       listeners: [ "NetworkActivity" ],
     });
-    consoleActor.onSetPreferences({
+    consoleActor.setPreferences({
       preferences: {
         "NetworkMonitor.throttleData": throttleData,
       }
     });
     return true;
   },
 
   /**
@@ -153,17 +153,17 @@ let EmulationActor = protocol.ActorClass
     };
   },
 
   _getNetworkThrottling() {
     let consoleActor = this._consoleActor;
     if (!consoleActor) {
       return null;
     }
-    let prefs = consoleActor.onGetPreferences({
+    let prefs = consoleActor.getPreferences({
       preferences: [ "NetworkMonitor.throttleData" ],
     });
     return prefs.preferences["NetworkMonitor.throttleData"] || null;
   },
 
   clearNetworkThrottling() {
     if (this._previousNetworkThrottling !== undefined) {
       return this._setNetworkThrottling(this._previousNetworkThrottling);
--- a/devtools/server/actors/moz.build
+++ b/devtools/server/actors/moz.build
@@ -14,16 +14,17 @@ DIRS += [
     'webconsole',
     'worker',
 ]
 
 DevToolsModules(
     'accessibility-parent.js',
     'accessibility.js',
     'actor-registry.js',
+    'addon-console.js',
     'addon.js',
     'addons.js',
     'animation-type-longhand.js',
     'animation.js',
     'array-buffer.js',
     'breakpoint.js',
     'call-watcher.js',
     'canvas.js',
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -565,23 +565,23 @@ WebConsoleActor.prototype =
   /**
    * Handler for the "startListeners" request.
    *
    * @param object request
    *        The JSON request object received from the Web Console client.
    * @return object
    *         The response object which holds the startedListeners array.
    */
-  onStartListeners: function(request) {
+  startListeners: function(request) {
     let startedListeners = [];
     let window = !this.parentActor.isRootActor ? this.window : null;
     let messageManager = null;
 
     // Check if the actor is running in a child process (but only if
-    // Services.appinfo exists, to prevent onStartListeners to fail
+    // Services.appinfo exists, to prevent startListeners to fail
     // when the target is a Worker).
     let processBoundary = Services.appinfo && (
       Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT
     );
 
     // Retrieve a message manager from the parent actor if this actor is
     // not currently running in the main process.
     if (processBoundary) {
@@ -706,17 +706,17 @@ WebConsoleActor.prototype =
    * Handler for the "stopListeners" request.
    *
    * @param object request
    *        The JSON request object received from the Web Console client.
    * @return object
    *         The response packet to send to the client: holds the
    *         stoppedListeners array.
    */
-  onStopListeners: function(request) {
+  stopListeners: function(request) {
     let stoppedListeners = [];
 
     // If no specific listeners are requested to be detached, we stop all
     // listeners.
     let toDetach = request.listeners ||
       ["PageError", "ConsoleAPI", "NetworkActivity",
        "FileActivity", "ContentProcessMessages"];
 
@@ -795,17 +795,17 @@ WebConsoleActor.prototype =
    * error messages and the window.console API calls to the client.
    *
    * @param object request
    *        The JSON request object received from the Web Console client.
    * @return object
    *         The response packet to send to the client: it holds the cached
    *         messages array.
    */
-  onGetCachedMessages: function(request) {
+  getCachedMessages: function(request) {
     let types = request.messageTypes;
     if (!types) {
       return {
         error: "missingParameter",
         message: "The messageTypes parameter is missing.",
       };
     }
 
@@ -877,46 +877,46 @@ WebConsoleActor.prototype =
    * that can be associated back to this request via the `resultID` field.
    *
    * @param object request
    *        The JSON request object received from the Web Console client.
    * @return object
    *         The response packet to send to with the unique id in the
    *         `resultID` field.
    */
-  onEvaluateJSAsync: function(request) {
+  evaluateJSAsync: function(request) {
     // We want to be able to run console commands without waiting
     // for the first to return (see Bug 1088861).
 
     // First, send a response packet with the id only.
     let resultID = Date.now();
     this.conn.send({
       from: this.actorID,
       resultID: resultID
     });
 
     // Then, execute the script that may pause.
-    let response = this.onEvaluateJS(request);
+    let response = this.evaluateJS(request);
     response.resultID = resultID;
 
     // Finally, send an unsolicited evaluationResult packet with
     // the normal return value
     this.conn.sendActorEvent(this.actorID, "evaluationResult", response);
   },
 
   /**
    * Handler for the "evaluateJS" request. This method evaluates the given
    * JavaScript string and sends back the result.
    *
    * @param object request
    *        The JSON request object received from the Web Console client.
    * @return object
    *         The evaluation response packet.
    */
-  onEvaluateJS: function(request) {
+  evaluateJS: function(request) {
     let input = request.text;
     let timestamp = Date.now();
 
     let evalOptions = {
       bindObjectActor: request.bindObjectActor,
       frameActor: request.frameActor,
       url: request.url,
       selectedNodeActor: request.selectedNodeActor,
@@ -1037,32 +1037,32 @@ WebConsoleActor.prototype =
   /**
    * The Autocomplete request handler.
    *
    * @param object request
    *        The request message - what input to autocomplete.
    * @return object
    *         The response message - matched properties.
    */
-  onAutocomplete: function(request) {
+  autocomplete: function(request) {
     let frameActorId = request.frameActor;
     let dbgObject = null;
     let environment = null;
     let hadDebuggee = false;
 
     // This is the case of the paused debugger
     if (frameActorId) {
       let frameActor = this.conn.getActor(frameActorId);
       try {
         // Need to try/catch since accessing frame.environment
         // can throw "Debugger.Frame is not live"
         let frame = frameActor.frame;
         environment = frame.environment;
       } catch (e) {
-        DevToolsUtils.reportException("onAutocomplete",
+        DevToolsUtils.reportException("autocomplete",
           Error("The frame actor was not found: " + frameActorId));
       }
     } else {
       // This is the general case (non-paused debugger)
       hadDebuggee = this.dbg.hasDebuggee(this.evalWindow);
       dbgObject = this.dbg.addDebuggee(this.evalWindow);
     }
 
@@ -1097,17 +1097,17 @@ WebConsoleActor.prototype =
       matches: matches.sort(),
       matchProp: result.matchProp,
     };
   },
 
   /**
    * The "clearMessagesCache" request handler.
    */
-  onClearMessagesCache: function() {
+  clearMessagesCache: function() {
     // TODO: Bug 717611 - Web Console clear button does not clear cached errors
     let windowId = !this.parentActor.isRootActor ?
                    WebConsoleUtils.getInnerWindowId(this.window) : null;
     let ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
                               .getService(Ci.nsIConsoleAPIStorage);
     ConsoleAPIStorage.clearEvents(windowId);
 
     CONSOLE_WORKER_IDS.forEach((id) => {
@@ -1124,31 +1124,31 @@ WebConsoleActor.prototype =
   /**
    * The "getPreferences" request handler.
    *
    * @param object request
    *        The request message - which preferences need to be retrieved.
    * @return object
    *         The response message - a { key: value } object map.
    */
-  onGetPreferences: function(request) {
+  getPreferences: function(request) {
     let prefs = Object.create(null);
     for (let key of request.preferences) {
       prefs[key] = this._prefs[key];
     }
     return { preferences: prefs };
   },
 
   /**
    * The "setPreferences" request handler.
    *
    * @param object request
    *        The request message - which preferences need to be updated.
    */
-  onSetPreferences: function(request) {
+  setPreferences: function(request) {
     for (let key in request.preferences) {
       this._prefs[key] = request.preferences[key];
 
       if (this.networkMonitor) {
         if (key == "NetworkMonitor.saveRequestAndResponseBodies") {
           this.networkMonitor.saveRequestAndResponseBodies = this._prefs[key];
           if (this.networkMonitorChild) {
             this.networkMonitorChild.saveRequestAndResponseBodies =
@@ -1686,17 +1686,17 @@ WebConsoleActor.prototype =
   },
 
   /**
    * Send a new HTTP request from the target's window.
    *
    * @param object message
    *        Object with 'request' - the HTTP request details.
    */
-  onSendHTTPRequest(message) {
+  sendHTTPRequest(message) {
     let { url, method, headers, body } = message.request;
 
     // Set the loadingNode and loadGroup to the target document - otherwise the
     // request won't show up in the opened netmonitor.
     let doc = this.window.document;
 
     let channel = NetUtil.newChannel({
       uri: NetUtil.newURI(url),
@@ -1874,34 +1874,34 @@ WebConsoleActor.prototype =
    * mostly to unregister previous listeners and start listening on the new document.
    */
   _onChangedToplevelDocument: function() {
     // Convert the Set to an Array
     let listeners = [...this._listeners];
 
     // Unregister existing listener on the previous document
     // (pass a copy of the array as it will shift from it)
-    this.onStopListeners({listeners: listeners.slice()});
+    this.stopListeners({listeners: listeners.slice()});
 
     // This method is called after this.window is changed,
     // so we register new listener on this new window
-    this.onStartListeners({listeners: listeners});
+    this.startListeners({listeners: listeners});
 
     // Also reset the cached top level chrome window being targeted
     this._lastChromeWindow = null;
   },
 };
 
 WebConsoleActor.prototype.requestTypes =
 {
-  startListeners: WebConsoleActor.prototype.onStartListeners,
-  stopListeners: WebConsoleActor.prototype.onStopListeners,
-  getCachedMessages: WebConsoleActor.prototype.onGetCachedMessages,
-  evaluateJS: WebConsoleActor.prototype.onEvaluateJS,
-  evaluateJSAsync: WebConsoleActor.prototype.onEvaluateJSAsync,
-  autocomplete: WebConsoleActor.prototype.onAutocomplete,
-  clearMessagesCache: WebConsoleActor.prototype.onClearMessagesCache,
-  getPreferences: WebConsoleActor.prototype.onGetPreferences,
-  setPreferences: WebConsoleActor.prototype.onSetPreferences,
-  sendHTTPRequest: WebConsoleActor.prototype.onSendHTTPRequest
+  startListeners: WebConsoleActor.prototype.startListeners,
+  stopListeners: WebConsoleActor.prototype.stopListeners,
+  getCachedMessages: WebConsoleActor.prototype.getCachedMessages,
+  evaluateJS: WebConsoleActor.prototype.evaluateJS,
+  evaluateJSAsync: WebConsoleActor.prototype.evaluateJSAsync,
+  autocomplete: WebConsoleActor.prototype.autocomplete,
+  clearMessagesCache: WebConsoleActor.prototype.clearMessagesCache,
+  getPreferences: WebConsoleActor.prototype.getPreferences,
+  setPreferences: WebConsoleActor.prototype.setPreferences,
+  sendHTTPRequest: WebConsoleActor.prototype.sendHTTPRequest
 };
 
 exports.WebConsoleActor = WebConsoleActor;
--- a/devtools/shared/specs/index.js
+++ b/devtools/shared/specs/index.js
@@ -220,16 +220,21 @@ const Types = exports.__TypesForTests = 
     front: "devtools/shared/fronts/timeline",
   },
   {
     types: ["audionode", "webaudio"],
     spec: "devtools/shared/specs/webaudio",
     front: "devtools/shared/fronts/webaudio",
   },
   {
+    types: ["console"],
+    spec: "devtools/shared/specs/webconsole",
+    front: null,
+  },
+  {
     types: ["webExtensionInspectedWindow"],
     spec: "devtools/shared/specs/webextension-inspected-window",
     front: "devtools/shared/fronts/webextension-inspected-window",
   },
   {
     types: ["webExtensionAddon"],
     spec: "devtools/shared/specs/webextension-parent",
     front: null,
--- a/devtools/shared/specs/moz.build
+++ b/devtools/shared/specs/moz.build
@@ -40,13 +40,14 @@ DevToolsModules(
     'string.js',
     'styles.js',
     'stylesheets.js',
     'symbol-iterator.js',
     'symbol.js',
     'tab.js',
     'timeline.js',
     'webaudio.js',
+    'webconsole.js',
     'webextension-inspected-window.js',
     'webextension-parent.js',
     'webgl.js',
     'worker.js'
 )
new file mode 100644
--- /dev/null
+++ b/devtools/shared/specs/webconsole.js
@@ -0,0 +1,119 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const {types, generateActorSpec, RetVal, Option} = require("devtools/shared/protocol");
+
+types.addDictType("console.traits", {
+  evaluateJSAsync: "boolean",
+  transferredResponseSize: "boolean",
+  selectedObjectActor: "boolean",
+  fetchCacheDescriptor: "boolean",
+});
+
+types.addDictType("console.startlisteners", {
+  startedListeners: "array:string",
+  nativeConsoleAPI: "boolean",
+  traits: "console.traits"
+});
+
+types.addDictType("console.autocomplete", {
+  matches: "array:string",
+  matchProp: "string"
+});
+
+types.addDictType("console.evaluatejsasync", {
+  resultID: "string",
+});
+
+types.addDictType("console.cachedmessages", {
+  // this type is a union of two potential return types:
+  // { error, message } and { _type, message, timeStamp }
+  error: "nullable:string",
+  message: "longstring",
+  _type: "nullable:string",
+  timeStamp: "nullable:string"
+});
+
+const webconsoleSpec = generateActorSpec({
+  typeName: "console",
+
+  methods: {
+    startListeners: {
+      request: {
+        listeners: Option(0, "array:string"),
+      },
+      response: RetVal("console.startlisteners")
+    },
+    stopListeners: {
+      request: {
+        listeners: Option(0, "nullable:array:string"),
+      },
+      response: RetVal("array:string")
+    },
+    getCachedMessages: {
+      request: {
+        messageTypes: Option(0, "array:string"),
+      },
+      // the return value here has a field "string" which can either be a longStringActor
+      // or a plain string. Since we do not have union types, we cannot fully type this
+      // response
+      response: RetVal("console.cachedmessages")
+    },
+    evaluateJS: {
+      request: {
+        text: Option(0, "string"),
+        bindObjectActor: Option(0, "string"),
+        frameActor: Option(0, "string"),
+        url: Option(0, "string"),
+        selectedNodeActor: Option(0, "string"),
+        selectedObjectActor: Option(0, "string"),
+      },
+      response: RetVal("json")
+    },
+    evaluateJSAsync: {
+      request: {
+        text: Option(0, "string"),
+        bindObjectActor: Option(0, "string"),
+        frameActor: Option(0, "string"),
+        url: Option(0, "string"),
+        selectedNodeActor: Option(0, "string"),
+        selectedObjectActor: Option(0, "string"),
+      },
+      response: RetVal("console.evaluatejsasync")
+    },
+    autocomplete: {
+      request: {
+        frameActor: Option(0, "string"),
+        text: Option(0, "string"),
+        cursor: Option(0, "number")
+      },
+      response: RetVal("console.autocomplete")
+    },
+    clearMessagesCache: {
+      request: {},
+      response: {}
+    },
+    getPreferences: {
+      request: {
+        preferences: Option(0, "json")
+      },
+      response: RetVal("json")
+    },
+    setPreferences: {
+      request: {
+        preferences: Option(0, "json")
+      },
+      response: RetVal("json")
+    },
+    sendHTTPRequest: {
+      request: {
+        request: Option(0, "json")
+      },
+      response: RetVal("json")
+    }
+  }
+});
+
+exports.webconsoleSpec = webconsoleSpec;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2842,19 +2842,17 @@ ContentParent::Observe(nsISupports* aSub
     SpinEventLoopUntil([&]() { return !mIPCOpen || mCalledKillHard; });
     NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
   }
 
   if (!mIsAlive || !mSubprocess)
     return NS_OK;
 
   // listening for memory pressure event
-  if (!strcmp(aTopic, "memory-pressure") &&
-      !StringEndsWith(nsDependentString(aData),
-                      NS_LITERAL_STRING("-no-forward"))) {
+  if (!strcmp(aTopic, "memory-pressure")) {
       Unused << SendFlushMemory(nsDependentString(aData));
   }
   else if (!strcmp(aTopic, "nsPref:changed")) {
     // A pref changed. If it's not on the blacklist, inform child processes.
 #define BLACKLIST_ENTRY(s) { s, (sizeof(s)/sizeof(char16_t)) - 1 }
     struct BlacklistEntry {
       const char16_t* mPrefBranch;
       size_t mLen;
new file mode 100644
--- /dev/null
+++ b/dom/media/mediasource/test/.eslintrc.js
@@ -0,0 +1,25 @@
+"use strict";
+
+module.exports = {
+  // Extend mochitest rules
+  "extends": "plugin:mozilla/mochitest-test",
+  // Globals from mediasource.js. We use false to indicate they should not
+  // be overwritten in scripts.
+  "globals": {
+    "addMSEPrefs": false,
+    "fetchAndLoad": false,
+    "fetchAndLoadAsync": false,
+    "fetchWithXHR": false,
+    "loadSegment": false,
+    "once": false,
+    "range": false,
+    "runWithMSE": false,
+    "waitUntilTime": false
+  },
+  // Use const/let instead of var for tighter scoping, avoiding redeclaration
+  "rules": {
+    "array-bracket-spacing": ["error", "always"],
+    "no-var": "error",
+    "prefer-const": "error"
+  }
+};
--- a/dom/media/mediasource/test/mediasource.js
+++ b/dom/media/mediasource/test/mediasource.js
@@ -1,161 +1,161 @@
 // Helpers for Media Source Extensions tests
 
-var gMSETestPrefs = [
+let gMSETestPrefs = [
   [ "media.mediasource.enabled", true ],
-  ['media.audio-max-decode-error', 0],
-  ['media.video-max-decode-error', 0],
+  [ "media.audio-max-decode-error", 0 ],
+  [ "media.video-max-decode-error", 0 ],
 ];
 
 // Called before runWithMSE() to set the prefs before running MSE tests.
 function addMSEPrefs(...prefs) {
   gMSETestPrefs = gMSETestPrefs.concat(prefs);
 }
 
 function runWithMSE(testFunction) {
   function bootstrapTest() {
-    var ms = new MediaSource();
+    const ms = new MediaSource();
 
-    var el = document.createElement("video");
+    const el = document.createElement("video");
     el.src = URL.createObjectURL(ms);
     el.preload = "auto";
 
     document.body.appendChild(el);
-    SimpleTest.registerCleanupFunction(function () {
+    SimpleTest.registerCleanupFunction(function() {
       el.remove();
       el.removeAttribute("src");
       el.load();
     });
 
     testFunction(ms, el);
   }
 
-  addLoadEvent(function () {
+  addLoadEvent(function() {
     SpecialPowers.pushPrefEnv({"set": gMSETestPrefs}, bootstrapTest);
   });
 }
 
 function fetchWithXHR(uri, onLoadFunction) {
-  var p = new Promise(function(resolve, reject) {
-    var xhr = new XMLHttpRequest();
+  const p = new Promise(function(resolve, reject) {
+    const xhr = new XMLHttpRequest();
     xhr.open("GET", uri, true);
     xhr.responseType = "arraybuffer";
-    xhr.addEventListener("load", function () {
+    xhr.addEventListener("load", function() {
       is(xhr.status, 200, "fetchWithXHR load uri='" + uri + "' status=" + xhr.status);
       resolve(xhr.response);
     });
     xhr.send();
   });
 
   if (onLoadFunction) {
     p.then(onLoadFunction);
   }
 
   return p;
-};
+}
 
 function range(start, end) {
-  var rv = [];
-  for (var i = start; i < end; ++i) {
+  const rv = [];
+  for (let i = start; i < end; ++i) {
     rv.push(i);
   }
   return rv;
 }
 
 function once(target, name, cb) {
-  var p = new Promise(function(resolve, reject) {
+  const p = new Promise(function(resolve, reject) {
     target.addEventListener(name, function() {
       resolve();
     }, {once: true});
   });
   if (cb) {
     p.then(cb);
   }
   return p;
 }
 
 function timeRangeToString(r) {
-  var str = "TimeRanges: ";
-  for (var i = 0; i < r.length; i++) {
+  let str = "TimeRanges: ";
+  for (let i = 0; i < r.length; i++) {
     str += "[" + r.start(i) + ", " + r.end(i) + ")";
   }
   return str;
 }
 
 function loadSegment(sb, typedArrayOrArrayBuffer) {
-  var typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
-                                                                    : typedArrayOrArrayBuffer;
+  const typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
+                                                                      : typedArrayOrArrayBuffer;
   info(`Loading buffer: [${typedArray.byteOffset}, ${typedArray.byteOffset + typedArray.byteLength})`);
-  var beforeBuffered = timeRangeToString(sb.buffered);
+  const beforeBuffered = timeRangeToString(sb.buffered);
   return new Promise(function(resolve, reject) {
-    once(sb, 'update').then(function() {
-      var afterBuffered = timeRangeToString(sb.buffered);
+    once(sb, "update").then(function() {
+      const afterBuffered = timeRangeToString(sb.buffered);
       info(`SourceBuffer buffered ranges grew from ${beforeBuffered} to ${afterBuffered}`);
       resolve();
     });
     sb.appendBuffer(typedArray);
   });
 }
 
 function fetchAndLoad(sb, prefix, chunks, suffix) {
 
   // Fetch the buffers in parallel.
-  var buffers = {};
-  var fetches = [];
-  for (var chunk of chunks) {
+  const buffers = {};
+  const fetches = [];
+  for (const chunk of chunks) {
     fetches.push(fetchWithXHR(prefix + chunk + suffix).then(((c, x) => buffers[c] = x).bind(null, chunk)));
   }
 
   // Load them in series, as required per spec.
   return Promise.all(fetches).then(function() {
-    var rv = Promise.resolve();
-    for (var chunk of chunks) {
+    let rv = Promise.resolve();
+    for (const chunk of chunks) {
       rv = rv.then(loadSegment.bind(null, sb, buffers[chunk]));
     }
     return rv;
   });
 }
 
 function loadSegmentAsync(sb, typedArrayOrArrayBuffer) {
-  var typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
-                                                                    : typedArrayOrArrayBuffer;
+  const typedArray = (typedArrayOrArrayBuffer instanceof ArrayBuffer) ? new Uint8Array(typedArrayOrArrayBuffer)
+                                                                      : typedArrayOrArrayBuffer;
   info(`Loading buffer2: [${typedArray.byteOffset}, ${typedArray.byteOffset + typedArray.byteLength})`);
-  var beforeBuffered = timeRangeToString(sb.buffered);
+  const beforeBuffered = timeRangeToString(sb.buffered);
   return sb.appendBufferAsync(typedArray).then(() => {
-    var afterBuffered = timeRangeToString(sb.buffered);
+    const afterBuffered = timeRangeToString(sb.buffered);
     info(`SourceBuffer buffered ranges grew from ${beforeBuffered} to ${afterBuffered}`);
   });
 }
 
 function fetchAndLoadAsync(sb, prefix, chunks, suffix) {
 
   // Fetch the buffers in parallel.
-  var buffers = {};
-  var fetches = [];
-  for (var chunk of chunks) {
+  const buffers = {};
+  const fetches = [];
+  for (const chunk of chunks) {
     fetches.push(fetchWithXHR(prefix + chunk + suffix).then(((c, x) => buffers[c] = x).bind(null, chunk)));
   }
 
   // Load them in series, as required per spec.
   return Promise.all(fetches).then(function() {
-    var rv = Promise.resolve();
-    for (var chunk of chunks) {
+    let rv = Promise.resolve();
+    for (const chunk of chunks) {
       rv = rv.then(loadSegmentAsync.bind(null, sb, buffers[chunk]));
     }
     return rv;
   });
 }
 
-//Register timeout function to dump debugging logs.
+// Register timeout function to dump debugging logs.
 SimpleTest.registerTimeoutFunction(function() {
-  for (var v of document.getElementsByTagName("video")) {
+  for (const v of document.getElementsByTagName("video")) {
     v.mozDumpDebugInfo();
   }
-  for (var a of document.getElementsByTagName("audio")) {
+  for (const a of document.getElementsByTagName("audio")) {
     a.mozDumpDebugInfo();
   }
 });
 
 function waitUntilTime(target, targetTime) {
   return new Promise(function(resolve, reject) {
     target.addEventListener("waiting", function onwaiting() {
       info("Got a waiting event at " + target.currentTime);
--- a/dom/media/mediasource/test/test_AVC3_mp4.html
+++ b/dom/media/mediasource/test/test_AVC3_mp4.html
@@ -9,36 +9,36 @@
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
 
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
 
-    fetchAndLoad(videosb, 'avc3/init', [''], '.mp4')
+    fetchAndLoad(videosb, "avc3/init", [ "" ], ".mp4")
     .then(function() {
-      var promises = [];
-      promises.push(fetchAndLoad(videosb, 'avc3/segment', range(1, 2), '.m4s'));
+      const promises = [];
+      promises.push(fetchAndLoad(videosb, "avc3/segment", range(1, 2), ".m4s"));
       promises.push(once(el, "loadeddata"));
       return Promise.all(promises);
     }).then(function() {
       is(videosb.buffered.length, 1, "continuous buffered range");
       ok(true, "got loadeddata");
       ms.endOfStream();
       return once(ms, "sourceended");
     }).then(function() {
       ok(true, "endOfStream completed");
       // Now ensure that we can play to the end.
       el.play();
-      once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+      once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
     });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_AppendPartialInitSegment.html
+++ b/dom/media/mediasource/test/test_AppendPartialInitSegment.html
@@ -7,21 +7,21 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", async function (arrayBuffer) {
+    fetchWithXHR("seek.webm", async function(arrayBuffer) {
       // init segment is total 236 bytes.
       info("- append partial init segment -");
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 100));
 
       info("- wait for updateend -");
       await once(sb, "updateend");
 
       info("- append remaining init segment -");
--- a/dom/media/mediasource/test/test_AudioChange_mp4.html
+++ b/dom/media/mediasource/test/test_AudioChange_mp4.html
@@ -11,61 +11,60 @@
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 // This test checks loading a stereo segment, followed by a 5.1 segment plays without error.
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     // Log events for debugging.
-    var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
-                  "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
-                  "waiting", "pause", "durationchange", "seeking", "seeked"];
+    const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                     "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                     "waiting", "pause", "durationchange", "seeking", "seeked" ];
     function logEvent(e) {
-      var v = e.target;
       info("got " + e.type + " event");
     }
     events.forEach(function(e) {
       el.addEventListener(e, logEvent);
     });
 
     ok(true, "Receive a sourceopen event");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
+    const audiosb = ms.addSourceBuffer("audio/mp4");
     el.addEventListener("error", function(e) {
       ok(false, "should not fire '" + e.type + "' event");
       SimpleTest.finish();
     });
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(audiosb, 'aac20-48000-64000-', ['init'], '.mp4'));
-    promises.push(once(el, 'loadedmetadata'));
-    Promise.all(promises)
+    const loadedmetadataPromises = [];
+    loadedmetadataPromises.push(fetchAndLoad(audiosb, "aac20-48000-64000-", [ "init" ], ".mp4"));
+    loadedmetadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(loadedmetadataPromises)
     .then(function() {
       ok(true, "got loadedmetadata event");
-      var promises = [];
-      promises.push(once(el, 'loadeddata'));
-      promises.push(once(el, 'canplay'));
-      promises.push(fetchAndLoad(audiosb, 'aac20-48000-64000-', ['1'], '.m4s'));
-      return Promise.all(promises);
+      const canplayPromises = [];
+      canplayPromises.push(once(el, "loadeddata"));
+      canplayPromises.push(once(el, "canplay"));
+      canplayPromises.push(fetchAndLoad(audiosb, "aac20-48000-64000-", [ "1" ], ".m4s"));
+      return Promise.all(canplayPromises);
     })
     .then(function() {
       ok(true, "got canplay event");
       el.play();
-      return fetchAndLoad(audiosb, 'aac51-48000-128000-', ['init'], '.mp4');
+      return fetchAndLoad(audiosb, "aac51-48000-128000-", [ "init" ], ".mp4");
     })
-    .then(fetchAndLoad.bind(null, audiosb, 'aac51-48000-128000-', ['2'], '.m4s'))
+    .then(fetchAndLoad.bind(null, audiosb, "aac51-48000-128000-", [ "2" ], ".m4s"))
     .then(function() {
       ms.endOfStream();
-      return once(el, 'ended');
+      return once(el, "ended");
     })
     .then(function() {
       ok(el.currentTime >= 6, "played to the end");
       SimpleTest.finish();
-    })
+    });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_AutoRevocation.html
+++ b/dom/media/mediasource/test/test_AutoRevocation.html
@@ -7,27 +7,27 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function () {
-  var ms = new MediaSource();
-  var o = URL.createObjectURL(ms);
-  var v = document.createElement("video");
+runWithMSE(function() {
+  const ms = new MediaSource();
+  const o = URL.createObjectURL(ms);
+  const v = document.createElement("video");
 
-  v.addEventListener("error", function (e) {
+  v.addEventListener("error", function(e) {
     ok(true, "ObjectURL should be auto-revoked");
     SimpleTest.finish();
   });
 
-  v.addEventListener("stalled", function (e) {
+  v.addEventListener("stalled", function(e) {
     ok(false, "If auto-revocation is gone, please turn on TODOs in browser_mediaSourceURL.js");
     SimpleTest.finish();
   });
 
   setTimeout(function() {
     v.src = o;
     v.preload = "auto";
     document.body.appendChild(v);
--- a/dom/media/mediasource/test/test_BufferedSeek.html
+++ b/dom/media/mediasource/test/test_BufferedSeek.html
@@ -7,39 +7,39 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
     });
 
-    var target = 2;
+    const target = 2;
 
-    v.addEventListener("loadedmetadata", function () {
+    v.addEventListener("loadedmetadata", function() {
       ok(true, "received loadedmetadata");
       v.currentTime = target;
     });
 
-    var wasSeeking = false;
+    let wasSeeking = false;
 
-    v.addEventListener("seeking", function () {
+    v.addEventListener("seeking", function() {
       wasSeeking = true;
       is(v.currentTime, target, "Video currentTime at target");
     });
 
-    v.addEventListener("seeked", function () {
+    v.addEventListener("seeked", function() {
       ok(wasSeeking, "Received expected seeking and seeked events");
       is(v.currentTime, target, "Video currentTime at target");
       SimpleTest.finish();
     });
   });
 });
 
 </script>
--- a/dom/media/mediasource/test/test_BufferedSeek_mp4.html
+++ b/dom/media/mediasource/test/test_BufferedSeek_mp4.html
@@ -7,39 +7,39 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
     });
 
-    var target = 1.3;
+    const target = 1.3;
 
-    v.addEventListener("loadedmetadata", function () {
+    v.addEventListener("loadedmetadata", function() {
       ok(true, "received loadedmetadata");
       v.currentTime = target;
     });
 
-    var wasSeeking = false;
+    let wasSeeking = false;
 
-    v.addEventListener("seeking", function () {
+    v.addEventListener("seeking", function() {
       wasSeeking = true;
       is(v.currentTime, target, "Video currentTime at target");
     });
 
-    v.addEventListener("seeked", function () {
+    v.addEventListener("seeked", function() {
       ok(wasSeeking, "Received expected seeking and seeked events");
       is(v.currentTime, target, "Video currentTime at target");
       SimpleTest.finish();
     });
   });
 });
 
 </script>
--- a/dom/media/mediasource/test/test_BufferingWait.html
+++ b/dom/media/mediasource/test/test_BufferingWait.html
@@ -6,44 +6,45 @@
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
 runWithMSE(function(ms, v) {
   ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
     receivedSourceOpen = true;
-    var sb = ms.addSourceBuffer("video/webm");
+    const sb = ms.addSourceBuffer("video/webm");
     ok(sb, "Create a SourceBuffer");
 
     fetchWithXHR("seek.webm", function(arrayBuffer) {
-      sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
-      loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))().then(
-      loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25523-318))).then(
-      loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25523, 46712-25523))).then(
+      sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+      loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))()
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25523 - 318)))
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25523, 46712 - 25523)))
       /* Note - Missing |46712, 67833 - 46712| segment here corresponding to (0.8, 1.2] */
       /* Note - Missing |67833, 88966 - 67833| segment here corresponding to (1.2, 1.6]  */
-      loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966))).then(function() {
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966)))
+      .then(function() {
         // 0.767 is the time of the last video sample +- 40ms.
-        var promise = waitUntilTime(v, .767-0.04);
+        const promise = waitUntilTime(v, .767 - 0.04);
         info("Playing video. It should play for a bit, then fire 'waiting'");
         v.play();
         return promise;
       }).then(function() {
         window.firstStop = Date.now();
         loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
-        return waitUntilTime(v, 1.167-0.04);
+        return waitUntilTime(v, 1.167 - 0.04);
       }).then(function() {
-        var waitDuration = (Date.now() - window.firstStop) / 1000;
+        const waitDuration = (Date.now() - window.firstStop) / 1000;
         ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
         SimpleTest.finish();
         /* If we allow the rest of the stream to be played, we get stuck at
            around 2s. See bug 1093133.
         once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
         return loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
         */
       });
--- a/dom/media/mediasource/test/test_BufferingWait_mp4.html
+++ b/dom/media/mediasource/test/test_BufferingWait_mp4.html
@@ -6,49 +6,49 @@
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
 runWithMSE(function(ms, v) {
   ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
     receivedSourceOpen = true;
-    var sb = ms.addSourceBuffer("video/mp4");
+    const sb = ms.addSourceBuffer("video/mp4");
     ok(sb, "Create a SourceBuffer");
 
-    sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
-    fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['1'], '.m4s'))
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['2'], '.m4s'))
+    sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+    fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", [ "1" ], ".m4s"))
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", [ "2" ], ".m4s"))
     /* Note - Missing |bipbop3| segment here corresponding to (1.62, 2.41] */
     /* Note - Missing |bipbop4| segment here corresponding to (2.41, 3.20]  */
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['5'], '.m4s'))
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", [ "5" ], ".m4s"))
     .then(function() {
-        // last audio sample has a start time of 1.578956s
-        var promise = waitUntilTime(v, 1.57895);
-        info("Playing video. It should play for a bit, then fire 'waiting'");
-        v.play();
-        return promise;
-      }).then(function() {
-        window.firstStop = Date.now();
-        fetchAndLoad(sb, 'bipbop/bipbop', ['3'], '.m4s');
-        // last audio sample has a start time of 2.368435
-        return waitUntilTime(v, 2.36843);
-      }).then(function() {
-        var waitDuration = (Date.now() - window.firstStop) / 1000;
-        ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
-        once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
-        return fetchAndLoad(sb, 'bipbop/bipbop', ['4'], '.m4s');
-      }).then(function() {
-        ms.endOfStream();
-      });;
+      // last audio sample has a start time of 1.578956s
+      const promise = waitUntilTime(v, 1.57895);
+      info("Playing video. It should play for a bit, then fire 'waiting'");
+      v.play();
+      return promise;
+    }).then(function() {
+      window.firstStop = Date.now();
+      fetchAndLoad(sb, "bipbop/bipbop", [ "3" ], ".m4s");
+      // last audio sample has a start time of 2.368435
+      return waitUntilTime(v, 2.36843);
+    }).then(function() {
+      const waitDuration = (Date.now() - window.firstStop) / 1000;
+      ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
+      once(v, "ended", SimpleTest.finish.bind(SimpleTest));
+      return fetchAndLoad(sb, "bipbop/bipbop", [ "4" ], ".m4s");
+    }).then(function() {
+      ms.endOfStream();
+    });
   });
 });
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_ChangeType.html
+++ b/dom/media/mediasource/test/test_ChangeType.html
@@ -6,79 +6,79 @@
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 async function setupTest() {
-  await SpecialPowers.pushPrefEnv({'set': [['media.mediasource.experimental.enabled', true]]});
+  await SpecialPowers.pushPrefEnv({"set": [ [ "media.mediasource.experimental.enabled", true ] ]});
 }
 setupTest();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     // Log events for debugging.
-    var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
-                  "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
-                  "waiting", "pause", "durationchange", "seeking", "seeked"];
+    const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                     "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                     "waiting", "pause", "durationchange", "seeking", "seeked" ];
     function logEvent(e) {
       info("got " + e.type + " event");
     }
     events.forEach(function(e) {
       el.addEventListener(e, logEvent);
     });
 
     ok(true, "Receive a sourceopen event");
 
-    var videosb = ms.addSourceBuffer("video/mp4");
-    if (typeof videosb.changeType === 'undefined') {
-      info('changeType API is not available');
+    const videosb = ms.addSourceBuffer("video/mp4");
+    if (typeof videosb.changeType === "undefined") {
+      info("changeType API is not available");
     }
 
     el.addEventListener("error", function(e) {
       ok(false, "should not fire '" + e.type + "' event");
       SimpleTest.finish();
     });
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop', ['init'], '.mp4'));
-    promises.push(once(el, 'loadedmetadata'));
-    Promise.all(promises)
+    const loadedmetadataPromises = [];
+    loadedmetadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop", [ "init" ], ".mp4"));
+    loadedmetadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(loadedmetadataPromises)
     .then(function() {
       ok(true, "got loadedmetadata event");
-      var promises = [];
-      promises.push(once(el, 'loadeddata'));
-      promises.push(once(el, 'canplay'));
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop', range(1,3), '.m4s'));
-      return Promise.all(promises);
+      const canplayPromises = [];
+      canplayPromises.push(once(el, "loadeddata"));
+      canplayPromises.push(once(el, "canplay"));
+      canplayPromises.push(fetchAndLoad(videosb, "bipbop/bipbop", range(1, 3), ".m4s"));
+      return Promise.all(canplayPromises);
     })
     .then(function() {
       ok(true, "got canplay event");
       el.play();
       videosb.timestampOffset = el.buffered.end(0);
-      return fetchAndLoad(videosb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4');
+      return fetchAndLoad(videosb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
     })
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_480_624kbps-video', range(1,3), '.m4s'))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
     .then(function() {
       videosb.timestampOffset = el.buffered.end(0);
       try {
         videosb.changeType("video/webm");
       } catch (e) {
         ok(false, "shouldn't throw an exception");
         SimpleTest.finish();
         throw e;
       }
-      return fetchAndLoad(videosb, 'bipbop/bipbop_300-3s', [''], '.webm');
+      return fetchAndLoad(videosb, "bipbop/bipbop_300-3s", [ "" ], ".webm");
     })
     .then(function() {
       ms.endOfStream();
-      return once(el, 'ended');
+      return once(el, "ended");
     })
     .then(function() {
       ok(el.currentTime >= el.buffered.end(0), "played to the end");
       SimpleTest.finish();
     });
   });
 });
 
--- a/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_ChangeWhileWaitingOnMissingData_mp4.html
@@ -8,36 +8,36 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var sb = ms.addSourceBuffer("video/mp4");
-    fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_480_624kbps-video', range(1, 3), '.m4s'))
+    const sb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
     .then(function() {
       el.play();
       // let seek to the last audio frame.
       // The seek will complete and then playback will stall.
       el.currentTime = 1.532517;
-      return Promise.all([once(el, 'seeked'), once(el, 'stalled')]);
+      return Promise.all([ once(el, "seeked"), once(el, "stalled") ]);
     })
     .then(function() {
       info("seek completed");
-      return fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4');
+      return fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4");
     })
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', range(1, 4), '.m4s'))
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop", range(1, 4), ".m4s"))
     .then(function() {
       ms.endOfStream();
-      return once(el, 'ended');
+      return once(el, "ended");
     }).then(function() {
       SimpleTest.finish();
     });
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_DrainOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_DrainOnMissingData_mp4.html
@@ -8,45 +8,45 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
-    fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
+    const videosb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
     .then(function() {
       // Set appendWindowEnd to ensure we only have about 6 frames worth.
       // We must feed at least 6 frames to pass the MDSM pre-roll.
       videosb.appendWindowEnd = .4;
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', ['1'], '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s");
     })
     .then(function() {
       info("Invoking play()");
-      var promises = [];
-      promises.push(once(el, 'playing'));
+      const promises = [];
+      promises.push(once(el, "playing"));
       el.play();
       return Promise.all(promises);
     })
     .then(function() {
       info("got playing");
-      return once(el, 'waiting');
+      return once(el, "waiting");
     }).then(function() {
       info("got waiting");
       info("Loading more data");
       // Waiting will be fired on the last frame +- 40ms.
-      isfuzzy(el.currentTime, videosb.buffered.end(0) - 1/30,
+      isfuzzy(el.currentTime, videosb.buffered.end(0) - 1 / 30,
               0.04, "Got a waiting event at " + el.currentTime);
       videosb.appendWindowEnd = 1;
-      var p = once(el, 'ended');
-      var loads = fetchAndLoad(videosb, 'bipbop/bipbop_video', [1], '.m4s');
+      const p = once(el, "ended");
+      const loads = fetchAndLoad(videosb, "bipbop/bipbop_video", [ 1 ], ".m4s");
       loads.then(() => ms.endOfStream());
       return p;
     }).then(function() {
       // These fuzz factors are bigger than they should be. We should investigate
       // and fix them in bug 1137574.
       is(el.duration, 0.801666, "Video has correct duration: " + el.duration);
       is(el.currentTime, el.duration, "Video has correct currentTime.");
       SimpleTest.finish();
--- a/dom/media/mediasource/test/test_DurationChange.html
+++ b/dom/media/mediasource/test/test_DurationChange.html
@@ -7,40 +7,40 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
-      var promises = [];
+      const promises = [];
       promises.push(once(v, "loadedmetadata"));
       promises.push(once(sb, "updateend"));
       Promise.all(promises)
       .then(function() {
         is(v.duration, ms.duration, "video duration is mediasource one");
         try {
           ms.duration = 0;
         } catch (e) { ok(false, "must not throw as operation is valid"); }
         is(v.duration, 0, "reducing duration with no data buffered is valid");
         sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
         // Adding more data will fire durationchange.
         once(sb, "updateend")
         .then(function() {
           ok(true, "got updateend");
           // XXX: Duration should be exactly 4.0, see bug 1065207.
           ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
-          var error = false;
+          let error = false;
           try {
             ms.duration = 0;
           } catch (e) {
             ok(true, "must use remove for range removal");
             is(e.name, "InvalidStateError", "Error is InvalidStateError");
             error = true;
           }
           ok(error, "got an error");
@@ -73,17 +73,17 @@ runWithMSE(function (ms, v) {
             ms.duration = -1;
           } catch (e) {
             ok(true, "can't set a negative duration");
             is(e.name, "TypeError", "Error is TypeError");
             error = true;
           }
           ok(error, "got an error");
           sb.remove(sb.buffered.end(0), Infinity);
-          is(sb.updating, true, "updating is true")
+          is(sb.updating, true, "updating is true");
           error = false;
           try {
             ms.duration = Infinity;
           } catch (e) {
             ok(true, "setting the duration while updating is not allowed");
             is(e.name, "InvalidStateError", "Error is InvalidStateError");
             error = true;
           }
@@ -98,17 +98,17 @@ runWithMSE(function (ms, v) {
           }
           ok(error, "got an error");
           is(v.duration, sb.buffered.end(0), "duration is the highest end time reported by the buffered attribute ");
           once(sb, "updateend", () => ms.endOfStream());
         });
       });
     });
   });
-  ms.addEventListener("sourceended", function () {
+  ms.addEventListener("sourceended", function() {
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_DurationUpdated.html
+++ b/dom/media/mediasource/test/test_DurationUpdated.html
@@ -7,30 +7,30 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var durationChangeCount = 0;
+let durationChangeCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    v.addEventListener("durationchange", function () {
+    v.addEventListener("durationchange", function() {
       durationChangeCount++;
     });
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
       // Adding the first init segment will fire a durationchange.
-      var promises = [];
+      const promises = [];
       promises.push(once(sb, "updateend"));
       promises.push(once(v, "loadedmetadata"));
       Promise.all(promises)
       .then(function() {
         ok(true, "got loadedmetadata");
         // Set mediasource duration to 0, so future appendBuffer
         // will update the mediasource duration.
         // Changing the duration will fire a durationchange.
@@ -41,17 +41,17 @@ runWithMSE(function (ms, v) {
         .then(function() {
           ok(true, "got updateend");
           // this will not fire durationchange as new duration == old duration
           ms.endOfStream();
         });
       });
     });
   });
-  ms.addEventListener("sourceended", function () {
+  ms.addEventListener("sourceended", function() {
     is(durationChangeCount, 3, "durationchange not fired as many times as expected");
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
     SimpleTest.finish();
   });
 });
 
 </script>
--- a/dom/media/mediasource/test/test_DurationUpdated_mp4.html
+++ b/dom/media/mediasource/test/test_DurationUpdated_mp4.html
@@ -7,30 +7,30 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var durationChangeCount = 0;
+let durationChangeCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    v.addEventListener("durationchange", function () {
+    v.addEventListener("durationchange", function() {
       durationChangeCount++;
     });
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
       // Adding the first init segment will fire a durationchange.
-      var promises = [];
+      const promises = [];
       promises.push(once(sb, "updateend"));
       promises.push(once(v, "loadedmetadata"));
       Promise.all(promises)
       .then(function() {
         ok(true, "got loadedmetadata");
         // Set mediasource duration to 0, so future appendBuffer
         // will update the mediasource duration.
         // Changing the duration will fire a durationchange.
@@ -41,17 +41,17 @@ runWithMSE(function (ms, v) {
         .then(function() {
           ok(true, "got updateend");
           // this will not fire durationchange as new duration == old duration
           ms.endOfStream();
         });
       });
     });
   });
-  ms.addEventListener("sourceended", function () {
+  ms.addEventListener("sourceended", function() {
     is(durationChangeCount, 3, "durationchange not fired as many times as expected");
     is(v.duration, 1.696666, "Video has correct duration");
     SimpleTest.finish();
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_EndOfStream.html
+++ b/dom/media/mediasource/test/test_EndOfStream.html
@@ -7,42 +7,42 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function () {
-  var ms = new MediaSource();
+runWithMSE(function() {
+  const ms = new MediaSource();
 
-  var v = document.createElement("video");
+  const v = document.createElement("video");
   v.src = URL.createObjectURL(ms);
   document.body.appendChild(v);
 
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 88966));
-      var count = 0;
-      sb.addEventListener("updateend", function () {
+      let count = 0;
+      sb.addEventListener("updateend", function() {
         ++count;
         if (count == 1) {
           setTimeout(function() {
-                       var fail = false;
-                       try {
-                         ms.endOfStream();
-                       } catch (e) {
-                         fail = true;
-                       }
-                       ok(!fail, "MediaSource.endOfStream succeeded");
-                       SimpleTest.finish();
-                     }, 0);
+            let fail = false;
+            try {
+              ms.endOfStream();
+            } catch (e) {
+              fail = true;
+            }
+            ok(!fail, "MediaSource.endOfStream succeeded");
+            SimpleTest.finish();
+          }, 0);
         }
       });
     });
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_EndOfStream_mp4.html
+++ b/dom/media/mediasource/test/test_EndOfStream_mp4.html
@@ -7,42 +7,42 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function () {
-  var ms = new MediaSource();
+runWithMSE(function() {
+  const ms = new MediaSource();
 
-  var v = document.createElement("video");
+  const v = document.createElement("video");
   v.src = URL.createObjectURL(ms);
   document.body.appendChild(v);
 
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
-      var count = 0;
-      sb.addEventListener("updateend", function () {
+      let count = 0;
+      sb.addEventListener("updateend", function() {
         ++count;
         if (count == 1) {
           setTimeout(function() {
-                       var fail = false;
-                       try {
-                         ms.endOfStream();
-                       } catch (e) {
-                         fail = true;
-                       }
-                       ok(!fail, "MediaSource.endOfStream succeeded");
-                       SimpleTest.finish();
-                     }, 0);
+            let fail = false;
+            try {
+              ms.endOfStream();
+            } catch (e) {
+              fail = true;
+            }
+            ok(!fail, "MediaSource.endOfStream succeeded");
+            SimpleTest.finish();
+          }, 0);
         }
       });
     });
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_EndedEvent.html
+++ b/dom/media/mediasource/test/test_EndedEvent.html
@@ -8,18 +8,18 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
-  once(ms, 'sourceopen').then(function() {
-    var sb = ms.addSourceBuffer("video/webm");
+  once(ms, "sourceopen").then(function() {
+    const sb = ms.addSourceBuffer("video/webm");
     fetchWithXHR("seek.webm", (buf) => sb.appendBuffer(new Uint8Array(buf)));
     sb.addEventListener("updateend", () => ms.endOfStream());
 
     // Test 'ended' is fired when seeking to the end of the media
     // once the duration is known.
     ms.onsourceended = () => {
       el.currentTime = el.duration;
     };
--- a/dom/media/mediasource/test/test_Eviction_mp4.html
+++ b/dom/media/mediasource/test/test_Eviction_mp4.html
@@ -17,64 +17,64 @@ SimpleTest.waitForExplicitFinish();
 
 // Fill up the SourceBuffer by appending data repeatedly via doAppendDataFunc until
 // an exception is thrown.
 function fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) {
   // We are appending data repeatedly in sequence mode, there should be no gaps.
   ok(sourceBuffer.buffered.length <= 1, "there should be no gap in buffered ranges.");
   try {
     doAppendDataFunc();
-  } catch(ex) {
+  } catch (ex) {
     onCaughtExceptionCallback(ex);
     return;
   }
-  once(sourceBuffer, 'updateend', () => {
+  once(sourceBuffer, "updateend", () => {
     fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback);
   });
 }
 
 addMSEPrefs(
-  ["media.mediasource.eviction_threshold.audio", 524288],
-  ["media.dormant-on-pause-timeout-ms", -1] // FIXME: bug 1319292
+  [ "media.mediasource.eviction_threshold.audio", 524288 ],
+  [ "media.dormant-on-pause-timeout-ms", -1 ] // FIXME: bug 1319292
 );
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    let audiosb = ms.addSourceBuffer("audio/mp4");
+    const audiosb = ms.addSourceBuffer("audio/mp4");
     audiosb.mode = "sequence";
-    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
+    fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
     .then(function() {
-      fetchWithXHR('bipbop/bipbop_audio1.m4s', function(audioBuffer) {
-         fillUpSourceBuffer(audiosb,
-           function() { // doAppendDataFunc
-             audiosb.appendBuffer(audioBuffer);
-           },
-           function(ex) { // onCaughtExceptionCallback
-             is(ex.name, 'QuotaExceededError', "QuotaExceededError thrown");
-             is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
-             let seekTime = audiosb.buffered.end(0) / 2;
-             el.currentTime = seekTime;
-             once(el, 'seeked', () => {
-               dump("dump: seeked to " + seekTime);
-               is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
-               try {
-                 audiosb.appendBuffer(audioBuffer);
-               } catch(ex) {
-                 ok(false, "Shouldn't throw another time when data can be evicted");
-                 el.mozDumpDebugInfo();
-                 SimpleTest.finish();
-                 return;
-               }
-               once(audiosb, 'update', () => {
-                 ok(true, "appendBuffer succeeded");
-                 SimpleTest.finish();
-               });
-             });
+      fetchWithXHR("bipbop/bipbop_audio1.m4s", function(audioBuffer) {
+        fillUpSourceBuffer(audiosb,
+          function() { // doAppendDataFunc
+            audiosb.appendBuffer(audioBuffer);
+          },
+          function(ex1) { // onCaughtExceptionCallback
+            is(ex1.name, "QuotaExceededError", "QuotaExceededError thrown");
+            is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
+            const seekTime = audiosb.buffered.end(0) / 2;
+            el.currentTime = seekTime;
+            once(el, "seeked", () => {
+              dump("dump: seeked to " + seekTime);
+              is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
+              try {
+                audiosb.appendBuffer(audioBuffer);
+              } catch (ex2) {
+                ok(false, "Shouldn't throw another time when data can be evicted");
+                el.mozDumpDebugInfo();
+                SimpleTest.finish();
+                return;
+              }
+              once(audiosb, "update", () => {
+                ok(true, "appendBuffer succeeded");
+                SimpleTest.finish();
+              });
+            });
           });
       });
     });
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_ExperimentalAsync.html
+++ b/dom/media/mediasource/test/test_ExperimentalAsync.html
@@ -7,92 +7,92 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 addMSEPrefs(
-  ["media.mediasource.eviction_threshold.audio", 524288],
-  ["media.dormant-on-pause-timeout-ms", -1], // FIXME: bug 1319292
-  ["media.mediasource.experimental.enabled", true]
+  [ "media.mediasource.eviction_threshold.audio", 524288 ],
+  [ "media.dormant-on-pause-timeout-ms", -1 ], // FIXME: bug 1319292
+  [ "media.mediasource.experimental.enabled", true ]
 );
 
 // We fill up the source buffer with audio data until the buffer is full.
 // We ensure that QuotaExceededError is thrown once the buffer is full.
 // We then seek to half the content. By that time, another appendBuffer must succeed
 // as the auto-eviction would succeed (removing all data prior currentTime)
 // The test then fills the audio buffer and plays until the end.
 
 // Fill up the SourceBuffer by appending data repeatedly via doAppendDataFunc until
 // an exception is thrown.
 async function fillUpSourceBuffer(sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) {
   try {
     // We are appending data repeatedly in sequence mode, there should be no gaps.
-    while(true) {
+    while (true) {
       ok(sourceBuffer.buffered.length <= 1, "there should be no gap in buffered ranges.");
       await doAppendDataFunc();
     }
   } catch (ex) {
     ok(true, "appendBuffer promise got rejected");
     onCaughtExceptionCallback(ex);
   }
 }
 
 runWithMSE(async function(ms, el) {
   el.controls = true;
   await once(ms, "sourceopen");
   ok(true, "Receive a sourceopen event");
-  let audiosb = ms.addSourceBuffer("audio/mp4");
+  const audiosb = ms.addSourceBuffer("audio/mp4");
 
   // Test removeAsync
   audiosb.mode = "sequence";
-  var audioInitBuffer = await fetchWithXHR("bipbop/bipbop_audioinit.mp4");
+  const audioInitBuffer = await fetchWithXHR("bipbop/bipbop_audioinit.mp4");
   await audiosb.appendBufferAsync(audioInitBuffer);
-  var audioBuffer = await fetchWithXHR("bipbop/bipbop_audio1.m4s");
+  const audioBuffer = await fetchWithXHR("bipbop/bipbop_audio1.m4s");
   fillUpSourceBuffer(audiosb,
     function() { // doAppendDataFunc
       return audiosb.appendBufferAsync(audioBuffer);
     },
-    async function(ex) { // onCaughtExceptionCallback
-      is(ex.name, "QuotaExceededError", "QuotaExceededError thrown");
+    async function(ex1) { // onCaughtExceptionCallback
+      is(ex1.name, "QuotaExceededError", "QuotaExceededError thrown");
       is(audiosb.buffered.end(0), el.duration, "Duration is end of buffered range");
-      let seekTime = audiosb.buffered.end(0) / 2;
+      const seekTime = audiosb.buffered.end(0) / 2;
       el.currentTime = seekTime;
       await once(el, "seeked");
       dump("dump: seeked to " + seekTime);
       is(el.currentTime, seekTime, "correctly seeked to " + seekTime);
-      await audiosb.appendBufferAsync(audioBuffer).catch(function(ex) {
+      await audiosb.appendBufferAsync(audioBuffer).catch(function(ex2) {
         ok(false, "Shouldn't throw another time when data can be evicted");
         el.mozDumpDebugInfo();
         SimpleTest.finish();
       });
       // Test that an error in remove return a rejected promise
-      await audiosb.removeAsync(5, 0).catch(async function(ex) {
+      await audiosb.removeAsync(5, 0).catch(async function(ex3) {
         ok(true, "remove promise got rejected with end <= start");
-        is(ex.name, "TypeError");
-        await audiosb.removeAsync(ms.duration + 1, Infinity).catch(async function(ex) {
+        is(ex3.name, "TypeError");
+        await audiosb.removeAsync(ms.duration + 1, Infinity).catch(async function(ex4) {
           ok(true, "remove promise got rejected with start > duration");
-          is(ex.name, "TypeError");
-          await audiosb.removeAsync(0, Infinity).catch(function(ex) {
+          is(ex4.name, "TypeError");
+          await audiosb.removeAsync(0, Infinity).catch(function(ex5) {
             ok(false, "shouldn't throw");
           });
           ok(true, "remove succeeded");
           is(audiosb.buffered.length, 0, "buffered should be empty");
           audiosb.mode = "segment";
           audiosb.timestampOffset = 0;
           el.currentTime = 0;
           await fetchAndLoadAsync(audiosb, "bipbop/bipbop_audio", range(1, 4), ".m4s");
           ms.endOfStream();
           el.play();
           await once(el, "ended");
           is(el.currentTime, el.duration, "played to the end");
           SimpleTest.finish();
-          throw ex; // ensure we don't fallback on lines below.
+          throw ex4; // ensure we don't fallback on lines below.
         });
         ok(false, "should have returned an error");
       });
       ok(false, "should have returned an error");
     }
   );
 });
 
--- a/dom/media/mediasource/test/test_FrameSelection.html
+++ b/dom/media/mediasource/test/test_FrameSelection.html
@@ -7,64 +7,64 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
+const updateCount = 0;
 
-    var targets = [{ currentTime: 3, videoWidth: 160, videoHeight: 120 },
-                   { currentTime: 2, videoWidth: 160, videoHeight: 120 },
-                   { currentTime: 0, videoWidth: 320, videoHeight: 240 }];
-    var target;
+const targets = [ { currentTime: 3, videoWidth: 160, videoHeight: 120 },
+                  { currentTime: 2, videoWidth: 160, videoHeight: 120 },
+                  { currentTime: 0, videoWidth: 320, videoHeight: 240 } ];
+let target;
 
-var lowResBuffer;
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+let lowResBuffer;
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
     fetchWithXHR("seek.webm")
-    .then(function (arrayBuffer) {
-      var p = once(v, 'loadedmetadata');
+    .then(function(arrayBuffer) {
+      const p = once(v, "loadedmetadata");
       // Append entire file covering range [0, 4].
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       return p;
     }).then(function() {
       is(v.currentTime, 0, "currentTime has correct initial value");
       is(v.videoWidth, 320, "videoWidth has correct initial value");
       is(v.videoHeight, 240, "videoHeight has correct initial value");
       return fetchWithXHR("seek_lowres.webm");
-    }).then(function (arrayBuffer) {
+    }).then(function(arrayBuffer) {
       // Append initialization segment.
-      var p = once(sb, 'updateend');
+      const p = once(sb, "updateend");
       info("Appending low-res init segment");
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
       lowResBuffer = arrayBuffer;
       return p;
     }).then(function() {
-      var p = once(sb, 'updateend');
+      const p = once(sb, "updateend");
       info("Appending low-res range [2,4]");
       // Append media segment covering range [2, 4].
       sb.appendBuffer(new Uint8Array(lowResBuffer, 51003));
       return p;
     }).then(function() {
       ms.endOfStream();
-      var p = Promise.all([once(v, 'seeked'), once(v, 'resize')]);
+      const p = Promise.all([ once(v, "seeked"), once(v, "resize") ]);
       info("Seeking to t=3");
       v.currentTime = 3;
       return p;
     }).then(function() {
       is(v.currentTime, 3, "Video currentTime at target");
       is(v.videoWidth, 160, "videoWidth has correct low-res value");
       is(v.videoHeight, 120, "videoHeight has correct low-res value");
 
-      var p = Promise.all([once(v, 'seeked'), once(v, 'resize')]);
+      const p = Promise.all([ once(v, "seeked"), once(v, "resize") ]);
       info("Seeking to t=1");
       v.currentTime = 1;
       return p;
     }).then(function() {
       is(v.currentTime, 1, "Video currentTime at target");
       is(v.videoWidth, 320, "videoWidth has correct high-res value");
       is(v.videoHeight, 240, "videoHeight has correct high-res value");
       SimpleTest.finish();
--- a/dom/media/mediasource/test/test_FrameSelection_mp4.html
+++ b/dom/media/mediasource/test/test_FrameSelection_mp4.html
@@ -9,65 +9,64 @@
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 // This test loads partial video, plays and waits until playback stalls.
 // It then loads only 3 frames of a video at higher resolution.
 
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
 runWithMSE(function(ms, v) {
   ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
     receivedSourceOpen = true;
-    var sb = ms.addSourceBuffer("video/mp4");
+    const sb = ms.addSourceBuffer("video/mp4");
     ok(sb, "Create a SourceBuffer");
 
     // Log events for debugging.
-    var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
-                  "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
-                  "waiting", "pause", "durationchange", "seeking", "seeked"];
+    const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                     "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                     "waiting", "pause", "durationchange", "seeking", "seeked" ];
     function logEvent(e) {
-      var v = e.target;
       info("got " + e.type + " event");
     }
     events.forEach(function(e) {
       v.addEventListener(e, logEvent);
     });
 
-    sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
-    fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
+    sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+    fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4")
     .then(function() {
-      var promises = [];
-      promises.push(fetchAndLoad(sb, 'bipbop/bipbop', range(1,3), '.m4s'));
+      const promises = [];
+      promises.push(fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s"));
       promises.push(once(v, "loadeddata"));
       return Promise.all(promises);
     }).then(function() {
       is(sb.buffered.length, 1, "continuous range");
       v.play();
       // We have nothing to play, waiting will be fired.
       return waitUntilTime(v, 1.5);
     }).then(function() {
-      return fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4');
+      return fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4");
     }).then(function() {
       sb.timestampOffset = 1.601666; // End of the video track buffered - time of first video sample (0.095).
       sb.appendWindowEnd = 1.796677; // Only allow room for three extra video frames (we need 3 as this video has b-frames).
-      return fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['1'], '.m4s');
+      return fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "1" ], ".m4s");
     }).then(function() {
       ms.endOfStream();
-      var promises = [];
+      const promises = [];
       promises.push(once(ms, "sourceended"));
       promises.push(once(v, "playing"));
       promises.push(once(v, "ended"));
       return Promise.all(promises);
     }).then(function() {
-      if(v.width, 640, "has proper width");
-      if(v.height, 480, "has proper height");
+      if (v.width, 640, "has proper width");
+      if (v.height, 480, "has proper height");
       SimpleTest.finish();
     });
   });
 });
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek.html
+++ b/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek.html
@@ -7,39 +7,39 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 67833));
     });
 
-    var target = 2;
+    const target = 2;
 
     v.addEventListener("loadeddata", function() {
       ok(v.readyState >= v.HAVE_CURRENT_DATA, "readyState is >= CURRENT_DATA");
       v.currentTime = target;
     }, {once: true});
 
-    v.addEventListener("seeking", function () {
+    v.addEventListener("seeking", function() {
       is(v.readyState, v.HAVE_METADATA, "readyState is HAVE_METADATA");
-      fetchWithXHR("seek.webm", function (arrayBuffer) {
+      fetchWithXHR("seek.webm", function(arrayBuffer) {
         sb.appendBuffer(new Uint8Array(arrayBuffer, 67833));
       });
     });
 
-    v.addEventListener("seeked", function () {
+    v.addEventListener("seeked", function() {
       SimpleTest.finish();
     });
   });
 });
 
 </script>
 </pre>
 </body>
--- a/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek_mp4.html
+++ b/dom/media/mediasource/test/test_HaveMetadataUnbufferedSeek_mp4.html
@@ -7,44 +7,44 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       // 25819 is the offset of the first media segment's end
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25819));
     });
 
-    var target = 1.3;
+    const target = 1.3;
 
     v.addEventListener("loadeddata", function() {
       ok(v.readyState >= v.HAVE_CURRENT_DATA, "readyState is >= CURRENT_DATA");
       v.currentTime = target;
     }, {once: true});
 
-    v.addEventListener("seeking", function () {
+    v.addEventListener("seeking", function() {
       is(v.readyState, v.HAVE_METADATA, "readyState is HAVE_METADATA");
-      fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+      fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
         // 25819 is the offset of the first media segment's end
-        sb.addEventListener("updateend", function () {
+        sb.addEventListener("updateend", function() {
           ms.endOfStream();
         });
         sb.appendBuffer(new Uint8Array(arrayBuffer, 25819));
       });
     });
 
-    v.addEventListener("seeked", function () {
+    v.addEventListener("seeked", function() {
       SimpleTest.finish();
     });
   });
 });
 
 </script>
 </pre>
 </body>
--- a/dom/media/mediasource/test/test_LiveSeekable.html
+++ b/dom/media/mediasource/test/test_LiveSeekable.html
@@ -7,24 +7,24 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
     // Load data with a +2 offset so that we can distinguish buffered range start
     // and seekable range start.
     sb.timestampOffset = 2;
-    var promises = [];
-    promises.push(fetchAndLoad(sb, 'seek', [''], '.webm'));
+    const promises = [];
+    promises.push(fetchAndLoad(sb, "seek", [ "" ], ".webm"));
     promises.push(once(v, "loadedmetadata"));
     Promise.all(promises)
     .then(function() {
       ms.duration = Infinity;
       sb.abort();
       is(sb.buffered.length, 1, "continuous buffered range");
       is(sb.buffered.start(0), 2, "buffered range start at timestamp offset");
       is(sb.buffered.end(0), 6.001, "buffered range end at original duration + timestamp offset");
--- a/dom/media/mediasource/test/test_LoadedDataFired_mp4.html
+++ b/dom/media/mediasource/test/test_LoadedDataFired_mp4.html
@@ -19,48 +19,48 @@ runWithMSE(function(ms, el) {
     is(el.buffered.start(0), 0, "must fire loadeddata when data has been loaded");
     is(el.currentTime, 0, "must fire loadeddata at start");
   });
   el.addEventListener("playing", function() {
     ok(el.buffered.length > 0, "data is buffered");
     is(el.buffered.start(0), 0, "must fire playing when data has been loaded");
     ok(el.currentTime >= 0, "must have started playback");
   });
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
-    promises.push(once(el, "loadedmetadata"));
-    Promise.all(promises)
+    const loadedmetadataPromises = [];
+    loadedmetadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+    loadedmetadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(loadedmetadataPromises)
     .then(function() {
       videosb.appendWindowStart = 2;
       videosb.appendWindowEnd = 4;
       is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
       // Load [2.4, 3.968344). 2.4 as it's the first keyframe after 2s and
       // 3.968344 as the last frame ends after 4s.
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 8), '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 8), ".m4s");
     })
     .then(function() {
       is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
       // test that appendWindowEnd did its job.
       ok(el.buffered.start(0) >= 2, "no data can be found prior appendWindowStart");
-      ok(el.buffered.end(el.buffered.length-1) <= 4, "no data can be found beyond appendWindowEnd");
+      ok(el.buffered.end(el.buffered.length - 1) <= 4, "no data can be found beyond appendWindowEnd");
       el.play();
       return once(el, "play");
     })
     .then(function() {
       videosb.appendWindowStart = 0;
-      var promises = [];
+      const playingPromises = [];
       // Load [0, 3.971666).
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 8), '.m4s'));
+      playingPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 8), ".m4s"));
       // playback can only start now.
-      promises.push(once(el, "playing"));
-      return Promise.all(promises);
+      playingPromises.push(once(el, "playing"));
+      return Promise.all(playingPromises);
     })
     .then(function() {
       ok(true, "playing");
       SimpleTest.finish();
     });
   });
 });
 
--- a/dom/media/mediasource/test/test_LoadedMetadataFired.html
+++ b/dom/media/mediasource/test/test_LoadedMetadataFired.html
@@ -7,28 +7,28 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    v.addEventListener("loadedmetadata", function () {
+    v.addEventListener("loadedmetadata", function() {
       ok(true, "Got loadedmetadata event");
       is(v.videoWidth, 320, "videoWidth has correct initial value");
       is(v.videoHeight, 240, "videoHeight has correct initial value");
       SimpleTest.finish();
     });
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
       v.play();
     });
   });
 
 });
 
 </script>
--- a/dom/media/mediasource/test/test_LoadedMetadataFired_mp4.html
+++ b/dom/media/mediasource/test/test_LoadedMetadataFired_mp4.html
@@ -7,28 +7,28 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    v.addEventListener("loadedmetadata", function () {
+    v.addEventListener("loadedmetadata", function() {
       ok(true, "Got loadedmetadata event");
       is(v.videoWidth, 400, "videoWidth has correct initial value");
       is(v.videoHeight, 300, "videoHeight has correct initial value");
       SimpleTest.finish();
     });
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
       v.play();
     });
   });
 
 });
 
 </script>
--- a/dom/media/mediasource/test/test_MediaSource.html
+++ b/dom/media/mediasource/test/test_MediaSource.html
@@ -7,95 +7,95 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function () {
+runWithMSE(function() {
   SimpleTest.doesThrow(() => new SourceBuffer, "new SourceBuffer should fail");
   SimpleTest.doesThrow(() => new SourceBufferList, "new SourceBufferList direct should fail");
 
-  var ms = new MediaSource();
+  const ms = new MediaSource();
   ok(ms, "Create a MediaSource object");
   ok(ms instanceof EventTarget, "MediaSource must be an EventTarget");
   is(ms.readyState, "closed", "New MediaSource must be in closed state");
 
   // Wrapper creation, tests for leaks.
   SpecialPowers.wrap(ms);
 
   // Set an expando to force wrapper creation, tests for leaks.
   ms.foo = null;
 
-  var o = URL.createObjectURL(ms);
+  const o = URL.createObjectURL(ms);
   ok(o, "Create an objectURL from the MediaSource");
 
-  var v = document.createElement("video");
+  const v = document.createElement("video");
   v.preload = "auto";
   v.src = o;
   document.body.appendChild(v);
 
-  var loadedmetadataCount = 0;
-  var updatestartCount = 0;
-  var updateendCount = 0;
-  var updateCount = 0;
+  let loadedmetadataCount = 0;
+  let updatestartCount = 0;
+  let updateendCount = 0;
+  let updateCount = 0;
 
   ok(MediaSource.isTypeSupported("video/webm; codecs=vp8"), "VP8 MSE is always supported");
   ok(MediaSource.isTypeSupported("audio/webm", "Audio MSE is always supported"));
 
-  ms.addEventListener("sourceopen", function () {
+  ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
-    var sb = ms.addSourceBuffer("video/webm");
+    const sb = ms.addSourceBuffer("video/webm");
     ok(sb, "Create a SourceBuffer");
     is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length");
     is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer");
     is(ms.activeSourceBuffers.length, 0, "MediaSource.activeSourceBuffers is expected length");
 
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer");
     });
 
-    sb.addEventListener("update", function () {
+    sb.addEventListener("update", function() {
       is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
       updateCount++;
       /* Ensure that we endOfStream on the first update event only as endOfStream can
          raise more if the duration of the last buffered range and the intial duration
          differ. See bug 1065207 */
       if (updateCount == 1) {
         ms.endOfStream();
       }
     });
 
-    sb.addEventListener("updatestart", function () {
+    sb.addEventListener("updatestart", function() {
       updatestartCount++;
     });
 
-    sb.addEventListener("updateend", function () {
+    sb.addEventListener("updateend", function() {
       is(ms.activeSourceBuffers[0], sb, "SourceBuffer in active list matches our SourceBuffer");
       is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
       updateendCount++;
       v.play();
     });
   });
 
-  ms.addEventListener("sourceended", function () {
+  ms.addEventListener("sourceended", function() {
     ok(true, "Receive a sourceended event");
     is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
   });
 
-  v.addEventListener("loadedmetadata", function () {
+  v.addEventListener("loadedmetadata", function() {
     loadedmetadataCount++;
   });
 
-  v.addEventListener("ended", function () {
+  v.addEventListener("ended", function() {
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
     ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
     // XXX: 2 update events can be received dueto duration differences, see bug 1065207.
     ok(updateCount == 1 || updateCount == 2, "update event received");
     ok(updateendCount == 1 || updateendCount == 2, "updateend event received");
     ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received");
     is(loadedmetadataCount, 1, "loadedmetadata event received");
--- a/dom/media/mediasource/test/test_MediaSource_disabled.html
+++ b/dom/media/mediasource/test/test_MediaSource_disabled.html
@@ -16,17 +16,16 @@ function test() {
      "MediaSource should be hidden behind a pref");
   SimpleTest.doesThrow(() => new MediaSource,
                        "MediaSource should be hidden behind a pref");
   SimpleTest.finish();
 }
 
 SpecialPowers.pushPrefEnv({"set":
     [
-      ["media.mediasource.enabled", false],
+      [ "media.mediasource.enabled", false ],
     ]
-  },
-                          test);
+}, test);
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_MediaSource_flac_mp4.html
+++ b/dom/media/mediasource/test/test_MediaSource_flac_mp4.html
@@ -8,28 +8,28 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  ms.addEventListener("sourceopen", function () {
+  ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
-    var sb = ms.addSourceBuffer("audio/mp4; codecs=\"flac\"");
+    const sb = ms.addSourceBuffer("audio/mp4; codecs=\"flac\"");
     ok(sb, "Create a SourceBuffer");
 
-    fetchAndLoad(sb, 'flac/IS', [''], '.mp4')
-    .then(fetchAndLoad.bind(null, sb, 'flac/0000', range(1, 3), '.m4s'))
+    fetchAndLoad(sb, "flac/IS", [ "" ], ".mp4")
+    .then(fetchAndLoad.bind(null, sb, "flac/0000", range(1, 3), ".m4s"))
     .then(function() {
       el.play();
       ms.endOfStream();
-      return once(el, 'ended');
+      return once(el, "ended");
     }).then(function() {
       SimpleTest.finish();
     });
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_MediaSource_memory_reporting.html
+++ b/dom/media/mediasource/test/test_MediaSource_memory_reporting.html
@@ -7,48 +7,48 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
+runWithMSE(function(ms, v) {
   // Test that memory reporting works once we've played a video.
   once(v, "ended", () => {
     // Grab a memory report.
-    var mgr = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
-          .getService(SpecialPowers.Ci.nsIMemoryReporterManager);
+    const mgr = SpecialPowers.Cc["@mozilla.org/memory-reporter-manager;1"]
+      .getService(SpecialPowers.Ci.nsIMemoryReporterManager);
 
-    var amount = 0;
-    var resourcesPathSeen = false;
-    var handleReport = function(aProcess, aPath, aKind, aUnits, aAmount, aDesc) {
+    let amount = 0;
+    let resourcePathSeen = false;
+    const handleReport = function(aProcess, aPath, aKind, aUnits, aAmount, aDesc) {
       if (aPath == "explicit/media/resources") {
         resourcePathSeen = true;
         amount += aAmount;
       }
-    }
+    };
 
-    var finished = function () {
+    const finished = function() {
       ok(true, "Yay didn't crash!");
       ok(resourcePathSeen, "Got media resources amount");
       ok(amount > 0, "Non-zero amount reported for media resources");
       SimpleTest.finish();
-    }
+    };
 
     mgr.getReports(handleReport, null, finished, null, /* anonymized = */ false);
   });
 
   // Load a webm video and play it.
   ms.addEventListener("sourceopen", () => {
-    var sb = ms.addSourceBuffer("video/webm");
-    fetchAndLoad(sb, 'seek', [''], '.webm').then(function() {
+    const sb = ms.addSourceBuffer("video/webm");
+    fetchAndLoad(sb, "seek", [ "" ], ".webm").then(function() {
       ms.endOfStream();
-      v.play()
+      v.play();
     });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_MediaSource_mp4.html
+++ b/dom/media/mediasource/test/test_MediaSource_mp4.html
@@ -7,92 +7,92 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function () {
+runWithMSE(function() {
   SimpleTest.doesThrow(() => new SourceBuffer, "new SourceBuffer should fail");
   SimpleTest.doesThrow(() => new SourceBufferList, "new SourceBufferList direct should fail");
 
-  var ms = new MediaSource();
+  const ms = new MediaSource();
   ok(ms, "Create a MediaSource object");
   ok(ms instanceof EventTarget, "MediaSource must be an EventTarget");
   is(ms.readyState, "closed", "New MediaSource must be in closed state");
 
   // Wrapper creation, tests for leaks.
   SpecialPowers.wrap(ms);
 
   // Set an expando to force wrapper creation, tests for leaks.
   ms.foo = null;
 
-  var o = URL.createObjectURL(ms);
+  const o = URL.createObjectURL(ms);
   ok(o, "Create an objectURL from the MediaSource");
 
-  var v = document.createElement("video");
+  const v = document.createElement("video");
   v.preload = "auto";
   v.src = o;
   document.body.appendChild(v);
 
-  var loadedmetadataCount = 0;
-  var updatestartCount = 0;
-  var updateendCount = 0;
-  var updateCount = 0;
+  let loadedmetadataCount = 0;
+  let updatestartCount = 0;
+  let updateendCount = 0;
+  let updateCount = 0;
 
-  ms.addEventListener("sourceopen", function () {
+  ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
-    var sb = ms.addSourceBuffer("video/mp4");
+    const sb = ms.addSourceBuffer("video/mp4");
     ok(sb, "Create a SourceBuffer");
     is(ms.sourceBuffers.length, 1, "MediaSource.sourceBuffers is expected length");
     is(ms.sourceBuffers[0], sb, "SourceBuffer in list matches our SourceBuffer");
     is(ms.activeSourceBuffers.length, 0, "MediaSource.activeSourceBuffers is expected length");
 
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       is(sb.updating, true, "SourceBuffer.updating is expected value after appendBuffer");
     });
 
-    sb.addEventListener("update", function () {
+    sb.addEventListener("update", function() {
       is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
       updateCount++;
       /* Ensure that we endOfStream on the first update event only as endOfStream can
          raise more if the duration of the last buffered range and the intial duration
          differ. See bug 1065207 */
       if (updateCount == 1) {
         ms.endOfStream();
       }
     });
 
-    sb.addEventListener("updatestart", function () {
+    sb.addEventListener("updatestart", function() {
       updatestartCount++;
     });
 
-    sb.addEventListener("updateend", function () {
+    sb.addEventListener("updateend", function() {
       is(ms.activeSourceBuffers[0], sb, "SourceBuffer in active list matches our SourceBuffer");
       is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
       updateendCount++;
       v.play();
     });
   });
 
-  ms.addEventListener("sourceended", function () {
+  ms.addEventListener("sourceended", function() {
     ok(true, "Receive a sourceended event");
     is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
   });
 
-  v.addEventListener("loadedmetadata", function () {
+  v.addEventListener("loadedmetadata", function() {
     loadedmetadataCount++;
   });
 
-  v.addEventListener("ended", function () {
+  v.addEventListener("ended", function() {
     // The bipbop video doesn't start at 0. The old MSE code adjust the
     // timestamps and ignore the audio track. The new one doesn't.
     isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration");
     isfuzzy(v.currentTime, 1.696, 0.166, "Video has correct duration");
     // XXX: 2 update events can be received dueto duration differences, see bug 1065207.
     ok(updateCount == 1 || updateCount == 2, "update event received");
     ok(updateendCount == 1 || updateendCount == 2, "updateend event received");
     ok(updatestartCount == 1 || updatestartCount == 2, "updatestart event received");
--- a/dom/media/mediasource/test/test_MultipleInitSegments.html
+++ b/dom/media/mediasource/test/test_MultipleInitSegments.html
@@ -8,40 +8,40 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
-    fetchWithXHR("seek_lowres.webm", function (seek_lowres) {
-      fetchWithXHR("seek.webm", function (seek) {
-        var data = [
-          [seek_lowres, 0, 438],     // lowres init segment
-          [seek_lowres, 438, 25950], // lowres media segment 0-1
-          [seek, 0, 318],            // init segment
-          [seek, 46712, 67833]       // media segment 0.8-1.201
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
+    fetchWithXHR("seek_lowres.webm", function(seek_lowres) {
+      fetchWithXHR("seek.webm", function(seek) {
+        const data = [
+          [ seek_lowres, 0, 438 ],     // lowres init segment
+          [ seek_lowres, 438, 25950 ], // lowres media segment 0-1
+          [ seek, 0, 318 ],            // init segment
+          [ seek, 46712, 67833 ]       // media segment 0.8-1.201
         ];
-        var length = data.map(d => d[2] - d[1]).reduce((a, b) => a + b);
-        var arrayBuffer = new Uint8Array(length);
-        var pos = 0;
+        const length = data.map(d => d[2] - d[1]).reduce((a, b) => a + b);
+        const arrayBuffer = new Uint8Array(length);
+        let pos = 0;
         data.forEach(function(d) {
-          var buffer = new Uint8Array(d[0], d[1], d[2]-d[1]);
+          const buffer = new Uint8Array(d[0], d[1], d[2] - d[1]);
           arrayBuffer.set(buffer, pos);
           pos += buffer.byteLength;
         });
         loadSegment.bind(null, sb, arrayBuffer)().then(function() {
           // Since we are passing multiple segments in one buffer,
           // the first durationchange event from parsing the init
           // segment will be fired before updateend.
-          v.addEventListener("durationchange", function () {
+          v.addEventListener("durationchange", function() {
             ok(v.duration, 1.201);
             SimpleTest.finish();
           });
           ms.endOfStream();
         });
       });
     });
   });
--- a/dom/media/mediasource/test/test_MultipleInitSegments_mp4.html
+++ b/dom/media/mediasource/test/test_MultipleInitSegments_mp4.html
@@ -8,38 +8,38 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
-    fetchWithXHR("bipbop/bipbop_videoinit.mp4", function (init) {
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
+    fetchWithXHR("bipbop/bipbop_videoinit.mp4", function(init) {
       init = new Uint8Array(init);
-      fetchWithXHR("bipbop/bipbop_video1.m4s", function (segment1) {
+      fetchWithXHR("bipbop/bipbop_video1.m4s", function(segment1) {
         segment1 = new Uint8Array(segment1);
-        fetchWithXHR("bipbop/bipbop_video2.m4s", function (segment2) {
+        fetchWithXHR("bipbop/bipbop_video2.m4s", function(segment2) {
           segment2 = new Uint8Array(segment2);
-          var data = [init, segment1, init, segment2];
-          var length = data.map(d => d.byteLength).reduce((a, b) => a + b);
-          var arrayBuffer = new Uint8Array(length);
-          var pos = 0;
+          const data = [ init, segment1, init, segment2 ];
+          const length = data.map(d => d.byteLength).reduce((a, b) => a + b);
+          const arrayBuffer = new Uint8Array(length);
+          let pos = 0;
           data.forEach(function(buffer) {
             arrayBuffer.set(buffer, pos);
             pos += buffer.byteLength;
           });
           loadSegment.bind(null, sb, arrayBuffer)().then(function() {
             // Since we are passing multiple segments in one buffer,
             // the first durationchange event from parsing the init
             // segment will be fired before updateend.
-            v.addEventListener("durationchange", function () {
+            v.addEventListener("durationchange", function() {
               ok(v.duration, 1.601666);
               SimpleTest.finish();
             });
             ms.endOfStream();
           });
         });
       });
     });
--- a/dom/media/mediasource/test/test_OnEvents.html
+++ b/dom/media/mediasource/test/test_OnEvents.html
@@ -7,55 +7,55 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
+runWithMSE(function(ms, v) {
   function initEvent(e) {
-    v['got' + e] = false;
+    v["got" + e] = false;
   }
   function receiveEvent(e) {
-    v['got' + e] = true;
+    v["got" + e] = true;
   }
-  var msevents = ["onsourceopen", "onsourceended"];
+  const msevents = [ "onsourceopen", "onsourceended" ];
   msevents.forEach(function(e) {
     initEvent(e);
     ms[e] = function() { receiveEvent(e); };
   });
 
-  var sblistevents = ["onaddsourcebuffer", "onremovesourcebuffer"];
+  const sblistevents = [ "onaddsourcebuffer", "onremovesourcebuffer" ];
   sblistevents.forEach(function(e) {
     initEvent(e);
     ms.sourceBuffers[e] = function() { receiveEvent(e); };
   });
 
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    var sbevents = ["onupdatestart", "onupdate", "onupdateend", "onabort"];
+    const sbevents = [ "onupdatestart", "onupdate", "onupdateend", "onabort" ];
     sbevents.forEach(function(e) {
       initEvent(e);
       sb[e] = function() { receiveEvent(e); };
     });
 
-    fetchAndLoad(sb, 'seek', [''], '.webm')
+    fetchAndLoad(sb, "seek", [ "" ], ".webm")
     .then(function() {
-      fetchWithXHR('seek.webm')
+      fetchWithXHR("seek.webm")
       .then(function(arrayBuffer) {
         sb.appendBuffer(arrayBuffer);
         ms.removeSourceBuffer(sb); // will fire abort and removesourcebuffer
         ms.endOfStream(); // will fire sourceended
         once(ms, "sourceended").then(function() {
-          var events = ["onsourceopen", "onsourceended", "onupdatestart", "onupdate", "onupdateend", "onabort", "onaddsourcebuffer", "onremovesourcebuffer"];
+          const events = [ "onsourceopen", "onsourceended", "onupdatestart", "onupdate", "onupdateend", "onabort", "onaddsourcebuffer", "onremovesourcebuffer" ];
           events.forEach(function(e) {
-            ok(v['got' + e], "got " + e);
+            ok(v["got" + e], "got " + e);
           });
           SimpleTest.finish();
         });
       });
     });
   });
 });
 
--- a/dom/media/mediasource/test/test_PlayEvents.html
+++ b/dom/media/mediasource/test/test_PlayEvents.html
@@ -18,150 +18,149 @@ SimpleTest.waitForExplicitFinish();
 // 3. Seek to an area with no buffered data, and ensure that readyState goes back to HAVE_METADATA
 // 4. Load 1.6s of data at the seek position and ensure that canplay is fired and that readyState is now HAVE_FUTURE_DATA
 // 5. Start playing video and check that once it reaches a position with no data, readyState goes back to HAVE_CURRENT_DATA and waiting event is fired.
 // 6. Add 1.6s of data once video element fired waiting, that canplay is fired once readyState is HAVE_FUTURE_DATA.
 // 7. Finally load data to the end and ensure that canplaythrough is fired and that readyState is now HAVE_ENOUGH_DATA
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     // Log events for debugging.
-    var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
-                  "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
-                  "waiting", "pause", "durationchange", "seeking", "seeked"];
+    const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                     "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                     "waiting", "pause", "durationchange", "seeking", "seeked" ];
     function logEvent(e) {
-      var v = e.target;
       info("got " + e.type + " event");
     }
     events.forEach(function(e) {
       el.addEventListener(e, logEvent);
     });
 
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     el.addEventListener("error", function(e) {
       ok(false, "should not fire '" + e + "' event");
     });
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
-    promises.push(once(el, 'loadedmetadata'));
-    Promise.all(promises)
+    const metadataPromises = [];
+    metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+    metadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(metadataPromises)
     .then(function() {
-       ok(true, "got loadedmetadata event");
-       var promises = [];
-       promises.push(once(el, 'loadeddata'));
-       promises.push(once(el, 'canplay'));
-       promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s'));
-       return Promise.all(promises);
+      ok(true, "got loadedmetadata event");
+      const canplayPromises = [];
+      canplayPromises.push(once(el, "loadeddata"));
+      canplayPromises.push(once(el, "canplay"));
+      canplayPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s"));
+      return Promise.all(canplayPromises);
     })
     .then(function() {
       ok(true, "got canplay event");
       // set element duration to 3.203333s. We do so in order to guarantee that
       // the end of the buffered range will be equal to duration, causing
       // canplaythrough to be fired later.
       ms.duration = 3.203333;
-      return once(el, 'durationchange');
+      return once(el, "durationchange");
     })
     .then(function() {
       ok(true, "got durationchange event");
-      var promises = [];
-      promises.push(once(el, 'canplaythrough'));
+      const promises = [];
+      promises.push(once(el, "canplaythrough"));
       // Load [0.801666, 3.203333]
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(3, 5), '.m4s'));
+      promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s"));
       return Promise.all(promises);
     })
     .then(function() {
       ok(true, "got canplaythrough event");
-     // set element duration to 9.203333s, this value is set to coincide with
-     // data added later (we now have an empty range from 6s to 9.203333s).
-     ms.duration = 9.203333;
-     return once(el, 'durationchange');
+      // set element duration to 9.203333s, this value is set to coincide with
+      // data added later (we now have an empty range from 6s to 9.203333s).
+      ms.duration = 9.203333;
+      return once(el, "durationchange");
     })
     .then(function() {
       ok(true, "got durationchange event");
       // An arbitrary value, so we are guaranteed to be in a range with no data.
       el.currentTime = 6;
       videosb.timestampOffset = 6;
       ok(el.seeking, "seeking started");
-      return once(el, 'seeking');
+      return once(el, "seeking");
     })
     .then(function() {
       ok(true, "got seeking event");
       is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
-      var promises = [];
-      promises.push(once(el, 'seeked'));
-      promises.push(once(el, 'canplay'));
+      const promises = [];
+      promises.push(once(el, "seeked"));
+      promises.push(once(el, "canplay"));
       // Load [6+0, 6+1.601666)
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s'));
+      promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s"));
       return Promise.all(promises);
     })
     .then(function() {
       ok(true, "got seeked and canplay event");
       is(el.currentTime, 6, "seeked to 6s");
       is(el.readyState, el.HAVE_FUTURE_DATA, "readyState is HAVE_FUTURE_DATA");
-      var promises = [];
-      promises.push(once(el, 'canplaythrough'));
+      const promises = [];
+      promises.push(once(el, "canplaythrough"));
       // Load [6+1.60166, 6+3.203333]
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(3, 5), '.m4s'));
+      promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s"));
       return Promise.all(promises);
     })
     .then(function() {
       ok(true, "got canplaythrough event");
       // set element duration to 19.805s, this value is set to coincide with
       // data added later (we now have an empty range from 15 to 19.805).
       ms.duration = 19.805;
-      return once(el, 'durationchange');
+      return once(el, "durationchange");
     })
     .then(function() {
       ok(true, "got durationchange event");
       el.currentTime = 15;
       videosb.timestampOffset = 15;
       ok(el.seeking, "seeking started");
-      return once(el, 'seeking');
+      return once(el, "seeking");
     })
     .then(function() {
       ok(true, "got seeking event");
-      var promises = [];
-      promises.push(once(el, 'seeked'));
+      const promises = [];
+      promises.push(once(el, "seeked"));
       // Load [15+0, 15+1.601666)
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s'));
+      promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s"));
       return Promise.all(promises);
     })
     .then(function() {
       ok(true, "got seeked event");
       // Load [15+1.60166, 15+3.203333]
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(3, 5), '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(3, 5), ".m4s");
     })
     .then(function() {
       ok(true, "data loaded");
       // Playback we play for a little while then stall.
-      var promises = [];
-      promises.push(once(el, 'playing'));
-      promises.push(once(el, 'waiting'));
+      const promises = [];
+      promises.push(once(el, "playing"));
+      promises.push(once(el, "waiting"));
       el.play();
       return Promise.all(promises);
     })
     .then(function() {
       ok(true, "got playing and waiting event");
       // Playback has stalled, readyState is back to HAVE_CURRENT_DATA.
       is(el.readyState, el.HAVE_CURRENT_DATA, "readyState is HAVE_CURRENT_DATA");
-      var promises = [];
-      promises.push(once(el, 'playing'));
-      promises.push(once(el, 'canplay'));
-      promises.push(once(el, 'canplaythrough'));
+      const promises = [];
+      promises.push(once(el, "playing"));
+      promises.push(once(el, "canplay"));
+      promises.push(once(el, "canplaythrough"));
       // Load [15+3.203333, 15+4.805)
       // Our final buffered range will now be [0, 3.203333)[6, 9.203333)[15, 19.805)
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 7), '.m4s'));
+      promises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 7), ".m4s"));
       return Promise.all(promises);
     })
     .then(function() {
       ok(true, "got playing, canplay and canplaythrough event");
       SimpleTest.finish();
-    })
+    });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_PlayEventsAutoPlaying.html
+++ b/dom/media/mediasource/test/test_PlayEventsAutoPlaying.html
@@ -14,64 +14,64 @@ SimpleTest.waitForExplicitFinish();
 
 // This test checks that readyState is properly set and the appropriate events are being fired accordingly:
 // 1. Ensure that play/playing aren't fired before any media data been added.
 // 2. Load 1.6s of data and ensure that canplay, play and playing events are fired.
 
 runWithMSE(function(ms, el) {
   el.controls = true;
   el.autoplay = true;
-  var eventCounts = { play: 0, playing: 0};
+  const eventCounts = { play: 0, playing: 0};
   function ForbiddenEvents(e) {
-    var v = e.target;
+    const v = e.target;
     ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
     is(eventCounts[e.type], 0, "event should have only be fired once");
     eventCounts[e.type]++;
   }
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     // Log events for debugging.
-    var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
-                  "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
-                  "waiting", "pause", "durationchange", "seeking", "seeked"];
+    const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                     "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                     "waiting", "pause", "durationchange", "seeking", "seeked" ];
     function logEvent(e) {
       info("got " + e.type + " event");
     }
     events.forEach(function(e) {
       el.addEventListener(e, logEvent);
     });
     el.addEventListener("play", ForbiddenEvents);
     el.addEventListener("playing", ForbiddenEvents);
 
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     el.addEventListener("error", function(e) {
       ok(false, "should not fire '" + e + "' event");
     });
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
-    promises.push(once(el, 'loadedmetadata'));
-    Promise.all(promises)
+    const metadataPromises = [];
+    metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+    metadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(metadataPromises)
     .then(function() {
-       ok(true, "got loadedmetadata event");
-       var promises = [];
-       promises.push(once(el, 'loadeddata'));
-       promises.push(once(el, 'canplay'));
-       promises.push(once(el, 'play'));
-       promises.push(once(el, 'playing'));
-       promises.push(once(el, 'ended'));
-       // We're only adding 1.6s worth of data, not enough for readyState to change to HAVE_ENOUGH_DATA
-       // So we end the media source so that all the playable data is available.
-       promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 3), '.m4s')
-                     .then(() => ms.endOfStream()));
-       return Promise.all(promises);
+      ok(true, "got loadedmetadata event");
+      const playedThroughPromises = [];
+      playedThroughPromises.push(once(el, "loadeddata"));
+      playedThroughPromises.push(once(el, "canplay"));
+      playedThroughPromises.push(once(el, "play"));
+      playedThroughPromises.push(once(el, "playing"));
+      playedThroughPromises.push(once(el, "ended"));
+      // We're only adding 1.6s worth of data, not enough for readyState to change to HAVE_ENOUGH_DATA
+      // So we end the media source so that all the playable data is available.
+      playedThroughPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 3), ".m4s")
+                                 .then(() => ms.endOfStream()));
+      return Promise.all(playedThroughPromises);
     })
     .then(function() {
       ok(true, "got all required event");
       SimpleTest.finish();
-    })
+    });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_PlayEventsAutoPlaying2.html
+++ b/dom/media/mediasource/test/test_PlayEventsAutoPlaying2.html
@@ -14,63 +14,63 @@ SimpleTest.waitForExplicitFinish();
 
 // This test checks that readyState is properly set and the appropriate events are being fired accordingly:
 // 1. Ensure that play/playing aren't fired before any media data been added.
 // 2. Load more than 10s of data and ensure that canplay, play and playing events are fired.
 
 runWithMSE(function(ms, el) {
   el.controls = true;
   el.autoplay = true;
-  var eventCounts = { play: 0, playing: 0};
+  const eventCounts = { play: 0, playing: 0};
   function ForbiddenEvents(e) {
-    var v = e.target;
+    const v = e.target;
     ok(v.readyState >= v.HAVE_FUTURE_DATA, "Must not have received event too early");
     is(eventCounts[e.type], 0, "event should have only be fired once");
     eventCounts[e.type]++;
   }
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     // Log events for debugging.
-    var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
-                  "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
-                  "waiting", "pause", "durationchange", "seeking", "seeked"];
+    const events = [ "suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
+                     "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
+                     "waiting", "pause", "durationchange", "seeking", "seeked" ];
     function logEvent(e) {
       info("got " + e.type + " event");
     }
     events.forEach(function(e) {
       el.addEventListener(e, logEvent);
     });
     el.addEventListener("play", ForbiddenEvents);
     el.addEventListener("playing", ForbiddenEvents);
 
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     el.addEventListener("error", function(e) {
       ok(false, "should not fire '" + e + "' event");
     });
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
-    promises.push(once(el, 'loadedmetadata'));
-    Promise.all(promises)
+    const metadataPromises = [];
+    metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+    metadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(metadataPromises)
     .then(function() {
-       ok(true, "got loadedmetadata event");
-       var promises = [];
-       // We shift the timestamps slightly to create a small gaps at the start.
-       // one that should normally be ignored.
-       videosb.timestampOffset = 0.1;
-       promises.push(once(el, 'loadeddata'));
-       promises.push(once(el, 'canplay'));
-       promises.push(once(el, 'play'));
-       promises.push(once(el, 'playing'));
-       promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 14), '.m4s'));
-       return Promise.all(promises);
+      ok(true, "got loadedmetadata event");
+      const playingPromises = [];
+      // We shift the timestamps slightly to create a small gaps at the start.
+      // one that should normally be ignored.
+      videosb.timestampOffset = 0.1;
+      playingPromises.push(once(el, "loadeddata"));
+      playingPromises.push(once(el, "canplay"));
+      playingPromises.push(once(el, "play"));
+      playingPromises.push(once(el, "playing"));
+      playingPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 14), ".m4s"));
+      return Promise.all(playingPromises);
     })
     .then(function() {
       ok(true, "got all required event");
       SimpleTest.finish();
-    })
+    });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_RemoveSourceBuffer.html
+++ b/dom/media/mediasource/test/test_RemoveSourceBuffer.html
@@ -4,29 +4,29 @@
   <title>MSE: check buffered status after removed all source buffer</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
-var videoURL = "seek.webm";
+const videoURL = "seek.webm";
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(async function(ms, el) {
   info("- wait for sourceopen -");
-  await once(ms, 'sourceopen');
+  await once(ms, "sourceopen");
 
   info("- wait for fetching data -");
-  var arrayBuffer = await fetchWithXHR(videoURL);
+  const arrayBuffer = await fetchWithXHR(videoURL);
 
   info("- create source buffer and append data -");
-  var sourceBuffer = ms.addSourceBuffer("video/webm");
+  const sourceBuffer = ms.addSourceBuffer("video/webm");
   sourceBuffer.appendBuffer(arrayBuffer);
   await once(sourceBuffer, "updateend");
   is(ms.sourceBuffers.length, 1,
      "the length of source buffers list is 1.");
   is(ms.activeSourceBuffers.length, 1,
      "the length of active source buffers list is 1.");
   ok(ms.duration != 0, "duration is not 0.");
   is(el.buffered.length, 1, "buffered range is 1.");
--- a/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
+++ b/dom/media/mediasource/test/test_ResumeAfterClearing_mp4.html
@@ -6,48 +6,48 @@
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
 runWithMSE(function(ms, v) {
   ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
     receivedSourceOpen = true;
-    var sb = ms.addSourceBuffer("video/mp4");
+    const sb = ms.addSourceBuffer("video/mp4");
     ok(sb, "Create a SourceBuffer");
 
-    sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
-    fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
+    sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+    fetchAndLoad(sb, "bipbop/bipbop", [ "init" ], ".mp4")
     .then(function() {
-      var promises = [];
-      promises.push(fetchAndLoad(sb, 'bipbop/bipbop', range(1,3), '.m4s'));
+      const promises = [];
+      promises.push(fetchAndLoad(sb, "bipbop/bipbop", range(1, 3), ".m4s"));
       promises.push(once(v, "loadeddata"));
       return Promise.all(promises);
     }).then(function() {
       // clear the entire sourcebuffer.
       sb.remove(0, 5);
       return once(sb, "updateend");
     }).then(function() {
       v.play();
       // We have nothing to play, waiting will be fired.
       return once(v, "waiting");
     }).then(function() {
-      var promises = [];
+      const promises = [];
       promises.push(once(v, "playing"));
-      promises.push(fetchAndLoad(sb, 'bipbop/bipbop', range(1,4), '.m4s'));
+      promises.push(fetchAndLoad(sb, "bipbop/bipbop", range(1, 4), ".m4s"));
       return Promise.all(promises);
     }).then(function() {
       ms.endOfStream();
-      var promises = [];
+      const promises = [];
       promises.push(once(ms, "sourceended"));
       promises.push(once(v, "ended"));
       return Promise.all(promises);
     }).then(SimpleTest.finish.bind(SimpleTest));
   });
 });
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_SeekNoData_mp4.html
+++ b/dom/media/mediasource/test/test_SeekNoData_mp4.html
@@ -14,57 +14,57 @@ SimpleTest.waitForExplicitFinish();
 
 // Avoid making trouble for people who fix rounding bugs.
 function fuzzyEquals(a, b) {
   return Math.abs(a - b) < 0.01;
 }
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const audiosb = ms.addSourceBuffer("audio/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     el.addEventListener("error", function(e) {
       ok(false, "should not fire '" + e + "' event");
     });
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
     try {
       el.currentTime = 3;
     } catch (e) {
       ok(false, "should not throw '" + e + "' exception");
     }
     is(el.currentTime, 3, "currentTime is default playback start position");
     is(el.seeking, false, "seek not started with HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4'));
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
-    promises.push(once(el, 'loadedmetadata'))
-    Promise.all(promises)
+    const metadataPromises = [];
+    metadataPromises.push(fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"));
+    metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+    metadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(metadataPromises)
     .then(function() {
-      var p = once(el, 'seeking');
+      const p = once(el, "seeking");
       el.play();
       el.currentTime = 5;
       is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
       is(el.seeking, true, "seek not started with HAVE_METADATA");
       is(el.currentTime, 5, "currentTime is seek position");
       return p;
     })
     .then(function() {
-       ok(true, "Got seeking event");
-       var promises = [];
-       promises.push(once(el, 'seeked'));
-       promises.push(fetchAndLoad(audiosb, 'bipbop/bipbop_audio', range(5, 9), '.m4s'));
-       promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', range(6, 10), '.m4s'));
-       return Promise.all(promises);
+      ok(true, "Got seeking event");
+      const seekedPromises = [];
+      seekedPromises.push(once(el, "seeked"));
+      seekedPromises.push(fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(5, 9), ".m4s"));
+      seekedPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", range(6, 10), ".m4s"));
+      return Promise.all(seekedPromises);
     })
     .then(function() {
       ok(true, "Got seeked event");
       ok(el.currentTime >= 5, "Time >= 5");
-      once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+      once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
       ms.endOfStream();
     });
   });
 });
 
 </script>
 </pre>
 </body>
--- a/dom/media/mediasource/test/test_SeekToEnd_mp4.html
+++ b/dom/media/mediasource/test/test_SeekToEnd_mp4.html
@@ -9,49 +9,49 @@
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
 
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
+    const audiosb = ms.addSourceBuffer("audio/mp4");
 
-    fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4'))
+    fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"))
     .then(function() {
       is(videosb.buffered.length, 1, "continuous buffered range");
       // Ensure we have at least 2s less audio than video.
       audiosb.appendWindowEnd = videosb.buffered.end(0) - 2;
-      return fetchAndLoad(audiosb, 'bipbop/bipbop_audio', range(1, 6), '.m4s');
+      return fetchAndLoad(audiosb, "bipbop/bipbop_audio", range(1, 6), ".m4s");
     }).then(function() {
       ms.endOfStream();
-      return Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
+      return Promise.all([ once(el, "durationchange"), once(ms, "sourceended") ]);
     }).then(function() {
       ok(true, "endOfStream completed");
       // Seek to the middle of the gap where audio is missing. As we are in readyState = ended
       // seeking must complete.
       el.currentTime = videosb.buffered.end(0) / 2 + audiosb.buffered.end(0) / 2;
       ok(el.currentTime - audiosb.buffered.end(0) > 1, "gap is big enough");
       is(el.buffered.length, 1, "continuous buffered range");
       is(el.buffered.end(0), videosb.buffered.end(0), "buffered range end is aligned with longest track");
       ok(el.seeking, "element is now seeking");
       ok(el.currentTime >= el.buffered.start(0) && el.currentTime <= el.buffered.end(0), "seeking time is in buffered range");
       ok(el.currentTime > audiosb.buffered.end(0), "seeking point is not buffered in audio track");
-      return once(el, 'seeked');
+      return once(el, "seeked");
     }).then(function() {
       ok(true, "we have successfully seeked");
       // Now ensure that we can play to the end, even though we are missing data in one track.
       el.play();
-      once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+      once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
     });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_SeekToLastFrame_mp4.html
+++ b/dom/media/mediasource/test/test_SeekToLastFrame_mp4.html
@@ -8,31 +8,31 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var sb = ms.addSourceBuffer("video/mp4");
-    fetchAndLoad(sb, 'bipbop/bipbop_480_624kbps-video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_480_624kbps-video', range(1, 3), '.m4s'))
+    const sb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(sb, "bipbop/bipbop_480_624kbps-video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_480_624kbps-video", range(1, 3), ".m4s"))
     .then(function() {
       el.play();
       // let seek to the last audio frame.
       el.currentTime = 1.532517;
-      return once(el, 'seeked');
+      return once(el, "seeked");
     })
     .then(function() {
       ok(true, "seek completed");
       ms.endOfStream();
-      return once(el, 'ended');
+      return once(el, "ended");
     }).then(function() {
       SimpleTest.finish();
     });
   });
 });
 
 </script>
 </pre>
--- a/dom/media/mediasource/test/test_SeekTwice_mp4.html
+++ b/dom/media/mediasource/test/test_SeekTwice_mp4.html
@@ -14,40 +14,40 @@ SimpleTest.waitForExplicitFinish();
 
 // Avoid making trouble for people who fix rounding bugs.
 function fuzzyEquals(a, b) {
   return Math.abs(a - b) < 0.01;
 }
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
-    var videosb = ms.addSourceBuffer("video/mp4");
-    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(6, 12), '.m4s'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(7, 14), '.m4s'))
+    const audiosb = ms.addSourceBuffer("audio/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"))
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(7, 14), ".m4s"))
     .then(function() {
-      var p = once(el, 'seeking');
+      const p = once(el, "seeking");
       el.play();
       el.currentTime = 4.5; // Seek to a gap in the video
       return p;
     }).then(function() {
       ok(true, "Got seeking event");
-      var p = once(el, 'seeked');
+      const p = once(el, "seeked");
       el.currentTime = 6; // Seek past the gap.
       return p;
     }).then(function() {
       ok(true, "Got seeked event");
       ok(el.currentTime >= 6, "Time >= 6");
-      once(el, 'ended').then(SimpleTest.finish.bind(SimpleTest));
+      once(el, "ended").then(SimpleTest.finish.bind(SimpleTest));
       ms.endOfStream();
     });
   });
 });
 
 </script>
 </pre>
 </body>
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream.html
@@ -7,32 +7,32 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", async function (arrayBuffer) {
+    fetchWithXHR("seek.webm", async function(arrayBuffer) {
       info("- append buffer -");
       sb.appendBuffer(new Uint8Array(arrayBuffer));
 
       info("- wait for metadata -");
       await once(v, "loadedmetadata");
 
       info("- wait for updateend -");
       await once(sb, "updateend");
 
       info("- check seekable -");
-      var target = 2;
+      const target = 2;
       ok(v.seekable.length, "Resource is seekable");
       is(v.seekable.start(0), 0, "Seekable's start point is correct");
       is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
       ok(v.seekable.length &&
          target >= v.seekable.start(0) &&
          target < v.seekable.end(0), "Target is within seekable range");
 
       info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit.html
@@ -7,37 +7,37 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", async function (arrayBuffer) {
+    fetchWithXHR("seek.webm", async function(arrayBuffer) {
       info("- append first buffer -");
       // 25523 is the offset of the first media segment's end
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25523));
 
       info("- wait for metadata -");
       await once(v, "loadedmetadata");
 
       info("- wait for updateend -");
       await once(sb, "updateend");
 
       info("- append second buffer -");
       sb.appendBuffer(new Uint8Array(arrayBuffer, 25523));
       await once(sb, "updateend");
 
       info("- check seekable -");
-      var target = 2;
+      const target = 2;
       ok(v.seekable.length, "Resource is seekable");
       is(v.seekable.start(0), 0, "Seekable's start point is correct");
       is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
       ok(v.seekable.length &&
          target >= v.seekable.start(0) &&
          target < v.seekable.end(0), "Target is within seekable range");
 
       info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit_mp4.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStreamSplit_mp4.html
@@ -7,37 +7,37 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", async function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", async function(arrayBuffer) {
       info("- append first buffer -");
       // 25819 is the offset of the first media segment's end
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 25819));
 
       info("- wait for metadata -");
       await once(v, "loadedmetadata");
 
       info("- wait for updateend -");
       await once(sb, "updateend");
 
       info("- append second buffer -");
       sb.appendBuffer(new Uint8Array(arrayBuffer, 25819));
       await once(sb, "updateend");
 
       info("- check seekable -");
-      var target = 1.3;
+      const target = 1.3;
       ok(v.seekable.length, "Resource is seekable");
       is(v.seekable.start(0), 0, "Seekable's start point is correct");
       is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
       ok(v.seekable.length &&
          target >= v.seekable.start(0) &&
          target < v.seekable.end(0), "Target is within seekable range");
 
       info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream_mp4.html
+++ b/dom/media/mediasource/test/test_SeekableBeforeAndAfterEndOfStream_mp4.html
@@ -7,32 +7,32 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", async function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", async function(arrayBuffer) {
       info("- append buffer -");
       sb.appendBuffer(new Uint8Array(arrayBuffer));
 
       info("- wait for metadata -");
       await once(v, "loadedmetadata");
 
       info("- wait for updateend -");
       await once(sb, "updateend");
 
       info("- check seekable -");
-      var target = 1.3;
+      const target = 1.3;
       ok(v.seekable.length, "Resource is seekable");
       is(v.seekable.start(0), 0, "Seekable's start point is correct");
       is(v.seekable.end(0), ms.duration, "Seekable's end point is correct");
       ok(v.seekable.length &&
          target >= v.seekable.start(0) &&
          target < v.seekable.end(0), "Target is within seekable range");
 
       info("- call end of stream -");
--- a/dom/media/mediasource/test/test_SeekedEvent_mp4.html
+++ b/dom/media/mediasource/test/test_SeekedEvent_mp4.html
@@ -30,45 +30,45 @@ runWithMSE(function(ms, el) {
     el._loadeddata = true;
   });
   el.addEventListener("playing", function() {
     ok(true, "got playing");
     is(el._seeked, true, "must have received seeked prior playing");
     is(el._loadeddata, true, "must have received loadeddata prior playing");
     el._playing = true;
   });
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
-    var promises = [];
-    promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4'));
-    promises.push(once(el, "loadedmetadata"));
-    Promise.all(promises)
+    const metadataPromises = [];
+    metadataPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"));
+    metadataPromises.push(once(el, "loadedmetadata"));
+    Promise.all(metadataPromises)
     .then(function() {
       el.play();
       videosb.timestampOffset = 2;
       is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
       // Load [2, 3.606).
-      var promises = [];
-      promises.push(once(el, "play"));
-      promises.push(fetchAndLoad(videosb, 'bipbop/bipbop_video', ['1'], '.m4s'));
-      return Promise.all(promises);
+      const playPromises = [];
+      playPromises.push(once(el, "play"));
+      playPromises.push(fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s"));
+      return Promise.all(playPromises);
     })
     .then(function() {
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', ['2'], '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", [ "2" ], ".m4s");
     })
     .then(function() {
       // TODO: readyState should be at least HAVE_CURRENTDATA, see bug 1367993.
       ok(el.readyState >= el.HAVE_METADATA, "readyState is HAVE_METADATA");
       el.currentTime = 2;
-      var promises = [];
-      promises.push(once(el, "seeked"));
-      promises.push(once(el, "playing"));
-      return Promise.all(promises);
+      const seekedAndPlayingPromises = [];
+      seekedAndPlayingPromises.push(once(el, "seeked"));
+      seekedAndPlayingPromises.push(once(el, "playing"));
+      return Promise.all(seekedAndPlayingPromises);
     })
     .then(function() {
       ok(true, "completed seek");
       SimpleTest.finish();
     });
   });
 });
 
--- a/dom/media/mediasource/test/test_Sequence_mp4.html
+++ b/dom/media/mediasource/test/test_Sequence_mp4.html
@@ -6,34 +6,34 @@
   <script type="text/javascript" src="mediasource.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var receivedSourceOpen = false;
+let receivedSourceOpen = false;
 runWithMSE(function(ms, v) {
   ms.addEventListener("sourceopen", function() {
     ok(true, "Receive a sourceopen event");
     ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
     receivedSourceOpen = true;
-    var sb = ms.addSourceBuffer("video/mp4");
+    const sb = ms.addSourceBuffer("video/mp4");
     ok(sb, "Create a SourceBuffer");
-    sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
-    sb.mode = 'sequence';
+    sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+    sb.mode = "sequence";
 
-    fetchAndLoad(sb, 'bipbop/bipbop_video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_video', ['5'], '.m4s'))
-    .then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop_video', ['2'], '.m4s'))
+    fetchAndLoad(sb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_video", [ "5" ], ".m4s"))
+    .then(fetchAndLoad.bind(null, sb, "bipbop/bipbop_video", [ "2" ], ".m4s"))
     .then(function() {
-        is(v.buffered.length, 1, "Continuous buffered range");
-        is(v.buffered.start(0), 0, "Buffered range starts at 0");
-        ok(sb.timestampOffset > 0, "SourceBuffer.timestampOffset set to allow continuous range");
-        SimpleTest.finish();
-      });
+      is(v.buffered.length, 1, "Continuous buffered range");
+      is(v.buffered.start(0), 0, "Buffered range starts at 0");
+      ok(sb.timestampOffset > 0, "SourceBuffer.timestampOffset set to allow continuous range");
+      SimpleTest.finish();
+    });
   });
 });
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_SetModeThrows.html
+++ b/dom/media/mediasource/test/test_SetModeThrows.html
@@ -8,19 +8,19 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 // MSE supports setting mode now. make sure it does not throw.
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
     sb.mode = "segments";
     ok("true", "Setting to segments does not throw");
     try {
       sb.mode = "sequence";
       ok("true", "Setting to sequence does not throw");
     } catch (e) { ok(false, "Should not throw setting mode to sequence: " + e); }
 
--- a/dom/media/mediasource/test/test_SplitAppend.html
+++ b/dom/media/mediasource/test/test_SplitAppend.html
@@ -7,38 +7,37 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
+let updateCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
-      sb.addEventListener("updateend", function () {
+      sb.addEventListener("updateend", function() {
         updateCount++;
         if (updateCount == 1) {
           sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
-        }
-        else if (updateCount == 2) {
+        } else if (updateCount == 2) {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
-  v.addEventListener("ended", function () {
+  v.addEventListener("ended", function() {
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
     ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
     SimpleTest.finish();
   });
 });
 
 </script>
--- a/dom/media/mediasource/test/test_SplitAppendDelay.html
+++ b/dom/media/mediasource/test/test_SplitAppendDelay.html
@@ -8,40 +8,39 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
-var updateCount = 0;
+let updateCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
-      sb.addEventListener("updateend", function () {
+      sb.addEventListener("updateend", function() {
         updateCount++;
         if (updateCount == 1) {
-          window.setTimeout(function () {
+          window.setTimeout(function() {
             sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
           }, 1000);
-        }
-        else if (updateCount == 2) {
+        } else if (updateCount == 2) {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
-  v.addEventListener("ended", function () {
+  v.addEventListener("ended", function() {
     // XXX: Duration should be exactly 4.0, see bug 1065207.
     ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
     ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
     SimpleTest.finish();
   });
 });
 
 </script>
--- a/dom/media/mediasource/test/test_SplitAppendDelay_mp4.html
+++ b/dom/media/mediasource/test/test_SplitAppendDelay_mp4.html
@@ -8,40 +8,39 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
-var updateCount = 0;
+let updateCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
-      sb.addEventListener("updateend", function () {
+      sb.addEventListener("updateend", function() {
         updateCount++;
         if (updateCount == 1) {
-          window.setTimeout(function () {
+          window.setTimeout(function() {
             sb.appendBuffer(new Uint8Array(arrayBuffer, 1395));
           }, 1000);
-        }
-        else if (updateCount == 2) {
+        } else if (updateCount == 2) {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
-  v.addEventListener("ended", function () {
+  v.addEventListener("ended", function() {
     // The bipbop video doesn't start at 0. The old MSE code adjust the
     // timestamps and ignore the audio track. The new one doesn't.
     isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration");
     isfuzzy(v.currentTime, 1.696, 0.166, "Video has played to end");
     SimpleTest.finish();
   });
 });
 
--- a/dom/media/mediasource/test/test_SplitAppend_mp4.html
+++ b/dom/media/mediasource/test/test_SplitAppend_mp4.html
@@ -7,38 +7,37 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-var updateCount = 0;
+let updateCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 1395));
-      sb.addEventListener("updateend", function () {
+      sb.addEventListener("updateend", function() {
         updateCount++;
         if (updateCount == 1) {
           sb.appendBuffer(new Uint8Array(arrayBuffer, 1395));
-        }
-        else if (updateCount == 2) {
+        } else if (updateCount == 2) {
           ms.endOfStream();
         }
       });
       v.play();
     });
   });
 
-  v.addEventListener("ended", function () {
+  v.addEventListener("ended", function() {
     // The bipbop video doesn't start at 0. The old MSE code adjust the
     // timestamps and ignore the audio track. The new one doesn't.
     isfuzzy(v.duration, 1.696, 0.166, "Video has correct duration");
     isfuzzy(v.currentTime, 1.696, 0.166, "Video has played to end");
     SimpleTest.finish();
   });
 });
 
--- a/dom/media/mediasource/test/test_Threshold_mp4.html
+++ b/dom/media/mediasource/test/test_Threshold_mp4.html
@@ -9,70 +9,70 @@
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
 
-var threshold = 0.5; // gap threshold in seconds.
-var fuzz = 0.000001; // fuzz when comparing double.
+  const threshold = 0.5; // gap threshold in seconds.
+  const fuzz = 0.000001; // fuzz when comparing double.
 
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var videosb = ms.addSourceBuffer("video/mp4");
-    var vchunks = [ {start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666}];
+    const videosb = ms.addSourceBuffer("video/mp4");
+    const vchunks = [ {start: 0, end: 3.203333}, { start: 3.203333, end: 6.406666} ];
 
-    fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'))
+    fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"))
     .then(function() {
       // We will insert a gap of threshold
       videosb.timestampOffset = threshold;
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
     }).then(function() {
       // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
       // has notified it of available data. Make sure that we get 'playing' before
       // we starting waiting for 'waiting'.
       info("Invoking play()");
-      var p = once(el, 'playing');
+      const p = once(el, "playing");
       el.play();
       return p;
     }).then(function() {
-      return once(el, 'waiting');
+      return once(el, "waiting");
     }).then(function() {
       // We're waiting for data after the start of the last frame.
       // 0.033333 is the duration of the last frame.
       ok(el.currentTime >= vchunks[1].end - 0.033333 + threshold - fuzz
          && el.currentTime <= vchunks[1].end + threshold + fuzz, "skipped the gap properly: " + el.currentTime + " " + (vchunks[1].end + threshold));
       is(el.buffered.length, 2, "buffered range has right length");
       // Now we test that seeking will succeed despite the gap.
       el.currentTime = el.buffered.end(0) + (threshold / 2);
-      return once(el, 'seeked');
+      return once(el, "seeked");
     }).then(function() {
       // Now we test that we don't pass the gap.
       // Clean up our sourcebuffer by removing all data.
       videosb.timestampOffset = 0;
       videosb.remove(0, Infinity);
       el.currentTime = 0;
       el.pause();
       return once(videosb, "updateend");
     }).then(function() {
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(1, 5), ".m4s");
     }).then(function() {
       // We will insert a gap of threshold + 1ms
-      videosb.timestampOffset = threshold + 1/1000;
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s');
+      videosb.timestampOffset = threshold + 1 / 1000;
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
     }).then(function() {
       info("Invoking play()");
-      var p = once(el, 'playing');
+      const p = once(el, "playing");
       el.play();
       return p;
     }).then(function() {
-      return once(el, 'waiting');
+      return once(el, "waiting");
     }).then(function() {
       // We're waiting for data after the start of the last frame.
       // 0.033333 is the duration of the last frame.
       ok(el.currentTime >= vchunks[0].end - 0.033333 - fuzz
          && el.currentTime <= vchunks[0].end + fuzz, "stopped at the gap properly: " + el.currentTime + " " + vchunks[0].end);
       SimpleTest.finish();
     });
   });
--- a/dom/media/mediasource/test/test_TimestampOffset_mp4.html
+++ b/dom/media/mediasource/test/test_TimestampOffset_mp4.html
@@ -8,79 +8,79 @@
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 function range(start, end) {
-  var rv = [];
-  for (var i = start; i < end; ++i) {
+  const rv = [];
+  for (let i = start; i < end; ++i) {
     rv.push(i);
   }
   return rv;
 }
 
-var eps = 0.01;
+const eps = 0.01;
 runWithMSE(function(ms, el) {
 
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const audiosb = ms.addSourceBuffer("audio/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     // We divide the video into 3 chunks:
     // chunk 0: segments 1-4
     // chunk 1: segments 5-8
     // chunk 2: segments 9-13
     // We then fill the timeline so that it seamlessly plays the chunks in order 0, 2, 1.
-    var vchunks = [ {start: 0, end: 3.2033}, { start: 3.2033, end: 6.4066}, { start: 6.4066, end: 10.01} ];
-    var firstvoffset = vchunks[2].end - vchunks[2].start; // Duration of chunk 2
-    var secondvoffset = -(vchunks[1].end - vchunks[1].start); // -(Duration of chunk 1)
+    const vchunks = [ {start: 0, end: 3.2033}, { start: 3.2033, end: 6.4066}, { start: 6.4066, end: 10.01} ];
+    const firstvoffset = vchunks[2].end - vchunks[2].start; // Duration of chunk 2
+    const secondvoffset = -(vchunks[1].end - vchunks[1].start); // -(Duration of chunk 1)
 
-    fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'))
+    fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"))
     .then(function() {
       is(videosb.buffered.length, 1, "No discontinuity");
       isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start");
       isfuzzy(videosb.buffered.end(0), vchunks[0].end, eps, "Chunk end");
       videosb.timestampOffset = firstvoffset;
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(5, 9), '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(5, 9), ".m4s");
     })
     .then(function(data) {
       is(videosb.buffered.length, 2, "One discontinuity");
       isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "First Chunk start");
       isfuzzy(videosb.buffered.end(0), vchunks[0].end, eps, "First chunk end");
-      isfuzzy(videosb.buffered.start(1),  vchunks[1].start + firstvoffset, eps, "Second chunk start");
+      isfuzzy(videosb.buffered.start(1), vchunks[1].start + firstvoffset, eps, "Second chunk start");
       isfuzzy(videosb.buffered.end(1), vchunks[1].end + firstvoffset, eps, "Second chunk end");
       videosb.timestampOffset = secondvoffset;
-      return fetchAndLoad(videosb, 'bipbop/bipbop_video', range(9, 14), '.m4s');
+      return fetchAndLoad(videosb, "bipbop/bipbop_video", range(9, 14), ".m4s");
     })
     .then(function() {
       is(videosb.buffered.length, 1, "No discontinuity (end)");
       isfuzzy(videosb.buffered.start(0), vchunks[0].start, eps, "Chunk start");
       isfuzzy(videosb.buffered.end(0), vchunks[2].end, eps, "Chunk end");
       audiosb.timestampOffset = 3;
-    }).then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4'))
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 12), '.m4s'))
+    }).then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4"))
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 12), ".m4s"))
     .then(function() {
       is(audiosb.buffered.length, 1, "No audio discontinuity");
       isfuzzy(audiosb.buffered.start(0), 3, eps, "Audio starts at 3");
 
       // Trim the rest of the audio.
       audiosb.remove(videosb.buffered.end(0), Infinity);
       videosb.remove(videosb.buffered.end(0), Infinity);
-      return Promise.all([audiosb.updating ? once(audiosb, 'updateend') : Promise.resolve(),
-                          videosb.updating ? once(videosb, 'updateend') : Promise.resolve()]);
+      return Promise.all([ audiosb.updating ? once(audiosb, "updateend") : Promise.resolve(),
+        videosb.updating ? once(videosb, "updateend") : Promise.resolve() ]);
     }).then(function() {
       info("waiting for play to complete");
       el.play();
       el.currentTime = el.buffered.start(0);
       ms.endOfStream();
-      Promise.all([once(el, 'ended'), once(el, 'seeked')]).then(SimpleTest.finish.bind(SimpleTest));
+      Promise.all([ once(el, "ended"), once(el, "seeked") ]).then(SimpleTest.finish.bind(SimpleTest));
     });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/mediasource/test/test_TruncatedDuration.html
+++ b/dom/media/mediasource/test/test_TruncatedDuration.html
@@ -20,48 +20,48 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function round(n) {
   return Math.round(n * 1000) / 1000;
 }
 
 function do_seeking(e) {
-  var v = e.target;
+  const v = e.target;
   v.removeEventListener("seeking", do_seeking);
   SimpleTest.finish();
 }
 
 function do_seeked(e) {
-  var v = e.target;
+  const v = e.target;
   v.removeEventListener("seeked", do_seeked);
-  var duration = round(v.duration / 3);
+  const duration = round(v.duration / 3);
   is(v._sb.updating, false, "sourcebuffer isn't updating");
   v._sb.remove(duration, Infinity);
   once(v._sb, "updateend", function() {
-    v._ms.duration = duration
+    v._ms.duration = duration;
     // frames aren't truncated, so duration may be slightly more.
-    isfuzzy(v.duration, duration, 1/30, "element duration was updated");
+    isfuzzy(v.duration, duration, 1 / 30, "element duration was updated");
     v._sb.abort(); // this shouldn't abort updating the duration (bug 1130826).
     ok(v.seeking, "seeking is true");
     // test playback position was updated (bug 1130839).
     is(v.currentTime, v.duration, "current time was updated");
     is(v._sb.buffered.length, 1, "One buffered range");
     // Truncated mediasource duration will cause the video element to seek.
     v.addEventListener("seeking", do_seeking);
   });
 }
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
     v._sb = sb;
     v._ms = ms;
 
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
+    fetchWithXHR("seek.webm", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       once(sb, "updateend", function() {
         v.currentTime = v.duration / 2;
         is(v.currentTime, v.duration / 2, "current time was updated");
         ok(v.seeking, "seeking is true");
         v.addEventListener("seeked", do_seeked);
       });
     });
--- a/dom/media/mediasource/test/test_TruncatedDuration_mp4.html
+++ b/dom/media/mediasource/test/test_TruncatedDuration_mp4.html
@@ -19,48 +19,48 @@
 
 SimpleTest.waitForExplicitFinish();
 
 function round(n) {
   return Math.round(n * 1000) / 1000;
 }
 
 function do_seeking(e) {
-  var v = e.target;
+  const v = e.target;
   v.removeEventListener("seeking", do_seeking);
   SimpleTest.finish();
 }
 
 function do_seeked(e) {
-  var v = e.target;
+  const v = e.target;
   v.removeEventListener("seeked", do_seeked);
-  var duration = round(v.duration / 3);
+  const duration = round(v.duration / 3);
   is(v._sb.updating, false, "sourcebuffer isn't updating");
   v._sb.remove(duration, Infinity);
   once(v._sb, "updateend", function() {
-    v._ms.duration = duration
+    v._ms.duration = duration;
     // frames aren't truncated, so duration may be slightly more.
-    isfuzzy(v.duration, duration, 1/30, "element duration was updated");
+    isfuzzy(v.duration, duration, 1 / 30, "element duration was updated");
     v._sb.abort(); // this shouldn't abort updating the duration (bug 1130826).
     ok(v.seeking, "seeking is true");
     // test playback position was updated (bug 1130839).
     is(v.currentTime, v.duration, "current time was updated");
     is(v._sb.buffered.length, 1, "One buffered range");
     // Truncated mediasource duration will cause the video element to seek.
     v.addEventListener("seeking", do_seeking);
   });
 }
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/mp4");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/mp4");
     v._sb = sb;
     v._ms = ms;
 
-    fetchWithXHR("bipbop/bipbop2s.mp4", function (arrayBuffer) {
+    fetchWithXHR("bipbop/bipbop2s.mp4", function(arrayBuffer) {
       sb.appendBuffer(new Uint8Array(arrayBuffer));
       once(sb, "updateend", function() {
         // mp4 metadata states 10s when we only have 1.6s worth of video.
         sb.remove(sb.buffered.end(0), Infinity);
         once(sb, "updateend", function() {
           ms.duration = sb.buffered.end(0);
           is(v.duration, ms.duration, "current time updated with mediasource duration");
           v.currentTime = v.duration / 2;
--- a/dom/media/mediasource/test/test_WaitingOnMissingData.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingData.html
@@ -7,49 +7,49 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var sb = ms.addSourceBuffer("video/webm");
+    const sb = ms.addSourceBuffer("video/webm");
     fetchWithXHR("seek.webm", function(arrayBuffer) {
-      sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
+      sb.addEventListener("error", (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
       loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))()
-      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25223-318)))
-      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25223, 46712-25223)))
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25223 - 318)))
+      .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25223, 46712 - 25223)))
       /* Note - Missing |46712, 67833 - 46712| segment here */
       .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833)))
       .then(loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966)))
       .then(function() {
         // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
         // has notified it of available data. Make sure that we get 'playing' before
         // we starting waiting for 'waiting'.
         info("Invoking play()");
-        var p = once(el, 'playing');
+        const p = once(el, "playing");
         el.play();
         return p;
       }).then(function() {
         ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
-        var p = once(el, 'waiting');
+        const p = once(el, "waiting");
         el.play();
         return p;
       }).then(function() {
         // currentTime is based on the current video frame, so if the audio ends just before
         // the next video frame, currentTime can be up to 1 frame's worth earlier than
         // min(audioEnd, videoEnd).
         // 0.0465 is the length of the last audio frame.
         ok(el.currentTime >= (sb.buffered.end(0) - 0.0465),
            "Got a waiting event at " + el.currentTime);
         info("Loading more data");
-        var p = once(el, 'ended');
+        const p = once(el, "ended");
         loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712)).then(() => ms.endOfStream());
         return p;
       }).then(function() {
         // These fuzz factors are bigger than they should be. We should investigate
         // and fix them in bug 1137574.
         isfuzzy(el.duration, 4.001, 0.1, "Video has correct duration: " + el.duration);
         isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
         SimpleTest.finish();
--- a/dom/media/mediasource/test/test_WaitingOnMissingDataEnded_mp4.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingDataEnded_mp4.html
@@ -8,40 +8,40 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    el.addEventListener("ended", function () {
+    el.addEventListener("ended", function() {
       ok(false, "ended should never fire");
       SimpleTest.finish();
     });
-    var videosb = ms.addSourceBuffer("video/mp4");
-    fetchAndLoad(videosb, 'bipbop/bipbop_video', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 5), '.m4s'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(6, 8), '.m4s'))
+    const videosb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 5), ".m4s"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(6, 8), ".m4s"))
     .then(function() {
       is(el.buffered.length, 2, "discontinuous buffered range");
       ms.endOfStream();
-      return Promise.all([once(el, "durationchange"), once(ms, "sourceended")]);
+      return Promise.all([ once(el, "durationchange"), once(ms, "sourceended") ]);
     }).then(function() {
       // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
       // has notified it of available data. Make sure that we get 'playing' before
       // we starting waiting for 'waiting'.
       info("Invoking play()");
       el.play();
-      return once(el, 'playing');
+      return once(el, "playing");
     }).then(function() {
       ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
-      return once(el, 'waiting');
+      return once(el, "waiting");
     }).then(function() {
       // waiting is fired when we start to play the last frame.
       // 0.033334 is the duration of the last frame, + 0.000001 of fuzz.
       // the next video frame, currentTime can be up to 1 frame's worth earlier than end of video.
       isfuzzy(el.currentTime, videosb.buffered.end(0), 0.033334, "waiting was fired on gap");
       SimpleTest.finish();
     });
   });
--- a/dom/media/mediasource/test/test_WaitingOnMissingData_mp4.html
+++ b/dom/media/mediasource/test/test_WaitingOnMissingData_mp4.html
@@ -8,50 +8,50 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
-    var videosb = ms.addSourceBuffer("video/mp4");
-    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(6, 12), '.m4s'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(7, 14), '.m4s'))
+    const audiosb = ms.addSourceBuffer("audio/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
+    fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"))
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(6, 12), ".m4s"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(7, 14), ".m4s"))
     .then(function() {
       // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
       // has notified it of available data. Make sure that we get 'playing' before
       // we starting waiting for 'waiting'.
       info("Invoking play()");
-      var p = once(el, 'playing');
+      const p = once(el, "playing");
       el.play();
       return p;
     }).then(function() {
       ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
-      var p = once(el, 'waiting');
+      const p = once(el, "waiting");
       el.play();
       return p;
     }).then(function() {
       // currentTime is based on the current video frame, so if the audio ends just before
       // the next video frame, currentTime can be up to 1 frame's worth earlier than
       // min(audioEnd, videoEnd).
       // 0.0465 is the length of the last audio frame.
       ok(el.currentTime >= (Math.min(audiosb.buffered.end(0), videosb.buffered.end(0)) - 0.0465),
-         "Got a waiting event at " + el.currentTime);
+          "Got a waiting event at " + el.currentTime);
       info("Loading more data");
-      var p = once(el, 'ended');
-      var loads = Promise.all([fetchAndLoad(audiosb, 'bipbop/bipbop_audio', [5], '.m4s'),
-                               fetchAndLoad(videosb, 'bipbop/bipbop_video', [6], '.m4s')]);
+      const p = once(el, "ended");
+      const loads = Promise.all([ fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ 5 ], ".m4s"),
+        fetchAndLoad(videosb, "bipbop/bipbop_video", [ 6 ], ".m4s") ]);
       loads.then(() => ms.endOfStream());
       return p;
     }).then(function() {
       // These fuzz factors are bigger than they should be. We should investigate
       // and fix them in bug 1137574.
       isfuzzy(el.duration, 10.1, 0.1, "Video has correct duration: " + el.duration);
       isfuzzy(el.currentTime, el.duration, 0.1, "Video has correct currentTime.");
       SimpleTest.finish();
--- a/dom/media/mediasource/test/test_WaitingToEndedTransition_mp4.html
+++ b/dom/media/mediasource/test/test_WaitingToEndedTransition_mp4.html
@@ -8,43 +8,43 @@
 </head>
 <body>
 <pre id="test"><script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 runWithMSE(function(ms, el) {
   el.controls = true;
-  once(ms, 'sourceopen').then(function() {
+  once(ms, "sourceopen").then(function() {
     ok(true, "Receive a sourceopen event");
-    var audiosb = ms.addSourceBuffer("audio/mp4");
-    var videosb = ms.addSourceBuffer("video/mp4");
+    const audiosb = ms.addSourceBuffer("audio/mp4");
+    const videosb = ms.addSourceBuffer("video/mp4");
     // ensure tracks end at approximately the same time to ensure ended event is
     // always fired (bug 1233639).
     audiosb.appendWindowEnd = 3.9;
     videosb.appendWindowEnd = 3.9;
-    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
-    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
-    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
+    fetchAndLoad(audiosb, "bipbop/bipbop_audio", [ "init" ], ".mp4")
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", [ "init" ], ".mp4"))
+    .then(fetchAndLoad.bind(null, audiosb, "bipbop/bipbop_audio", range(1, 5), ".m4s"))
+    .then(fetchAndLoad.bind(null, videosb, "bipbop/bipbop_video", range(1, 6), ".m4s"))
     .then(function() {
       // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
       // has notified it of available data. Make sure that we get 'playing' before
       // we starting waiting for 'waiting'.
       info("Invoking play()");
-      var p = once(el, 'playing');
+      const p = once(el, "playing");
       el.play();
       return p;
     }).then(function() {
       ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
-      var p = once(el, 'waiting');
+      const p = once(el, "waiting");
       el.play();
       return p;
     }).then(function() {
-      var p = once(el, 'ended');
+      const p = once(el, "ended");
       ms.endOfStream();
       return p;
     }).then(function() {
       is(el.duration, 3.854512, "Video has correct duration: " + el.duration);
       is(el.currentTime, el.duration, "Video has correct currentTime.");
       SimpleTest.finish();
     });
   });
--- a/dom/media/mediasource/test/test_WebMTagsBeforeCluster.html
+++ b/dom/media/mediasource/test/test_WebMTagsBeforeCluster.html
@@ -7,23 +7,23 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-addMSEPrefs(["media.mediasource.webm.enabled", true]);
+addMSEPrefs([ "media.mediasource.webm.enabled", true ]);
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
+runWithMSE(function(ms, v) {
+  ms.addEventListener("sourceopen", function() {
+    const sb = ms.addSourceBuffer("video/webm");
 
-    fetchWithXHR("tags_before_cluster.webm", async function (arrayBuffer) {
+    fetchWithXHR("tags_before_cluster.webm", async function(arrayBuffer) {
       info("- append buffer -");
       sb.appendBuffer(new Uint8Array(arrayBuffer));
 
       info("- wait for metadata -");
       await once(v, "loadedmetadata");
 
       info("- wait for updateend -");
       await once(sb, "updateend");
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1687,16 +1687,17 @@ dnl =
 dnl = Maintainer debug option (no --enable equivalent)
 dnl =
 dnl ========================================================
 
 AC_SUBST(AR)
 AC_SUBST(AR_FLAGS)
 AC_SUBST(AR_EXTRACT)
 AC_SUBST(AS)
+AC_SUBST(NM)
 AC_SUBST_LIST(ASFLAGS)
 AC_SUBST(AS_DASH_C_FLAG)
 AC_SUBST(RC)
 AC_SUBST(RCFLAGS)
 AC_SUBST(WINDRES)
 AC_SUBST(IMPLIB)
 AC_SUBST(FILTER)
 AC_SUBST_LIST(MOZ_DEBUG_LDFLAGS)
--- a/layout/style/test/file_shape_outside_CORS.html
+++ b/layout/style/test/file_shape_outside_CORS.html
@@ -23,26 +23,23 @@
   display: inline-block;
 }
 </style>
 
 <script>
 const DOMAIN = "http://mochi.test:8888";
 
 function sendResults() {
-  // Disable this first part until Bug 1454694.
-  /*
   let divAllow = document.getElementById("allow");
   let divAllowSib = divAllow.nextElementSibling;
   window.parent.postMessage({
     "result": (divAllowSib.getBoundingClientRect().left == divAllow.getBoundingClientRect().left),
     "message": "Test 1: Sibling should be at same left offset as div (shape-outside should be allowed), and onload should only fire after layout is complete.",
     },
     DOMAIN);
-  */
 
   let divRefuse = document.getElementById("refuse");
   let divRefuseSib = divRefuse.nextElementSibling;
   window.parent.postMessage({
     "result": (divRefuseSib.getBoundingClientRect().left != divRefuse.getBoundingClientRect().left),
     "message": "Test 2: Sibling should be at different left offset from div (shape-outside should be refused).",
     },
     DOMAIN);
--- a/old-configure.in
+++ b/old-configure.in
@@ -4059,16 +4059,17 @@ dnl =
 dnl = Maintainer debug option (no --enable equivalent)
 dnl =
 dnl ========================================================
 
 AC_SUBST(AR)
 AC_SUBST(AR_FLAGS)
 AC_SUBST(AR_EXTRACT)
 AC_SUBST(AS)
+AC_SUBST(NM)
 AC_SUBST_LIST(ASFLAGS)
 AC_SUBST(AS_DASH_C_FLAG)
 AC_SUBST(RC)
 AC_SUBST(RCFLAGS)
 AC_SUBST(WINDRES)
 AC_SUBST(IMPLIB)
 AC_SUBST(FILTER)
 AC_SUBST(MOZ_AUTH_EXTENSION)
--- a/testing/geckodriver/src/marionette.rs
+++ b/testing/geckodriver/src/marionette.rs
@@ -49,17 +49,19 @@ use webdriver::common::{Date, ELEMENT_KE
 use webdriver::error::{ErrorStatus, WebDriverError, WebDriverResult};
 use webdriver::server::{WebDriverHandler, Session};
 use webdriver::httpapi::{WebDriverExtensionRoute};
 
 use capabilities::{FirefoxCapabilities, FirefoxOptions};
 use logging;
 use prefs;
 
-const DEFAULT_HOST: &'static str = "localhost";
+// Bind host to IPv4 only because Marionette only listens on that interface
+const DEFAULT_HOST: &'static str = "127.0.0.1";
+
 const CHROME_ELEMENT_KEY: &'static str = "chromeelement-9fc5-4b51-a3c8-01716eedeb04";
 const LEGACY_ELEMENT_KEY: &'static str = "ELEMENT";
 
 pub fn extension_routes() -> Vec<(Method, &'static str, GeckoExtensionRoute)> {
     return vec![(Method::Get, "/session/{sessionId}/moz/context", GeckoExtensionRoute::GetContext),
              (Method::Post, "/session/{sessionId}/moz/context", GeckoExtensionRoute::SetContext),
              (Method::Post,
               "/session/{sessionId}/moz/xbl/{elementId}/anonymous_children",
--- a/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription.html
+++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-setRemoteDescription.html
@@ -76,38 +76,36 @@
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     const pc2 = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
     t.add_cleanup(() => pc2.close());
 
     let eventCount = 0;
     const states = [
-      'stable', 'have-local-offer', 'stable', 'have-remote-offer', 'closed'
+      'stable', 'have-local-offer', 'stable', 'have-remote-offer',
     ];
-    pc.onsignalingstatechange = () =>
-        assert_equals(pc.signalingState, states[++eventCount]);
+    pc.onsignalingstatechange = t.step_func(() =>
+        assert_equals(pc.signalingState, states[++eventCount]));
 
     const assert_state = state => {
       assert_equals(state, pc.signalingState);
       assert_equals(state, states[eventCount]);
     };
 
     const offer = await pc.createOffer({ offerToReceiveAudio: true });
     assert_state('stable');
     await pc.setLocalDescription(offer);
     assert_state('have-local-offer');
     await pc2.setRemoteDescription(offer);
     await pc2.setLocalDescription(await pc2.createAnswer());
     await pc.setRemoteDescription(pc2.localDescription);
     assert_state('stable');
     await pc.setRemoteDescription(await pc2.createOffer());
     assert_state('have-remote-offer');
-    pc.close();
-    assert_state('closed');
   }, 'Negotiation should fire signalingsstate events');
 
   /* Operations after returning to stable state */
 
   promise_test(async t => {
     const pc = new RTCPeerConnection();
     const pc2 = new RTCPeerConnection();
     t.add_cleanup(() => pc.close());
--- a/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
+++ b/toolkit/components/aboutmemory/tests/test_memoryReporters.xul
@@ -152,16 +152,17 @@
     "heapOverheadFraction",
     "JSMainRuntimeGCHeap",
     "JSMainRuntimeTemporaryPeak",
     "JSMainRuntimeRealmsSystem",
     "JSMainRuntimeRealmsUser",
     "imagesContentUsedUncompressed",
     "storageSQLite",
     "lowMemoryEventsVirtual",
+    "lowMemoryEventsCommitSpace",
     "lowMemoryEventsPhysical",
     "ghostWindows",
     "pageFaultsHard",
   ];
   for (let i = 0; i < amounts.length; i++) {
     try {
       // If mgr[amounts[i]] throws an exception, just move on -- some amounts
       // aren't available on all platforms.  But if the attribute simply
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -1072,44 +1072,47 @@
     "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 1024,
     "n_buckets": 10,
     "description": "Time(ms) to purge dirty heap pages."
   },
   "LOW_MEMORY_EVENTS_VIRTUAL": {
-    "record_in_processes": ["main", "content"],
+    "record_in_processes": ["main"],
     "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 1024,
     "n_buckets": 21,
     "description": "Number of low-virtual-memory events fired since last ping",
-    "cpp_guard": "XP_WIN"
+    "cpp_guard": "XP_WIN",
+    "bug_numbers": [711490,1451005]
   },
   "LOW_MEMORY_EVENTS_PHYSICAL": {
-    "record_in_processes": ["main", "content"],
+    "record_in_processes": ["main"],
     "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 1024,
     "n_buckets": 21,
     "description": "Number of low-physical-memory events fired since last ping",
-    "cpp_guard": "XP_WIN"
+    "cpp_guard": "XP_WIN",
+    "bug_numbers": [711490,1451005]
   },
   "LOW_MEMORY_EVENTS_COMMIT_SPACE": {
-    "record_in_processes": ["main", "content"],
+    "record_in_processes": ["main"],
     "alert_emails": ["memshrink-telemetry-alerts@mozilla.com"],
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 1024,
     "n_buckets": 21,
     "description": "Number of low-commit-space events fired since last ping",
-    "cpp_guard": "XP_WIN"
+    "cpp_guard": "XP_WIN",
+    "bug_numbers": [1451005]
   },
   "PAGE_FAULTS_HARD": {
     "record_in_processes": ["main", "content"],
     "expires_in_version": "default",
     "kind": "exponential",
     "low": 8,
     "high": 65536,
     "n_buckets": 13,
--- a/toolkit/components/telemetry/TelemetrySession.jsm
+++ b/toolkit/components/telemetry/TelemetrySession.jsm
@@ -1089,16 +1089,17 @@ var Impl = {
     b("MEMORY_UNIQUE", "residentUnique");
     p("MEMORY_HEAP_OVERHEAD_FRACTION", "heapOverheadFraction");
     b("MEMORY_JS_GC_HEAP", "JSMainRuntimeGCHeap");
     c("MEMORY_JS_COMPARTMENTS_SYSTEM", "JSMainRuntimeRealmsSystem");
     c("MEMORY_JS_COMPARTMENTS_USER", "JSMainRuntimeRealmsUser");
     b("MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED", "imagesContentUsedUncompressed");
     b("MEMORY_STORAGE_SQLITE", "storageSQLite");
     cc("LOW_MEMORY_EVENTS_VIRTUAL", "lowMemoryEventsVirtual");
+    cc("LOW_MEMORY_EVENTS_COMMIT_SPACE", "lowMemoryEventsCommitSpace");
     cc("LOW_MEMORY_EVENTS_PHYSICAL", "lowMemoryEventsPhysical");
     cc("PAGE_FAULTS_HARD", "pageFaultsHard");
 
     try {
       mgr.getHeapAllocatedAsync(heapAllocated => {
         boundHandleMemoryReport("MEMORY_HEAP_ALLOCATED",
                                 Ci.nsIMemoryReporter.UNITS_BYTES,
                                 heapAllocated);
--- a/toolkit/components/telemetry/histogram-whitelists.json
+++ b/toolkit/components/telemetry/histogram-whitelists.json
@@ -838,19 +838,16 @@
     "LOCALDOMSTORAGE_GETVALUE_BLOCKING_MS",
     "LOCALDOMSTORAGE_PRELOAD_PENDING_ON_FIRST_ACCESS",
     "LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS",
     "LOCALDOMSTORAGE_SESSIONONLY_PRELOAD_BLOCKING_MS",
     "LOCALDOMSTORAGE_SETVALUE_BLOCKING_MS",
     "LOCALDOMSTORAGE_SHUTDOWN_DATABASE_MS",
     "LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS",
     "LONG_REFLOW_INTERRUPTIBLE",
-    "LOW_MEMORY_EVENTS_COMMIT_SPACE",
-    "LOW_MEMORY_EVENTS_PHYSICAL",
-    "LOW_MEMORY_EVENTS_VIRTUAL",
     "MAC_INITFONTLIST_TOTAL",
     "MASTER_PASSWORD_ENABLED",
     "MEDIA_CODEC_USED",
     "MEDIA_WMF_DECODE_ERROR",
     "MEMORY_FREE_PURGED_PAGES_MS",
     "MEMORY_HEAP_ALLOCATED",
     "MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED",
     "MEMORY_JS_COMPARTMENTS_SYSTEM",
--- a/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
+++ b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp
@@ -4,13 +4,18 @@
  * on Windows. Somehow, placing the object last is not enough with PGO/LTCG. */
 #ifdef _MSC_VER
 /* Sections on Windows are in two parts, separated with $. When linking,
  * sections with the same first part are all grouped, and ordered
  * alphabetically with the second part as sort key. */
 #  pragma section(".kPStaticModules$Z", read)
 #  undef NSMODULE_SECTION
 #  define NSMODULE_SECTION __declspec(allocate(".kPStaticModules$Z"), dllexport)
+#elif MOZ_LTO
+/* Clang+lld with LTO does not order modules correctly either, but fortunately
+ * the same trick works. */
+#  undef NSMODULE_SECTION
+#  define NSMODULE_SECTION __attribute__((section(".kPStaticModules$Z"), visibility("default")))
 #endif
 /* This could be null, but this needs a dummy value to ensure it actually ends
  * up in the same section as other NSMODULE_DEFNs, instead of being moved to a
  * separate readonly section. */
 NSMODULE_DEFN(end_kPStaticModules) = (mozilla::Module*)&NSMODULE_NAME(end_kPStaticModules);
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -540,16 +540,17 @@ public:
 
   virtual void SetPluginFocused(bool& aFocused) override;
 
   bool IsPluginFocused() { return mPluginFocused; }
 
   virtual LayoutDeviceIntPoint GetClientOffset() override;
 
   void DispatchAPZWheelInputEvent(mozilla::InputData& aEvent, bool aCanTriggerSwipe);
+  nsEventStatus DispatchAPZInputEvent(mozilla::InputData& aEvent);
 
   void SwipeFinished();
 
 protected:
   virtual ~nsChildView();
 
   void              ReportMoveEvent();
   void              ReportSizeEvent();
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2900,16 +2900,27 @@ nsChildView::ReportSwipeStarted(uint64_t
       for (size_t i = 1; i < mSwipeEventQueue->queuedEvents.Length(); i++) {
         mSwipeTracker->ProcessEvent(mSwipeEventQueue->queuedEvents[i]);
       }
     }
     mSwipeEventQueue = nullptr;
   }
 }
 
+nsEventStatus
+nsChildView::DispatchAPZInputEvent(InputData& aEvent)
+{
+  if (mAPZC) {
+    uint64_t inputBlockId = 0;
+    ScrollableLayerGuid guid;
+    return mAPZC->InputBridge()->ReceiveInputEvent(aEvent, &guid, &inputBlockId);
+  }
+  return nsEventStatus_eIgnore;
+}
+
 void
 nsChildView::DispatchAPZWheelInputEvent(InputData& aEvent, bool aCanTriggerSwipe)
 {
   if (mSwipeTracker && aEvent.mInputType == PANGESTURE_INPUT) {
     // Give the swipe tracker a first pass at the event. If a new pan gesture
     // has been started since the beginning of the swipe, the swipe tracker
     // will know to ignore the event.
     nsEventStatus status = mSwipeTracker->ProcessEvent(aEvent.AsPanGestureInput());
@@ -4174,76 +4185,127 @@ NSEvent* gLastDragMouseDownEvent = nil;
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 // Pinch zoom gesture.
 - (void)magnifyWithEvent:(NSEvent *)anEvent
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  if (!anEvent || !mGeckoChild ||
-      [self beginOrEndGestureForEventPhase:anEvent]) {
-    return;
-  }
-
-  nsAutoRetainCocoaObject kungFuDeathGrip(self);
-
-  float deltaZ = [anEvent deltaZ];
-
-  EventMessage msg;
-  switch (mGestureState) {
-  case eGestureState_StartGesture:
-    msg = eMagnifyGestureStart;
-    mGestureState = eGestureState_MagnifyGesture;
-    break;
-
-  case eGestureState_MagnifyGesture:
-    msg = eMagnifyGestureUpdate;
-    break;
-
-  case eGestureState_None:
-  case eGestureState_RotateGesture:
-  default:
+  if (!mGeckoChild) {
     return;
   }
 
-  // This sends the pinch gesture value as a fake wheel event that has the
-  // control key pressed so that pages can implement custom pinch gesture
-  // handling. It may seem strange that this doesn't use a wheel event with
-  // the deltaZ property set, but this matches Chrome's behavior as described
-  // at https://code.google.com/p/chromium/issues/detail?id=289887
-  //
-  // The intent of the formula below is to produce numbers similar to Chrome's
-  // implementation of this feature. Chrome implements deltaY using the formula
-  // "-100 * log(1 + [event magnification])" which is unfortunately incorrect.
-  // All deltas for a single pinch gesture should sum to 0 if the start and end
-  // of a pinch gesture end up in the same place. This doesn't happen in Chrome
-  // because they followed Apple's misleading documentation, which implies that
-  // "1 + [event magnification]" is the scale factor. The scale factor is
-  // instead "pow(ratio, [event magnification])" so "[event magnification]" is
-  // already in log space.
-  //
-  // The multiplication by the backing scale factor below counteracts the
-  // division by the backing scale factor in WheelEvent.
-  WidgetWheelEvent geckoWheelEvent(true, EventMessage::eWheel, mGeckoChild);
-  [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoWheelEvent];
-  double backingScale = mGeckoChild->BackingScaleFactor();
-  geckoWheelEvent.mDeltaY = -100.0 * [anEvent magnification] * backingScale;
-  geckoWheelEvent.mModifiers |= MODIFIER_CONTROL;
-  mGeckoChild->DispatchWindowEvent(geckoWheelEvent);
-
-  // If the fake wheel event wasn't stopped, then send a normal magnify event.
-  if (!geckoWheelEvent.mFlags.mDefaultPrevented) {
-    WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild);
-    geckoEvent.mDelta = deltaZ;
-    [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
-    mGeckoChild->DispatchWindowEvent(geckoEvent);
-
-    // Keep track of the cumulative magnification for the final "magnify" event.
-    mCumulativeMagnification += deltaZ;
+  if (gfxPrefs::APZAllowZooming()) {
+    NSPoint locationInWindow = nsCocoaUtils::EventLocationForWindow(anEvent, [self window]);
+    ScreenPoint position = ViewAs<ScreenPixel>(
+      [self convertWindowCoordinatesRoundDown:locationInWindow],
+      PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent);
+
+    PRIntervalTime eventIntervalTime = PR_IntervalNow();
+    TimeStamp eventTimeStamp = nsCocoaUtils::GetEventTimeStamp([anEvent timestamp]);
+    NSEventPhase eventPhase = [anEvent phase];
+    PinchGestureInput::PinchGestureType pinchGestureType;
+
+    switch (eventPhase) {
+      case NSEventPhaseBegan: {
+        pinchGestureType = PinchGestureInput::PINCHGESTURE_START;
+        break;
+      }
+      case NSEventPhaseChanged: {
+        pinchGestureType = PinchGestureInput::PINCHGESTURE_SCALE;
+        break;
+      }
+      case NSEventPhaseEnded: {
+        pinchGestureType = PinchGestureInput::PINCHGESTURE_END;
+        break;
+      }
+      default: {
+        NS_WARNING("Unexpected phase for pinch gesture event.");
+        return;
+      }
+    }
+
+    PinchGestureInput event{pinchGestureType,
+                            eventIntervalTime,
+                            eventTimeStamp,
+                            position,
+                            100.0,
+                            100.0 * (1.0 - [anEvent magnification]),
+                            nsCocoaUtils::ModifiersForEvent(anEvent)};
+
+    if (pinchGestureType == PinchGestureInput::PINCHGESTURE_END) {
+      event.mFocusPoint = PinchGestureInput::BothFingersLifted<ScreenPixel>();
+    }
+
+    mGeckoChild->DispatchAPZInputEvent(event);
+  } else {
+
+    if (!anEvent ||
+        [self beginOrEndGestureForEventPhase:anEvent]) {
+      return;
+    }
+
+    nsAutoRetainCocoaObject kungFuDeathGrip(self);
+
+    float deltaZ = [anEvent deltaZ];
+
+    EventMessage msg;
+    switch (mGestureState) {
+    case eGestureState_StartGesture:
+      msg = eMagnifyGestureStart;
+      mGestureState = eGestureState_MagnifyGesture;
+      break;
+
+    case eGestureState_MagnifyGesture:
+      msg = eMagnifyGestureUpdate;
+      break;
+
+    case eGestureState_None:
+    case eGestureState_RotateGesture:
+    default:
+      return;
+    }
+
+    // This sends the pinch gesture value as a fake wheel event that has the
+    // control key pressed so that pages can implement custom pinch gesture
+    // handling. It may seem strange that this doesn't use a wheel event with
+    // the deltaZ property set, but this matches Chrome's behavior as described
+    // at https://code.google.com/p/chromium/issues/detail?id=289887
+    //
+    // The intent of the formula below is to produce numbers similar to Chrome's
+    // implementation of this feature. Chrome implements deltaY using the formula
+    // "-100 * log(1 + [event magnification])" which is unfortunately incorrect.
+    // All deltas for a single pinch gesture should sum to 0 if the start and end
+    // of a pinch gesture end up in the same place. This doesn't happen in Chrome
+    // because they followed Apple's misleading documentation, which implies that
+    // "1 + [event magnification]" is the scale factor. The scale factor is
+    // instead "pow(ratio, [event magnification])" so "[event magnification]" is
+    // already in log space.
+    //
+    // The multiplication by the backing scale factor below counteracts the
+    // division by the backing scale factor in WheelEvent.
+    WidgetWheelEvent geckoWheelEvent(true, EventMessage::eWheel, mGeckoChild);
+    [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoWheelEvent];
+    double backingScale = mGeckoChild->BackingScaleFactor();
+    geckoWheelEvent.mDeltaY = -100.0 * [anEvent magnification] * backingScale;
+    geckoWheelEvent.mModifiers |= MODIFIER_CONTROL;
+    mGeckoChild->DispatchWindowEvent(geckoWheelEvent);
+
+    // If the fake wheel event wasn't stopped, then send a normal magnify event.
+    if (!geckoWheelEvent.mFlags.mDefaultPrevented) {
+      WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild);
+      geckoEvent.mDelta = deltaZ;
+      [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
+      mGeckoChild->DispatchWindowEvent(geckoEvent);
+
+      // Keep track of the cumulative magnification for the final "magnify" event.
+      mCumulativeMagnification += deltaZ;
+    }
+
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 // Smart zoom gesture, i.e. two-finger double tap on trackpads.
 - (void)smartMagnifyWithEvent:(NSEvent *)anEvent
 {
--- a/widget/gtk/gtk3drawing.cpp
+++ b/widget/gtk/gtk3drawing.cpp
@@ -883,26 +883,24 @@ moz_gtk_scrollbar_button_paint(cairo_t *
       // box occupies the full width of the "contents" gadget content box.
       InsetByMargin(&rect, style);
     } else {
         // Scrollbar button has to be inset by trough_border because its DOM
         // element is filling width of vertical scrollbar's track (or height
         // in case of horizontal scrollbars).
         GtkOrientation orientation = flags & MOZ_GTK_STEPPER_VERTICAL ?
             GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
-        const auto& metrics = sScrollbarMetrics[orientation];
-        if (!metrics.initialized) {
-            NS_WARNING("Didn't measure before drawing?");
-        }
+
+        const ScrollbarGTKMetrics* metrics = GetScrollbarMetrics(orientation);
         if (flags & MOZ_GTK_STEPPER_VERTICAL) {
-            rect.x += metrics.border.track.left;
-            rect.width = metrics.size.thumb.width;
+            rect.x += metrics->border.track.left;
+            rect.width = metrics->size.thumb.width;
         } else {
-            rect.y += metrics.border.track.top;
-            rect.height = metrics.size.thumb.height;
+            rect.y += metrics->border.track.top;
+            rect.height = metrics->size.thumb.height;
         }
     }
 
     gtk_render_background(style, cr, rect.x, rect.y, rect.width, rect.height);
     gtk_render_frame(style, cr, rect.x, rect.y, rect.width, rect.height);
 
     arrow_rect.width = rect.width / 2;
     arrow_rect.height = rect.height / 2;
--- a/xpcom/base/AvailableMemoryTracker.cpp
+++ b/xpcom/base/AvailableMemoryTracker.cpp
@@ -12,39 +12,46 @@
 #include "nsIMemoryReporter.h"
 #include "nsMemoryPressure.h"
 #endif
 
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsIRunnable.h"
 #include "nsISupports.h"
+#include "nsITimer.h"
 #include "nsThreadUtils.h"
+#include "nsXULAppAPI.h"
 
-#include "mozilla/Preferences.h"
+#include "mozilla/ResultExtensions.h"
 #include "mozilla/Services.h"
+#include "mozilla/Unused.h"
 
 #if defined(XP_WIN)
 #   include "nsWindowsDllInterceptor.h"
 #   include <windows.h>
 #endif
 
 #if defined(MOZ_MEMORY)
 #   include "mozmemory.h"
 #endif  // MOZ_MEMORY
 
 using namespace mozilla;
 
 namespace {
 
-#if defined(_M_IX86) && defined(XP_WIN)
+#if defined(XP_WIN)
 
 // Fire a low-memory notification if we have less than this many bytes of
 // virtual address space available.
+#if defined(HAVE_64BIT_BUILD)
+static const size_t kLowVirtualMemoryThreshold = 0;
+#else
 static const size_t kLowVirtualMemoryThreshold = 256 * 1024 * 1024;
+#endif
 
 // Fire a low-memory notification if we have less than this many bytes of commit
 // space (physical memory plus page file) left.
 static const size_t kLowCommitSpaceThreshold = 256 * 1024 * 1024;
 
 // Fire a low-memory notification if we have less than this many bytes of
 // physical memory available on the whole machine.
 static const size_t kLowPhysicalMemoryThreshold = 0;
@@ -52,16 +59,18 @@ static const size_t kLowPhysicalMemoryTh
 // Don't fire a low-memory notification because of low available physical
 // memory or low commit space more often than this interval.
 static const uint32_t kLowMemoryNotificationIntervalMS = 10000;
 
 Atomic<uint32_t, MemoryOrdering::Relaxed> sNumLowVirtualMemEvents;
 Atomic<uint32_t, MemoryOrdering::Relaxed> sNumLowCommitSpaceEvents;
 Atomic<uint32_t, MemoryOrdering::Relaxed> sNumLowPhysicalMemEvents;
 
+#if !defined(HAVE_64BIT_BUILD)
+
 WindowsDllInterceptor sKernel32Intercept;
 WindowsDllInterceptor sGdi32Intercept;
 
 // Has Init() been called?
 bool sInitialized = false;
 
 // Has Activate() been called?  The hooks don't do anything until this happens.
 bool sHooksActive = false;
@@ -248,23 +257,212 @@ CreateDIBSectionHook(HDC aDC,
 
   if (doCheck) {
     CheckMemAvailable();
   }
 
   return result;
 }
 
+#else
+
+class nsAvailableMemoryWatcher final : public nsIObserver,
+                                       public nsITimerCallback
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIOBSERVER
+  NS_DECL_NSITIMERCALLBACK
+
+  nsresult Init();
+
+private:
+  // Poll the amount of free memory at this rate.
+  static const uint32_t kPollingIntervalMS = 1000;
+
+  // Observer topics we subscribe to
+  static const char* const kObserverTopics[];
+
+  static bool IsVirtualMemoryLow(const MEMORYSTATUSEX& aStat);
+  static bool IsCommitSpaceLow(const MEMORYSTATUSEX& aStat);
+  static bool IsPhysicalMemoryLow(const MEMORYSTATUSEX& aStat);
+
+  ~nsAvailableMemoryWatcher() {};
+  void AdjustPollingInterval(const bool aLowMemory);
+  void SendMemoryPressureEvent();
+  void Shutdown();
+
+  nsCOMPtr<nsITimer> mTimer;
+  bool mUnderMemoryPressure;
+};
+
+const char* const nsAvailableMemoryWatcher::kObserverTopics[] = {
+  "quit-application",
+  "user-interaction-active",
+  "user-interaction-inactive",
+};
+
+NS_IMPL_ISUPPORTS(nsAvailableMemoryWatcher, nsIObserver, nsITimerCallback)
+
+nsresult
+nsAvailableMemoryWatcher::Init()
+{
+  mTimer = NS_NewTimer();
+
+  nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
+  MOZ_ASSERT(observerService);
+
+  for (auto topic : kObserverTopics) {
+    nsresult rv = observerService->AddObserver(this, topic,
+                                               /* ownsWeak */ false);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  MOZ_TRY(mTimer->InitWithCallback(this, kPollingIntervalMS,
+                                   nsITimer::TYPE_REPEATING_SLACK));
+  return NS_OK;
+}
+
+void
+nsAvailableMemoryWatcher::Shutdown()
+{
+  nsCOMPtr<nsIObserverService> observerService = services::GetObserverService();
+  MOZ_ASSERT(observerService);
+
+  for (auto topic : kObserverTopics) {
+    Unused << observerService->RemoveObserver(this, topic);
+  }
+
+  if (mTimer) {
+    mTimer->Cancel();
+    mTimer = nullptr;
+  }
+}
+
+/* static */ bool
+nsAvailableMemoryWatcher::IsVirtualMemoryLow(const MEMORYSTATUSEX& aStat)
+{
+  if ((kLowVirtualMemoryThreshold != 0) &&
+      (aStat.ullAvailVirtual < kLowVirtualMemoryThreshold)) {
+    sNumLowVirtualMemEvents++;
+    return true;
+  }
+
+  return false;
+}
+
+/* static */ bool
+nsAvailableMemoryWatcher::IsCommitSpaceLow(const MEMORYSTATUSEX& aStat)
+{
+  if ((kLowCommitSpaceThreshold != 0) &&
+      (aStat.ullAvailPageFile < kLowCommitSpaceThreshold)) {
+    sNumLowCommitSpaceEvents++;
+    return true;
+  }
+
+  return false;
+}
+
+/* static */ bool
+nsAvailableMemoryWatcher::IsPhysicalMemoryLow(const MEMORYSTATUSEX& aStat)
+{
+  if ((kLowPhysicalMemoryThreshold != 0) &&
+      (aStat.ullAvailPhys < kLowPhysicalMemoryThreshold)) {
+    sNumLowPhysicalMemEvents++;
+    return true;
+  }
+
+  return false;
+}
+
+void
+nsAvailableMemoryWatcher::SendMemoryPressureEvent()
+{
+    MemoryPressureState state = mUnderMemoryPressure ? MemPressure_Ongoing
+                                                     : MemPressure_New;
+    NS_DispatchEventualMemoryPressure(state);
+}
+
+void
+nsAvailableMemoryWatcher::AdjustPollingInterval(const bool aLowMemory)
+{
+  if (aLowMemory) {
+    // We entered a low-memory state, wait for a longer interval before polling
+    // again as there's no point in rapidly sending further notifications.
+    mTimer->SetDelay(kLowMemoryNotificationIntervalMS);
+  } else if (mUnderMemoryPressure) {
+    // We were under memory pressure but we're not anymore, resume polling at
+    // a faster pace.
+    mTimer->SetDelay(kPollingIntervalMS);
+  }
+}
+
+// Timer callback, polls memory stats to detect low-memory conditions. This
+// will send memory-pressure events if memory is running low and adjust the
+// polling interval accordingly.
+NS_IMETHODIMP
+nsAvailableMemoryWatcher::Notify(nsITimer* aTimer)
+{
+  MEMORYSTATUSEX stat;
+  stat.dwLength = sizeof(stat);
+  bool success = GlobalMemoryStatusEx(&stat);
+
+  if (success) {
+    bool lowMemory =
+      IsVirtualMemoryLow(stat) ||
+      IsCommitSpaceLow(stat) ||
+      IsPhysicalMemoryLow(stat);
+
+    if (lowMemory) {
+      SendMemoryPressureEvent();
+    }
+
+    AdjustPollingInterval(lowMemory);
+    mUnderMemoryPressure = lowMemory;
+  }
+
+  return NS_OK;
+}
+
+// Observer service callback, used to stop the polling timer when the user
+// stops interacting with Firefox and resuming it when they interact again.
+// Also used to shut down the service if the application is quitting.
+NS_IMETHODIMP
+nsAvailableMemoryWatcher::Observe(nsISupports* aSubject, const char* aTopic,
+                                  const char16_t* aData)
+{
+  if (strcmp(aTopic, "quit-application") == 0) {
+    Shutdown();
+  } else if (strcmp(aTopic, "user-interaction-inactive") == 0) {
+    mTimer->Cancel();
+  } else if (strcmp(aTopic, "user-interaction-active") == 0) {
+    mTimer->InitWithCallback(this, kPollingIntervalMS,
+                             nsITimer::TYPE_REPEATING_SLACK);
+  } else {
+    MOZ_ASSERT_UNREACHABLE("Unknown topic");
+  }
+
+  return NS_OK;
+}
+
+#endif // !defined(HAVE_64BIT_BUILD)
+
 static int64_t
 LowMemoryEventsVirtualDistinguishedAmount()
 {
   return sNumLowVirtualMemEvents;
 }
 
 static int64_t
+LowMemoryEventsCommitSpaceDistinguishedAmount()
+{
+  return sNumLowCommitSpaceEvents;
+}
+
+static int64_t
 LowMemoryEventsPhysicalDistinguishedAmount()
 {
   return sNumLowPhysicalMemEvents;
 }
 
 class LowEventsReporter final : public nsIMemoryReporter
 {
   ~LowEventsReporter() {}
@@ -281,17 +479,17 @@ public:
 "Number of low-virtual-memory events fired since startup. We fire such an "
 "event if we notice there is less than memory.low_virtual_mem_threshold_mb of "
 "virtual address space available (if zero, this behavior is disabled). The "
 "process will probably crash if it runs out of virtual address space, so "
 "this event is dire.");
 
     MOZ_COLLECT_REPORT(
       "low-memory-events/commit-space", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
-      sNumLowCommitSpaceEvents,
+      LowMemoryEventsCommitSpaceDistinguishedAmount(),
 "Number of low-commit-space events fired since startup. We fire such an "
 "event if we notice there is less than memory.low_commit_space_threshold_mb of "
 "commit space available (if zero, this behavior is disabled). Windows will "
 "likely kill the process if it runs out of commit space, so this event is "
 "dire.");
 
     MOZ_COLLECT_REPORT(
       "low-memory-events/physical", KIND_OTHER, UNITS_COUNT_CUMULATIVE,
@@ -302,17 +500,17 @@ public:
 "machine will start to page if it runs out of physical memory.  This may "
 "cause it to run slowly, but it shouldn't cause it to crash.");
 
     return NS_OK;
   }
 };
 NS_IMPL_ISUPPORTS(LowEventsReporter, nsIMemoryReporter)
 
-#endif // defined(_M_IX86) && defined(XP_WIN)
+#endif // defined(XP_WIN)
 
 /**
  * This runnable is executed in response to a memory-pressure event; we spin
  * the event-loop when receiving the memory-pressure event in the hope that
  * other observers will synchronously free some memory that we'll be able to
  * purge here.
  */
 class nsJemallocFreeDirtyPagesRunnable final : public nsIRunnable
@@ -391,46 +589,56 @@ nsMemoryPressureWatcher::Observe(nsISupp
 } // namespace
 
 namespace mozilla {
 namespace AvailableMemoryTracker {
 
 void
 Activate()
 {
-#if defined(_M_IX86) && defined(XP_WIN)
+#if defined(XP_WIN) && !defined(HAVE_64BIT_BUILD)
   MOZ_ASSERT(sInitialized);
   MOZ_ASSERT(!sHooksActive);
 
   RegisterStrongMemoryReporter(new LowEventsReporter());
   RegisterLowMemoryEventsVirtualDistinguishedAmount(
     LowMemoryEventsVirtualDistinguishedAmount);
   RegisterLowMemoryEventsPhysicalDistinguishedAmount(
     LowMemoryEventsPhysicalDistinguishedAmount);
   sHooksActive = true;
-#endif
+#endif // defined(XP_WIN) && !defined(HAVE_64BIT_BUILD)
 
-  // This object is held alive by the observer service.
+  // The watchers are held alive by the observer service.
   RefPtr<nsMemoryPressureWatcher> watcher = new nsMemoryPressureWatcher();
   watcher->Init();
+
+#if defined(XP_WIN) && defined(HAVE_64BIT_BUILD)
+  if (XRE_IsParentProcess()) {
+    RefPtr<nsAvailableMemoryWatcher> poller = new nsAvailableMemoryWatcher();
+
+    if (NS_FAILED(poller->Init())) {
+      NS_WARNING("Could not start the available memory watcher");
+    }
+  }
+#endif // defined(XP_WIN) && defined(HAVE_64BIT_BUILD)
 }
 
 void
 Init()
 {
   // Do nothing on x86-64, because nsWindowsDllInterceptor is not thread-safe
   // on 64-bit.  (On 32-bit, it's probably thread-safe.)  Even if we run Init()
   // before any other of our threads are running, another process may have
   // started a remote thread which could call VirtualAlloc!
   //
   // Moreover, the benefit of this code is less clear when we're a 64-bit
   // process, because we aren't going to run out of virtual memory, and the
   // system is likely to have a fair bit of physical memory.
 
-#if defined(_M_IX86) && defined(XP_WIN)
+#if defined(XP_WIN) && !defined(HAVE_64BIT_BUILD)
   // Don't register the hooks if we're a build instrumented for PGO: If we're
   // an instrumented build, the compiler adds function calls all over the place
   // which may call VirtualAlloc; this makes it hard to prevent
   // VirtualAllocHook from reentering itself.
   if (!PR_GetEnv("MOZ_PGO_INSTRUMENTED")) {
     sKernel32Intercept.Init("Kernel32.dll");
     sKernel32Intercept.AddHook("VirtualAlloc",
                                reinterpret_cast<intptr_t>(VirtualAllocHook),
@@ -441,13 +649,13 @@ Init()
 
     sGdi32Intercept.Init("Gdi32.dll");
     sGdi32Intercept.AddHook("CreateDIBSection",
                             reinterpret_cast<intptr_t>(CreateDIBSectionHook),
                             reinterpret_cast<void**>(&sCreateDIBSectionOrig));
   }
 
   sInitialized = true;
-#endif
+#endif // defined(XP_WIN) && !defined(HAVE_64BIT_BUILD)
 }
 
 } // namespace AvailableMemoryTracker
 } // namespace mozilla
--- a/xpcom/base/nsIMemory.idl
+++ b/xpcom/base/nsIMemory.idl
@@ -27,20 +27,16 @@
  * observer is being asked to flush for low-memory conditions.
  *
  * "low-memory-ongoing"
  * This will be passed when we continue to be in a low-memory
  * condition and we want to flush caches and do other cheap
  * forms of memory minimization, but heavy handed approaches like
  * a GC are unlikely to succeed.
  *
- * "-no-forward"
- * This is appended to the above two parameters when the resulting
- * notification should not be forwarded to the child processes.
- *
  * "heap-minimize"
  * This will be passed as the extra data when the pressure 
  * observer is being asked to flush because of a heap minimize 
  * call.
  */
 
 [scriptable, uuid(1e004834-6d8f-425a-bc9c-a2812ed43bb7)]
 interface nsIMemory : nsISupports
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -365,19 +365,19 @@ interface nsIMemoryReporterManager : nsI
    * |JSMainRuntimeRealms{System,User}| (UNITS_COUNT)  The number of
    * {system,user} realms in the main JS runtime.
    *
    * |imagesContentUsedUncompressed| (UNITS_BYTES)  Memory used for decoded
    * raster images in content.
    *
    * |storageSQLite| (UNITS_BYTES)  Memory used by SQLite.
    *
-   * |lowMemoryEvents{Virtual,Physical}| (UNITS_COUNT_CUMULATIVE)  The number
-   * of low-{virtual,physical}-memory events that have occurred since the
-   * process started.
+   * |lowMemoryEvents{Virtual,CommitSpace,Physical}| (UNITS_COUNT_CUMULATIVE)
+   * The number of low-{virtual,commit-space,physical}-memory events that have
+   * occurred since the process started.
    *
    * |ghostWindows| (UNITS_COUNT)  A cached value of the number of ghost
    * windows. This should have been updated within the past 60s.
    *
    * |pageFaultsHard| (UNITS_COUNT_CUMULATIVE)  The number of hard (a.k.a.
    * major) page faults that have occurred since the process started.
    */
   [must_use] readonly attribute int64_t vsize;
@@ -395,16 +395,17 @@ interface nsIMemoryReporterManager : nsI
   [must_use] readonly attribute int64_t JSMainRuntimeRealmsSystem;
   [must_use] readonly attribute int64_t JSMainRuntimeRealmsUser;
 
   [must_use] readonly attribute int64_t imagesContentUsedUncompressed;
 
   [must_use] readonly attribute int64_t storageSQLite;
 
   [must_use] readonly attribute int64_t lowMemoryEventsVirtual;
+  [must_use] readonly attribute int64_t lowMemoryEventsCommitSpace;
   [must_use] readonly attribute int64_t lowMemoryEventsPhysical;
 
   [must_use] readonly attribute int64_t ghostWindows;
 
   [must_use] readonly attribute int64_t pageFaultsHard;
 
   /*
    * This attribute indicates if moz_malloc_usable_size() works.
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -2515,16 +2515,22 @@ nsMemoryReporterManager::GetStorageSQLit
 
 NS_IMETHODIMP
 nsMemoryReporterManager::GetLowMemoryEventsVirtual(int64_t* aAmount)
 {
   return GetInfallibleAmount(mAmountFns.mLowMemoryEventsVirtual, aAmount);
 }
 
 NS_IMETHODIMP
+nsMemoryReporterManager::GetLowMemoryEventsCommitSpace(int64_t* aAmount)
+{
+  return GetInfallibleAmount(mAmountFns.mLowMemoryEventsCommitSpace, aAmount);
+}
+
+NS_IMETHODIMP
 nsMemoryReporterManager::GetLowMemoryEventsPhysical(int64_t* aAmount)
 {
   return GetInfallibleAmount(mAmountFns.mLowMemoryEventsPhysical, aAmount);
 }
 
 NS_IMETHODIMP
 nsMemoryReporterManager::GetGhostWindows(int64_t* aAmount)
 {
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -144,16 +144,17 @@ public:
     mozilla::InfallibleAmountFn mJSMainRuntimeRealmsSystem;
     mozilla::InfallibleAmountFn mJSMainRuntimeRealmsUser;
 
     mozilla::InfallibleAmountFn mImagesContentUsedUncompressed;
 
     mozilla::InfallibleAmountFn mStorageSQLite;
 
     mozilla::InfallibleAmountFn mLowMemoryEventsVirtual;
+    mozilla::InfallibleAmountFn mLowMemoryEventsCommitSpace;
     mozilla::InfallibleAmountFn mLowMemoryEventsPhysical;
 
     mozilla::InfallibleAmountFn mGhostWindows;
 
     AmountFns()
     {
       mozilla::PodZero(this);
     }
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -1266,21 +1266,19 @@ nsThread::DoMainThreadSpecificProcessing
     MemoryPressureState mpPending = NS_GetPendingMemoryPressure();
     if (mpPending != MemPressure_None) {
       nsCOMPtr<nsIObserverService> os = services::GetObserverService();
 
       if (os) {
         if (mpPending == MemPressure_Stopping) {
           os->NotifyObservers(nullptr, "memory-pressure-stop", nullptr);
         } else {
-          // Use no-forward to prevent the notifications from being transferred to
-          // the children of this process.
           os->NotifyObservers(nullptr, "memory-pressure",
-                              mpPending == MemPressure_New ? u"low-memory-no-forward" :
-                              u"low-memory-ongoing-no-forward");
+                              mpPending == MemPressure_New ? u"low-memory" :
+                              u"low-memory-ongoing");
         }
       } else {
         NS_WARNING("Can't get observer service!");
       }
     }
   }
 
   if (!ShuttingDown()) {