Merge fx-team to m-c. a=merge
authorRyan VanderMeulen <ryanvm@gmail.com>
Sat, 05 Dec 2015 15:09:41 -0500
changeset 309781 094bf2eff9d7f6b5d6c926b709f8975562c740e8
parent 309760 cba488c0af7031be976c19e0bc589be6f078c4db (current diff)
parent 309780 22d7d0b39c38a48fbb86c5c961404ae75403e4d4 (diff)
child 309812 fb4801cfdbbf072a071f6a6ef8c1cf13dd6de960
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone45.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 fx-team to m-c. a=merge
--- a/.eslintignore
+++ b/.eslintignore
@@ -37,41 +37,17 @@ nsprpub/**
 other-licenses/**
 parser/**
 probes/**
 python/**
 rdf/**
 security/**
 services/**
 startupcache/**
-storage/**
 testing/**
-toolkit/components/**
-toolkit/content/**
-toolkit/crashreporter/**
-toolkit/forgetaboutsite/**
-toolkit/identity/**
-toolkit/library/**
-toolkit/locales/**
-toolkit/modules/**
-# This file contains preprocessor statements.
-toolkit/mozapps/extensions/internal/AddonConstants.jsm
-toolkit/mozapps/downloads/**
-toolkit/mozapps/handling/**
-toolkit/mozapps/installer/**
-toolkit/mozapps/preferences/**
-toolkit/mozapps/update/**
-toolkit/obsolete/**
-toolkit/pluginproblem/**
-toolkit/profile/**
-toolkit/system/**
-toolkit/themes/**
-toolkit/toolkit.mozbuild/**
-toolkit/webapps/**
-toolkit/xre/**
 tools/**
 uriloader/**
 view/**
 webapprt/**
 widget/**
 xpcom/**
 xpfe/**
 xulrunner/**
@@ -191,8 +167,39 @@ mobile/android/modules/ContactService.js
 #   https://github.com/eslint/espree/issues/125
 mobile/android/modules/WebappManager.jsm
 
 # Non-standard `(catch ex if ...)`
 mobile/android/components/Snippets.js
 
 # Bug 1178739: Ignore this file as a quick fix for "Illegal yield expression"
 mobile/android/modules/HomeProvider.jsm
+
+# toolkit/ exclusions
+
+# Not part of the default build
+toolkit/components/help/**
+
+# Intentionally invalid JS
+toolkit/components/workerloader/tests/moduleF-syntax-error.js
+
+# Tests old non-star function generators
+toolkit/modules/tests/xpcshell/test_task.js
+
+# Not yet updated
+toolkit/components/osfile/**
+toolkit/components/passwordmgr/**
+toolkit/components/places/**
+toolkit/mozapps/extensions/**
+
+# Uses preprocessing
+toolkit/content/contentAreaUtils.js
+toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+toolkit/components/search/nsSearchService.js
+toolkit/components/url-classifier/**
+toolkit/components/urlformatter/nsURLFormatter.js
+toolkit/identity/FirefoxAccounts.jsm
+toolkit/modules/AppConstants.jsm
+toolkit/modules/SessionRecorder.jsm
+toolkit/mozapps/downloads/nsHelperAppDlg.js
+toolkit/mozapps/extensions/internal/AddonConstants.jsm
+toolkit/mozapps/update/tests/data/xpcshellConstantsPP.js
+toolkit/webapps/**
--- a/browser/base/content/aboutNetError.xhtml
+++ b/browser/base/content/aboutNetError.xhtml
@@ -280,70 +280,82 @@
         var event = new CustomEvent("AboutNetErrorLoad", {bubbles:true});
         document.dispatchEvent(event);
 
         if (err == "nssBadCert") {
           // Remove the "Try again" button for security exceptions, since it's
           // almost certainly useless.
           document.getElementById("errorTryAgain").style.display = "none";
           document.getElementById("errorPageContainer").setAttribute("class", "certerror");
-          addDomainErrorLink();
         }
         else {
           // Remove the override block for non-certificate errors.  CSS-hiding
           // isn't good enough here, because of bug 39098
           var secOverride = document.getElementById("securityOverrideDiv");
           secOverride.parentNode.removeChild(secOverride);
         }
+        addDomainErrorLinks();
       }
 
       function showSecuritySection() {
         // Swap link out, content in
         document.getElementById('securityOverrideContent').style.display = '';
         document.getElementById('securityOverrideLink').style.display = 'none';
       }
 
-      /* In the case of SSL error pages about domain mismatch, see if
+      /* Try to preserve the links contained in the error description, like
+         the error code.
+
+         Also, in the case of SSL error pages about domain mismatch, see if
          we can hyperlink the user to the correct site.  We don't want
          to do this generically since it allows MitM attacks to redirect
          users to a site under attacker control, but in certain cases
          it is safe (and helpful!) to do so.  Bug 402210
       */
-      function addDomainErrorLink() {
+      function addDomainErrorLinks() {
         // Rather than textContent, we need to treat description as HTML
         var sd = document.getElementById("errorShortDescText");
         if (sd) {
           var desc = getDescription();
 
           // sanitize description text - see bug 441169
 
-          // First, find the index of the <a> tag we care about, being careful not to
-          // use an over-greedy regex
-          var re = /<a id="cert_domain_link" title="([^"]+)">/;
-          var result = re.exec(desc);
-          if(!result)
+          // First, find the index of the <a> tags we care about, being
+          // careful not to use an over-greedy regex.
+          var codeRe = /<a id="errorCode" title="([^"]+)">/;
+          var codeResult = codeRe.exec(desc);
+          var domainRe = /<a id="cert_domain_link" title="([^"]+)">/;
+          var domainResult = domainRe.exec(desc);
+
+          // The order of these links in the description is fixed in
+          // TransportSecurityInfo.cpp:formatOverridableCertErrorMessage.
+          var firstResult = domainResult;
+          if(!domainResult)
+            firstResult = codeResult;
+          if (!firstResult)
             return;
-
           // Remove sd's existing children
           sd.textContent = "";
 
-          // Everything up to the link should be text content
-          sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
+          // Everything up to the first link should be text content.
+          sd.appendChild(document.createTextNode(desc.slice(0, firstResult.index)));
 
-          // Now create the link itself
-          var anchorEl = document.createElement("a");
-          anchorEl.setAttribute("id", "cert_domain_link");
-          anchorEl.setAttribute("title", result[1]);
-          anchorEl.appendChild(document.createTextNode(result[1]));
-          sd.appendChild(anchorEl);
+          // Now create the actual links.
+          if (domainResult) {
+            createLink(sd, "cert_domain_link", domainResult[1])
+            // Append text for anything between the two links.
+            sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length, codeResult.index)));
+          }
+          createLink(sd, "errorCode", codeResult[1])
 
-          // Finally, append text for anything after the closing </a>
-          sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length)));
+          // Finally, append text for anything after the last closing </a>.
+          sd.appendChild(document.createTextNode(desc.slice(desc.lastIndexOf("</a>") + "</a>".length)));
         }
 
+        // Initialize the cert domain link.
         var link = document.getElementById('cert_domain_link');
         if (!link)
           return;
 
         var okHost = link.getAttribute("title");
         var thisHost = document.location.hostname;
         var proto = document.location.protocol;
 
@@ -360,30 +372,39 @@
          * Make sure to include the "." ahead of thisHost so that
          * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
          *
          * We'd normally just use a RegExp here except that we lack a
          * library function to escape them properly (bug 248062), and
          * domain names are famous for having '.' characters in them,
          * which would allow spurious and possibly hostile matches.
          */
-        if (endsWith(okHost, "." + thisHost))
+        if (okHost.endsWith("." + thisHost))
           link.href = proto + okHost;
 
         /* case #2:
          * browser.garage.maemo.org uses an invalid security certificate.
          *
          * The certificate is only valid for garage.maemo.org
          */
-        if (endsWith(thisHost, "." + okHost))
+        if (thisHost.endsWith("." + okHost))
           link.href = proto + okHost;
+
+        // If we set a link, meaning there's something helpful for
+        // the user here, expand the section by default
+        if (link.href && getCSSClass() != "expertBadCert")
+          toggleVisibility("advancedPanel");
       }
 
-      function endsWith(haystack, needle) {
-        return haystack.slice(-needle.length) == needle;
+      function createLink(el, id, text) {
+        var anchorEl = document.createElement("a");
+        anchorEl.setAttribute("id", id);
+        anchorEl.setAttribute("title", text);
+        anchorEl.appendChild(document.createTextNode(text));
+        el.appendChild(anchorEl);
       }
     ]]></script>
   </head>
 
   <body dir="&locale.dir;">
 
     <!-- ERROR ITEM CONTAINER (removed during loading to avoid bug 39098) -->
     <div id="errorContainer">
@@ -439,18 +460,18 @@
         <div id="ed_nssFailure2">&nssFailure2.longDesc2;</div>
         <div id="ed_nssBadCert">&nssBadCert.longDesc2;</div>
         <div id="ed_malwareBlocked">&malwareBlocked.longDesc;</div>
         <div id="ed_unwantedBlocked">&unwantedBlocked.longDesc;</div>
         <div id="ed_forbiddenBlocked">&forbiddenBlocked.longDesc;</div>
         <div id="ed_cspBlocked">&cspBlocked.longDesc;</div>
         <div id="ed_remoteXUL">&remoteXUL.longDesc;</div>
         <div id="ed_corruptedContentError">&corruptedContentError.longDesc;</div>
-        <div id="ed_sslv3Used">&sslv3Used.longDesc;</div>
-        <div id="ed_weakCryptoUsed">&weakCryptoUsed.longDesc;</div>
+        <div id="ed_sslv3Used">&sslv3Used.longDesc2;</div>
+        <div id="ed_weakCryptoUsed">&weakCryptoUsed.longDesc2;</div>
       </div>
     </div>
 
     <!-- PAGE CONTAINER (for styling purposes only) -->
     <div id="errorPageContainer">
 
       <!-- Error Title -->
       <div id="errorTitle">
--- a/browser/base/content/aboutcerterror/aboutCertError.xhtml
+++ b/browser/base/content/aboutcerterror/aboutCertError.xhtml
@@ -50,16 +50,23 @@
         // parenthetical match is the second entry
         return decodeURIComponent(matches[1]);
       }
 
       function toggleVisibility(id)
       {
         var node = document.getElementById(id);
         node.style.visibility = node.style.visibility == "" ? "hidden" : "";
+        // Toggling the advanced panel must ensure that the debugging
+        // information panel is hidden as well, since it's opened by the
+        // error code link in the advanced panel.
+        if (id == "advancedPanel") {
+          var div = document.getElementById("certificateErrorDebugInformation");
+          div.style.display = "none";
+        }
       }
 
       function getDescription()
       {
         var url = document.documentURI;
         var desc = url.search(/d\=/);
 
         // desc == -1 if not found; if so, return an empty string
@@ -90,57 +97,89 @@
         if (cssClass != "badStsCert") {
           document.getElementById("badStsCertExplanation").setAttribute("hidden", "true");
         }
 
         var tech = document.getElementById("technicalContentText");
         if (tech)
           tech.textContent = getDescription();
 
-        addDomainErrorLink();
+        var event = new CustomEvent("AboutCertErrorLoad", {bubbles:true});
+        document.getElementById("advancedButton").dispatchEvent(event);
+
+        addDomainErrorLinks();
       }
 
-      /* In the case of SSL error pages about domain mismatch, see if
+      /* Try to preserve the links contained in the error description, like
+         the error code.
+
+         Also, in the case of SSL error pages about domain mismatch, see if
          we can hyperlink the user to the correct site.  We don't want
          to do this generically since it allows MitM attacks to redirect
          users to a site under attacker control, but in certain cases
          it is safe (and helpful!) to do so.  Bug 402210
       */
-      function addDomainErrorLink() {
+      function addDomainErrorLinks() {
         // Rather than textContent, we need to treat description as HTML
         var sd = document.getElementById("technicalContentText");
         if (sd) {
           var desc = getDescription();
 
           // sanitize description text - see bug 441169
 
-          // First, find the index of the <a> tag we care about, being careful not to
-          // use an over-greedy regex
-          var re = /<a id="cert_domain_link" title="([^"]+)">/;
-          var result = re.exec(desc);
-          if(!result)
+          // First, find the index of the <a> tags we care about, being
+          // careful not to use an over-greedy regex.
+          var codeRe = /<a id="errorCode" title="([^"]+)">/;
+          var codeResult = codeRe.exec(desc);
+          var domainRe = /<a id="cert_domain_link" title="([^"]+)">/;
+          var domainResult = domainRe.exec(desc);
+
+          // The order of these links in the description is fixed in
+          // TransportSecurityInfo.cpp:formatOverridableCertErrorMessage.
+          var firstResult = domainResult;
+          if(!domainResult)
+            firstResult = codeResult;
+          if (!firstResult)
             return;
 
           // Remove sd's existing children
           sd.textContent = "";
 
-          // Everything up to the link should be text content
-          sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
+          // Everything up to the first link should be text content.
+          sd.appendChild(document.createTextNode(desc.slice(0, firstResult.index)));
 
-          // Now create the link itself
-          var anchorEl = document.createElement("a");
-          anchorEl.setAttribute("id", "cert_domain_link");
-          anchorEl.setAttribute("title", result[1]);
-          anchorEl.appendChild(document.createTextNode(result[1]));
-          sd.appendChild(anchorEl);
+          // Now create the actual links.
+          if (domainResult) {
+            createLink(sd, "cert_domain_link", domainResult[1])
+            // Append text for anything between the two links.
+            sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length, codeResult.index)));
+          }
+          createLink(sd, "errorCode", codeResult[1])
 
-          // Finally, append text for anything after the closing </a>
-          sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length)));
+          // Finally, append text for anything after the last closing </a>.
+          sd.appendChild(document.createTextNode(desc.slice(desc.lastIndexOf("</a>") + "</a>".length)));
         }
 
+        // Initialize the error code link embedded in the error message to
+        // display debug information about the cert error.
+        var errorCode = document.getElementById("errorCode");
+        if (errorCode) {
+          errorCode.href = "#technicalInformation";
+          errorCode.addEventListener("click", () => {
+            var div = document.getElementById("certificateErrorDebugInformation");
+            if (div.style.display == "block") {
+              div.style.display = "none";
+            } else {
+              div.style.display = "block";
+              div.scrollIntoView(true);
+            }
+          }, false);
+        }
+
+        // Then initialize the cert domain link.
         var link = document.getElementById('cert_domain_link');
         if (!link)
           return;
 
         var okHost = link.getAttribute("title");
         var thisHost = document.location.hostname;
         var proto = document.location.protocol;
 
@@ -173,16 +212,24 @@
         if (thisHost.endsWith("." + okHost))
           link.href = proto + okHost;
 
         // If we set a link, meaning there's something helpful for
         // the user here, expand the section by default
         if (link.href && getCSSClass() != "expertBadCert")
           toggleVisibility("advancedPanel");
       }
+
+      function createLink(el, id, text) {
+        var anchorEl = document.createElement("a");
+        anchorEl.setAttribute("id", id);
+        anchorEl.setAttribute("title", text);
+        anchorEl.appendChild(document.createTextNode(text));
+        el.appendChild(anchorEl);
+      }
     ]]></script>
   </head>
 
   <body dir="&locale.dir;">
     <!-- PAGE CONTAINER (for styling purposes only) -->
     <div id="errorPageContainer">
 
       <!-- Error Title -->
@@ -205,21 +252,28 @@
         <div id="buttonContainer">
           <button id="returnButton" autocomplete="off" autofocus="true">&certerror.returnToPreviousPage.label;</button>
           <div id="buttonSpacer"></div>
           <button id="advancedButton" autocomplete="off" onclick="toggleVisibility('advancedPanel');" autofocus="true">&certerror.advanced.label;</button>
         </div>
         <!-- Advanced panel, which is hidden by default -->
         <div id="advancedPanel" style="visibility: hidden;">
           <p id="technicalContentText"/>
-          <button id='exceptionDialogButton'>&certerror.addException.label;</button>
+          <button id="exceptionDialogButton">&certerror.addException.label;</button>
         </div>
       </div>
     </div>
 
+    <div id="certificateErrorDebugInformation">
+      <a name="technicalInformation"></a>
+      <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
+      <div id="certificateErrorText"/>
+      <button id="copyToClipboard">&certerror.copyToClipboard.label;</button>
+    </div>
+
     <!--
     - Note: It is important to run the script this way, instead of using
     - an onload handler. This is because error pages are loaded as
     - LOAD_BACKGROUND, which means that onload handlers will not be executed.
     -->
     <script type="application/javascript">initPage();</script>
 
   </body>
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2696,17 +2696,17 @@ var BrowserOnClick = {
     }
   },
 
   receiveMessage: function (msg) {
     switch (msg.name) {
       case "Browser:CertExceptionError":
         this.onAboutCertError(msg.target, msg.data.elementId,
                               msg.data.isTopFrame, msg.data.location,
-                              msg.data.sslStatusAsString);
+                              msg.data.securityInfoAsString);
       break;
       case "Browser:SiteBlockedError":
         this.onAboutBlocked(msg.data.elementId, msg.data.reason,
                             msg.data.isTopFrame, msg.data.location);
       break;
       case "Browser:EnableOnlineMode":
         if (Services.io.offline) {
           // Reset network state and refresh the page.
@@ -2782,29 +2782,16 @@ var BrowserOnClick = {
      * - Error type (e.g. Pinning, domain mismatch, etc)
      * - Cert chain (at minimum, same data to distrust each cert in the
      *   chain)
      * - Request data (e.g. User Agent, IP, Timestamp)
      *
      * The request data should be added to the report by the receiving server.
      */
 
-    // TODO: can we pull this in from pippki.js isntead of duplicating it
-    // here?
-    function getDERString(cert)
-    {
-      var length = {};
-      var derArray = cert.getRawDER(length);
-      var derString = '';
-      for (var i = 0; i < derArray.length; i++) {
-        derString += String.fromCharCode(derArray[i]);
-      }
-      return derString;
-    }
-
     // Convert the nsIX509CertList into a format that can be parsed into
     // JSON
     let asciiCertChain = [];
 
     if (transportSecurityInfo.failedCertChain) {
       let certs = transportSecurityInfo.failedCertChain.getEnumerator();
       while (certs.hasMoreElements()) {
         let cert = certs.getNext();
@@ -2851,29 +2838,30 @@ var BrowserOnClick = {
       } else {
         showReportStatus("complete");
       }
     };
 
     xhr.send(JSON.stringify(report));
   },
 
-  onAboutCertError: function (browser, elementId, isTopFrame, location, sslStatusAsString) {
+  onAboutCertError: function (browser, elementId, isTopFrame, location, securityInfoAsString) {
     let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
 
     switch (elementId) {
       case "exceptionDialogButton":
         if (isTopFrame) {
           secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_BAD_CERT_TOP_CLICK_ADD_EXCEPTION);
         }
 
         let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
                            .getService(Ci.nsISerializationHelper);
-        let sslStatus = serhelper.deserializeObject(sslStatusAsString);
-        sslStatus.QueryInterface(Components.interfaces.nsISSLStatus);
+        let securityInfo = serhelper.deserializeObject(securityInfoAsString);
+        let sslStatus = securityInfo.QueryInterface(Ci.nsISSLStatusProvider)
+                                    .SSLStatus;
         let params = { exceptionAdded : false,
                        sslStatus : sslStatus };
 
         try {
           switch (Services.prefs.getIntPref("browser.ssl_override_behavior")) {
             case 2 : // Pre-fetch & pre-populate
               params.prefetchCert = true;
             case 1 : // Pre-populate
@@ -2898,16 +2886,29 @@ var BrowserOnClick = {
         }
         goBackFromErrorPage();
         break;
 
       case "advancedButton":
         if (isTopFrame) {
           secHistogram.add(Ci.nsISecurityUITelemetry.WARNING_BAD_CERT_TOP_UNDERSTAND_RISKS);
         }
+
+        let errorInfo = getDetailedCertErrorInfo(location,
+                                                 securityInfoAsString);
+        browser.messageManager.sendAsyncMessage("AboutCertErrorDetails",
+                                                { info: errorInfo });
+        break;
+
+      case "copyToClipboard":
+        const gClipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"]
+                                    .getService(Ci.nsIClipboardHelper);
+        let detailedInfo = getDetailedCertErrorInfo(location,
+                                                    securityInfoAsString);
+        gClipboardHelper.copyString(detailedInfo);
         break;
 
     }
   },
 
   onAboutBlocked: function (elementId, reason, isTopFrame, location) {
     // Depending on what page we are displaying here (malware/phishing/unwanted)
     // use the right strings and links for each.
@@ -3152,16 +3153,86 @@ function BrowserReloadWithFlags(reloadFl
 
   gBrowser.selectedBrowser
           .messageManager
           .sendAsyncMessage("Browser:Reload",
                             { flags: reloadFlags,
                               handlingUserInput: windowUtils.isHandlingUserInput });
 }
 
+/**
+ * Returns a string with detailed information about the certificate validation
+ * failure from the specified URI that can be used to send a report.
+ */
+function getDetailedCertErrorInfo(location, securityInfoAsString) {
+  if (!securityInfoAsString)
+    return "";
+
+  let details = [];
+  details.push(location);
+
+  const serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
+                       .getService(Ci.nsISerializationHelper);
+  let securityInfo = serhelper.deserializeObject(securityInfoAsString);
+  securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
+
+  let errors = Cc["@mozilla.org/nss_errors_service;1"]
+                  .getService(Ci.nsINSSErrorsService);
+  let code = securityInfo.errorCode;
+  details.push(errors.getErrorMessage(errors.getXPCOMFromNSSError(code)));
+
+  const sss = Cc["@mozilla.org/ssservice;1"]
+                 .getService(Ci.nsISiteSecurityService);
+  // SiteSecurityService uses different storage if the channel is
+  // private. Thus we must give isSecureHost correct flags or we
+  // might get incorrect results.
+  let flags = PrivateBrowsingUtils.isWindowPrivate(window) ?
+              Ci.nsISocketProvider.NO_PERMANENT_STORAGE : 0;
+
+  let uri = Services.io.newURI(location, null, null);
+  details.push(sss.isSecureHost(sss.HEADER_HSTS, uri.host, flags));
+  details.push(sss.isSecureHost(sss.HEADER_HPKP, uri.host, flags));
+
+  let certChain = "";
+  if (securityInfo.failedCertChain) {
+    let certs = securityInfo.failedCertChain.getEnumerator();
+    while (certs.hasMoreElements()) {
+      let cert = certs.getNext();
+      cert.QueryInterface(Ci.nsIX509Cert);
+      certChain += getPEMString(cert);
+    }
+  }
+  details.push(certChain);
+  return gNavigatorBundle.getFormattedString("certErrorDetails.label", details, 5);
+}
+
+// TODO: can we pull getDERString and getPEMString in from pippki.js instead of
+// duplicating them here?
+function getDERString(cert)
+{
+  var length = {};
+  var derArray = cert.getRawDER(length);
+  var derString = '';
+  for (var i = 0; i < derArray.length; i++) {
+    derString += String.fromCharCode(derArray[i]);
+  }
+  return derString;
+}
+
+function getPEMString(cert)
+{
+  var derb64 = btoa(getDERString(cert));
+  // Wrap the Base64 string into lines of 64 characters,
+  // with CRLF line breaks (as specified in RFC 1421).
+  var wrapped = derb64.replace(/(\S{64}(?!$))/g, "$1\r\n");
+  return "-----BEGIN CERTIFICATE-----\r\n"
+         + wrapped
+         + "\r\n-----END CERTIFICATE-----\r\n";
+}
+
 var PrintPreviewListener = {
   _printPreviewTab: null,
   _tabBeforePrintPreview: null,
 
   getPrintPreviewBrowser: function () {
     if (!this._printPreviewTab) {
       let browser = gBrowser.selectedTab.linkedBrowser;
       let forceNotRemote = gMultiProcessBrowser && !browser.isRemoteBrowser;
@@ -5318,20 +5389,24 @@ function hrefAndLinkNodeForClickEvent(ev
 
   if (node)
     return [node.href, node];
 
   // If there is no linkNode, try simple XLink.
   let href, baseURI;
   node = event.target;
   while (node && !href) {
-    if (node.nodeType == Node.ELEMENT_NODE) {
+    if (node.nodeType == Node.ELEMENT_NODE &&
+        (node.localName == "a" ||
+         node.namespaceURI == "http://www.w3.org/1998/Math/MathML")) {
       href = node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
-      if (href)
+      if (href) {
         baseURI = node.baseURI;
+        break;
+      }
     }
     node = node.parentNode;
   }
 
   // In case of XLink, we don't return the node we got href from since
   // callers expect <a>-like elements.
   return [href ? makeURLAbsolute(baseURI, href) : null, null];
 }
@@ -7936,9 +8011,8 @@ TabModalPromptBox.prototype = {
   get browser() {
     let browser = this._weakBrowserRef.get();
     if (!browser) {
       throw "Stale promptbox! The associated browser is gone.";
     }
     return browser;
   },
 };
-
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -311,17 +311,16 @@ var AboutNetErrorListener = {
           reportSendingMsg.style.display = "none";
           sendAsyncMessage("Browser:SSLErrorReportTelemetry",
                            {reportStatus: TLS_ERROR_REPORT_TELEMETRY_SUCCESS});
           break;
         }
       }
     });
 
-    let failedChannel = docShell.failedChannel;
     let location = contentDoc.location.href;
 
     let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
                      .getService(Ci.nsISerializationHelper);
 
     let serializable =  docShell.failedChannel.securityInfo
                                 .QueryInterface(Ci.nsITransportSecurityInfo)
                                 .QueryInterface(Ci.nsISerializable);
@@ -431,31 +430,31 @@ var ClickEventHandler = {
   },
 
   onAboutCertError: function (targetElement, ownerDoc) {
     let docshell = ownerDoc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
                                        .getInterface(Ci.nsIWebNavigation)
                                        .QueryInterface(Ci.nsIDocShell);
     let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
                      .getService(Ci.nsISerializationHelper);
-    let serializedSSLStatus = "";
+    let serializedSecurityInfo = "";
 
     try {
       let serializable =  docShell.failedChannel.securityInfo
-                                  .QueryInterface(Ci.nsISSLStatusProvider)
-                                  .SSLStatus
+                                  .QueryInterface(Ci.nsITransportSecurityInfo)
                                   .QueryInterface(Ci.nsISerializable);
-      serializedSSLStatus = serhelper.serializeToString(serializable);
+
+      serializedSecurityInfo = serhelper.serializeToString(serializable);
     } catch (e) { }
 
     sendAsyncMessage("Browser:CertExceptionError", {
       location: ownerDoc.location.href,
       elementId: targetElement.getAttribute("id"),
       isTopFrame: (ownerDoc.defaultView.parent === ownerDoc.defaultView),
-      sslStatusAsString: serializedSSLStatus
+      securityInfoAsString: serializedSecurityInfo
     });
   },
 
   onAboutBlocked: function (targetElement, ownerDoc) {
     var reason = 'phishing';
     if (/e=malwareBlocked/.test(ownerDoc.documentURI)) {
       reason = 'malware';
     } else if (/e=unwantedBlocked/.test(ownerDoc.documentURI)) {
@@ -515,17 +514,19 @@ var ClickEventHandler = {
 
     if (node)
       return [node.href, node, node.ownerDocument.nodePrincipal];
 
     // If there is no linkNode, try simple XLink.
     let href, baseURI;
     node = event.target;
     while (node && !href) {
-      if (node.nodeType == content.Node.ELEMENT_NODE) {
+      if (node.nodeType == content.Node.ELEMENT_NODE &&
+          (node.localName == "a" ||
+           node.namespaceURI == "http://www.w3.org/1998/Math/MathML")) {
         href = node.getAttributeNS("http://www.w3.org/1999/xlink", "href");
         if (href) {
           baseURI = node.ownerDocument.baseURIObject;
           break;
         }
       }
       node = node.parentNode;
     }
@@ -547,16 +548,27 @@ var pluginContent = new PluginContent(gl
 addEventListener("DOMWebNotificationClicked", function(event) {
   sendAsyncMessage("DOMWebNotificationClicked", {});
 }, false);
 
 addEventListener("DOMServiceWorkerFocusClient", function(event) {
   sendAsyncMessage("DOMServiceWorkerFocusClient", {});
 }, false);
 
+addEventListener("AboutCertErrorLoad", function(event) {
+  let originalTarget = event.originalTarget;
+  let ownerDoc = originalTarget.ownerDocument;
+  ClickEventHandler.onAboutCertError(originalTarget, ownerDoc);
+}, false, true);
+
+addMessageListener("AboutCertErrorDetails", function(message) {
+  let div = content.document.getElementById("certificateErrorText");
+  div.textContent = message.data.info;
+});
+
 ContentWebRTC.init();
 addMessageListener("rtcpeer:Allow", ContentWebRTC);
 addMessageListener("rtcpeer:Deny", ContentWebRTC);
 addMessageListener("webrtc:Allow", ContentWebRTC);
 addMessageListener("webrtc:Deny", ContentWebRTC);
 addMessageListener("webrtc:StopSharing", ContentWebRTC);
 addMessageListener("webrtc:StartBrowserSharing", () => {
   let windowID = content.QueryInterface(Ci.nsIInterfaceRequestor)
--- a/browser/base/content/test/general/browser_aboutCertError.js
+++ b/browser/base/content/test/general/browser_aboutCertError.js
@@ -1,13 +1,12 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// This is testing the aboutCertError page (Bug 1207107).  It's a start,
-// but should be expanded to include cert_domain_link
+// This is testing the aboutCertError page (Bug 1207107).
 
 const GOOD_PAGE = "https://example.com/";
 const BAD_CERT = "https://expired.example.com/";
 const BAD_STS_CERT = "https://badchain.include-subdomains.pinning.example.com:443";
 const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
 const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
 add_task(function* checkReturnToAboutHome() {
@@ -98,17 +97,186 @@ add_task(function* checkBadStsCert() {
     let exceptionButton = doc.getElementById("exceptionDialogButton");
     return exceptionButton.hidden;
   });
   ok(exceptionButtonHidden, "Exception button is hidden");
 
   gBrowser.removeCurrentTab();
 });
 
+add_task(function* checkAdvancedDetails() {
+  info("Loading a bad cert page and verifying the advanced details section");
+  let browser;
+  let certErrorLoaded;
+  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
+    gBrowser.selectedTab = gBrowser.addTab(BAD_CERT);
+    browser = gBrowser.selectedBrowser;
+    certErrorLoaded = waitForCertErrorLoad(browser);
+  }, false);
+
+  info("Loading and waiting for the cert error");
+  yield certErrorLoaded;
+
+  let message = yield ContentTask.spawn(browser, null, function* () {
+    let doc = content.document;
+    let advancedButton = doc.getElementById("advancedButton");
+    advancedButton.click();
+    let el = doc.getElementById("errorCode");
+    return { textContent: el.textContent, tagName: el.tagName };
+  });
+  is(message.textContent, "SEC_ERROR_EXPIRED_CERTIFICATE",
+     "Correct error message found");
+  is(message.tagName, "a", "Error message is a link");
+
+  message = yield ContentTask.spawn(browser, null, function* () {
+    let doc = content.document;
+    let errorCode = doc.getElementById("errorCode");
+    errorCode.click();
+    let div = doc.getElementById("certificateErrorDebugInformation");
+    let text = doc.getElementById("certificateErrorText");
+
+    let docshell = content.QueryInterface(Ci.nsIInterfaceRequestor)
+                          .getInterface(Ci.nsIWebNavigation)
+                          .QueryInterface(Ci.nsIDocShell);
+    let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
+                     .getService(Ci.nsISerializationHelper);
+    let serializable =  docShell.failedChannel.securityInfo
+                                .QueryInterface(Ci.nsITransportSecurityInfo)
+                                .QueryInterface(Ci.nsISerializable);
+    let serializedSecurityInfo = serhelper.serializeToString(serializable);
+    return {
+      divDisplay: div.style.display,
+      text: text.textContent,
+      securityInfoAsString: serializedSecurityInfo
+    };
+  });
+  is(message.divDisplay, "block", "Debug information is visible");
+  ok(message.text.contains(BAD_CERT), "Correct URL found");
+  ok(message.text.contains("Certificate has expired"),
+     "Correct error message found");
+  ok(message.text.contains("HTTP Strict Transport Security: false"),
+     "Correct HSTS value found");
+  ok(message.text.contains("HTTP Public Key Pinning: false"),
+     "Correct HPKP value found");
+  let certChain = getCertChain(message.securityInfoAsString);
+  ok(message.text.contains(certChain), "Found certificate chain");
+
+  gBrowser.removeCurrentTab();
+});
+
+add_task(function* checkAdvancedDetailsForHSTS() {
+  info("Loading a bad STS cert page and verifying the advanced details section");
+  let browser;
+  let certErrorLoaded;
+  let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, () => {
+    gBrowser.selectedTab = gBrowser.addTab(BAD_STS_CERT);
+    browser = gBrowser.selectedBrowser;
+    certErrorLoaded = waitForCertErrorLoad(browser);
+  }, false);
+
+  info("Loading and waiting for the cert error");
+  yield certErrorLoaded;
+
+  let message = yield ContentTask.spawn(browser, null, function* () {
+    let doc = content.document;
+    let advancedButton = doc.getElementById("advancedButton");
+    advancedButton.click();
+    let ec = doc.getElementById("errorCode");
+    let cdl = doc.getElementById("cert_domain_link");
+    return {
+      ecTextContent: ec.textContent,
+      ecTagName: ec.tagName,
+      cdlTextContent: cdl.textContent,
+      cdlTagName: cdl.tagName
+    };
+  });
+
+  const badStsUri = Services.io.newURI(BAD_STS_CERT, null, null);
+  is(message.ecTextContent, "SSL_ERROR_BAD_CERT_DOMAIN",
+     "Correct error message found");
+  is(message.ecTagName, "a", "Error message is a link");
+  const url = badStsUri.prePath.slice(badStsUri.prePath.indexOf(".") + 1);
+  is(message.cdlTextContent, url,
+     "Correct cert_domain_link contents found");
+  is(message.cdlTagName, "a", "cert_domain_link is a link");
+
+  message = yield ContentTask.spawn(browser, null, function* () {
+    let doc = content.document;
+    let errorCode = doc.getElementById("errorCode");
+    errorCode.click();
+    let div = doc.getElementById("certificateErrorDebugInformation");
+    let text = doc.getElementById("certificateErrorText");
+
+    let docshell = content.QueryInterface(Ci.nsIInterfaceRequestor)
+                          .getInterface(Ci.nsIWebNavigation)
+                          .QueryInterface(Ci.nsIDocShell);
+    let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
+                     .getService(Ci.nsISerializationHelper);
+    let serializable =  docShell.failedChannel.securityInfo
+                                .QueryInterface(Ci.nsITransportSecurityInfo)
+                                .QueryInterface(Ci.nsISerializable);
+    let serializedSecurityInfo = serhelper.serializeToString(serializable);
+    return {
+      divDisplay: div.style.display,
+      text: text.textContent,
+      securityInfoAsString: serializedSecurityInfo
+    };
+  });
+  is(message.divDisplay, "block", "Debug information is visible");
+  ok(message.text.contains(badStsUri.spec), "Correct URL found");
+  ok(message.text.contains("requested domain name does not match the server's certificate"),
+     "Correct error message found");
+  ok(message.text.contains("HTTP Strict Transport Security: false"),
+     "Correct HSTS value found");
+  ok(message.text.contains("HTTP Public Key Pinning: true"),
+     "Correct HPKP value found");
+  let certChain = getCertChain(message.securityInfoAsString);
+  ok(message.text.contains(certChain), "Found certificate chain");
+
+  gBrowser.removeCurrentTab();
+});
+
 function waitForCertErrorLoad(browser) {
   return new Promise(resolve => {
     info("Waiting for DOMContentLoaded event");
     browser.addEventListener("DOMContentLoaded", function load() {
       browser.removeEventListener("DOMContentLoaded", load, false, true);
       resolve();
     }, false, true);
   });
 }
+
+function getCertChain(securityInfoAsString) {
+  let certChain = "";
+  const serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
+                       .getService(Ci.nsISerializationHelper);
+  let securityInfo = serhelper.deserializeObject(securityInfoAsString);
+  securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
+  let certs = securityInfo.failedCertChain.getEnumerator();
+  while (certs.hasMoreElements()) {
+    let cert = certs.getNext();
+    cert.QueryInterface(Ci.nsIX509Cert);
+    certChain += getPEMString(cert);
+  }
+  return certChain;
+}
+
+function getDERString(cert)
+{
+  var length = {};
+  var derArray = cert.getRawDER(length);
+  var derString = '';
+  for (var i = 0; i < derArray.length; i++) {
+    derString += String.fromCharCode(derArray[i]);
+  }
+  return derString;
+}
+
+function getPEMString(cert)
+{
+  var derb64 = btoa(getDERString(cert));
+  // Wrap the Base64 string into lines of 64 characters,
+  // with CRLF line breaks (as specified in RFC 1421).
+  var wrapped = derb64.replace(/(\S{64}(?!$))/g, "$1\r\n");
+  return "-----BEGIN CERTIFICATE-----\r\n"
+         + wrapped
+         + "\r\n-----END CERTIFICATE-----\r\n";
+}
--- a/browser/base/content/test/general/browser_blockHPKP.js
+++ b/browser/base/content/test/general/browser_blockHPKP.js
@@ -68,17 +68,17 @@ var successfulPinningPageListener = {
 
 // The browser should load about:neterror, when this happens, proceed
 // to load the pinning domain again, this time removing the pinning information
 var certErrorProgressListener = {
   onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
     if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
       let textElement = content.document.getElementById("errorShortDescText");
       let text = textElement.innerHTML;
-      ok(text.indexOf("mozilla_pkix_error_key_pinning_failure") > 0,
+      ok(text.indexOf("MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE") > 0,
          "Got a pinning error page");
       gBrowser.removeProgressListener(this);
       gBrowser.selectedBrowser.addEventListener("load",
                                                 successfulPinningRemovalPageListener,
                                                 true);
       gBrowser.selectedBrowser.loadURI("https://" + kPinningDomain + kURLPath + "zeromaxagevalid");
     }
   }
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -34,16 +34,19 @@ const kNSXUL = "http://www.mozilla.org/k
 const kSpecialWidgetPfx = "customizableui-special-";
 
 const kPrefCustomizationState        = "browser.uiCustomization.state";
 const kPrefCustomizationAutoAdd      = "browser.uiCustomization.autoAdd";
 const kPrefCustomizationDebug        = "browser.uiCustomization.debug";
 const kPrefDrawInTitlebar            = "browser.tabs.drawInTitlebar";
 const kPrefWebIDEInNavbar            = "devtools.webide.widget.inNavbarByDefault";
 
+const kExpectedWindowURL = "chrome://browser/content/browser.xul";
+
+
 /**
  * The keys are the handlers that are fired when the event type (the value)
  * is fired on the subview. A widget that provides a subview has the option
  * of providing onViewShowing and onViewHiding event handlers.
  */
 const kSubviewEvents = [
   "ViewShowing",
   "ViewHiding"
@@ -1295,16 +1298,19 @@ var CustomizableUIInternal = {
           return node;
         }
       }
     }
     return null;
   },
 
   buildWidget: function(aDocument, aWidget) {
+    if (aDocument.documentURI != kExpectedWindowURL) {
+      throw new Error("buildWidget was called for a non-browser window!");
+    }
     if (typeof aWidget == "string") {
       aWidget = gPalette.get(aWidget);
     }
     if (!aWidget) {
       throw new Error("buildWidget was passed a non-widget to build.");
     }
 
     LOG("Building " + aWidget.id + " of type " + aWidget.type);
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/.eslintrc
@@ -0,0 +1,16 @@
+{
+  "extends": "../../../toolkit/components/extensions/.eslintrc",
+
+  "globals": {
+    "currentWindow": true,
+    "EventEmitter": true,
+    "IconDetails": true,
+    "openPanel": true,
+    "makeWidgetId": true,
+    "TabContext": true,
+    "AllWindowEvents": true,
+    "WindowEventManager": true,
+    "WindowListManager": true,
+    "WindowManager": true,
+  },
+}
--- a/browser/components/extensions/ext-bookmarks.js
+++ b/browser/components/extensions/ext-bookmarks.js
@@ -1,16 +1,19 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/PlacesUtils.jsm");
 var Bookmarks = PlacesUtils.bookmarks;
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
-  EventManager,
   runSafe,
 } = ExtensionUtils;
 
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 
 function getTree(rootGuid, onlyChildren) {
   function convert(node, parent) {
@@ -35,21 +38,22 @@ function getTree(rootGuid, onlyChildren)
         treenode.children = node.children.map(child => convert(child, node));
       }
     }
 
     return treenode;
   }
 
   return PlacesUtils.promiseBookmarksTree(rootGuid, {
-    excludeItemsCallback: aItem => {
-      if (aItem.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR)
+    excludeItemsCallback: item => {
+      if (item.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR) {
         return true;
-      return aItem.annos &&
-             aItem.annos.find(a => a.name == PlacesUtils.EXCLUDE_FROM_BACKUP_ANNO);
+      }
+      return item.annos &&
+             item.annos.find(a => a.name == PlacesUtils.EXCLUDE_FROM_BACKUP_ANNO);
     },
   }).then(root => {
     if (onlyChildren) {
       let children = root.children || [];
       return children.map(child => convert(child, root));
     } else {
       // It seems like the array always just contains the root node.
       return [convert(root, null)];
@@ -163,24 +167,24 @@ extensions.registerPrivilegedAPI("bookma
         };
 
         try {
           Bookmarks.insert(info).then(result => {
             if (callback) {
               runSafe(context, callback, convert(result));
             }
           }, failure);
-        } catch(e) {
+        } catch (e) {
           failure(e);
         }
       },
 
       move: function(id, destination, callback) {
         let info = {
-          guid: id
+          guid: id,
         };
 
         if ("parentId" in destination) {
           info.parentGuid = destination.parentId;
         }
         if ("index" in destination) {
           info.index = destination.index;
         }
@@ -199,17 +203,17 @@ extensions.registerPrivilegedAPI("bookma
           }, failure);
         } catch (e) {
           failure(e);
         }
       },
 
       update: function(id, changes, callback) {
         let info = {
-          guid: id
+          guid: id,
         };
 
         if ("title" in changes) {
           info.title = changes.title;
         }
         if ("url" in changes) {
           info.url = changes.url;
         }
@@ -228,17 +232,17 @@ extensions.registerPrivilegedAPI("bookma
           }, failure);
         } catch (e) {
           failure(e);
         }
       },
 
       remove: function(id, callback) {
         let info = {
-          guid: id
+          guid: id,
         };
 
         let failure = reason => {
           if (callback) {
             runSafe(context, callback, null);
           }
         };
 
@@ -247,14 +251,14 @@ extensions.registerPrivilegedAPI("bookma
             if (callback) {
               // The API doesn't give you the old bookmark at the moment
               runSafe(context, callback);
             }
           }, failure);
         } catch (e) {
           failure(e);
         }
-      }
-    }
+      },
+    },
   };
 });
 
 
--- a/browser/components/extensions/ext-browserAction.js
+++ b/browser/components/extensions/ext-browserAction.js
@@ -5,34 +5,29 @@
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
                                   "resource:///modules/CustomizableUI.jsm");
 
 Cu.import("resource://devtools/shared/event-emitter.js");
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
   EventManager,
-  DefaultWeakMap,
   runSafe,
 } = ExtensionUtils;
 
 // WeakMap[Extension -> BrowserAction]
 var browserActionMap = new WeakMap();
 
-function browserActionOf(extension)
-{
+function browserActionOf(extension) {
   return browserActionMap.get(extension);
 }
 
-var nextActionId = 0;
-
 // Responsible for the browser_action section of the manifest as well
 // as the associated popup.
-function BrowserAction(options, extension)
-{
+function BrowserAction(options, extension) {
   this.extension = extension;
   this.id = makeWidgetId(extension.id) + "-browser-action";
   this.widget = null;
 
   this.tabManager = TabManager.for(extension);
 
   let title = extension.localize(options.default_title || "");
   let popup = extension.localize(options.default_popup || "");
@@ -68,33 +63,33 @@ BrowserAction.prototype = {
         node.id = this.id;
         node.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional badged-button");
         node.setAttribute("constrain-size", "true");
 
         this.updateButton(node, this.defaults);
 
         let tabbrowser = document.defaultView.gBrowser;
 
-        node.addEventListener("command", event => {
+        node.addEventListener("command", event => { // eslint-disable-line mozilla/balanced-listeners
           let tab = tabbrowser.selectedTab;
           let popup = this.getProperty(tab, "popup");
           this.tabManager.addActiveTabPermission(tab);
           if (popup) {
             this.togglePopup(node, popup);
           } else {
             this.emit("click");
           }
         });
 
         return node;
       },
     });
 
-    this.tabContext.on("tab-select",
-                       (evt, tab) => { this.updateWindow(tab.ownerDocument.defaultView); })
+    this.tabContext.on("tab-select", // eslint-disable-line mozilla/balanced-listeners
+                       (evt, tab) => { this.updateWindow(tab.ownerDocument.defaultView); });
 
     this.widget = widget;
   },
 
   togglePopup(node, popupResource) {
     openPanel(node, popupResource, this.extension);
   },
 
@@ -119,17 +114,17 @@ BrowserAction.prototype = {
 
     if (tabData.enabled) {
       node.removeAttribute("disabled");
     } else {
       node.setAttribute("disabled", "true");
     }
 
     let badgeNode = node.ownerDocument.getAnonymousElementByAttribute(node,
-                                        'class', 'toolbarbutton-badge');
+                                        "class", "toolbarbutton-badge");
     if (badgeNode) {
       let color = tabData.badgeBackgroundColor;
       if (Array.isArray(color)) {
         color = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
       }
       badgeNode.style.backgroundColor = color || "";
     }
 
@@ -185,28 +180,30 @@ BrowserAction.prototype = {
   },
 
   shutdown() {
     this.tabContext.shutdown();
     CustomizableUI.destroyWidget(this.id);
   },
 };
 
+/* eslint-disable mozilla/balanced-listeners */
 extensions.on("manifest_browser_action", (type, directive, extension, manifest) => {
   let browserAction = new BrowserAction(manifest.browser_action, extension);
   browserAction.build();
   browserActionMap.set(extension, browserAction);
 });
 
 extensions.on("shutdown", (type, extension) => {
   if (browserActionMap.has(extension)) {
     browserActionMap.get(extension).shutdown();
     browserActionMap.delete(extension);
   }
 });
+/* eslint-enable mozilla/balanced-listeners */
 
 extensions.registerAPI((extension, context) => {
   return {
     browserAction: {
       onClicked: new EventManager(context, "browserAction.onClicked", fire => {
         let listener = () => {
           let tab = TabManager.activeTab;
           fire(TabManager.convert(extension, tab));
@@ -268,21 +265,20 @@ extensions.registerAPI((extension, conte
 
       getPopup: function(details, callback) {
         let tab = details.tabId ? TabManager.getTab(details.tabId) : null;
         let popup = browserActionOf(extension).getProperty(tab, "popup");
         runSafe(context, callback, popup);
       },
 
       setBadgeBackgroundColor: function(details) {
-        let color = details.color;
         let tab = details.tabId ? TabManager.getTab(details.tabId) : null;
         browserActionOf(extension).setProperty(tab, "badgeBackgroundColor", details.color);
       },
 
       getBadgeBackgroundColor: function(details, callback) {
         let tab = details.tabId ? TabManager.getTab(details.tabId) : null;
         let color = browserActionOf(extension).getProperty(tab, "badgeBackgroundColor");
         runSafe(context, callback, color);
       },
-    }
+    },
   };
 });
--- a/browser/components/extensions/ext-contextMenus.js
+++ b/browser/components/extensions/ext-contextMenus.js
@@ -1,36 +1,34 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 Cu.import("resource://gre/modules/MatchPattern.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 var {
   EventManager,
-  contextMenuItems,
-  runSafe
+  runSafe,
 } = ExtensionUtils;
 
 
 // Map[Extension -> Map[ID -> MenuItem]]
 // Note: we want to enumerate all the menu items so
 // this cannot be a weak map.
 var contextMenuMap = new Map();
 
 // Not really used yet, will be used for event pages.
 var onClickedCallbacksMap = new WeakMap();
 
 // If id is not specified for an item we use an integer.
 var nextID = 0;
 
-function contextMenuObserver(subject, topic, data) {
-  subject = subject.wrappedJSObject;
-  menuBuilder.build(subject);
-}
-
 // When a new contextMenu is opened, this function is called and
 // we populate the |xulMenu| with all the items from extensions
 // to be displayed. We always clear all the items again when
 // popuphidden fires. Since most of the info we need is already
 // calculated in nsContextMenu.jsm we simple reuse its flags here.
 // For remote processes there is a gContextMenuContentData where all
 // the important info is stored from the child process. We get
 // this data in |contextData|.
@@ -77,17 +75,17 @@ var menuBuilder = {
             // If parentId is set we have to look up its parent
             // and appened to its menupopup.
             let parentElement = parentMap.get(parentId);
             parentElement.appendChild(element);
           } else {
             topLevelItems.add(element);
           }
 
-          element.addEventListener("command", event => {
+          element.addEventListener("command", event => { // eslint-disable-line mozilla/balanced-listeners
             item.tabManager.addActiveTabPermission();
             if (item.onclick) {
               let clickData = item.getClickData(contextData, event);
               runSafe(item.extContext, item.onclick, clickData);
             }
           });
         }
       }
@@ -119,68 +117,72 @@ var menuBuilder = {
     for (let item of this._itemsToCleanUp) {
       target.removeChild(item);
     }
     // Let's detach the top level items.
     this._itemsToCleanUp.clear();
   },
 
   _itemsToCleanUp: new Set(),
+};
+
+function contextMenuObserver(subject, topic, data) {
+  subject = subject.wrappedJSObject;
+  menuBuilder.build(subject);
 }
 
 function getContexts(contextData) {
   let contexts = new Set(["all"]);
 
   contexts.add("page");
 
   if (contextData.inFrame) {
-    contexts.add("frame")
+    contexts.add("frame");
   }
 
   if (contextData.isTextSelected) {
-    contexts.add("selection")
+    contexts.add("selection");
   }
 
   if (contextData.onLink) {
-    contexts.add("link")
+    contexts.add("link");
   }
 
   if (contextData.onEditableArea) {
-    contexts.add("editable")
+    contexts.add("editable");
   }
 
   if (contextData.onImage) {
-    contexts.add("image")
+    contexts.add("image");
   }
 
   if (contextData.onVideo) {
-    contexts.add("video")
+    contexts.add("video");
   }
 
   if (contextData.onAudio) {
-    contexts.add("audio")
+    contexts.add("audio");
   }
 
   return contexts;
 }
 
-function MenuItem(extension, extContext, createProperties)
-{
+function MenuItem(extension, extContext, createProperties) {
   this.extension = extension;
   this.extContext = extContext;
 
   this.tabManager = TabManager.for(extension);
 
   this.init(createProperties);
 }
 
 MenuItem.prototype = {
   // init is called from the MenuItem ctor and from update. The |update|
   // flag is for the later case.
-  init(createProperties, update=false) {
+  init(createProperties, update = false) {
     let item = this;
     // return true if the prop was set on |this|
     function parseProp(propName, defaultValue = null) {
       if (propName in createProperties) {
         item[propName] = createProperties[propName];
         return true;
       } else if (!update && defaultValue !== null) {
         item[propName] = defaultValue;
@@ -209,18 +211,18 @@ MenuItem.prototype = {
     if ("onclick" in createProperties.wrappedJSObject) {
       this.onclick = createProperties.wrappedJSObject.onclick;
     }
 
     if (parseProp("parentId")) {
       let found = false;
       let menuMap = contextMenuMap.get(this.extension);
       if (menuMap.has(this.parentId)) {
-          found = true;
-          menuMap.get(this.parentId).isMenu = true;
+        found = true;
+        menuMap.get(this.parentId).isMenu = true;
       }
       if (!found) {
         throw new Error("MenuItem with this parentId not found");
       }
     } else {
       this.parentId = undefined;
     }
 
@@ -260,17 +262,17 @@ MenuItem.prototype = {
       }
       let rv = hasAncestorWithId(parent, id);
       checked.set(item, rv);
       return rv;
     }
 
     let toRemove = new Set();
     toRemove.add(this.id);
-    for (let [id, item] of menuMap) {
+    for (let [, item] of menuMap) {
       if (hasAncestorWithId(item, this.id)) {
         toRemove.add(item.id);
       }
     }
     for (let id of toRemove) {
       menuMap.delete(id);
     }
   },
@@ -283,17 +285,17 @@ MenuItem.prototype = {
     if (contextData.onAudio) {
       mediaType = "audio";
     }
     if (contextData.onImage) {
       mediaType = "image";
     }
 
     let clickData = {
-      menuItemId: this.id
+      menuItemId: this.id,
     };
 
     function setIfDefined(argName, value) {
       if (value) {
         clickData[argName] = value;
       }
     }
 
@@ -313,17 +315,17 @@ MenuItem.prototype = {
   },
 
   enabledForContext(contextData) {
     let enabled = false;
     let contexts = getContexts(contextData);
     for (let c of this.contexts) {
       if (contexts.has(c)) {
         enabled = true;
-        break
+        break;
       }
     }
     if (!enabled) {
       return false;
     }
 
     if (this.documentUrlMatchPattern &&
         !this.documentUrlMatchPattern.matches(contextData.documentURIObject)) {
@@ -337,32 +339,34 @@ MenuItem.prototype = {
       return false;
     }
 
     return true;
   },
 };
 
 var extCount = 0;
+/* eslint-disable mozilla/balanced-listeners */
 extensions.on("startup", (type, extension) => {
   contextMenuMap.set(extension, new Map());
   if (++extCount == 1) {
     Services.obs.addObserver(contextMenuObserver,
                              "on-build-contextmenu",
                              false);
   }
 });
 
 extensions.on("shutdown", (type, extension) => {
   contextMenuMap.delete(extension);
   if (--extCount == 0) {
     Services.obs.removeObserver(contextMenuObserver,
                                 "on-build-contextmenu");
   }
 });
+/* eslint-enable mozilla/balanced-listeners */
 
 extensions.registerPrivilegedAPI("contextMenus", (extension, context) => {
   return {
     contextMenus: {
       create: function(createProperties, callback) {
         let menuItem = new MenuItem(extension, context, createProperties);
         contextMenuMap.get(extension).set(menuItem.id, menuItem);
         if (callback) {
@@ -387,17 +391,17 @@ extensions.registerPrivilegedAPI("contex
           menuItem.remove();
         }
         if (callback) {
           runSafe(context, callback);
         }
       },
 
       removeAll: function(callback) {
-        for (let [id, menuItem] of contextMenuMap.get(extension)) {
+        for (let [, menuItem] of contextMenuMap.get(extension)) {
           menuItem.remove();
         }
         if (callback) {
           runSafe(context, callback);
         }
       },
 
       // TODO: implement this once event pages are ready.
--- a/browser/components/extensions/ext-pageAction.js
+++ b/browser/components/extensions/ext-pageAction.js
@@ -1,27 +1,25 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
   EventManager,
-  DefaultWeakMap,
   runSafe,
 } = ExtensionUtils;
 
 // WeakMap[Extension -> PageAction]
 var pageActionMap = new WeakMap();
 
 
 // Handles URL bar icons, including the |page_action| manifest entry
 // and associated API.
-function PageAction(options, extension)
-{
+function PageAction(options, extension) {
   this.extension = extension;
   this.id = makeWidgetId(extension.id) + "-page-action";
 
   this.tabManager = TabManager.for(extension);
 
   let title = extension.localize(options.default_title || "");
   let popup = extension.localize(options.default_popup || "");
   if (popup) {
@@ -34,17 +32,17 @@ function PageAction(options, extension)
     icon: IconDetails.normalize({ path: options.default_icon }, extension,
                                 null, true),
     popup: popup && extension.baseURI.resolve(popup),
   };
 
   this.tabContext = new TabContext(tab => Object.create(this.defaults),
                                    extension);
 
-  this.tabContext.on("location-change", this.handleLocationChange.bind(this));
+  this.tabContext.on("location-change", this.handleLocationChange.bind(this)); // eslint-disable-line mozilla/balanced-listeners
 
   // WeakMap[ChromeWindow -> <xul:image>]
   this.buttons = new WeakMap();
 
   EventEmitter.decorate(this);
 }
 
 PageAction.prototype = {
@@ -105,17 +103,17 @@ PageAction.prototype = {
   // container in the given window.
   addButton(window) {
     let document = window.document;
 
     let button = document.createElement("image");
     button.id = this.id;
     button.setAttribute("class", "urlbar-icon");
 
-    button.addEventListener("click", event => {
+    button.addEventListener("click", event => { // eslint-disable-line mozilla/balanced-listeners
       if (event.button == 0) {
         this.handleClick(window);
       }
     });
 
     document.getElementById("urlbar-icons").appendChild(button);
 
     return button;
@@ -168,27 +166,29 @@ PageAction.prototype = {
   },
 };
 
 PageAction.for = extension => {
   return pageActionMap.get(extension);
 };
 
 
+/* eslint-disable mozilla/balanced-listeners */
 extensions.on("manifest_page_action", (type, directive, extension, manifest) => {
   let pageAction = new PageAction(manifest.page_action, extension);
   pageActionMap.set(extension, pageAction);
 });
 
 extensions.on("shutdown", (type, extension) => {
   if (pageActionMap.has(extension)) {
     pageActionMap.get(extension).shutdown();
     pageActionMap.delete(extension);
   }
 });
+/* eslint-enable mozilla/balanced-listeners */
 
 
 extensions.registerAPI((extension, context) => {
   return {
     pageAction: {
       onClicked: new EventManager(context, "pageAction.onClicked", fire => {
         let listener = (evt, tab) => {
           fire(TabManager.convert(extension, tab));
@@ -239,11 +239,11 @@ extensions.registerAPI((extension, conte
         PageAction.for(extension).setProperty(tab, "popup", url);
       },
 
       getPopup(details, callback) {
         let tab = TabManager.getTab(details.tabId);
         let popup = PageAction.for(extension).getProperty(tab, "popup");
         runSafe(context, callback, popup);
       },
-    }
+    },
   };
 });
--- a/browser/components/extensions/ext-tabs.js
+++ b/browser/components/extensions/ext-tabs.js
@@ -1,57 +1,59 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
                                    "@mozilla.org/browser/aboutnewtab-service;1",
                                    "nsIAboutNewTabService");
 
 XPCOMUtils.defineLazyModuleGetter(this, "MatchPattern",
                                   "resource://gre/modules/MatchPattern.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 
+/* globals aboutNewTabService */
+
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 
 var {
   EventManager,
   ignoreEvent,
   runSafe,
 } = ExtensionUtils;
 
 // This function is pretty tightly tied to Extension.jsm.
 // Its job is to fill in the |tab| property of the sender.
-function getSender(context, target, sender)
-{
+function getSender(context, target, sender) {
   // The message was sent from a content script to a <browser> element.
   // We can just get the |tab| from |target|.
   if (target instanceof Ci.nsIDOMXULElement) {
     // The message came from a content script.
     let tabbrowser = target.ownerDocument.defaultView.gBrowser;
     if (!tabbrowser) {
       return;
     }
     let tab = tabbrowser.getTabForBrowser(target);
 
     sender.tab = TabManager.convert(context.extension, tab);
-  } else {
+  } else if ("tabId" in sender) {
     // The message came from an ExtensionPage. In that case, it should
     // include a tabId property (which is filled in by the page-open
     // listener below).
-    if ("tabId" in sender) {
-      sender.tab = TabManager.convert(context.extension, TabManager.getTab(sender.tabId));
-      delete sender.tabId;
-    }
+    sender.tab = TabManager.convert(context.extension, TabManager.getTab(sender.tabId));
+    delete sender.tabId;
   }
 }
 
 // WeakMap[ExtensionPage -> {tab, parentWindow}]
 var pageDataMap = new WeakMap();
 
+/* eslint-disable mozilla/balanced-listeners */
 // This listener fires whenever an extension page opens in a tab
 // (either initiated by the extension or the user). Its job is to fill
 // in some tab-specific details and keep data around about the
 // ExtensionPage.
 extensions.on("page-load", (type, page, params, sender, delegate) => {
   if (params.type == "tab" || params.type == "popup") {
     let browser = params.docShell.chromeEventHandler;
 
@@ -90,25 +92,25 @@ extensions.on("fill-browser-data", (type
   let tabId = TabManager.getBrowserId(browser);
   if (tabId == -1) {
     result.cancel = true;
     return;
   }
 
   data.tabId = tabId;
 });
+/* eslint-enable mozilla/balanced-listeners */
 
-global.currentWindow = function(context)
-{
+global.currentWindow = function(context) {
   let pageData = pageDataMap.get(context);
   if (pageData) {
     return pageData.parentWindow;
   }
   return WindowManager.topWindow;
-}
+};
 
 // TODO: activeTab permission
 
 extensions.registerAPI((extension, context) => {
   let self = {
     tabs: {
       onActivated: new WindowEventManager(context, "tabs.onActivated", "TabSelect", (fire, event) => {
         let tab = event.originalTarget;
@@ -206,17 +208,17 @@ extensions.registerAPI((extension, conte
             if (!webProgress.isTopLevel) {
               return;
             }
             let gBrowser = browser.ownerDocument.defaultView.gBrowser;
             let tab = gBrowser.getTabForBrowser(browser);
             let tabId = TabManager.getId(tab);
             let [needed, changeInfo] = sanitize(extension, {
               status: webProgress.isLoadingDocument ? "loading" : "complete",
-              url: locationURI.spec
+              url: locationURI.spec,
             });
             if (needed) {
               fire(tabId, changeInfo, TabManager.convert(extension, tab));
             }
           },
         };
 
         AllWindowEvents.addListener("progress", progressListener);
@@ -384,17 +386,17 @@ extensions.registerAPI((extension, conte
           tab = TabManager.convert(extension, TabManager.getTab(context.tabId));
         }
         runSafe(context, callback, tab);
       },
 
       getAllInWindow: function(...args) {
         let window, callback;
         if (args.length == 1) {
-          callbacks = args[0];
+          callback = args[0];
         } else {
           window = WindowManager.getWindow(args[0]);
           callback = args[1];
         }
 
         if (!window) {
           window = WindowManager.topWindow;
         }
@@ -430,20 +432,18 @@ extensions.registerAPI((extension, conte
             return false;
           }
 
           if ("windowId" in queryInfo) {
             if (queryInfo.windowId == WindowManager.WINDOW_ID_CURRENT) {
               if (currentWindow(context) != window) {
                 return false;
               }
-            } else {
-              if (queryInfo.windowId != tab.windowId) {
-                return false;
-              }
+            } else if (queryInfo.windowId != tab.windowId) {
+              return false;
             }
           }
 
           if ("currentWindow" in queryInfo) {
             let eq = window == currentWindow(context);
             if (queryInfo.currentWindow != eq) {
               return false;
             }
@@ -490,17 +490,17 @@ extensions.registerAPI((extension, conte
           // If we have the "activeTab" permission for this tab, ignore
           // the host whitelist.
           options.matchesHost = ["<all_urls>"];
         } else {
           options.matchesHost = extension.whiteListedHosts.serialize();
         }
 
         if (details.code) {
-          options[kind + 'Code'] = details.code;
+          options[kind + "Code"] = details.code;
         }
         if (details.file) {
           let url = context.uri.resolve(details.file);
           if (extension.isExtensionURL(url)) {
             // We should really set |lastError| here, and go straight to
             // the callback, but we don't have |lastError| yet.
             options[kind].push(url);
           }
@@ -517,27 +517,27 @@ extensions.registerAPI((extension, conte
         mm.sendAsyncMessage("Extension:Execute",
                             {extensionId: extension.id, options});
 
         // TODO: Call the callback with the result (which is what???).
       },
 
       executeScript: function(...args) {
         if (args.length == 1) {
-          self.tabs._execute(undefined, args[0], 'js', undefined);
+          self.tabs._execute(undefined, args[0], "js", undefined);
         } else {
-          self.tabs._execute(args[0], args[1], 'js', args[2]);
+          self.tabs._execute(args[0], args[1], "js", args[2]);
         }
       },
 
-      insertCss: function(tabId, details, callback) {
+      insertCss: function(...args) {
         if (args.length == 1) {
-          self.tabs._execute(undefined, args[0], 'css', undefined);
+          self.tabs._execute(undefined, args[0], "css", undefined);
         } else {
-          self.tabs._execute(args[0], args[1], 'css', args[2]);
+          self.tabs._execute(args[0], args[1], "css", args[2]);
         }
       },
 
       connect: function(tabId, connectInfo) {
         let tab = TabManager.getTab(tabId);
         let mm = tab.linkedBrowser.messageManager;
 
         let name = connectInfo.name || "";
--- a/browser/components/extensions/ext-utils.js
+++ b/browser/components/extensions/ext-utils.js
@@ -26,17 +26,17 @@ global.IconDetails = {
   // with icon size as key and icon URL as value.
   //
   // If a context is specified (function is called from an extension):
   // Throws an error if an invalid icon size was provided or the
   // extension is not allowed to load the specified resources.
   //
   // If no context is specified, instead of throwing an error, this
   // function simply logs a warning message.
-  normalize(details, extension, context=null, localize=false) {
+  normalize(details, extension, context = null, localize = false) {
     let result = {};
 
     try {
       if (details.imageData) {
         let imageData = details.imageData;
 
         if (imageData instanceof Cu.getGlobalForObject(imageData).ImageData) {
           imageData = {"19": imageData};
@@ -107,24 +107,24 @@ global.IconDetails = {
   convertImageDataToPNG(imageData, context) {
     let document = context.contentWindow.document;
     let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
     canvas.width = imageData.width;
     canvas.height = imageData.height;
     canvas.getContext("2d").putImageData(imageData, 0, 0);
 
     return canvas.toDataURL("image/png");
-  }
+  },
 };
 
 global.makeWidgetId = id => {
   id = id.toLowerCase();
   // FIXME: This allows for collisions.
   return id.replace(/[^a-z0-9_-]/g, "_");
-}
+};
 
 // Open a panel anchored to the given node, containing a browser opened
 // to the given URL, owned by the given extension. If |popupURL| is not
 // an absolute URL, it is resolved relative to the given extension's
 // base URL.
 global.openPanel = (node, popupURL, extension) => {
   let document = node.ownerDocument;
 
@@ -156,24 +156,26 @@ global.openPanel = (node, popupURL, exte
   const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
   let browser = document.createElementNS(XUL_NS, "browser");
   browser.setAttribute("type", "content");
   browser.setAttribute("disableglobalhistory", "true");
   panel.appendChild(browser);
 
   let titleChangedListener = () => {
     panel.setAttribute("aria-label", browser.contentTitle);
-  }
+  };
 
   let context;
-  panel.addEventListener("popuphidden", () => {
+  let popuphidden = () => {
+    panel.removeEventListener("popuphidden", popuphidden);
     browser.removeEventListener("DOMTitleChanged", titleChangedListener, true);
     context.unload();
     panel.remove();
-  });
+  };
+  panel.addEventListener("popuphidden", popuphidden);
 
   let loadListener = () => {
     panel.removeEventListener("load", loadListener);
 
     context = new ExtensionPage(extension, {
       type: "popup",
       contentWindow: browser.contentWindow,
       uri: popupURI,
@@ -211,31 +213,31 @@ global.openPanel = (node, popupURL, exte
     };
     browser.addEventListener("load", contentLoadListener, true);
 
     browser.addEventListener("DOMTitleChanged", titleChangedListener, true);
   };
   panel.addEventListener("load", loadListener);
 
   return panel;
-}
+};
 
 // Manages tab-specific context data, and dispatching tab select events
 // across all windows.
 global.TabContext = function TabContext(getDefaults, extension) {
   this.extension = extension;
   this.getDefaults = getDefaults;
 
   this.tabData = new WeakMap();
 
   AllWindowEvents.addListener("progress", this);
   AllWindowEvents.addListener("TabSelect", this);
 
   EventEmitter.decorate(this);
-}
+};
 
 TabContext.prototype = {
   get(tab) {
     if (!this.tabData.has(tab)) {
       this.tabData.set(tab, this.getDefaults(tab));
     }
 
     return this.tabData.get(tab);
@@ -306,17 +308,16 @@ ExtensionTabManager.prototype = {
   },
 
   hasTabPermission(tab) {
     return this.extension.hasPermission("tabs") || this.hasActiveTabPermission(tab);
   },
 
   convert(tab) {
     let window = tab.ownerDocument.defaultView;
-    let windowActive = window == WindowManager.topWindow;
 
     let result = {
       id: TabManager.getId(tab),
       index: tab._tPos,
       windowId: WindowManager.getId(window),
       selected: tab.selected,
       highlighted: tab.selected,
       active: tab.selected,
@@ -406,26 +407,28 @@ global.TabManager = {
   },
 };
 
 // WeakMap[Extension -> ExtensionTabManager]
 let tabManagers = new WeakMap();
 
 // Returns the extension-specific tab manager for the given extension, or
 // creates one if it doesn't already exist.
-TabManager.for = function (extension) {
+TabManager.for = function(extension) {
   if (!tabManagers.has(extension)) {
     tabManagers.set(extension, new ExtensionTabManager(extension));
   }
   return tabManagers.get(extension);
 };
 
+/* eslint-disable mozilla/balanced-listeners */
 extensions.on("shutdown", (type, extension) => {
   tabManagers.delete(extension);
 });
+/* eslint-enable mozilla/balanced-listeners */
 
 // Manages mapping between XUL windows and extension window IDs.
 global.WindowManager = {
   _windows: new WeakMap(),
   _nextId: 0,
 
   WINDOW_ID_NONE: -1,
   WINDOW_ID_CURRENT: -2,
@@ -484,17 +487,17 @@ global.WindowManager = {
 // considered open when the "load" event fires on it. A window is
 // closed when a "domwindowclosed" notification fires for it.
 global.WindowListManager = {
   _openListeners: new Set(),
   _closeListeners: new Set(),
 
   // Returns an iterator for all browser windows. Unless |includeIncomplete| is
   // true, only fully-loaded windows are returned.
-  *browserWindows(includeIncomplete = false) {
+  * browserWindows(includeIncomplete = false) {
     // The window type parameter is only available once the window's document
     // element has been created. This means that, when looking for incomplete
     // browser windows, we need to ignore the type entirely for windows which
     // haven't finished loading, since we would otherwise skip browser windows
     // in their early loading stages.
     // This is particularly important given that the "domwindowcreated" event
     // fires for browser windows when they're in that in-between state, and just
     // before we register our own "domwindowcreated" listener.
@@ -649,20 +652,19 @@ global.AllWindowEvents = {
     }
   },
 };
 
 AllWindowEvents.openListener = AllWindowEvents.openListener.bind(AllWindowEvents);
 
 // Subclass of EventManager where we just need to call
 // add/removeEventListener on each XUL window.
-global.WindowEventManager = function(context, name, event, listener)
-{
+global.WindowEventManager = function(context, name, event, listener) {
   EventManager.call(this, context, name, fire => {
     let listener2 = (...args) => listener(fire, ...args);
     AllWindowEvents.addListener(event, listener2);
     return () => {
       AllWindowEvents.removeListener(event, listener2);
-    }
+    };
   });
-}
+};
 
 WindowEventManager.prototype = Object.create(EventManager.prototype);
--- a/browser/components/extensions/ext-windows.js
+++ b/browser/components/extensions/ext-windows.js
@@ -1,12 +1,18 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
                                    "@mozilla.org/browser/aboutnewtab-service;1",
                                    "nsIAboutNewTabService");
 
+/* globals aboutNewTabService */
+
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
   EventManager,
   runSafe,
 } = ExtensionUtils;
 
 extensions.registerAPI((extension, context) => {
   return {
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/.eslintrc
@@ -0,0 +1,43 @@
+{
+  "extends": "../../.eslintrc",
+
+  "globals": {
+    // DOM window globals
+    "CustomEvent": false,
+    "document": false,
+    "ImageData": false,
+    "MouseEvent": false,
+    "window": false,
+    "XMLHttpRequest": false,
+
+    "gBrowser": false,
+
+    "sendAsyncMessage": false,
+
+    "NetUtil": true,
+    "XPCOMUtils": true,
+    "Task": true,
+
+    "browser": false,
+
+    // Test harness globals
+    "add_task": false,
+    "BrowserTestUtils": false,
+    "ContentTask": false,
+    "EventUtils": false,
+    "ExtensionTestUtils": false,
+    "info": false,
+    "is": false,
+    "ok": false,
+    "registerCleanupFunction": false,
+    "SimpleTest": false,
+    "SpecialPowers": false,
+    "waitForFocus": false,
+
+    "clickBrowserAction": true,
+    "clickPageAction": true,
+    "CustomizableUI": true,
+    "focusWindow": true,
+    "makeWidgetId": true,
+  }
+}
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js
@@ -1,26 +1,25 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testTabSwitchContext() {
-
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {
         "default_icon": "default.png",
         "default_popup": "default.html",
         "default_title": "Default Title",
       },
       "permissions": ["tabs"],
     },
 
-    background: function () {
-      var details = [
+    background: function() {
+      let details = [
         { "icon": browser.runtime.getURL("default.png"),
           "popup": browser.runtime.getURL("default.html"),
           "title": "Default Title",
           "badge": "",
           "badgeBackgroundColor": null },
         { "icon": browser.runtime.getURL("1.png"),
           "popup": browser.runtime.getURL("default.html"),
           "title": "Default Title",
@@ -46,19 +45,20 @@ add_task(function* testTabSwitchContext(
           "disabled": false },
         { "icon": browser.runtime.getURL("default-2.png"),
           "popup": browser.runtime.getURL("default-2.html"),
           "title": "Default Title 2",
           "badge": "d2",
           "badgeBackgroundColor": [0, 0xff, 0] },
       ];
 
-      var tabs = [];
+      let tabs = [];
 
-      var tests = [
+      let expectDefaults;
+      let tests = [
         expect => {
           browser.test.log("Initial state, expect default properties.");
           expectDefaults(details[0]).then(() => {
             expect(details[0]);
           });
         },
         expect => {
           browser.test.log("Change the icon in the current tab. Expect default properties excluding the icon.");
@@ -73,17 +73,17 @@ add_task(function* testTabSwitchContext(
             tabs.push(tab.id);
             expectDefaults(details[0]).then(() => {
               expect(details[0]);
             });
           });
         },
         expect => {
           browser.test.log("Change properties. Expect new properties.");
-          var tabId = tabs[1];
+          let tabId = tabs[1];
           browser.browserAction.setIcon({ tabId, path: "2.png" });
           browser.browserAction.setPopup({ tabId, popup: "2.html" });
           browser.browserAction.setTitle({ tabId, title: "Title 2" });
           browser.browserAction.setBadgeText({ tabId, text: "2" });
           browser.browserAction.setBadgeBackgroundColor({ tabId, color: [0xff, 0, 0] });
           browser.browserAction.disable(tabId);
 
           expectDefaults(details[0]).then(() => {
@@ -186,24 +186,24 @@ add_task(function* testTabSwitchContext(
                                 "expected value from getBadge");
 
           browser.test.assertEq(String(expecting.badgeBackgroundColor),
                                 String(details.badgeBackgroundColor),
                                 "expected value from getBadgeBackgroundColor");
         });
       }
 
-      function expectDefaults(expecting) {
+      expectDefaults = expecting => {
         return checkDetails(expecting);
-      }
+      };
 
       // Runs the next test in the `tests` array, checks the results,
       // and passes control back to the outer test scope.
       function nextTest() {
-        var test = tests.shift();
+        let test = tests.shift();
 
         test(expecting => {
           // Check that the API returns the expected values, and then
           // run the next test.
           new Promise(resolve => {
             return browser.tabs.query({ active: true, currentWindow: true }, resolve);
           }).then(tabs => {
             return checkDetails(expecting, tabs[0].id);
@@ -242,35 +242,35 @@ add_task(function* testTabSwitchContext(
     is(button.getAttribute("tooltiptext"), details.title, "image title is correct");
     is(button.getAttribute("label"), details.title, "image label is correct");
     is(button.getAttribute("aria-label"), details.title, "image aria-label is correct");
     is(button.getAttribute("badge"), details.badge, "badge text is correct");
     is(button.getAttribute("disabled") == "true", Boolean(details.disabled), "disabled state is correct");
 
     if (details.badge && details.badgeBackgroundColor) {
       let badge = button.ownerDocument.getAnonymousElementByAttribute(
-        button, 'class', 'toolbarbutton-badge');
+        button, "class", "toolbarbutton-badge");
 
       let badgeColor = window.getComputedStyle(badge).backgroundColor;
       let color = details.badgeBackgroundColor;
-      let expectedColor = `rgb(${color[0]}, ${color[1]}, ${color[2]})`
+      let expectedColor = `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
 
       is(badgeColor, expectedColor, "badge color is correct");
     }
 
 
     // TODO: Popup URL.
   }
 
   let awaitFinish = new Promise(resolve => {
     extension.onMessage("nextTest", (expecting, testsRemaining) => {
       checkDetails(expecting);
 
       if (testsRemaining) {
-        extension.sendMessage("runNextTest")
+        extension.sendMessage("runNextTest");
       } else {
         resolve();
       }
     });
   });
 
   yield extension.startup();
 
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_disabled.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_disabled.js
@@ -1,21 +1,20 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testDisabled() {
-
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "browser_action": {}
+      "browser_action": {},
     },
 
-    background: function () {
-      var clicked = false;
+    background: function() {
+      let clicked = false;
 
       browser.browserAction.onClicked.addListener(() => {
         browser.test.log("Got click event");
         clicked = true;
       });
 
       browser.test.onMessage.addListener((msg, expectClick) => {
         if (msg == "enable") {
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_pageAction_icon.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_pageAction_icon.js
@@ -3,37 +3,38 @@
 "use strict";
 
 // Test that various combinations of icon details specs, for both paths
 // and ImageData objects, result in the correct image being displayed in
 // all display resolutions.
 add_task(function* testDetailsObjects() {
   function background() {
     function getImageData(color) {
-      var canvas = document.createElement("canvas");
+      let canvas = document.createElement("canvas");
       canvas.width = 2;
       canvas.height = 2;
-      var canvasContext = canvas.getContext("2d");
+      let canvasContext = canvas.getContext("2d");
 
       canvasContext.clearRect(0, 0, canvas.width, canvas.height);
       canvasContext.fillStyle = color;
       canvasContext.fillRect(0, 0, 1, 1);
 
       return {
         url: canvas.toDataURL("image/png"),
         imageData: canvasContext.getImageData(0, 0, canvas.width, canvas.height),
       };
     }
 
-    var imageData = {
+    let imageData = {
       red: getImageData("red"),
       green: getImageData("green"),
     };
 
-    var iconDetails = [
+    /* eslint-disable comma-dangle, indent */
+    let iconDetails = [
       // Only paths.
       { details: { "path": "a.png" },
         resolutions: {
           "1": browser.runtime.getURL("data/a.png"),
           "2": browser.runtime.getURL("data/a.png"), } },
       { details: { "path": "/a.png" },
         resolutions: {
           "1": browser.runtime.getURL("a.png"),
@@ -124,28 +125,28 @@ add_task(function* testDetailsObjects() 
         resolutions: {
           "1": browser.runtime.getURL("data/18.png"),
           "2": browser.runtime.getURL("data/48.png"), } },
     ];
 
     // Allow serializing ImageData objects for logging.
     ImageData.prototype.toJSON = () => "<ImageData>";
 
-    var tabId;
+    let tabId;
 
     browser.test.onMessage.addListener((msg, test) => {
       if (msg != "setIcon") {
         browser.test.fail("expecting 'setIcon' message");
       }
 
-      var details = iconDetails[test.index];
-      var expectedURL = details.resolutions[test.resolution];
+      let details = iconDetails[test.index];
+      let expectedURL = details.resolutions[test.resolution];
 
-      var detailString = JSON.stringify(details);
-      browser.test.log(`Setting browerAction/pageAction to ${detailString} expecting URL ${expectedURL}`)
+      let detailString = JSON.stringify(details);
+      browser.test.log(`Setting browerAction/pageAction to ${detailString} expecting URL ${expectedURL}`);
 
       browser.browserAction.setIcon(Object.assign({tabId}, details.details));
       browser.pageAction.setIcon(Object.assign({tabId}, details.details));
 
       browser.test.sendMessage("imageURL", expectedURL);
     });
 
     // Generate a list of tests and resolutions to send back to the test
@@ -153,19 +154,19 @@ add_task(function* testDetailsObjects() 
     //
     // This process is a bit convoluted, because the outer test context needs
     // to handle checking the button nodes and changing the screen resolution,
     // but it can't pass us icon definitions with ImageData objects. This
     // shouldn't be a problem, since structured clones should handle ImageData
     // objects without issue. Unfortunately, |cloneInto| implements a slightly
     // different algorithm than we use in web APIs, and does not handle them
     // correctly.
-    var tests = [];
-    for (var [idx, icon] of iconDetails.entries()) {
-      for (var res of Object.keys(icon.resolutions)) {
+    let tests = [];
+    for (let [idx, icon] of iconDetails.entries()) {
+      for (let res of Object.keys(icon.resolutions)) {
         tests.push({ index: idx, resolution: Number(res) });
       }
     }
 
     // Sort by resolution, so we don't needlessly switch back and forth
     // between each test.
     tests.sort(test => test.resolution);
 
@@ -216,45 +217,44 @@ add_task(function* testDetailsObjects() 
     let pageActionImage = document.getElementById(pageActionId);
     is(pageActionImage.src, imageURL, "page action has the correct image");
   }
 
   yield extension.unload();
 });
 
 // Test that an error is thrown when providing invalid icon sizes
-add_task(function *testInvalidIconSizes() {
-
+add_task(function* testInvalidIconSizes() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {},
       "page_action": {},
     },
 
-    background: function () {
+    background: function() {
       browser.tabs.query({ active: true, currentWindow: true }, tabs => {
-        var tabId = tabs[0].id;
+        let tabId = tabs[0].id;
 
-        for (var api of ["pageAction", "browserAction"]) {
+        for (let api of ["pageAction", "browserAction"]) {
           // helper function to run setIcon and check if it fails
           let assertSetIconThrows = function(detail, error, message) {
             try {
               detail.tabId = tabId;
               browser[api].setIcon(detail);
 
               browser.test.fail("Expected an error on invalid icon size.");
               browser.test.notifyFail("setIcon with invalid icon size");
               return;
             } catch (e) {
               browser.test.succeed("setIcon with invalid icon size");
             }
-          }
+          };
 
           // test invalid icon size inputs
-          for (var type of ["path", "imageData"]) {
+          for (let type of ["path", "imageData"]) {
             assertSetIconThrows({ [type]: { "abcdef": "test.png" } });
             assertSetIconThrows({ [type]: { "48px": "test.png" } });
             assertSetIconThrows({ [type]: { "20.5": "test.png" } });
             assertSetIconThrows({ [type]: { "5.0": "test.png" } });
             assertSetIconThrows({ [type]: { "-300": "test.png" } });
             assertSetIconThrows({ [type]: {
               "abc": "test.png",
               "5": "test.png"
@@ -273,17 +273,17 @@ add_task(function *testInvalidIconSizes(
   yield Promise.all([extension.startup(), extension.awaitFinish("setIcon with invalid icon size")]);
 
   yield extension.unload();
 });
 
 
 // Test that default icon details in the manifest.json file are handled
 // correctly.
-add_task(function *testDefaultDetails() {
+add_task(function* testDefaultDetails() {
   // TODO: Test localized variants.
   let icons = [
     "foo/bar.png",
     "/foo/bar.png",
     { "19": "foo/bar.png" },
     { "38": "foo/bar.png" },
     { "19": "foo/bar.png", "38": "baz/quux.png" },
   ];
@@ -292,19 +292,19 @@ add_task(function *testDefaultDetails() 
 
   for (let icon of icons) {
     let extension = ExtensionTestUtils.loadExtension({
       manifest: {
         "browser_action": { "default_icon": icon },
         "page_action": { "default_icon": icon },
       },
 
-      background: function () {
+      background: function() {
         browser.tabs.query({ active: true, currentWindow: true }, tabs => {
-          var tabId = tabs[0].id;
+          let tabId = tabs[0].id;
 
           browser.pageAction.show(tabId);
           browser.test.sendMessage("ready");
         });
       }
     });
 
     yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
@@ -327,34 +327,33 @@ add_task(function *testDefaultDetails() 
     let node = document.getElementById(pageActionId);
     is(node, undefined, "pageAction image removed from document");
   }
 });
 
 
 // Check that attempts to load a privileged URL as an icon image fail.
 add_task(function* testSecureURLsDenied() {
-
   // Test URLs passed to setIcon.
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {},
       "page_action": {},
     },
 
-    background: function () {
+    background: function() {
       browser.tabs.query({ active: true, currentWindow: true }, tabs => {
-        var tabId = tabs[0].id;
+        let tabId = tabs[0].id;
 
-        var urls = ["chrome://browser/content/browser.xul",
+        let urls = ["chrome://browser/content/browser.xul",
                     "javascript:true"];
 
-        for (var url of urls) {
-          for (var api of ["pageAction", "browserAction"]) {
+        for (let url of urls) {
+          for (let api of ["pageAction", "browserAction"]) {
             try {
               browser[api].setIcon({tabId, path: url});
 
               browser.test.fail(`Load of '${url}' succeeded. Expected failure.`);
               browser.test.notifyFail("setIcon security tests");
               return;
             } catch (e) {
               // We can't actually inspect the error here, since the
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js
@@ -15,38 +15,39 @@ function promisePopupShown(popup) {
     }
   });
 }
 
 add_task(function* testPageActionPopup() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "background": {
-        "page": "data/background.html"
+        "page": "data/background.html",
       },
       "browser_action": {
-        "default_popup": "popup-a.html"
-      }
+        "default_popup": "popup-a.html",
+      },
     },
 
     files: {
       "popup-a.html": `<script src="popup-a.js"></script>`,
       "popup-a.js": function() {
         browser.runtime.sendMessage("from-popup-a");
       },
 
       "data/popup-b.html": `<script src="popup-b.js"></script>`,
       "data/popup-b.js": function() {
         browser.runtime.sendMessage("from-popup-b");
       },
 
       "data/background.html": `<script src="background.js"></script>`,
 
       "data/background.js": function() {
-        var tests = [
+        let sendClick;
+        let tests = [
           () => {
             sendClick({ expectEvent: false, expectPopup: "a" });
           },
           () => {
             sendClick({ expectEvent: false, expectPopup: "a" });
           },
           () => {
             browser.browserAction.setPopup({ popup: "popup-b.html" });
@@ -63,21 +64,21 @@ add_task(function* testPageActionPopup()
             sendClick({ expectEvent: true, expectPopup: null });
           },
           () => {
             browser.browserAction.setPopup({ popup: "/popup-a.html" });
             sendClick({ expectEvent: false, expectPopup: "a" });
           },
         ];
 
-        var expect = {};
-        function sendClick({ expectEvent, expectPopup }) {
+        let expect = {};
+        sendClick = ({ expectEvent, expectPopup }) => {
           expect = { event: expectEvent, popup: expectPopup };
           browser.test.sendMessage("send-click");
-        }
+        };
 
         browser.runtime.onMessage.addListener(msg => {
           if (expect.popup) {
             browser.test.assertEq(msg, `from-popup-${expect.popup}`,
                                   "expected popup opened");
           } else {
             browser.test.fail("unexpected popup");
           }
@@ -98,17 +99,17 @@ add_task(function* testPageActionPopup()
         });
 
         browser.test.onMessage.addListener((msg) => {
           if (msg != "next-test") {
             browser.test.fail("Expecting 'next-test' message");
           }
 
           if (tests.length) {
-            var test = tests.shift();
+            let test = tests.shift();
             test();
           } else {
             browser.test.notifyPass("browseraction-tests-done");
           }
         });
 
         browser.test.sendMessage("next-test");
       },
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_simple.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_simple.js
@@ -1,27 +1,31 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": {
-        "default_popup": "popup.html"
-      }
+        "default_popup": "popup.html",
+      },
     },
 
     files: {
       "popup.html": `
       <!DOCTYPE html>
       <html><body>
       <script src="popup.js"></script>
       </body></html>
       `,
 
       "popup.js": function() {
         browser.runtime.sendMessage("from-popup");
-      }
+      },
     },
 
     background: function() {
       browser.runtime.onMessage.addListener(msg => {
         browser.test.assertEq(msg, "from-popup", "correct message received");
         browser.test.sendMessage("popup");
       });
     },
@@ -31,17 +35,17 @@ add_task(function* () {
 
   let widgetId = makeWidgetId(extension.id) + "-browser-action";
   let node = CustomizableUI.getWidget(widgetId).forWindow(window).node;
 
   // Do this a few times to make sure the pop-up is reloaded each time.
   for (let i = 0; i < 3; i++) {
     let evt = new CustomEvent("command", {
       bubbles: true,
-      cancelable: true
+      cancelable: true,
     });
     node.dispatchEvent(evt);
 
     yield extension.awaitMessage("popup");
 
     let panel = node.querySelector("panel");
     if (panel) {
       panel.hidePopup();
--- a/browser/components/extensions/test/browser/browser_ext_contentscript_connect.js
+++ b/browser/components/extensions/test/browser/browser_ext_contentscript_connect.js
@@ -1,58 +1,62 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["http://mochi.test/"]
+      "permissions": ["http://mochi.test/"],
     },
 
     background: function() {
-      var ports_received = 0;
-      var port_messages_received = 0;
+      let ports_received = 0;
+      let port_messages_received = 0;
 
       browser.runtime.onConnect.addListener((port) => {
         browser.test.assertTrue(!!port, "port1 received");
 
         ports_received++;
         browser.test.assertEq(1, ports_received, "1 port received");
 
         port.onMessage.addListener((msg, sender) => {
           browser.test.assertEq("port message", msg, "listener1 port message received");
 
-          port_messages_received++
+          port_messages_received++;
           browser.test.assertEq(1, port_messages_received, "1 port message received");
-        })
+        });
       });
       browser.runtime.onConnect.addListener((port) => {
         browser.test.assertTrue(!!port, "port2 received");
 
         ports_received++;
         browser.test.assertEq(2, ports_received, "2 ports received");
 
         port.onMessage.addListener((msg, sender) => {
           browser.test.assertEq("port message", msg, "listener2 port message received");
 
-          port_messages_received++
+          port_messages_received++;
           browser.test.assertEq(2, port_messages_received, "2 port messages received");
 
           browser.test.notifyPass("contentscript_connect.pass");
         });
       });
 
       browser.tabs.executeScript({ file: "script.js" });
     },
 
     files: {
       "script.js": function() {
-        var port = browser.runtime.connect();
+        let port = browser.runtime.connect();
         port.postMessage("port message");
-      }
-    }
+      },
+    },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("contentscript_connect.pass");
   yield extension.unload();
 
   yield BrowserTestUtils.removeTab(tab);
 });
--- a/browser/components/extensions/test/browser/browser_ext_contextMenus.js
+++ b/browser/components/extensions/test/browser/browser_ext_contextMenus.js
@@ -1,48 +1,55 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+/* globals content */
+/* eslint-disable mozilla/no-cpows-in-tests */
+
 add_task(function* () {
   let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser,
     "http://mochi.test:8888/browser/browser/components/extensions/test/browser/context.html");
 
   gBrowser.selectedTab = tab1;
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["contextMenus"]
+      "permissions": ["contextMenus"],
     },
 
     background: function() {
       // A generic onclick callback function.
       function genericOnClick(info) {
         browser.test.sendMessage("menuItemClick", JSON.stringify(info));
       }
 
       browser.contextMenus.create({ "contexts": ["all"], "type": "separator" });
 
-      var contexts = ["page", "selection", "image"];
-      for (var i = 0; i < contexts.length; i++) {
-        var context = contexts[i];
-        var title = context;
-        var id = browser.contextMenus.create({ "title": title, "contexts": [context], "id": "ext-" + context,
-                                               "onclick": genericOnClick });
+      let contexts = ["page", "selection", "image"];
+      for (let i = 0; i < contexts.length; i++) {
+        let context = contexts[i];
+        let title = context;
+        browser.contextMenus.create({ "title": title, "contexts": [context], "id": "ext-" + context,
+                                      "onclick": genericOnClick });
         if (context == "selection") {
           browser.contextMenus.update("ext-selection", { "title": "selection-edited" });
         }
       }
 
-      var parent = browser.contextMenus.create({ "title": "parent" });
-      var child1 = browser.contextMenus.create(
+      let parent = browser.contextMenus.create({ "title": "parent" });
+      browser.contextMenus.create(
         { "title": "child1", "parentId": parent, "onclick": genericOnClick });
-      var child2 = browser.contextMenus.create(
+      browser.contextMenus.create(
         { "title": "child2", "parentId": parent, "onclick": genericOnClick });
 
-      var parentToDel = browser.contextMenus.create({ "title": "parentToDel" });
-      var child1ToDel = browser.contextMenus.create(
+      let parentToDel = browser.contextMenus.create({ "title": "parentToDel" });
+      browser.contextMenus.create(
         { "title": "child1", "parentId": parentToDel, "onclick": genericOnClick });
-      var child2ToDel = browser.contextMenus.create(
+      browser.contextMenus.create(
         { "title": "child2", "parentId": parentToDel, "onclick": genericOnClick });
       browser.contextMenus.remove(parentToDel);
 
       browser.test.notifyPass();
     },
   });
 
   let expectedClickInfo;
@@ -79,17 +86,17 @@ add_task(function* () {
   is(items.length, 0, "contextMenu item for selection was not found (context=image)");
 
   items = top.getElementsByAttribute("label", "parentToDel");
   is(items.length, 0, "contextMenu item for removed parent was not found (context=image)");
 
   items = top.getElementsByAttribute("label", "parent");
   is(items.length, 1, "contextMenu item for parent was found (context=image)");
 
-  is(items.item(0).childNodes[0].childNodes.length, 2, "child items for parent were found (context=image)")
+  is(items.item(0).childNodes[0].childNodes.length, 2, "child items for parent were found (context=image)");
 
   // Click on ext-image item and check the results
   let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden");
   expectedClickInfo = {
     menuItemId: "ext-image",
     mediaType: "image",
     srcUrl: "http://mochi.test:8888/browser/browser/components/extensions/test/browser/ctxmenu-image.png",
     pageUrl: "http://mochi.test:8888/browser/browser/components/extensions/test/browser/context.html",
--- a/browser/components/extensions/test/browser/browser_ext_currentWindow.js
+++ b/browser/components/extensions/test/browser/browser_ext_currentWindow.js
@@ -1,42 +1,45 @@
-function genericChecker()
-{
-  var kind = "background";
-  var path = window.location.pathname;
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+function genericChecker() {
+  let kind = "background";
+  let path = window.location.pathname;
   if (path.indexOf("popup") != -1) {
     kind = "popup";
   } else if (path.indexOf("page") != -1) {
     kind = "page";
   }
 
   browser.test.onMessage.addListener((msg, ...args) => {
     if (msg == kind + "-check-current1") {
       browser.tabs.query({
-        currentWindow: true
+        currentWindow: true,
       }, function(tabs) {
         browser.test.sendMessage("result", tabs[0].windowId);
       });
     } else if (msg == kind + "-check-current2") {
       browser.tabs.query({
-        windowId: browser.windows.WINDOW_ID_CURRENT
+        windowId: browser.windows.WINDOW_ID_CURRENT,
       }, function(tabs) {
         browser.test.sendMessage("result", tabs[0].windowId);
       });
     } else if (msg == kind + "-check-current3") {
       browser.windows.getCurrent(function(window) {
         browser.test.sendMessage("result", window.id);
       });
     } else if (msg == kind + "-open-page") {
-      browser.tabs.create({windowId: args[0], url: chrome.runtime.getURL("page.html")});
+      browser.tabs.create({windowId: args[0], url: browser.runtime.getURL("page.html")});
     } else if (msg == kind + "-close-page") {
       browser.tabs.query({
         windowId: args[0],
       }, tabs => {
-        var tab = tabs.find(tab => tab.url.indexOf("page.html") != -1);
+        let tab = tabs.find(tab => tab.url.indexOf("page.html") != -1);
         browser.tabs.remove(tab.id, () => {
           browser.test.sendMessage("closed");
         });
       });
     }
   });
   browser.test.sendMessage(kind + "-ready");
 }
@@ -53,17 +56,17 @@ add_task(function* () {
   yield BrowserTestUtils.loadURI(win2.gBrowser.selectedBrowser, "about:config");
   yield BrowserTestUtils.browserLoaded(win2.gBrowser.selectedBrowser);
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
 
       "browser_action": {
-        "default_popup": "popup.html"
+        "default_popup": "popup.html",
       },
     },
 
     files: {
       "page.html": `
       <!DOCTYPE html>
       <html><body>
       <script src="page.js"></script>
@@ -82,17 +85,17 @@ add_task(function* () {
       "popup.js": genericChecker,
     },
 
     background: genericChecker,
   });
 
   yield Promise.all([extension.startup(), extension.awaitMessage("background-ready")]);
 
-  let {TabManager, WindowManager} = Cu.import("resource://gre/modules/Extension.jsm", {});
+  let {WindowManager} = Cu.import("resource://gre/modules/Extension.jsm", {});
 
   let winId1 = WindowManager.getId(win1);
   let winId2 = WindowManager.getId(win2);
 
   function* checkWindow(kind, winId, name) {
     extension.sendMessage(kind + "-check-current1");
     is((yield extension.awaitMessage("result")), winId, `${name} is on top (check 1) [${kind}]`);
     extension.sendMessage(kind + "-check-current2");
@@ -107,17 +110,17 @@ add_task(function* () {
   yield checkWindow("background", winId2, "win2");
 
   function* triggerPopup(win, callback) {
     let widgetId = makeWidgetId(extension.id) + "-browser-action";
     let node = CustomizableUI.getWidget(widgetId).forWindow(win).node;
 
     let evt = new CustomEvent("command", {
       bubbles: true,
-      cancelable: true
+      cancelable: true,
     });
     node.dispatchEvent(evt);
 
     yield extension.awaitMessage("popup-ready");
 
     yield callback();
 
     let panel = node.querySelector("panel");
--- a/browser/components/extensions/test/browser/browser_ext_getViews.js
+++ b/browser/components/extensions/test/browser/browser_ext_getViews.js
@@ -1,44 +1,47 @@
-function genericChecker()
-{
-  var kind = "background";
-  var path = window.location.pathname;
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+function genericChecker() {
+  let kind = "background";
+  let path = window.location.pathname;
   if (path.indexOf("popup") != -1) {
     kind = "popup";
   } else if (path.indexOf("tab") != -1) {
     kind = "tab";
   }
   window.kind = kind;
 
   browser.test.onMessage.addListener((msg, ...args) => {
     if (msg == kind + "-check-views") {
-      var views = browser.extension.getViews();
-      var counts = {
+      let views = browser.extension.getViews();
+      let counts = {
         "background": 0,
         "tab": 0,
-        "popup": 0
+        "popup": 0,
       };
-      for (var i = 0; i < views.length; i++) {
-        var view = views[i];
+      for (let i = 0; i < views.length; i++) {
+        let view = views[i];
         browser.test.assertTrue(view.kind in counts, "view type is valid");
         counts[view.kind]++;
         if (view.kind == "background") {
           browser.test.assertTrue(view === browser.extension.getBackgroundPage(),
                                   "background page is correct");
         }
       }
       browser.test.sendMessage("counts", counts);
     } else if (msg == kind + "-open-tab") {
-      browser.tabs.create({windowId: args[0], url: chrome.runtime.getURL("tab.html")});
+      browser.tabs.create({windowId: args[0], url: browser.runtime.getURL("tab.html")});
     } else if (msg == kind + "-close-tab") {
       browser.tabs.query({
         windowId: args[0],
       }, tabs => {
-        var tab = tabs.find(tab => tab.url.indexOf("tab.html") != -1);
+        let tab = tabs.find(tab => tab.url.indexOf("tab.html") != -1);
         browser.tabs.remove(tab.id, () => {
           browser.test.sendMessage("closed");
         });
       });
     }
   });
   browser.test.sendMessage(kind + "-ready");
 }
@@ -47,17 +50,17 @@ add_task(function* () {
   let win1 = yield BrowserTestUtils.openNewBrowserWindow();
   let win2 = yield BrowserTestUtils.openNewBrowserWindow();
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
 
       "browser_action": {
-        "default_popup": "popup.html"
+        "default_popup": "popup.html",
       },
     },
 
     files: {
       "tab.html": `
       <!DOCTYPE html>
       <html><body>
       <script src="tab.js"></script>
@@ -78,17 +81,17 @@ add_task(function* () {
 
     background: genericChecker,
   });
 
   yield Promise.all([extension.startup(), extension.awaitMessage("background-ready")]);
 
   info("started");
 
-  let {TabManager, WindowManager} = Cu.import("resource://gre/modules/Extension.jsm", {});
+  let {WindowManager} = Cu.import("resource://gre/modules/Extension.jsm", {});
 
   let winId1 = WindowManager.getId(win1);
   let winId2 = WindowManager.getId(win2);
 
   function* openTab(winId) {
     extension.sendMessage("background-open-tab", winId);
     yield extension.awaitMessage("tab-ready");
   }
@@ -113,17 +116,17 @@ add_task(function* () {
   yield checkViews("background", 2, 0);
 
   function* triggerPopup(win, callback) {
     let widgetId = makeWidgetId(extension.id) + "-browser-action";
     let node = CustomizableUI.getWidget(widgetId).forWindow(win).node;
 
     let evt = new CustomEvent("command", {
       bubbles: true,
-      cancelable: true
+      cancelable: true,
     });
     node.dispatchEvent(evt);
 
     yield extension.awaitMessage("popup-ready");
 
     yield callback();
 
     let panel = node.querySelector("panel");
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
@@ -1,40 +1,39 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* testTabSwitchContext() {
-
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "page_action": {
         "default_icon": "default.png",
         "default_popup": "default.html",
         "default_title": "Default Title",
       },
       "permissions": ["tabs"],
     },
 
-    background: function () {
-      var details = [
+    background: function() {
+      let details = [
         { "icon": browser.runtime.getURL("default.png"),
           "popup": browser.runtime.getURL("default.html"),
           "title": "Default Title" },
         { "icon": browser.runtime.getURL("1.png"),
           "popup": browser.runtime.getURL("default.html"),
           "title": "Default Title" },
         { "icon": browser.runtime.getURL("2.png"),
           "popup": browser.runtime.getURL("2.html"),
           "title": "Title 2" },
       ];
 
-      var tabs;
-      var tests;
-      var allTests = [
+      let tabs;
+      let tests;
+      let allTests = [
         expect => {
           browser.test.log("Initial state. No icon visible.");
           expect(null);
         },
         expect => {
           browser.test.log("Show the icon on the first tab, expect default properties.");
           browser.pageAction.show(tabs[0]);
           expect(details[0]);
@@ -48,17 +47,17 @@ add_task(function* testTabSwitchContext(
           browser.test.log("Create a new tab. No icon visible.");
           browser.tabs.create({ active: true, url: "about:blank?0" }, tab => {
             tabs.push(tab.id);
             expect(null);
           });
         },
         expect => {
           browser.test.log("Change properties. Expect new properties.");
-          var tabId = tabs[1];
+          let tabId = tabs[1];
           browser.pageAction.show(tabId);
           browser.pageAction.setIcon({ tabId, path: "2.png" });
           browser.pageAction.setPopup({ tabId, popup: "2.html" });
           browser.pageAction.setTitle({ tabId, title: "Title 2" });
 
           expect(details[2]);
         },
         expect => {
@@ -107,31 +106,31 @@ add_task(function* testTabSwitchContext(
       ];
 
       // Gets the current details of the page action, and returns a
       // promise that resolves to an object containing them.
       function getDetails() {
         return new Promise(resolve => {
           return browser.tabs.query({ active: true, currentWindow: true }, resolve);
         }).then(tabs => {
-          var tabId = tabs[0].id;
+          let tabId = tabs[0].id;
           return Promise.all([
             new Promise(resolve => browser.pageAction.getTitle({tabId}, resolve)),
-            new Promise(resolve => browser.pageAction.getPopup({tabId}, resolve))])
+            new Promise(resolve => browser.pageAction.getPopup({tabId}, resolve))]);
         }).then(details => {
           return Promise.resolve({ title: details[0],
                                    popup: details[1] });
         });
       }
 
 
       // Runs the next test in the `tests` array, checks the results,
       // and passes control back to the outer test scope.
       function nextTest() {
-        var test = tests.shift();
+        let test = tests.shift();
 
         test(expecting => {
           function finish() {
             // Check that the actual icon has the expected values, then
             // run the next test.
             browser.test.sendMessage("nextTest", expecting, tests.length);
           }
 
@@ -148,37 +147,37 @@ add_task(function* testTabSwitchContext(
               finish();
             });
           } else {
             finish();
           }
         });
       }
 
-      browser.test.onMessage.addListener((msg) => {
-        if (msg == "runTests") {
-          runTests();
-        } else if (msg == "runNextTest") {
-          nextTest();
-        } else {
-          browser.test.fail(`Unexpected message: ${msg}`);
-        }
-      });
-
       function runTests() {
         tabs = [];
         tests = allTests.slice();
 
         browser.tabs.query({ active: true, currentWindow: true }, resultTabs => {
           tabs[0] = resultTabs[0].id;
 
           nextTest();
         });
       }
 
+      browser.test.onMessage.addListener((msg) => {
+        if (msg == "runTests") {
+          runTests();
+        } else if (msg == "runNextTest") {
+          nextTest();
+        } else {
+          browser.test.fail(`Unexpected message: ${msg}`);
+        }
+      });
+
       runTests();
     },
   });
 
   let pageActionId = makeWidgetId(extension.id) + "-page-action";
   let currentWindow = window;
   let windows = [];
 
@@ -198,26 +197,26 @@ add_task(function* testTabSwitchContext(
 
   let testNewWindows = 1;
 
   let awaitFinish = new Promise(resolve => {
     extension.onMessage("nextTest", (expecting, testsRemaining) => {
       checkDetails(expecting);
 
       if (testsRemaining) {
-        extension.sendMessage("runNextTest")
+        extension.sendMessage("runNextTest");
       } else if (testNewWindows) {
         testNewWindows--;
 
         BrowserTestUtils.openNewBrowserWindow().then(window => {
           windows.push(window);
           currentWindow = window;
           return focusWindow(window);
         }).then(() => {
-          extension.sendMessage("runTests")
+          extension.sendMessage("runTests");
         });
       } else {
         resolve();
       }
     });
   });
 
   yield extension.startup();
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js
@@ -15,40 +15,41 @@ function promisePopupShown(popup) {
     }
   });
 }
 
 add_task(function* testPageActionPopup() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "background": {
-        "page": "data/background.html"
+        "page": "data/background.html",
       },
       "page_action": {
-        "default_popup": "popup-a.html"
-      }
+        "default_popup": "popup-a.html",
+      },
     },
 
     files: {
       "popup-a.html": `<script src="popup-a.js"></script>`,
       "popup-a.js": function() {
         browser.runtime.sendMessage("from-popup-a");
       },
 
       "data/popup-b.html": `<script src="popup-b.js"></script>`,
       "data/popup-b.js": function() {
         browser.runtime.sendMessage("from-popup-b");
       },
 
       "data/background.html": `<script src="background.js"></script>`,
 
       "data/background.js": function() {
-        var tabId;
+        let tabId;
 
-        var tests = [
+        let sendClick;
+        let tests = [
           () => {
             sendClick({ expectEvent: false, expectPopup: "a" });
           },
           () => {
             sendClick({ expectEvent: false, expectPopup: "a" });
           },
           () => {
             browser.pageAction.setPopup({ tabId, popup: "popup-b.html" });
@@ -65,21 +66,21 @@ add_task(function* testPageActionPopup()
             sendClick({ expectEvent: true, expectPopup: null });
           },
           () => {
             browser.pageAction.setPopup({ tabId, popup: "/popup-a.html" });
             sendClick({ expectEvent: false, expectPopup: "a" });
           },
         ];
 
-        var expect = {};
-        function sendClick({ expectEvent, expectPopup }) {
+        let expect = {};
+        sendClick = ({ expectEvent, expectPopup }) => {
           expect = { event: expectEvent, popup: expectPopup };
           browser.test.sendMessage("send-click");
-        }
+        };
 
         browser.runtime.onMessage.addListener(msg => {
           if (expect.popup) {
             browser.test.assertEq(msg, `from-popup-${expect.popup}`,
                                   "expected popup opened");
           } else {
             browser.test.fail("unexpected popup");
           }
@@ -100,17 +101,17 @@ add_task(function* testPageActionPopup()
         });
 
         browser.test.onMessage.addListener((msg) => {
           if (msg != "next-test") {
             browser.test.fail("Expecting 'next-test' message");
           }
 
           if (tests.length) {
-            var test = tests.shift();
+            let test = tests.shift();
             test();
           } else {
             browser.test.notifyPass("pageaction-tests-done");
           }
         });
 
         browser.tabs.query({ active: true, currentWindow: true }, tabs => {
           tabId = tabs[0].id;
@@ -154,20 +155,16 @@ add_task(function* testPageActionPopup()
   let panel = document.getElementById(panelId);
   is(panel, undefined, "pageAction panel removed from document");
 });
 
 
 add_task(function* testPageActionSecurity() {
   const URL = "chrome://browser/content/browser.xul";
 
-  let matchURLForbidden = url => ({
-    message: new RegExp(`Loading extension.*Access to.*'${URL}' denied`),
-  });
-
   let messages = [/Access to restricted URI denied/,
                   /Access to restricted URI denied/];
 
   let waitForConsole = new Promise(resolve => {
     // Not necessary in browser-chrome tests, but monitorConsole gripes
     // if we don't call it.
     SimpleTest.waitForExplicitFinish();
 
@@ -175,19 +172,19 @@ add_task(function* testPageActionSecurit
   });
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "browser_action": { "default_popup": URL },
       "page_action": { "default_popup": URL },
     },
 
-    background: function () {
+    background: function() {
       browser.tabs.query({ active: true, currentWindow: true }, tabs => {
-        var tabId = tabs[0].id;
+        let tabId = tabs[0].id;
 
         browser.pageAction.show(tabId);
         browser.test.sendMessage("ready");
       });
     },
   });
 
   yield extension.startup();
--- a/browser/components/extensions/test/browser/browser_ext_popup_api_injection.js
+++ b/browser/components/extensions/test/browser/browser_ext_popup_api_injection.js
@@ -21,17 +21,17 @@ add_task(function* testPageActionPopup()
       </script></head></html>`,
 
       "popup-b.html": String.raw`<html><head><meta charset="utf-8"><script type="application/javascript">
         browser.test.sendMessage("from-popup-b");
       </script></head></html>`,
     },
 
     background: function() {
-      let tabId
+      let tabId;
       browser.tabs.query({ active: true, currentWindow: true }, tabs => {
         tabId = tabs[0].id;
         browser.pageAction.show(tabId);
         browser.test.sendMessage("ready");
       });
 
       browser.test.onMessage.addListener(() => {
         browser.browserAction.setPopup({ popup: "/popup-a.html" });
@@ -48,17 +48,17 @@ add_task(function* testPageActionPopup()
   function openPopup(buttonId) {
     let button = document.getElementById(buttonId);
     if (buttonId == pageActionId) {
       // TODO: I don't know why a proper synthesized event doesn't work here.
       button.dispatchEvent(new MouseEvent("click", {}));
     } else {
       EventUtils.synthesizeMouseAtCenter(button, {}, window);
     }
-  };
+  }
 
   let promiseConsoleMessage = pattern => new Promise(resolve => {
     Services.console.registerListener(function listener(msg) {
       if (pattern.test(msg.message)) {
         resolve(msg.message);
         Services.console.unregisterListener(listener);
       }
     });
--- a/browser/components/extensions/test/browser/browser_ext_simple.js
+++ b/browser/components/extensions/test/browser/browser_ext_simple.js
@@ -1,16 +1,20 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* test_simple() {
   let extensionData = {
     manifest: {
       "name": "Simple extension test",
       "version": "1.0",
       "manifest_version": 2,
-      "description": ""
-    }
+      "description": "",
+    },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   yield extension.startup();
   info("startup complete");
   yield extension.unload();
   info("extension unloaded successfully");
@@ -31,18 +35,18 @@ add_task(function* test_background() {
   }
 
   let extensionData = {
     background: "(" + backgroundScript.toString() + ")()",
     manifest: {
       "name": "Simple extension test",
       "version": "1.0",
       "manifest_version": 2,
-      "description": ""
-    }
+      "description": "",
+    },
   };
 
   let extension = ExtensionTestUtils.loadExtension(extensionData);
   info("load complete");
   let [, x] = yield Promise.all([extension.startup(), extension.awaitMessage("running")]);
   is(x, 1, "got correct value from extension");
   info("startup complete");
   extension.sendMessage(10, 20);
--- a/browser/components/extensions/test/browser/browser_ext_tab_runtimeConnect.js
+++ b/browser/components/extensions/test/browser/browser_ext_tab_runtimeConnect.js
@@ -1,24 +1,28 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
-      var messages_received = [];
+      let messages_received = [];
 
-      var tabId;
+      let tabId;
 
       browser.runtime.onConnect.addListener((port) => {
         browser.test.assertTrue(!!port, "tab to background port received");
-        browser.test.assertEq("tab-connection-name", port.name, "port name should be defined and equal to connectInfo.name")
+        browser.test.assertEq("tab-connection-name", port.name, "port name should be defined and equal to connectInfo.name");
         browser.test.assertTrue(!!port.sender.tab, "port.sender.tab should be defined");
         browser.test.assertEq(tabId, port.sender.tab.id, "port.sender.tab.id should be equal to the expected tabId");
 
         port.onMessage.addListener((msg) => {
           messages_received.push(msg);
 
           if (messages_received.length == 1) {
             browser.test.assertEq("tab to background port message", msg, "'tab to background' port message received");
@@ -26,27 +30,26 @@ add_task(function* () {
           }
 
           if (messages_received.length == 2) {
             browser.test.assertTrue(!!msg.tabReceived, "'background to tab' reply port message received");
             browser.test.assertEq("background to tab port message", msg.tabReceived, "reply port content contains the message received");
 
             browser.test.notifyPass("tabRuntimeConnect.pass");
           }
-        })
+        });
       });
 
-      browser.tabs.create({
-        url: "tab.html"
-      }, (tab) => { tabId = tab.id });
+      browser.tabs.create({ url: "tab.html" },
+                          (tab) => { tabId = tab.id; });
     },
 
     files: {
       "tab.js": function() {
-        var port = browser.runtime.connect({ name: "tab-connection-name"});
+        let port = browser.runtime.connect({ name: "tab-connection-name"});
         port.postMessage("tab to background port message");
         port.onMessage.addListener((msg) => {
           port.postMessage({ tabReceived: msg });
         });
       },
       "tab.html": `
         <!DOCTYPE html>
         <html>
@@ -54,18 +57,18 @@ add_task(function* () {
             <title>test tab extension page</title>
             <meta charset="utf-8">
             <script src="tab.js" async></script>
           </head>
           <body>
             <h1>test tab extension page</h1>
           </body>
         </html>
-      `
-    }
+      `,
+    },
   });
 
   yield extension.startup();
   yield extension.awaitFinish("tabRuntimeConnect.pass");
   yield extension.unload();
 
   yield BrowserTestUtils.removeTab(tab);
 });
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_bad.js
@@ -1,57 +1,59 @@
 "use strict";
 
 // This is a pretty terrible hack, but it's the best we can do until we
 // support |executeScript| callbacks and |lastError|.
 function* testHasNoPermission(params) {
   let contentSetup = params.contentSetup || (() => Promise.resolve());
 
+  function background(contentSetup) {
+    browser.runtime.onMessage.addListener((msg, sender) => {
+      browser.test.assertEq(msg, "second script ran", "second script ran");
+      browser.test.notifyPass("executeScript");
+    });
+
+    browser.test.onMessage.addListener(msg => {
+      browser.test.assertEq(msg, "execute-script");
+
+      browser.tabs.query({ activeWindow: true }, tabs => {
+        browser.tabs.executeScript({
+          file: "script.js",
+        });
+
+        // Execute a script we know we have permissions for in the
+        // second tab, in the hopes that it will execute after the
+        // first one. This has intermittent failure written all over
+        // it, but it's just about the best we can do until we
+        // support callbacks for executeScript.
+        browser.tabs.executeScript(tabs[1].id, {
+          file: "second-script.js",
+        });
+      });
+    });
+
+    contentSetup().then(() => {
+      browser.test.sendMessage("ready");
+    });
+  }
+
   let extension = ExtensionTestUtils.loadExtension({
     manifest: params.manifest,
 
-    background: `(${function(contentSetup) {
-      browser.runtime.onMessage.addListener((msg, sender) => {
-        browser.test.assertEq(msg, "second script ran", "second script ran");
-        browser.test.notifyPass("executeScript");
-      });
-
-      browser.test.onMessage.addListener(msg => {
-        browser.test.assertEq(msg, "execute-script");
-
-        browser.tabs.query({ activeWindow: true }, tabs => {
-          browser.tabs.executeScript({
-            file: "script.js"
-          });
-
-          // Execute a script we know we have permissions for in the
-          // second tab, in the hopes that it will execute after the
-          // first one. This has intermittent failure written all over
-          // it, but it's just about the best we can do until we
-          // support callbacks for executeScript.
-          browser.tabs.executeScript(tabs[1].id, {
-            file: "second-script.js"
-          });
-        });
-      });
-
-      contentSetup().then(() => {
-        browser.test.sendMessage("ready");
-      });
-    }})(${contentSetup})`,
+    background: `(${background})(${contentSetup})`,
 
     files: {
       "script.js": function() {
         browser.runtime.sendMessage("first script ran");
       },
 
       "second-script.js": function() {
         browser.runtime.sendMessage("second script ran");
-      }
-    }
+      },
+    },
   });
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
 
   if (params.setup) {
     yield params.setup(extension);
   }
@@ -63,22 +65,22 @@ function* testHasNoPermission(params) {
 }
 
 add_task(function* testBadPermissions() {
   let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
   let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
 
   info("Test no special permissions");
   yield testHasNoPermission({
-    manifest: { "permissions": ["http://example.com/"] }
+    manifest: { "permissions": ["http://example.com/"] },
   });
 
   info("Test tabs permissions");
   yield testHasNoPermission({
-    manifest: { "permissions": ["http://example.com/", "tabs"] }
+    manifest: { "permissions": ["http://example.com/", "tabs"] },
   });
 
   info("Test active tab, browser action, no click");
   yield testHasNoPermission({
     manifest: {
       "permissions": ["http://example.com/", "activeTab"],
       "browser_action": {},
     },
@@ -92,17 +94,17 @@ add_task(function* testBadPermissions() 
     },
     contentSetup() {
       return new Promise(resolve => {
         browser.tabs.query({ active: true, currentWindow: true }, tabs => {
           browser.pageAction.show(tabs[0].id);
           resolve();
         });
       });
-    }
+    },
   });
 
   yield BrowserTestUtils.removeTab(tab2);
   yield BrowserTestUtils.removeTab(tab1);
 });
 
 // TODO: Test that |executeScript| fails if the tab has navigated to a
 // new page, and no longer matches our expected state. This involves
--- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js
@@ -1,40 +1,44 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 function* testHasPermission(params) {
   let contentSetup = params.contentSetup || (() => Promise.resolve());
 
+  function background(contentSetup) {
+    browser.runtime.onMessage.addListener((msg, sender) => {
+      browser.test.assertEq(msg, "script ran", "script ran");
+      browser.test.notifyPass("executeScript");
+    });
+
+    browser.test.onMessage.addListener(msg => {
+      browser.test.assertEq(msg, "execute-script");
+
+      browser.tabs.executeScript({
+        file: "script.js",
+      });
+    });
+
+    contentSetup().then(() => {
+      browser.test.sendMessage("ready");
+    });
+  }
+
   let extension = ExtensionTestUtils.loadExtension({
     manifest: params.manifest,
 
-    background: `(${function(contentSetup) {
-      browser.runtime.onMessage.addListener((msg, sender) => {
-        browser.test.assertEq(msg, "script ran", "script ran");
-        browser.test.notifyPass("executeScript");
-      });
-
-      browser.test.onMessage.addListener(msg => {
-        browser.test.assertEq(msg, "execute-script");
-
-        browser.tabs.executeScript({
-          file: "script.js"
-        });
-      });
-
-      contentSetup().then(() => {
-        browser.test.sendMessage("ready");
-      });
-    }})(${contentSetup})`,
+    background: `(${background})(${contentSetup})`,
 
     files: {
       "script.js": function() {
         browser.runtime.sendMessage("script ran");
-      }
-    }
+      },
+    },
   });
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
 
   if (params.setup) {
     yield params.setup(extension);
   }
@@ -45,27 +49,27 @@ function* testHasPermission(params) {
   yield extension.unload();
 }
 
 add_task(function* testGoodPermissions() {
   let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/", true);
 
   info("Test explicit host permission");
   yield testHasPermission({
-    manifest: { "permissions": ["http://mochi.test/"] }
+    manifest: { "permissions": ["http://mochi.test/"] },
   });
 
   info("Test explicit host subdomain permission");
   yield testHasPermission({
-    manifest: { "permissions": ["http://*.mochi.test/"] }
+    manifest: { "permissions": ["http://*.mochi.test/"] },
   });
 
   info("Test explicit <all_urls> permission");
   yield testHasPermission({
-    manifest: { "permissions": ["<all_urls>"] }
+    manifest: { "permissions": ["<all_urls>"] },
   });
 
   info("Test activeTab permission with a browser action click");
   yield testHasPermission({
     manifest: {
       "permissions": ["activeTab"],
       "browser_action": {},
     },
--- a/browser/components/extensions/test/browser/browser_ext_tabs_getCurrent.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_getCurrent.js
@@ -1,8 +1,10 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 add_task(function* () {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
 
       "browser_action": { "default_popup": "popup.html" },
--- a/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js
@@ -1,103 +1,107 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
   let win1 = yield BrowserTestUtils.openNewBrowserWindow();
 
   yield focusWindow(win1);
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": ["tabs"],
       "content_scripts": [{
         "matches": ["http://mochi.test/*/context_tabs_onUpdated_page.html"],
         "js": ["content-script.js"],
-        "run_at": "document_start"
-      },],
+        "run_at": "document_start",
+      }],
     },
 
     background: function() {
-      var pageURL = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/context_tabs_onUpdated_page.html";
+      let pageURL = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/context_tabs_onUpdated_page.html";
 
-      var expectedSequence = [
+      let expectedSequence = [
         { status: "loading" },
         { status: "loading", url: pageURL },
-        { status: "complete" }
+        { status: "complete" },
       ];
-      var collectedSequence = [];
+      let collectedSequence = [];
 
-      browser.tabs.onUpdated.addListener(function (tabId, updatedInfo) {
+      browser.tabs.onUpdated.addListener(function(tabId, updatedInfo) {
         collectedSequence.push(updatedInfo);
       });
 
-      browser.runtime.onMessage.addListener(function () {
-          if (collectedSequence.length !== expectedSequence.length) {
+      browser.runtime.onMessage.addListener(function() {
+        if (collectedSequence.length !== expectedSequence.length) {
+          browser.test.assertEq(
+            JSON.stringify(expectedSequence),
+            JSON.stringify(collectedSequence),
+            "got unexpected number of updateInfo data"
+          );
+        } else {
+          for (let i = 0; i < expectedSequence.length; i++) {
             browser.test.assertEq(
-              JSON.stringify(expectedSequence),
-              JSON.stringify(collectedSequence),
-              "got unexpected number of updateInfo data"
+              expectedSequence[i].status,
+              collectedSequence[i].status,
+              "check updatedInfo status"
             );
-          } else {
-            for (var i = 0; i < expectedSequence.length; i++) {
+            if (expectedSequence[i].url || collectedSequence[i].url) {
               browser.test.assertEq(
-                expectedSequence[i].status,
-                collectedSequence[i].status,
-                "check updatedInfo status"
+                expectedSequence[i].url,
+                collectedSequence[i].url,
+                "check updatedInfo url"
               );
-              if (expectedSequence[i].url || collectedSequence[i].url) {
-                browser.test.assertEq(
-                  expectedSequence[i].url,
-                  collectedSequence[i].url,
-                  "check updatedInfo url"
-                );
-              }
             }
           }
+        }
 
-          browser.test.notifyPass("tabs.onUpdated");
+        browser.test.notifyPass("tabs.onUpdated");
       });
 
       browser.tabs.create({ url: pageURL });
     },
     files: {
       "content-script.js": `
         window.addEventListener("message", function(evt) {
           if (evt.data == "frame-updated") {
             browser.runtime.sendMessage("load-completed");
           }
         }, true);
       `,
-    }
+    },
   });
 
   yield Promise.all([
     extension.startup(),
-    extension.awaitFinish("tabs.onUpdated")
+    extension.awaitFinish("tabs.onUpdated"),
   ]);
 
   yield extension.unload();
 
   yield BrowserTestUtils.closeWindow(win1);
 });
 
 function* do_test_update(background) {
   let win1 = yield BrowserTestUtils.openNewBrowserWindow();
 
   yield focusWindow(win1);
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: background,
   });
 
   yield Promise.all([
     yield extension.startup(),
-    yield extension.awaitFinish("finish")
+    yield extension.awaitFinish("finish"),
   ]);
 
   yield extension.unload();
 
   yield BrowserTestUtils.closeWindow(win1);
 }
 
 add_task(function* test_pinned() {
--- a/browser/components/extensions/test/browser/browser_ext_tabs_query.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_query.js
@@ -1,26 +1,30 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
   let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
   let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
 
   gBrowser.selectedTab = tab1;
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
       browser.tabs.query({
-        lastFocusedWindow: true
+        lastFocusedWindow: true,
       }, function(tabs) {
         browser.test.assertEq(tabs.length, 3, "should have three tabs");
 
-        tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
+        tabs.sort((tab1, tab2) => tab1.index - tab2.index);
 
         browser.test.assertEq(tabs[0].url, "about:blank", "first tab blank");
         tabs.shift();
 
         browser.test.assertTrue(tabs[0].active, "tab 0 active");
         browser.test.assertFalse(tabs[1].active, "tab 1 inactive");
 
         browser.test.assertFalse(tabs[0].pinned, "tab 0 unpinned");
@@ -48,26 +52,26 @@ add_task(function* () {
 
   tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
   tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.net/");
   let tab3 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://test1.example.org/MochiKit/");
 
   // test simple queries
   extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
       browser.tabs.query({
-        url: "<all_urls>"
+        url: "<all_urls>",
       }, function(tabs) {
         browser.test.assertEq(tabs.length, 3, "should have three tabs");
 
-        tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
+        tabs.sort((tab1, tab2) => tab1.index - tab2.index);
 
         browser.test.assertEq(tabs[0].url, "http://example.com/", "tab 0 url correct");
         browser.test.assertEq(tabs[1].url, "http://example.net/", "tab 1 url correct");
         browser.test.assertEq(tabs[2].url, "http://test1.example.org/MochiKit/", "tab 2 url correct");
 
         browser.test.notifyPass("tabs.query");
       });
     },
@@ -75,22 +79,22 @@ add_task(function* () {
 
   yield extension.startup();
   yield extension.awaitFinish("tabs.query");
   yield extension.unload();
 
   // match pattern
   extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
       browser.tabs.query({
-        url: "http://*/MochiKit*"
+        url: "http://*/MochiKit*",
       }, function(tabs) {
         browser.test.assertEq(tabs.length, 1, "should have one tab");
 
         browser.test.assertEq(tabs[0].url, "http://test1.example.org/MochiKit/", "tab 0 url correct");
 
         browser.test.notifyPass("tabs.query");
       });
     },
@@ -98,26 +102,26 @@ add_task(function* () {
 
   yield extension.startup();
   yield extension.awaitFinish("tabs.query");
   yield extension.unload();
 
   // match array of patterns
   extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
       browser.tabs.query({
-        url: ["http://*/MochiKit*", "http://*.com/*"]
+        url: ["http://*/MochiKit*", "http://*.com/*"],
       }, function(tabs) {
         browser.test.assertEq(tabs.length, 2, "should have two tabs");
 
-        tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
+        tabs.sort((tab1, tab2) => tab1.index - tab2.index);
 
         browser.test.assertEq(tabs[0].url, "http://example.com/", "tab 0 url correct");
         browser.test.assertEq(tabs[1].url, "http://test1.example.org/MochiKit/", "tab 1 url correct");
 
         browser.test.notifyPass("tabs.query");
       });
     },
   });
--- a/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js
@@ -1,31 +1,35 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* tabsSendMessageNoExceptionOnNonExistentTab() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
-      chrome.tabs.create({ url: "about:robots"}, function (tab) {
-        var exception;
+      browser.tabs.create({ url: "about:robots"}, tab => {
+        let exception;
         try {
           browser.tabs.sendMessage(tab.id, "message");
           browser.tabs.sendMessage(tab.id + 100, "message");
-        } catch(e) {
+        } catch (e) {
           exception = e;
         }
 
         browser.test.assertEq(undefined, exception, "no exception should be raised on tabs.sendMessage to unexistent tabs");
-        chrome.tabs.remove(tab.id, function() {
+        browser.tabs.remove(tab.id, function() {
           browser.test.notifyPass("tabs.sendMessage");
-        })
-      })
+        });
+      });
     },
   });
 
   yield Promise.all([
     extension.startup(),
-    extension.awaitFinish("tabs.sendMessage")
+    extension.awaitFinish("tabs.sendMessage"),
   ]);
 
   yield extension.unload();
 });
--- a/browser/components/extensions/test/browser/browser_ext_tabs_update.js
+++ b/browser/components/extensions/test/browser/browser_ext_tabs_update.js
@@ -1,26 +1,30 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
   let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
   let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
 
   gBrowser.selectedTab = tab1;
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["tabs"]
+      "permissions": ["tabs"],
     },
 
     background: function() {
       browser.tabs.query({
         lastFocusedWindow: true,
       }, function(tabs) {
         browser.test.assertEq(tabs.length, 3, "should have three tabs");
 
-        tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
+        tabs.sort((tab1, tab2) => tab1.index - tab2.index);
 
         browser.test.assertEq(tabs[0].url, "about:blank", "first tab blank");
         tabs.shift();
 
         browser.test.assertTrue(tabs[0].active, "tab 0 active");
         browser.test.assertFalse(tabs[1].active, "tab 1 inactive");
 
         browser.tabs.update(tabs[1].id, {active: true}, function() {
--- a/browser/components/extensions/test/browser/browser_ext_windows_update.js
+++ b/browser/components/extensions/test/browser/browser_ext_windows_update.js
@@ -1,27 +1,31 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
 add_task(function* () {
-  function promiseWaitForFocus(aWindow) {
-    return new Promise(function(aResolve, aReject) {
+  function promiseWaitForFocus(window) {
+    return new Promise(resolve => {
       waitForFocus(function() {
-        ok(Services.focus.activeWindow === aWindow, "correct window focused");
-        aResolve();
-      }, aWindow);
+        ok(Services.focus.activeWindow === window, "correct window focused");
+        resolve();
+      }, window);
     });
   }
 
   let window1 = window;
   let window2 = yield BrowserTestUtils.openNewBrowserWindow();
 
   Services.focus.activeWindow = window2;
   yield promiseWaitForFocus(window2);
 
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
-      "permissions": ["windows"]
+      "permissions": ["windows"],
     },
 
     background: function() {
       browser.windows.getAll(undefined, function(wins) {
         browser.test.assertEq(wins.length, 2, "should have two windows");
 
         // Sort the unfocused window to the lower index.
         wins.sort(function(win1, win2) {
@@ -30,17 +34,16 @@ add_task(function* () {
           }
 
           return win1.focused ? 1 : -1;
         });
 
         browser.windows.update(wins[0].id, {focused: true}, function() {
           browser.test.sendMessage("check");
         });
-
       });
     },
   });
 
   yield Promise.all([extension.startup(), extension.awaitMessage("check")]);
 
   yield promiseWaitForFocus(window1);
 
--- a/browser/components/extensions/test/browser/head.js
+++ b/browser/components/extensions/test/browser/head.js
@@ -1,18 +1,22 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+/* exported CustomizableUI makeWidgetId focusWindow clickBrowserAction clickPageAction */
+
 var {CustomizableUI} = Cu.import("resource:///modules/CustomizableUI.jsm");
 
-function makeWidgetId(id)
-{
+function makeWidgetId(id) {
   id = id.toLowerCase();
   return id.replace(/[^a-z0-9_-]/g, "_");
 }
 
-var focusWindow = Task.async(function* focusWindow(win)
-{
+var focusWindow = Task.async(function* focusWindow(win) {
   let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
   if (fm.activeWindow == win) {
     return;
   }
 
   let promise = new Promise(resolve => {
     win.addEventListener("focus", function listener() {
       win.removeEventListener("focus", listener, true);
@@ -34,16 +38,17 @@ function clickBrowserAction(extension, w
 
 function clickPageAction(extension, win = window) {
   // This would normally be set automatically on navigation, and cleared
   // when the user types a value into the URL bar, to show and hide page
   // identity info and icons such as page action buttons.
   //
   // Unfortunately, that doesn't happen automatically in browser chrome
   // tests.
+  /* globals SetPageProxyState */
   SetPageProxyState("valid");
 
   let pageActionId = makeWidgetId(extension.id) + "-page-action";
   let elem = win.document.getElementById(pageActionId);
 
   EventUtils.synthesizeMouseAtCenter(elem, {}, win);
   return new Promise(SimpleTest.executeSoon);
 }
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1288,18 +1288,17 @@ PlacesController.prototype = {
     } catch(ex) {
       // No supported data exists or nodes unwrap failed, just bail out.
       return;
     }
 
     let itemsToSelect = [];
     if (PlacesUIUtils.useAsyncTransactions) {
       if (ip.isTag) {
-        let uris = [for (item of items) if ("uri" in item)
-                    NetUtil.newURI(item.uri)];
+        let uris = items.filter(item => "uri" in item).map(item => NetUtil.newURI(item.uri));
         yield PlacesTransactions.Tag({ uris: uris, tag: ip.tagName }).transact();
       }
       else {
         yield PlacesTransactions.batch(function* () {
           let insertionIndex = ip.index;
           let parent = yield ip.promiseGuid();
 
           for (let item of items) {
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -668,17 +668,17 @@ var PlacesOrganizer = {
 
       gEditItemOverlay.initPanel({ node: selectedNode
                                  , hiddenRows: ["folderPicker"] });
 
       this._detectAndSetDetailsPaneMinimalState(selectedNode);
     }
     else if (!selectedNode && aNodeList[0]) {
       if (aNodeList.every(PlacesUtils.nodeIsURI)) {
-        let uris = [for (node of aNodeList) PlacesUtils._uri(node.uri)];
+        let uris = aNodeList.map(node => PlacesUtils._uri(node.uri));
         detailsDeck.selectedIndex = 1;
         gEditItemOverlay.initPanel({ uris
                                    , hiddenRows: ["folderPicker",
                                                   "loadInSidebar",
                                                   "location",
                                                   "keyword",
                                                   "description",
                                                   "name"]});
--- a/browser/components/places/content/treeView.js
+++ b/browser/components/places/content/treeView.js
@@ -149,17 +149,17 @@ PlacesTreeView.prototype = {
   _getRowForNode:
   function PTV__getRowForNode(aNode, aForceBuild, aParentRow, aNodeIndex) {
     if (aNode == this._rootNode)
       throw new Error("The root node is never visible");
 
     // A node is removed form the view either if it has no parent or if its
     // root-ancestor is not the root node (in which case that's the node
     // for which nodeRemoved was called).
-    let ancestors = [x for (x of PlacesUtils.nodeAncestors(aNode))];
+    let ancestors = Array.from(PlacesUtils.nodeAncestors(aNode));
     if (ancestors.length == 0 ||
         ancestors[ancestors.length - 1] != this._rootNode) {
       throw new Error("Removed node passed to _getRowForNode");
     }
 
     // Ensure that the entire chain is open, otherwise that node is invisible.
     for (let ancestor of ancestors) {
       if (!ancestor.containerOpen)
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -396,16 +396,30 @@ var SessionStoreInternal = {
   // properly handle final update message.
   _closedTabs: new WeakMap(),
 
   // A map (xul:browser -> object) that maps a browser associated with a
   // recently closed tab due to a window closure to the tab state information
   // that is being stored in _closedWindows for that tab.
   _closedWindowTabs: new WeakMap(),
 
+  // A set of window data that has the potential to be saved in the _closedWindows
+  // array for the session. We will remove window data from this set whenever
+  // forgetClosedWindow is called for the window, or when session history is
+  // purged, so that we don't accidentally save that data after the flush has
+  // completed. Closed tabs use a more complicated mechanism for this particular
+  // problem. When forgetClosedTab is called, the browser is removed from the
+  // _closedTabs map, so its data is not recorded. In the purge history case,
+  // the closedTabs array per window is overwritten so that once the flush is
+  // complete, the tab would only ever add itself to an array that SessionStore
+  // no longer cares about. Bug 1230636 has been filed to make the tab case
+  // work more like the window case, which is more explicit, and easier to
+  // reason about.
+  _saveableClosedWindowData: new WeakSet(),
+
   // A map (xul:browser -> object) that maps a browser that is switching
   // remoteness via navigateAndRestore, to the loadArguments that were
   // most recently passed when calling navigateAndRestore.
   _remotenessChangingBrowsers: new WeakMap(),
 
   // whether a setBrowserState call is in progress
   _browserSetState: false,
 
@@ -1265,16 +1279,20 @@ var SessionStoreInternal = {
       // we explicitly allow saving an "empty" window state.
       let isLastWindow =
         Object.keys(this._windows).length == 1 &&
         !this._closedWindows.some(win => win._shouldRestore || false);
 
       // clear this window from the list, since it has definitely been closed.
       delete this._windows[aWindow.__SSi];
 
+      // This window has the potential to be saved in the _closedWindows
+      // array (maybeSaveClosedWindows gets the final call on that).
+      this._saveableClosedWindowData.add(winData);
+
       // Now we have to figure out if this window is worth saving in the _closedWindows
       // Object.
       //
       // We're about to flush the tabs from this window, but it's possible that we
       // might never hear back from the content process(es) in time before the user
       // chooses to restore the closed window. So we do the following:
       //
       // 1) Use the tab state cache to determine synchronously if the window is
@@ -1347,16 +1365,17 @@ var SessionStoreInternal = {
     }
 
     // Cache the window state until it is completely gone.
     DyingWindowCache.set(aWindow, winData);
 
     let mm = aWindow.getGroupMessageManager("browsers");
     MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));
 
+    this._saveableClosedWindowData.delete(winData);
     delete aWindow.__SSi;
   },
 
   /**
    * Decides whether or not a closed window should be put into the
    * _closedWindows Object. This might be called multiple times per
    * window, and will do the right thing of moving the window data
    * in or out of _closedWindows if the winData indicates that our
@@ -1368,17 +1387,19 @@ var SessionStoreInternal = {
    *        Whether or not the window being closed is the last
    *        browser window. Callers of this function should pass
    *        in the value of SessionStoreInternal.atLastWindow for
    *        this argument, and pass in the same value if they happen
    *        to call this method again asynchronously (for example, after
    *        a window flush).
    */
   maybeSaveClosedWindow(winData, isLastWindow) {
-    if (RunState.isRunning) {
+    // Make sure SessionStore is still running, and make sure that we
+    // haven't chosen to forget this window.
+    if (RunState.isRunning && this._saveableClosedWindowData.has(winData)) {
       // Determine whether the window has any tabs worth saving.
       let hasSaveableTabs = winData.tabs.some(this._shouldSaveTabState);
 
       // Note that we might already have this window stored in
       // _closedWindows from a previous call to this function.
       let winIndex = this._closedWindows.indexOf(winData);
       let alreadyStored = (winIndex != -1);
       let shouldStore = (hasSaveableTabs || isLastWindow);
@@ -1541,16 +1562,17 @@ var SessionStoreInternal = {
     var win = this._getMostRecentBrowserWindow();
     if (win) {
       win.setTimeout(() => SessionSaver.run(), 0);
     } else if (RunState.isRunning) {
       SessionSaver.run();
     }
 
     this._clearRestoringWindows();
+    this._saveableClosedWindowData.clear();
   },
 
   /**
    * On purge of domain data
    * @param aData
    *        String domain data
    */
   onPurgeDomainData: function ssi_onPurgeDomainData(aData) {
@@ -2185,17 +2207,19 @@ var SessionStoreInternal = {
   forgetClosedWindow: function ssi_forgetClosedWindow(aIndex) {
     // default to the most-recently closed window
     aIndex = aIndex || 0;
     if (!(aIndex in this._closedWindows)) {
       throw Components.Exception("Invalid index: not in the closed windows", Cr.NS_ERROR_INVALID_ARG);
     }
 
     // remove closed window from the array
+    let winData = this._closedWindows[aIndex];
     this._closedWindows.splice(aIndex, 1);
+    this._saveableClosedWindowData.delete(winData);
   },
 
   getWindowValue: function ssi_getWindowValue(aWindow, aKey) {
     if ("__SSi" in aWindow) {
       var data = this._windows[aWindow.__SSi].extData || {};
       return data[aKey] || "";
     }
 
--- a/browser/components/sessionstore/test/browser.ini
+++ b/browser/components/sessionstore/test/browser.ini
@@ -213,8 +213,9 @@ skip-if = true
 [browser_625016.js]
 skip-if = os == "mac"
 
 [browser_911547.js]
 [browser_send_async_message_oom.js]
 [browser_multiple_navigateAndRestore.js]
 run-if = e10s
 [browser_async_window_flushing.js]
+[browser_forget_async_closings.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/sessionstore/test/browser_forget_async_closings.js
@@ -0,0 +1,144 @@
+"use strict";
+
+const PAGE = "http://example.com/";
+
+/**
+ * Creates a tab in the current window worth storing in the
+ * closedTabs array, and then closes it. Runs a synchronous
+ * forgetFn passed in that should cause us to forget the tab,
+ * and then ensures that after the tab has sent its final
+ * update message that we didn't accidentally store it in
+ * the closedTabs array.
+ *
+ * @param forgetFn (function)
+ *        A synchronous function that should cause the tab
+ *        to be forgotten.
+ * @returns Promise
+ */
+let forgetTabHelper = Task.async(function*(forgetFn) {
+  // We want to suppress all non-final updates from the browser tabs
+  // so as to eliminate any racy-ness with this test.
+  yield pushPrefs(["browser.sessionstore.debug.no_auto_updates", true]);
+
+  // Forget any previous closed tabs from other tests that may have
+  // run in the same session.
+  Services.obs.notifyObservers(null, "browser:purge-session-history", 0);
+
+  is(ss.getClosedTabCount(window), 0,
+     "We should have 0 closed tabs being stored.");
+
+  // Create a tab worth remembering.
+  let tab = gBrowser.addTab(PAGE);
+  let browser = tab.linkedBrowser;
+  yield BrowserTestUtils.browserLoaded(browser, false, PAGE);
+  yield TabStateFlusher.flush(browser);
+
+  // Now close the tab, and immediately choose to forget it.
+  let promise = BrowserTestUtils.removeTab(tab);
+
+  // At this point, the tab will have closed, but the final update
+  // to SessionStore hasn't come up yet. Now do the operation that
+  // should cause us to forget the tab.
+  forgetFn();
+
+  is(ss.getClosedTabCount(window), 0, "Should have forgotten the closed tab");
+
+  // Now wait for the final update to come up.
+  yield promise;
+
+  is(ss.getClosedTabCount(window), 0,
+     "Should not have stored the forgotten closed tab");
+});
+
+/**
+ * Creates a new window worth storing in the closeWIndows array,
+ * and then closes it. Runs a synchronous forgetFn passed in that
+ * should cause us to forget the window, and then ensures that after
+ * the window has sent its final update message that we didn't
+ * accidentally store it in the closedWindows array.
+ *
+ * @param forgetFn (function)
+ *        A synchronous function that should cause the window
+ *        to be forgotten.
+ * @returns Promise
+ */
+let forgetWinHelper = Task.async(function*(forgetFn) {
+  // We want to suppress all non-final updates from the browser tabs
+  // so as to eliminate any racy-ness with this test.
+  yield pushPrefs(["browser.sessionstore.debug.no_auto_updates", true]);
+
+  // Forget any previous closed windows from other tests that may have
+  // run in the same session.
+  Services.obs.notifyObservers(null, "browser:purge-session-history", 0);
+
+  is(ss.getClosedWindowCount(), 0, "We should have 0 closed windows being stored.");
+
+  let newWin = yield BrowserTestUtils.openNewBrowserWindow();
+
+  // Create a tab worth remembering.
+  let tab = newWin.gBrowser.selectedTab;
+  let browser = tab.linkedBrowser;
+  browser.loadURI(PAGE);
+  yield BrowserTestUtils.browserLoaded(browser, false, PAGE);
+  yield TabStateFlusher.flush(browser);
+
+  // Now close the window and immediately choose to forget it.
+  let windowClosed = BrowserTestUtils.windowClosed(newWin);
+  let domWindowClosed = BrowserTestUtils.domWindowClosed(newWin);
+
+  newWin.close();
+  yield domWindowClosed;
+
+  // At this point, the window will have closed and the onClose handler
+  // has run, but the final update  to SessionStore hasn't come up yet.
+  // Now do the oepration that should cause us to forget the window.
+  forgetFn();
+
+  is(ss.getClosedWindowCount(), 0, "Should have forgotten the closed window");
+
+  // Now wait for the final update to come up.
+  yield windowClosed;
+
+  is(ss.getClosedWindowCount(), 0, "Should not have stored the closed window");
+});
+
+/**
+ * Tests that if we choose to forget a tab while waiting for its
+ * final flush to complete, we don't accidentally store it.
+ */
+add_task(function* test_forget_closed_tab() {
+  yield forgetTabHelper(() => {
+    ss.forgetClosedTab(window, 0);
+  });
+});
+
+/**
+ * Tests that if we choose to forget a tab while waiting for its
+ * final flush to complete, we don't accidentally store it.
+ */
+add_task(function* test_forget_closed_window() {
+  yield forgetWinHelper(() => {
+    ss.forgetClosedWindow(0);
+  });
+});
+
+/**
+ * Tests that if we choose to purge history while waiting for a
+ * final flush of a tab to complete, we don't accidentally store it.
+ */
+add_task(function* test_forget_purged_tab() {
+  yield forgetTabHelper(() => {
+    Services.obs.notifyObservers(null, "browser:purge-session-history", 0);
+  });
+});
+
+/**
+ * Tests that if we choose to purge history while waiting for a
+ * final flush of a window to complete, we don't accidentally
+ * store it.
+ */
+add_task(function* test_forget_purged_window() {
+  yield forgetWinHelper(() => {
+    Services.obs.notifyObservers(null, "browser:purge-session-history", 0);
+  });
+});
--- a/browser/extensions/loop/test/desktop-local/conversation_test.js
+++ b/browser/extensions/loop/test/desktop-local/conversation_test.js
@@ -24,16 +24,17 @@ describe("loop.conversation", function()
       },
       GetLocale: function() {
         return "en-US";
       },
       SetLoopPref: setLoopPrefStub,
       GetLoopPref: function(prefName) {
         switch (prefName) {
           case "debug.sdk":
+          case "debug.dispatcher":
             return false;
           default:
             return "http://fake";
         }
       },
       GetAllConstants: function() {
         return {
           LOOP_SESSION_TYPE: {
--- a/browser/extensions/loop/test/desktop-local/panel_test.js
+++ b/browser/extensions/loop/test/desktop-local/panel_test.js
@@ -51,17 +51,21 @@ describe("loop.panel", function() {
       },
       GetAllConstants: function() { return {}; },
       GetLocale: function() {
         return "en-US";
       },
       GetPluralRule: sinon.stub(),
       SetLoopPref: sinon.stub(),
       GetLoopPref: function(prefName) {
-        return "unseen";
+        if (prefName === "gettingStarted.seen") {
+          return "unseen";
+        }
+
+        return false;
       },
       GetPluralForm: function() {
         return "fakeText";
       },
       "Rooms:GetAll": function(version) {
         return [];
       },
       "Rooms:PushSubscription": sinon.stub(),
--- a/browser/extensions/loop/test/desktop-local/roomStore_test.js
+++ b/browser/extensions/loop/test/desktop-local/roomStore_test.js
@@ -45,18 +45,20 @@ describe("loop.store.RoomStore", functio
           },
           ROOM_CONTEXT_ADD: {
             ADD_FROM_PANEL: 0,
             ADD_FROM_CONVERSATION: 1
           }
         };
       },
       CopyString: sinon.stub(),
-      GetLoopPref: function(pref) {
-        return pref;
+      GetLoopPref: function(prefName) {
+        if (prefName === "debug.dispatcher") {
+          return false;
+        }
       },
       NotifyUITour: function() {},
       "Rooms:Create": sinon.stub().returns({ roomToken: "fakeToken" }),
       "Rooms:Delete": sinon.stub(),
       "Rooms:GetAll": sinon.stub(),
       "Rooms:Open": sinon.stub(),
       "Rooms:Rename": sinon.stub(),
       "Rooms:PushSubscription": sinon.stub(),
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,3 +1,3 @@
 This is the pdf.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 1.3.42
+Current extension version is: 1.3.56
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -15,18 +15,18 @@
 /*jshint globalstrict: false */
 /* globals PDFJS */
 
 // Initializing PDFJS global object (if still undefined)
 if (typeof PDFJS === 'undefined') {
   (typeof window !== 'undefined' ? window : this).PDFJS = {};
 }
 
-PDFJS.version = '1.3.42';
-PDFJS.build = '84a47f8';
+PDFJS.version = '1.3.56';
+PDFJS.build = 'e2aca38';
 
 (function pdfjsWrapper() {
   // Use strict in our context only - users might not want it
   'use strict';
 
 
 
 var globalScope = (typeof window === 'undefined') ? this : window;
@@ -243,17 +243,16 @@ function deprecated(details) {
 
 // Fatal errors that should trigger the fallback UI and halt execution by
 // throwing an exception.
 function error(msg) {
   if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
     console.log('Error: ' + msg);
     console.log(backtrace());
   }
-  UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
   throw new Error(msg);
 }
 
 function backtrace() {
   try {
     throw new Error();
   } catch (e) {
     return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
@@ -270,32 +269,16 @@ var UNSUPPORTED_FEATURES = PDFJS.UNSUPPO
   unknown: 'unknown',
   forms: 'forms',
   javaScript: 'javaScript',
   smask: 'smask',
   shadingPattern: 'shadingPattern',
   font: 'font'
 };
 
-var UnsupportedManager = PDFJS.UnsupportedManager =
-  (function UnsupportedManagerClosure() {
-  var listeners = [];
-  return {
-    listen: function (cb) {
-      listeners.push(cb);
-    },
-    notify: function (featureId) {
-      warn('Unsupported feature "' + featureId + '"');
-      for (var i = 0, ii = listeners.length; i < ii; i++) {
-        listeners[i](featureId);
-      }
-    }
-  };
-})();
-
 // Combines two URLs. The baseUrl shall be absolute URL. If the url is an
 // absolute URL, it will be returned as is.
 function combineUrl(baseUrl, url) {
   if (!url) {
     return baseUrl;
   }
   if (/^[a-z][a-z0-9+\-.]*:/i.test(url)) {
     return url;
@@ -1767,16 +1750,22 @@ var PDFDocumentLoadingTask = (function P
     this.onPassword = null;
 
     /**
      * Callback to be able to monitor the loading progress of the PDF file
      * (necessary to implement e.g. a loading bar). The callback receives
      * an {Object} with the properties: {number} loaded and {number} total.
      */
     this.onProgress = null;
+
+    /**
+     * Callback to when unsupported feature is used. The callback receives
+     * an {PDFJS.UNSUPPORTED_FEATURES} argument.
+     */
+    this.onUnsupportedFeature = null;
   }
 
   PDFDocumentLoadingTask.prototype =
       /** @lends PDFDocumentLoadingTask.prototype */ {
     /**
      * @return {Promise}
      */
     get promise() {
@@ -2525,19 +2514,16 @@ var PDFWorker = (function PDFWorkerClosu
           }.bind(this));
 
           messageHandler.on('console_log', function (data) {
             console.log.apply(console, data);
           });
           messageHandler.on('console_error', function (data) {
             console.error.apply(console, data);
           });
-          messageHandler.on('_unsupported_feature', function (data) {
-            UnsupportedManager.notify(data);
-          });
 
           var testObj = new Uint8Array([PDFJS.postMessageTransfers ? 255 : 0]);
           // Some versions of Opera throw a DATA_CLONE_ERR on serializing the
           // typed array. Also, checking if we can use transfers.
           try {
             messageHandler.send('test', testObj, [testObj.buffer]);
           } catch (ex) {
             info('Cannot use postMessage transfers');
@@ -2894,16 +2880,29 @@ var WorkerTransport = (function WorkerTr
         var intentState = page.intentStates[data.intent];
         if (intentState.displayReadyCapability) {
           intentState.displayReadyCapability.reject(data.error);
         } else {
           error(data.error);
         }
       }, this);
 
+      messageHandler.on('UnsupportedFeature',
+          function transportUnsupportedFeature(data) {
+        if (this.destroyed) {
+          return; // Ignore any pending requests if the worker was terminated.
+        }
+        var featureId = data.featureId;
+        var loadingTask = this.loadingTask;
+        if (loadingTask.onUnsupportedFeature) {
+          loadingTask.onUnsupportedFeature(featureId);
+        }
+        PDFJS.UnsupportedManager.notify(featureId);
+      }, this);
+
       messageHandler.on('JpegDecode', function(data) {
         if (this.destroyed) {
           return Promise.reject('Worker was terminated');
         }
 
         var imageUrl = data[0];
         var components = data[1];
         if (components !== 3 && components !== 1) {
@@ -3311,16 +3310,36 @@ var InternalRenderTask = (function Inter
       }
     }
 
   };
 
   return InternalRenderTask;
 })();
 
+/**
+ * (Deprecated) Global observer of unsupported feature usages. Use
+ * onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance.
+ */
+PDFJS.UnsupportedManager = (function UnsupportedManagerClosure() {
+  var listeners = [];
+  return {
+    listen: function (cb) {
+      deprecated('Global UnsupportedManager.listen is used: ' +
+                 ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
+      listeners.push(cb);
+    },
+    notify: function (featureId) {
+      for (var i = 0, ii = listeners.length; i < ii; i++) {
+        listeners[i](featureId);
+      }
+    }
+  };
+})();
+
 
 var Metadata = PDFJS.Metadata = (function MetadataClosure() {
   function fixMetadata(meta) {
     return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
       var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
                                 function(code, d1, d2, d3) {
         return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
       });
@@ -4347,16 +4366,17 @@ var CanvasGraphics = (function CanvasGra
     },
     endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
       var groupCtx = this.ctx;
       this.groupLevel--;
       this.ctx = this.groupStack.pop();
 
       composeSMask(this.ctx, this.current.activeSMask, groupCtx);
       this.ctx.restore();
+      copyCtxState(groupCtx, this.ctx);
     },
     save: function CanvasGraphics_save() {
       this.ctx.save();
       var old = this.current;
       this.stateStack.push(old);
       this.current = old.clone();
       this.current.activeSMask = null;
     },
@@ -5466,17 +5486,16 @@ var CanvasGraphics = (function CanvasGra
     },
 
     paintSolidColorImageMask:
       function CanvasGraphics_paintSolidColorImageMask() {
         this.ctx.fillRect(0, 0, 1, 1);
     },
 
     paintXObject: function CanvasGraphics_paintXObject() {
-      UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
       warn('Unsupported \'paintXObject\' command.');
     },
 
     // Marked content
 
     markPoint: function CanvasGraphics_markPoint(tag) {
       // TODO Marked content.
     },
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -15,18 +15,18 @@
 /*jshint globalstrict: false */
 /* globals PDFJS */
 
 // Initializing PDFJS global object (if still undefined)
 if (typeof PDFJS === 'undefined') {
   (typeof window !== 'undefined' ? window : this).PDFJS = {};
 }
 
-PDFJS.version = '1.3.42';
-PDFJS.build = '84a47f8';
+PDFJS.version = '1.3.56';
+PDFJS.build = 'e2aca38';
 
 (function pdfjsWrapper() {
   // Use strict in our context only - users might not want it
   'use strict';
 
 
 
 var globalScope = (typeof window === 'undefined') ? this : window;
@@ -243,17 +243,16 @@ function deprecated(details) {
 
 // Fatal errors that should trigger the fallback UI and halt execution by
 // throwing an exception.
 function error(msg) {
   if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
     console.log('Error: ' + msg);
     console.log(backtrace());
   }
-  UnsupportedManager.notify(UNSUPPORTED_FEATURES.unknown);
   throw new Error(msg);
 }
 
 function backtrace() {
   try {
     throw new Error();
   } catch (e) {
     return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
@@ -270,32 +269,16 @@ var UNSUPPORTED_FEATURES = PDFJS.UNSUPPO
   unknown: 'unknown',
   forms: 'forms',
   javaScript: 'javaScript',
   smask: 'smask',
   shadingPattern: 'shadingPattern',
   font: 'font'
 };
 
-var UnsupportedManager = PDFJS.UnsupportedManager =
-  (function UnsupportedManagerClosure() {
-  var listeners = [];
-  return {
-    listen: function (cb) {
-      listeners.push(cb);
-    },
-    notify: function (featureId) {
-      warn('Unsupported feature "' + featureId + '"');
-      for (var i = 0, ii = listeners.length; i < ii; i++) {
-        listeners[i](featureId);
-      }
-    }
-  };
-})();
-
 // Combines two URLs. The baseUrl shall be absolute URL. If the url is an
 // absolute URL, it will be returned as is.
 function combineUrl(baseUrl, url) {
   if (!url) {
     return baseUrl;
   }
   if (/^[a-z][a-z0-9+\-.]*:/i.test(url)) {
     return url;
@@ -1871,17 +1854,16 @@ var ChunkedStreamManager = (function Chu
       }
     }
   };
 
   return ChunkedStreamManager;
 })();
 
 
-// TODO(mack): Make use of PDFJS.Util.inherit() when it becomes available
 var BasePdfManager = (function BasePdfManagerClosure() {
   function BasePdfManager() {
     throw new Error('Cannot initialize BaseManagerManager');
   }
 
   BasePdfManager.prototype = {
     get docId() {
       return this._docId;
@@ -1898,29 +1880,29 @@ var BasePdfManager = (function BasePdfMa
     ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
       return this.ensure(this.pdfDocument.xref, prop, args);
     },
 
     ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
       return this.ensure(this.pdfDocument.catalog, prop, args);
     },
 
-    getPage: function BasePdfManager_pagePage(pageIndex) {
+    getPage: function BasePdfManager_getPage(pageIndex) {
       return this.pdfDocument.getPage(pageIndex);
     },
 
     cleanup: function BasePdfManager_cleanup() {
       return this.pdfDocument.cleanup();
     },
 
     ensure: function BasePdfManager_ensure(obj, prop, args) {
       return new NotImplementedException();
     },
 
-    requestRange: function BasePdfManager_ensure(begin, end) {
+    requestRange: function BasePdfManager_requestRange(begin, end) {
       return new NotImplementedException();
     },
 
     requestLoadedStream: function BasePdfManager_requestLoadedStream() {
       return new NotImplementedException();
     },
 
     sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
@@ -1951,55 +1933,50 @@ var LocalPdfManager = (function LocalPdf
   function LocalPdfManager(docId, data, password) {
     this._docId = docId;
     var stream = new Stream(data);
     this.pdfDocument = new PDFDocument(this, stream, password);
     this._loadedStreamCapability = createPromiseCapability();
     this._loadedStreamCapability.resolve(stream);
   }
 
-  LocalPdfManager.prototype = Object.create(BasePdfManager.prototype);
-  LocalPdfManager.prototype.constructor = LocalPdfManager;
-
-  LocalPdfManager.prototype.ensure =
-      function LocalPdfManager_ensure(obj, prop, args) {
-    return new Promise(function (resolve, reject) {
-      try {
-        var value = obj[prop];
-        var result;
-        if (typeof value === 'function') {
-          result = value.apply(obj, args);
-        } else {
-          result = value;
-        }
-        resolve(result);
-      } catch (e) {
-        reject(e);
-      }
-    });
-  };
-
-  LocalPdfManager.prototype.requestRange =
-      function LocalPdfManager_requestRange(begin, end) {
-    return Promise.resolve();
-  };
-
-  LocalPdfManager.prototype.requestLoadedStream =
-      function LocalPdfManager_requestLoadedStream() {
-  };
-
-  LocalPdfManager.prototype.onLoadedStream =
-      function LocalPdfManager_getLoadedStream() {
-    return this._loadedStreamCapability.promise;
-  };
-
-  LocalPdfManager.prototype.terminate =
-      function LocalPdfManager_terminate() {
-    return;
-  };
+  Util.inherit(LocalPdfManager, BasePdfManager, {
+    ensure: function LocalPdfManager_ensure(obj, prop, args) {
+      return new Promise(function (resolve, reject) {
+        try {
+          var value = obj[prop];
+          var result;
+          if (typeof value === 'function') {
+            result = value.apply(obj, args);
+          } else {
+            result = value;
+          }
+          resolve(result);
+        } catch (e) {
+          reject(e);
+        }
+      });
+    },
+
+    requestRange: function LocalPdfManager_requestRange(begin, end) {
+      return Promise.resolve();
+    },
+
+    requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
+      return;
+    },
+
+    onLoadedStream: function LocalPdfManager_onLoadedStream() {
+      return this._loadedStreamCapability.promise;
+    },
+
+    terminate: function LocalPdfManager_terminate() {
+      return;
+    }
+  });
 
   return LocalPdfManager;
 })();
 
 var NetworkPdfManager = (function NetworkPdfManagerClosure() {
   function NetworkPdfManager(docId, args, msgHandler) {
     this._docId = docId;
     this.msgHandler = msgHandler;
@@ -2010,77 +1987,70 @@ var NetworkPdfManager = (function Networ
       withCredentials: args.withCredentials,
       chunkedViewerLoading: args.chunkedViewerLoading,
       disableAutoFetch: args.disableAutoFetch,
       initialData: args.initialData
     };
     this.streamManager = new ChunkedStreamManager(args.length,
                                                   args.rangeChunkSize,
                                                   args.url, params);
-
     this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(),
-                                    args.password);
-  }
-
-  NetworkPdfManager.prototype = Object.create(BasePdfManager.prototype);
-  NetworkPdfManager.prototype.constructor = NetworkPdfManager;
-
-  NetworkPdfManager.prototype.ensure =
-      function NetworkPdfManager_ensure(obj, prop, args) {
-    var pdfManager = this;
-
-    return new Promise(function (resolve, reject) {
-      function ensureHelper() {
-        try {
-          var result;
-          var value = obj[prop];
-          if (typeof value === 'function') {
-            result = value.apply(obj, args);
-          } else {
-            result = value;
-          }
-          resolve(result);
-        } catch(e) {
-          if (!(e instanceof MissingDataException)) {
-            reject(e);
-            return;
-          }
-          pdfManager.streamManager.requestRange(e.begin, e.end).
-            then(ensureHelper, reject);
-        }
-      }
-
-      ensureHelper();
-    });
-  };
-
-  NetworkPdfManager.prototype.requestRange =
-      function NetworkPdfManager_requestRange(begin, end) {
-    return this.streamManager.requestRange(begin, end);
-  };
-
-  NetworkPdfManager.prototype.requestLoadedStream =
-      function NetworkPdfManager_requestLoadedStream() {
-    this.streamManager.requestAllChunks();
-  };
-
-  NetworkPdfManager.prototype.sendProgressiveData =
-      function NetworkPdfManager_sendProgressiveData(chunk) {
-    this.streamManager.onReceiveData({ chunk: chunk });
-  };
-
-  NetworkPdfManager.prototype.onLoadedStream =
-      function NetworkPdfManager_getLoadedStream() {
-    return this.streamManager.onLoadedStream();
-  };
-
-  NetworkPdfManager.prototype.terminate =
-      function NetworkPdfManager_terminate() {
-    this.streamManager.abort();
-  };
+                                       args.password);
+  }
+
+  Util.inherit(NetworkPdfManager, BasePdfManager, {
+    ensure: function NetworkPdfManager_ensure(obj, prop, args) {
+      var pdfManager = this;
+
+      return new Promise(function (resolve, reject) {
+        function ensureHelper() {
+          try {
+            var result;
+            var value = obj[prop];
+            if (typeof value === 'function') {
+              result = value.apply(obj, args);
+            } else {
+              result = value;
+            }
+            resolve(result);
+          } catch(e) {
+            if (!(e instanceof MissingDataException)) {
+              reject(e);
+              return;
+            }
+            pdfManager.streamManager.requestRange(e.begin, e.end).
+              then(ensureHelper, reject);
+          }
+        }
+
+        ensureHelper();
+      });
+    },
+
+    requestRange: function NetworkPdfManager_requestRange(begin, end) {
+      return this.streamManager.requestRange(begin, end);
+    },
+
+    requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
+      this.streamManager.requestAllChunks();
+    },
+
+    sendProgressiveData:
+        function NetworkPdfManager_sendProgressiveData(chunk) {
+      this.streamManager.onReceiveData({ chunk: chunk });
+    },
+
+    onLoadedStream: function NetworkPdfManager_onLoadedStream() {
+      return this.streamManager.onLoadedStream();
+    },
+
+    terminate: function NetworkPdfManager_terminate() {
+      this.streamManager.abort();
+    }
+  });
 
   return NetworkPdfManager;
 })();
 
 
 var Page = (function PageClosure() {
 
   var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
@@ -2265,17 +2235,17 @@ var Page = (function PageClosure() {
         var annotations = datas[1];
 
         if (annotations.length === 0) {
           pageOpList.flush(true);
           return pageOpList;
         }
 
         var annotationsReadyPromise = Annotation.appendToOperatorList(
-          annotations, pageOpList, pdfManager, partialEvaluator, task, intent);
+          annotations, pageOpList, partialEvaluator, task, intent);
         return annotationsReadyPromise.then(function () {
           pageOpList.flush(true);
           return pageOpList;
         });
       });
     },
 
     extractTextContent: function Page_extractTextContent(task,
@@ -4538,35 +4508,32 @@ var Annotation = (function AnnotationClo
     } else {
       appearance = appearances;
     }
     return appearance;
   }
 
   function Annotation(params) {
     var dict = params.dict;
-    var data = this.data = {};
-
-    data.subtype = dict.get('Subtype').name;
 
     this.setFlags(dict.get('F'));
-    data.annotationFlags = this.flags;
-
     this.setRectangle(dict.get('Rect'));
-    data.rect = this.rectangle;
-
     this.setColor(dict.get('C'));
-    data.color = this.color;
-
-    this.borderStyle = data.borderStyle = new AnnotationBorderStyle();
     this.setBorderStyle(dict);
-
     this.appearance = getDefaultAppearance(dict);
-    data.hasAppearance = !!this.appearance;
-    data.id = params.ref.num;
+
+    // Expose public properties using a data object.
+    this.data = {};
+    this.data.id = params.ref.num;
+    this.data.subtype = dict.get('Subtype').name;
+    this.data.annotationFlags = this.flags;
+    this.data.rect = this.rectangle;
+    this.data.color = this.color;
+    this.data.borderStyle = this.borderStyle;
+    this.data.hasAppearance = !!this.appearance;
   }
 
   Annotation.prototype = {
     /**
      * @return {boolean}
      */
     get viewable() {
       if (this.flags) {
@@ -4683,16 +4650,17 @@ var Annotation = (function AnnotationClo
     /**
      * Set the border style (as AnnotationBorderStyle object).
      *
      * @public
      * @memberof Annotation
      * @param {Dict} borderStyle - The border style dictionary
      */
     setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
+      this.borderStyle = new AnnotationBorderStyle();
       if (!isDict(borderStyle)) {
         return;
       }
       if (borderStyle.has('BS')) {
         var dict = borderStyle.get('BS');
         var dictType;
 
         if (!dict.has('Type') || (isName(dictType = dict.get('Type')) &&
@@ -4735,23 +4703,21 @@ var Annotation = (function AnnotationClo
           objectLoader.load().then(function() {
             resolve(resources);
           }, reject);
         }, reject);
       }.bind(this));
     },
 
     getOperatorList: function Annotation_getOperatorList(evaluator, task) {
-
       if (!this.appearance) {
         return Promise.resolve(new OperatorList());
       }
 
       var data = this.data;
-
       var appearanceDict = this.appearance.dict;
       var resourcesPromise = this.loadResources([
         'ExtGState',
         'ColorSpace',
         'Pattern',
         'Shading',
         'XObject',
         'Font'
@@ -4773,43 +4739,32 @@ var Annotation = (function AnnotationClo
               self.appearance.reset();
               return opList;
             });
         });
     }
   };
 
   Annotation.appendToOperatorList = function Annotation_appendToOperatorList(
-      annotations, opList, pdfManager, partialEvaluator, task, intent) {
-
-    function reject(e) {
-      annotationsReadyCapability.reject(e);
-    }
-
-    var annotationsReadyCapability = createPromiseCapability();
-
+      annotations, opList, partialEvaluator, task, intent) {
     var annotationPromises = [];
     for (var i = 0, n = annotations.length; i < n; ++i) {
-      if (intent === 'display' && annotations[i].viewable ||
-          intent === 'print' && annotations[i].printable) {
+      if ((intent === 'display' && annotations[i].viewable) ||
+          (intent === 'print' && annotations[i].printable)) {
         annotationPromises.push(
           annotations[i].getOperatorList(partialEvaluator, task));
       }
     }
-    Promise.all(annotationPromises).then(function(datas) {
+    return Promise.all(annotationPromises).then(function(operatorLists) {
       opList.addOp(OPS.beginAnnotations, []);
-      for (var i = 0, n = datas.length; i < n; ++i) {
-        var annotOpList = datas[i];
-        opList.addOpList(annotOpList);
+      for (var i = 0, n = operatorLists.length; i < n; ++i) {
+        opList.addOpList(operatorLists[i]);
       }
       opList.addOp(OPS.endAnnotations, []);
-      annotationsReadyCapability.resolve();
-    }, reject);
-
-    return annotationsReadyCapability.promise;
+    });
   };
 
   return Annotation;
 })();
 
 /**
  * Contains all data regarding an annotation's border style.
  *
@@ -4944,17 +4899,16 @@ var AnnotationBorderStyle = (function An
       }
     }
   };
 
   return AnnotationBorderStyle;
 })();
 
 var WidgetAnnotation = (function WidgetAnnotationClosure() {
-
   function WidgetAnnotation(params) {
     Annotation.call(this, params);
 
     var dict = params.dict;
     var data = this.data;
 
     data.fieldValue = stringToPDFString(
       Util.getInheritableProperty(dict, 'V') || '');
@@ -5068,17 +5022,17 @@ var TextAnnotation = (function TextAnnot
       data.name = dict.has('Name') ? dict.get('Name').name : 'Note';
     }
 
     if (dict.has('C')) {
       data.hasBgColor = true;
     }
   }
 
-  Util.inherit(TextAnnotation, Annotation, { });
+  Util.inherit(TextAnnotation, Annotation, {});
 
   return TextAnnotation;
 })();
 
 var LinkAnnotation = (function LinkAnnotationClosure() {
   function LinkAnnotation(params) {
     Annotation.call(this, params);
 
@@ -5144,17 +5098,17 @@ var LinkAnnotation = (function LinkAnnot
   // Lets URLs beginning with 'www.' default to using the 'http://' protocol.
   function addDefaultProtocolToUrl(url) {
     if (url && url.indexOf('www.') === 0) {
       return ('http://' + url);
     }
     return url;
   }
 
-  Util.inherit(LinkAnnotation, Annotation, { });
+  Util.inherit(LinkAnnotation, Annotation, {});
 
   return LinkAnnotation;
 })();
 
 
 var PDFFunction = (function PDFFunctionClosure() {
   var CONSTRUCT_SAMPLED = 0;
   var CONSTRUCT_INTERPOLATED = 2;
@@ -9562,17 +9516,17 @@ var Pattern = (function PatternClosure()
     // Input: current Canvas context
     // Output: the appropriate fillStyle or strokeStyle
     getPattern: function Pattern_getPattern(ctx) {
       error('Should not call Pattern.getStyle: ' + ctx);
     }
   };
 
   Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref,
-                                                       res) {
+                                                       res, handler) {
 
     var dict = isStream(shading) ? shading.dict : shading;
     var type = dict.get('ShadingType');
 
     try {
       switch (type) {
         case ShadingType.AXIAL:
         case ShadingType.RADIAL:
@@ -9585,17 +9539,18 @@ var Pattern = (function PatternClosure()
           return new Shadings.Mesh(shading, matrix, xref, res);
         default:
           throw new Error('Unsupported ShadingType: ' + type);
       }
     } catch (ex) {
       if (ex instanceof MissingDataException) {
         throw ex;
       }
-      UnsupportedManager.notify(UNSUPPORTED_FEATURES.shadingPattern);
+      handler.send('UnsupportedFeature',
+                   {featureId: UNSUPPORTED_FEATURES.shadingPattern});
       warn(ex);
       return new Shadings.Dummy();
     }
   };
   return Pattern;
 })();
 
 var Shadings = {};
@@ -10623,16 +10578,19 @@ var PartialEvaluator = (function Partial
           function (translated) {
         if (!translated.font.isType3Font) {
           return translated;
         }
         return translated.loadType3Data(self, resources, operatorList, task).
           then(function () {
           return translated;
         }, function (reason) {
+          // Error in the font data -- sending unsupported feature notification.
+          self.handler.send('UnsupportedFeature',
+                            {featureId: UNSUPPORTED_FEATURES.font});
           return new TranslatedFont('g_font_error',
             new ErrorFont('Type3 font load error: ' + reason), translated.font);
         });
       }).then(function (translated) {
         state.font = translated.font;
         translated.send(self.handler);
         return translated.loadedName;
       });
@@ -10847,27 +10805,30 @@ var PartialEvaluator = (function Partial
       var translatedPromise;
       try {
         translatedPromise = Promise.resolve(
           this.translateFont(preEvaluatedFont, xref));
       } catch (e) {
         translatedPromise = Promise.reject(e);
       }
 
+      var self = this;
       translatedPromise.then(function (translatedFont) {
         if (translatedFont.fontType !== undefined) {
           var xrefFontStats = xref.stats.fontTypes;
           xrefFontStats[translatedFont.fontType] = true;
         }
 
         fontCapability.resolve(new TranslatedFont(font.loadedName,
           translatedFont, font));
       }, function (reason) {
         // TODO fontCapability.reject?
-        UnsupportedManager.notify(UNSUPPORTED_FEATURES.font);
+        // Error in the font data -- sending unsupported feature notification.
+        self.handler.send('UnsupportedFeature',
+                          {featureId: UNSUPPORTED_FEATURES.font});
 
         try {
           // error, but it's still nice to have font type reported
           var descriptor = preEvaluatedFont.descriptor;
           var fontFile3 = descriptor && descriptor.get('FontFile3');
           var subtype = fontFile3 && fontFile3.get('Subtype');
           var fontType = getFontType(preEvaluatedFont.type,
                                      subtype && subtype.name);
@@ -10910,17 +10871,18 @@ var PartialEvaluator = (function Partial
 
         if (typeNum === TILING_PATTERN) {
           var color = cs.base ? cs.base.getRgb(args, 0) : null;
           return this.handleTilingType(fn, color, resources, pattern,
                                        dict, operatorList, task);
         } else if (typeNum === SHADING_PATTERN) {
           var shading = dict.get('Shading');
           var matrix = dict.get('Matrix');
-          pattern = Pattern.parseShading(shading, matrix, xref, resources);
+          pattern = Pattern.parseShading(shading, matrix, xref, resources,
+                                         this.handler);
           operatorList.addOp(fn, pattern.getIR());
           return Promise.resolve();
         } else {
           return Promise.reject('Unknown PatternType: ' + typeNum);
         }
       }
       // TODO shall we fail here?
       operatorList.addOp(fn, args);
@@ -11147,17 +11109,17 @@ var PartialEvaluator = (function Partial
               }
 
               var shading = shadingRes.get(args[0].name);
               if (!shading) {
                 error('No shading object found');
               }
 
               var shadingFill = Pattern.parseShading(shading, null, xref,
-                resources);
+                resources, self.handler);
               var patternIR = shadingFill.getIR();
               args = [patternIR];
               fn = OPS.shadingFill;
               break;
             case OPS.setGState:
               var dictName = args[0];
               var extGState = resources.get('ExtGState');
 
@@ -16924,21 +16886,25 @@ var Font = (function FontClosure() {
     }
     return {
       toFontChar: toFontChar,
       charCodeToGlyphId: newMap,
       nextAvailableFontCharCode: nextAvailableFontCharCode
     };
   }
 
-  function getRanges(glyphs) {
+  function getRanges(glyphs, numGlyphs) {
     // Array.sort() sorts by characters, not numerically, so convert to an
     // array of characters.
     var codes = [];
     for (var charCode in glyphs) {
+      // Remove an invalid glyph ID mappings to make OTS happy.
+      if (glyphs[charCode] >= numGlyphs) {
+        continue;
+      }
       codes.push({ fontCharCode: charCode | 0, glyphId: glyphs[charCode] });
     }
     codes.sort(function fontGetRangesSort(a, b) {
       return a.fontCharCode - b.fontCharCode;
     });
 
     // Split the sorted codes into ranges.
     var ranges = [];
@@ -16957,18 +16923,18 @@ var Font = (function FontClosure() {
         }
       }
       ranges.push([start, end, codeIndices]);
     }
 
     return ranges;
   }
 
-  function createCmapTable(glyphs) {
-    var ranges = getRanges(glyphs);
+  function createCmapTable(glyphs, numGlyphs) {
+    var ranges = getRanges(glyphs, numGlyphs);
     var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
     var cmap = '\x00\x00' + // version
                string16(numTables) +  // numTables
                '\x00\x03' + // platformID
                '\x00\x01' + // encodingID
                string32(4 + numTables * 8); // start of the table record
 
     var i, ii, j, jj;
@@ -18461,17 +18427,17 @@ var Font = (function FontClosure() {
         charCodeToGlyphId[0] = 0;
       }
 
       // Converting glyphs and ids into font's cmap table
       var newMapping = adjustMapping(charCodeToGlyphId, properties);
       this.toFontChar = newMapping.toFontChar;
       tables.cmap = {
         tag: 'cmap',
-        data: createCmapTable(newMapping.charCodeToGlyphId)
+        data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
       };
 
       if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
         tables['OS/2'] = {
           tag: 'OS/2',
           data: createOS2Table(properties, newMapping.charCodeToGlyphId,
                                metricsOverride)
         };
@@ -18599,17 +18565,18 @@ var Font = (function FontClosure() {
 
       var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
       // PostScript Font Program
       builder.addTable('CFF ', font.data);
       // OS/2 and Windows Specific metrics
       builder.addTable('OS/2', createOS2Table(properties,
                                               newMapping.charCodeToGlyphId));
       // Character to glyphs mapping
-      builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId));
+      builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId,
+                       numGlyphs));
       // Font header
       builder.addTable('head',
             '\x00\x01\x00\x00' + // Version number
             '\x00\x00\x10\x00' + // fontRevision
             '\x00\x00\x00\x00' + // checksumAdjustement
             '\x5F\x0F\x3C\xF5' + // magicNumber
             '\x00\x00' + // Flags
             safeString16(unitsPerEm) + // unitsPerEM
@@ -31002,27 +30969,42 @@ var Lexer = (function LexerClosure() {
         }
         if (!charBuffered) {
           ch = this.nextChar();
         }
       }
       return strBuf.join('');
     },
     getName: function Lexer_getName() {
-      var ch;
+      var ch, previousCh;
       var strBuf = this.strBuf;
       strBuf.length = 0;
       while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
         if (ch === 0x23) { // '#'
           ch = this.nextChar();
+          if (specialChars[ch]) {
+            warn('Lexer_getName: ' +
+                 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
+            strBuf.push('#');
+            break;
+          }
           var x = toHexDigit(ch);
           if (x !== -1) {
-            var x2 = toHexDigit(this.nextChar());
+            previousCh = ch;
+            ch = this.nextChar();
+            var x2 = toHexDigit(ch);
             if (x2 === -1) {
-              error('Illegal digit in hex char in name: ' + x2);
+              warn('Lexer_getName: Illegal digit (' +
+                   String.fromCharCode(ch) +') in hexadecimal number.');
+              strBuf.push('#', String.fromCharCode(previousCh));
+              if (specialChars[ch]) {
+                break;
+              }
+              strBuf.push(String.fromCharCode(ch));
+              continue;
             }
             strBuf.push(String.fromCharCode((x << 4) | x2));
           } else {
             strBuf.push('#', String.fromCharCode(ch));
           }
         } else {
           strBuf.push(String.fromCharCode(ch));
         }
@@ -34346,16 +34328,21 @@ var WorkerMessageHandler = PDFJS.WorkerM
           info('page=' + pageNum + ' - getOperatorList: time=' +
                (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
         }, function(e) {
           finishWorkerTask(task);
           if (task.terminated) {
             return; // ignoring errors from the terminated thread
           }
 
+          // For compatibility with older behavior, generating unknown
+          // unsupported feature notification on errors.
+          handler.send('UnsupportedFeature',
+                       {featureId: UNSUPPORTED_FEATURES.unknown});
+
           var minimumStackMessage =
             'worker.js: while trying to getPage() and getOperatorList()';
 
           var wrappedException;
 
           // Turn the error into an obj that can be serialized
           if (typeof e === 'string') {
             wrappedException = {
@@ -34480,25 +34467,16 @@ var workerConsole = {
 
 
 // Worker thread?
 if (typeof window === 'undefined') {
   if (!('console' in globalScope)) {
     globalScope.console = workerConsole;
   }
 
-  // Listen for unsupported features so we can pass them on to the main thread.
-  PDFJS.UnsupportedManager.listen(function (msg) {
-    globalScope.postMessage({
-      targetName: 'main',
-      action: '_unsupported_feature',
-      data: msg
-    });
-  });
-
   var handler = new MessageHandler('worker', 'main', this);
   WorkerMessageHandler.setup(handler, this);
 }
 
 
 /* This class implements the QM Coder decoding as defined in
  *   JPEG 2000 Part I Final Committee Draft Version 1.0
  *   Annex C.3 Arithmetic decoding procedure
--- a/browser/extensions/pdfjs/content/web/viewer.css
+++ b/browser/extensions/pdfjs/content/web/viewer.css
@@ -16,16 +16,17 @@
 .textLayer {
   position: absolute;
   left: 0;
   top: 0;
   right: 0;
   bottom: 0;
   overflow: hidden;
   opacity: 0.2;
+  line-height: 1.0;
 }
 
 .textLayer > div {
   color: transparent;
   position: absolute;
   white-space: pre;
   cursor: text;
   -moz-transform-origin: 0% 0%;
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -6508,16 +6508,19 @@ var PDFViewerApplication = {
       PasswordPrompt.reason = reason;
       PasswordPrompt.open();
     };
 
     loadingTask.onProgress = function getDocumentProgress(progressData) {
       self.progress(progressData.loaded / progressData.total);
     };
 
+    // Listen for unsupported features to trigger the fallback UI.
+    loadingTask.onUnsupportedFeature = this.fallback.bind(this);
+
     var result = loadingTask.promise.then(
       function getDocumentCallback(pdfDocument) {
         self.load(pdfDocument, scale);
       },
       function getDocumentError(exception) {
         var message = exception && exception.message;
         var loadingErrorMessage = mozL10n.get('loading_error', null,
           'An error occurred while loading the PDF.');
@@ -7243,20 +7246,16 @@ function webViewerInitialized() {
     document.getElementById('secondaryPresentationMode').
       classList.add('hidden');
   }
 
   if (PDFViewerApplication.supportsIntegratedFind) {
     document.getElementById('viewFind').classList.add('hidden');
   }
 
-  // Listen for unsupported features to trigger the fallback UI.
-  PDFJS.UnsupportedManager.listen(
-    PDFViewerApplication.fallback.bind(PDFViewerApplication));
-
   // Suppress context menus for some controls
   document.getElementById('scaleSelect').oncontextmenu = noContextMenuHandler;
 
   var mainContainer = document.getElementById('mainContainer');
   var outerContainer = document.getElementById('outerContainer');
   mainContainer.addEventListener('transitionend', function(e) {
     if (e.target === mainContainer) {
       var event = document.createEvent('UIEvents');
--- a/browser/locales/en-US/chrome/browser/aboutCertError.dtd
+++ b/browser/locales/en-US/chrome/browser/aboutCertError.dtd
@@ -28,8 +28,9 @@ certificate.">
 
 <!ENTITY certerror.expert.content "If you understand what's going on, you
 can tell &brandShortName; to start trusting this site's identification.
 <b>Even if you trust the site, this error could mean that someone is
 tampering with your connection.</b>">
 <!ENTITY certerror.expert.contentPara2 "Don't add an exception unless
 you know there's a good reason why this site doesn't use trusted identification.">
 <!ENTITY certerror.addException.label "Add Exception…">
+<!ENTITY certerror.copyToClipboard.label "Copy text to clipboard">
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -796,14 +796,21 @@ muteTab.label = Mute Tab
 muteTab.accesskey = M
 unmuteTab.label = Unmute Tab
 unmuteTab.accesskey = M
 
 # LOCALIZATION NOTE (weakCryptoOverriding.message): %S is brandShortName
 weakCryptoOverriding.message = %S recommends that you don't enter your password, credit card and other personal information on this website.
 revokeOverride.label = Don't Trust This Website
 revokeOverride.accesskey = D
+# LOCALIZATION NOTE (certErrorDetails.label): This is a text string that
+# appears in the about:certerror page, so that the user can copy and send it to
+# the server administrators for troubleshooting. %1$S is the visited URL, %2$S
+# is the error message, %3$S is true or false, depending on whether the server
+# supports HSTS, %4$S is true or false, depending on whether the server
+# supports HPKP, %5$S is the certificate chain in PEM format.
+certErrorDetails.label = %1$S\r\n\r\n%2$S\r\n\r\nHTTP Strict Transport Security: %3$S\r\nHTTP Public Key Pinning: %4$S\r\n\r\nCertificate chain:\r\n\r\n%5$S
 
 # LOCALIZATION NOTE (tabgroups.migration.anonGroup):
 # %S is the group number/ID
 tabgroups.migration.anonGroup = Group %S
 tabgroups.migration.tabGroupBookmarkFolderName = Bookmarked Tab Groups
 
--- a/browser/locales/en-US/chrome/overrides/netError.dtd
+++ b/browser/locales/en-US/chrome/overrides/netError.dtd
@@ -210,19 +210,19 @@ functionality specific to firefox. -->
 <!ENTITY errorReporting.sent "Report sent">
 <!ENTITY errorReporting.report "Report">
 <!ENTITY errorReporting.tryAgain "Try again">
 
 <!ENTITY remoteXUL.title "Remote XUL">
 <!ENTITY remoteXUL.longDesc "<p><ul><li>Please contact the website owners to inform them of this problem.</li></ul></p>">
 
 <!ENTITY sslv3Used.title "Unable to Connect Securely">
-<!-- LOCALIZATION NOTE (sslv3Used.longDesc) - Do not translate
-     "ssl_error_unsupported_version". -->
-<!ENTITY sslv3Used.longDesc "Advanced info: ssl_error_unsupported_version">
+<!-- LOCALIZATION NOTE (sslv3Used.longDesc2) - Do not translate
+     "SSL_ERROR_UNSUPPORTED_VERSION". -->
+<!ENTITY sslv3Used.longDesc2 "Advanced info: SSL_ERROR_UNSUPPORTED_VERSION">
 
 <!ENTITY weakCryptoUsed.title "Your connection is not secure">
-<!-- LOCALIZATION NOTE (weakCryptoUsed.longDesc) - Do not translate
-     "ssl_error_no_cypher_overlap". -->
-<!ENTITY weakCryptoUsed.longDesc "Advanced info: ssl_error_no_cypher_overlap">
+<!-- LOCALIZATION NOTE (weakCryptoUsed.longDesc2) - Do not translate
+     "SSL_ERROR_NO_CYPHER_OVERLAP". -->
+<!ENTITY weakCryptoUsed.longDesc2 "Advanced info: SSL_ERROR_NO_CYPHER_OVERLAP">
 <!ENTITY weakCryptoAdvanced.title "Advanced">
 <!ENTITY weakCryptoAdvanced.longDesc "<span class='hostname'></span> uses security technology that is outdated and vulnerable to attack. An attacker could easily reveal information which you thought to be safe.">
 <!ENTITY weakCryptoAdvanced.override "(Not secure) Try loading <span class='hostname'></span> using outdated security">
--- a/browser/themes/shared/aboutCertError.css
+++ b/browser/themes/shared/aboutCertError.css
@@ -48,16 +48,37 @@ body {
   display: flex;
   flex-flow: row wrap;
 }
 
 #buttonSpacer {
   flex: 1;
 }
 
+#certificateErrorDebugInformation {
+  display: none;
+  background-color: var(--in-content-box-background-hover) !important;
+  border-top: 1px solid var(--in-content-border-color);
+  position: absolute;
+  left: 0%;
+  top: 100%;
+  width: 65%;
+  padding: 1em 17.5%;
+}
+
+#certificateErrorText {
+  font-family: monospace;
+  white-space: pre-wrap;
+  padding: 1em 0;
+}
+
+#errorCode {
+  white-space: nowrap;
+}
+
 #returnButton {
   background-color: var(--in-content-primary-button-background);
   border: none;
   color: var(--in-content-selected-text);
   min-width: 250px;
   margin-inline-start: 0;
 }
 
--- a/browser/themes/shared/aboutNetError.css
+++ b/browser/themes/shared/aboutNetError.css
@@ -168,8 +168,14 @@ div#weakCryptoAdvancedPanel {
 
 span#hostname {
   font-weight: bold;
 }
 
 #automaticallyReportInFuture {
   cursor: pointer;
 }
+
+#errorCode {
+  color: var(--in-content-page-color);
+  cursor: text;
+  text-decoration: none;
+}
--- a/mobile/android/base/resources/values-v21/themes.xml
+++ b/mobile/android/base/resources/values-v21/themes.xml
@@ -11,25 +11,30 @@
     <style name="GeckoBase" parent="Theme.AppCompat.Light.DarkActionBar">
         <item name="colorPrimary">@color/text_and_tabs_tray_grey</item>
         <item name="colorPrimaryDark">@color/text_and_tabs_tray_grey</item>
         <item name="windowActionBar">false</item>
         <item name="windowNoTitle">true</item>
         <item name="android:windowContentOverlay">@null</item>
         <item name="android:actionBarStyle">@style/GeckoActionBar</item>
         <!-- TODO (bug 1220863): Once we extend AppCompatActivity, set actionBarStyle. -->
+        <item name="android:alertDialogTheme">@style/GeckoAlertDialog</item>
     </style>
 
     <style name="GeckoPreferencesBase" parent="Gecko">
         <item name="android:windowActionBar">true</item>
         <item name="android:windowNoTitle">false</item>
         <item name="android:actionBarStyle">@style/ActionBar.GeckoPreferences</item>
         <item name="android:actionBarTheme">@style/ActionBarThemeGeckoPreferences</item>
     </style>
 
+    <style name="GeckoAlertDialog" parent="@android:style/Theme.Material.Light.Dialog.Alert">
+        <item name="android:colorAccent">@color/fennec_ui_orange</item>
+    </style>
+
     <style name="ActionBar.FxAccountStatusActivity" parent="@android:style/Widget.Material.ActionBar.Solid">
         <item name="android:displayOptions">homeAsUp|showTitle</item>
         <item name="android:titleTextStyle">@style/ActionBarTitleTextStyle</item>
     </style>
 
     <style name="ActionBar.GeckoPreferences" parent="@android:style/Widget.Material.ActionBar.Solid">
         <item name="android:titleTextStyle">@style/ActionBarTitleTextStyle</item>
     </style>
--- a/security/manager/locales/en-US/chrome/pipnss/pipnss.properties
+++ b/security/manager/locales/en-US/chrome/pipnss/pipnss.properties
@@ -287,17 +287,18 @@ certErrorMismatchSinglePlain=The certifi
 certErrorMismatchMultiple=The certificate is only valid for the following names:
 certErrorMismatchNoNames=The certificate is not valid for any server names.
 
 # LOCALIZATION NOTE (certErrorExpiredNow): Do not translate %1$S (date+time of expired certificate) or %2$S (current date+time)
 certErrorExpiredNow=The certificate expired on %1$S. The current time is %2$S.
 # LOCALIZATION NOTE (certErrorNotYetValidNow): Do not translate %1$S (date+time certificate will become valid) or %2$S (current date+time)
 certErrorNotYetValidNow=The certificate will not be valid until %1$S. The current time is %2$S.
 
-certErrorCodePrefix=(Error code: %S)
+# LOCALIZATION NOTE (certErrorCodePrefix2): Do not translate <a id="errorCode" title="%1$S">%1$S</a>
+certErrorCodePrefix2=Error code: <a id="errorCode" title="%1$S">%1$S</a>
 
 CertInfoIssuedFor=Issued to:
 CertInfoIssuedBy=Issued by:
 CertInfoValid=Valid
 CertInfoFrom=from
 CertInfoTo=to
 CertInfoPurposes=Purposes
 CertInfoEmail=Email
--- a/security/manager/ssl/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/TransportSecurityInfo.cpp
@@ -877,25 +877,24 @@ static void
 AppendErrorTextCode(PRErrorCode errorCodeToReport,
                     nsINSSComponent *component,
                     nsString &returnedMessage)
 {
   const char *codeName = nsNSSErrors::getDefaultErrorStringName(errorCodeToReport);
   if (codeName)
   {
     nsCString error_id(codeName);
-    ToLowerCase(error_id);
     NS_ConvertASCIItoUTF16 idU(error_id);
 
     const char16_t *params[1];
     params[0] = idU.get();
 
     nsString formattedString;
     nsresult rv;
-    rv = component->PIPBundleFormatStringFromName("certErrorCodePrefix", 
+    rv = component->PIPBundleFormatStringFromName("certErrorCodePrefix2",
                                                   params, 1, 
                                                   formattedString);
     if (NS_SUCCEEDED(rv)) {
       returnedMessage.Append('\n');
       returnedMessage.Append(formattedString);
       returnedMessage.Append('\n');
     }
     else {
--- a/security/manager/ssl/nsNSSErrors.cpp
+++ b/security/manager/ssl/nsNSSErrors.cpp
@@ -73,24 +73,23 @@ nsNSSErrors::getErrorMessageFromCode(PRE
     returnedMessage.AppendASCII(PR_ErrorToString(err, PR_LANGUAGE_EN));
     returnedMessage.Append('\n');
   }
   
   if (nss_error_id_str)
   {
     nsresult rv;
     nsCString error_id(nss_error_id_str);
-    ToLowerCase(error_id);
     NS_ConvertASCIItoUTF16 idU(error_id);
 
     const char16_t *params[1];
     params[0] = idU.get();
 
     nsString formattedString;
-    rv = component->PIPBundleFormatStringFromName("certErrorCodePrefix", 
+    rv = component->PIPBundleFormatStringFromName("certErrorCodePrefix2",
                                                   params, 1, 
                                                   formattedString);
     if (NS_SUCCEEDED(rv)) {
       returnedMessage.Append('\n');
       returnedMessage.Append(formattedString);
       returnedMessage.Append('\n');
     }
     else {
copy from browser/.eslintrc
copy to storage/.eslintrc
--- a/storage/test/unit/head_storage.js
+++ b/storage/test/unit/head_storage.js
@@ -11,16 +11,18 @@ Cu.import("resource://gre/modules/XPCOMU
 XPCOMUtils.defineLazyModuleGetter(this, "Promise",
     "resource://gre/modules/Promise.jsm");
 
 
 do_get_profile();
 var dirSvc = Cc["@mozilla.org/file/directory_service;1"].
              getService(Ci.nsIProperties);
 
+var gDBConn = null;
+
 function getTestDB()
 {
   var db = dirSvc.get("ProfD", Ci.nsIFile);
   db.append("test_storage.sqlite");
   return db;
 }
 
 /**
@@ -48,54 +50,52 @@ function cleanup()
   // we need to null out the database variable to get a new connection the next
   // time getOpenedDatabase is called
   gDBConn = null;
 
   // removing test db
   print("*** Storage Tests: Trying to remove file!");
   var dbFile = getTestDB();
   if (dbFile.exists())
-    try { dbFile.remove(false); } catch(e) { /* stupid windows box */ }
+    try { dbFile.remove(false); } catch (e) { /* stupid windows box */ }
 }
 
 /**
  * Use asyncClose to cleanup a connection.  Synchronous by means of internally
  * spinning an event loop.
  */
 function asyncCleanup()
 {
   let closed = false;
 
   // close the connection
   print("*** Storage Tests: Trying to asyncClose!");
-  getOpenedDatabase().asyncClose(function() { closed = true; });
+  getOpenedDatabase().asyncClose(function () { closed = true; });
 
   let curThread = Components.classes["@mozilla.org/thread-manager;1"]
                             .getService().currentThread;
   while (!closed)
     curThread.processNextEvent(true);
 
   // we need to null out the database variable to get a new connection the next
   // time getOpenedDatabase is called
   gDBConn = null;
 
   // removing test db
   print("*** Storage Tests: Trying to remove file!");
   var dbFile = getTestDB();
   if (dbFile.exists())
-    try { dbFile.remove(false); } catch(e) { /* stupid windows box */ }
+    try { dbFile.remove(false); } catch (e) { /* stupid windows box */ }
 }
 
 function getService()
 {
   return Cc["@mozilla.org/storage/service;1"].getService(Ci.mozIStorageService);
 }
 
-var gDBConn = null;
-
 /**
  * Get a connection to the test database.  Creates and caches the connection
  * if necessary, otherwise reuses the existing cached connection. This
  * connection shares its cache.
  *
  * @returns the mozIStorageConnection for the file.
  */
 function getOpenedDatabase()
@@ -164,17 +164,17 @@ function createAsyncStatement(aSQL)
  *        The function to invoke and expect an XPCOM-style error from.
  */
 function expectError(aErrorCode, aFunction)
 {
   let exceptionCaught = false;
   try {
     aFunction();
   }
-  catch(e) {
+  catch (e) {
     if (e.result != aErrorCode) {
       do_throw("Got an exception, but the result code was not the expected " +
                "one.  Expected " + aErrorCode + ", got " + e.result);
     }
     exceptionCaught = true;
   }
   if (!exceptionCaught)
     do_throw(aFunction + " should have thrown an exception but did not!");
@@ -203,27 +203,27 @@ function verifyQuery(aSQLString, aBind, 
                "there are only " + aResults.length + "!");
     for (let iCol = 0; iCol < nCols; iCol++) {
       let expectedVal = aResults[iCol];
       let valType = stmt.getTypeOfIndex(iCol);
       if (expectedVal === null) {
         do_check_eq(stmt.VALUE_TYPE_NULL, valType);
         do_check_true(stmt.getIsNull(iCol));
       }
-      else if (typeof(expectedVal) == "number") {
+      else if (typeof expectedVal == "number") {
         if (Math.floor(expectedVal) == expectedVal) {
           do_check_eq(stmt.VALUE_TYPE_INTEGER, valType);
           do_check_eq(expectedVal, stmt.getInt32(iCol));
         }
         else {
           do_check_eq(stmt.VALUE_TYPE_FLOAT, valType);
           do_check_eq(expectedVal, stmt.getDouble(iCol));
         }
       }
-      else if (typeof(expectedVal) == "string") {
+      else if (typeof expectedVal == "string") {
         do_check_eq(stmt.VALUE_TYPE_TEXT, valType);
         do_check_eq(expectedVal, stmt.getUTF8String(iCol));
       }
       else { // blob
         do_check_eq(stmt.VALUE_TYPE_BLOB, valType);
         let count = { value: 0 }, blob = { value: null };
         stmt.getBlob(iCol, count, blob);
         do_check_eq(count.value, expectedVal.length);
--- a/storage/test/unit/test_bug-365166.js
+++ b/storage/test/unit/test_bug-365166.js
@@ -1,27 +1,24 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/licenses/publicdomain/  */ 
-
 // Testcase for bug 365166 - crash [@ strlen] calling
 // mozIStorageStatement::getColumnName of a statement created with
 // "PRAGMA user_version" or "PRAGMA schema_version"
 function run_test() {
   test('user');
   test('schema');
 
   function test(param)
   {
     var colName = param + "_version";
     var sql = "PRAGMA " + colName;
 
     var file = getTestDB();
     var storageService = Components.classes["@mozilla.org/storage/service;1"].
                          getService(Components.interfaces.mozIStorageService);
-    var conn = storageService.openDatabase(file); 
+    var conn = storageService.openDatabase(file);
     var statement = conn.createStatement(sql);
     try {
       // This shouldn't crash:
       do_check_eq(statement.getColumnName(0), colName);
     } finally {
       statement.reset();
       statement.finalize();
     }
--- a/storage/test/unit/test_bug-393952.js
+++ b/storage/test/unit/test_bug-393952.js
@@ -1,14 +1,14 @@
 /* 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/. */
 
 // Testcase for bug 393952:  crash when I try to VACUUM and one of the tables
-// has a UNIQUE text column.   StorageUnicodeFunctions::likeFunction() 
+// has a UNIQUE text column.   StorageUnicodeFunctions::likeFunction()
 // needs to handle null aArgv[0] and aArgv[1]
 
 function setup()
 {
   getOpenedDatabase().createTable("t1", "x TEXT UNIQUE");
 
   var stmt = createStatement("INSERT INTO t1 (x) VALUES ('a')");
   stmt.execute();
@@ -27,12 +27,12 @@ function test_vacuum()
 var tests = [test_vacuum];
 
 function run_test()
 {
   setup();
 
   for (var i = 0; i < tests.length; i++)
     tests[i]();
-    
+
   cleanup();
 }
 
--- a/storage/test/unit/test_bug-429521.js
+++ b/storage/test/unit/test_bug-429521.js
@@ -1,49 +1,46 @@
 /* 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/. */
 
-function setup() 
-{
-    getOpenedDatabase().createTable("t1", "x TEXT");
+function setup() {
+  getOpenedDatabase().createTable("t1", "x TEXT");
 
-    var stmt = createStatement("INSERT INTO t1 (x) VALUES ('/mozilla.org/20070129_1/Europe/Berlin')");
-    stmt.execute();
-    stmt.finalize();
+  var stmt = createStatement("INSERT INTO t1 (x) VALUES ('/mozilla.org/20070129_1/Europe/Berlin')");
+  stmt.execute();
+  stmt.finalize();
 }
 
-function test_bug429521() 
-{
-    var stmt = createStatement(
-        "SELECT DISTINCT(zone) FROM ("+
-            "SELECT x AS zone FROM t1 WHERE x LIKE '/mozilla.org%'" +
-        ");");
+function test_bug429521() {
+  var stmt = createStatement(
+    "SELECT DISTINCT(zone) FROM (" +
+        "SELECT x AS zone FROM t1 WHERE x LIKE '/mozilla.org%'" +
+    ");");
 
-    print("*** test_bug429521: started");
+  print("*** test_bug429521: started");
 
-    try {
-        while (stmt.executeStep()) {
-            print("*** test_bug429521: step() Read wrapper.row.zone");
+  try {
+    while (stmt.executeStep()) {
+      print("*** test_bug429521: step() Read wrapper.row.zone");
 
-            // BUG: the print commands after the following statement
-            // are never executed. Script stops immediately.
-            var tzId = stmt.row.zone;
+      // BUG: the print commands after the following statement
+      // are never executed. Script stops immediately.
+      var tzId = stmt.row.zone;
 
-            print("*** test_bug429521: step() Read wrapper.row.zone finished");
-        }
-    } catch (e) {
-        print("*** test_bug429521: " + e);
+      print("*** test_bug429521: step() Read wrapper.row.zone finished");
     }
+  } catch (e) {
+    print("*** test_bug429521: " + e);
+  }
 
-    print("*** test_bug429521: finished");
+  print("*** test_bug429521: finished");
 
-    stmt.finalize();
+  stmt.finalize();
 }
 
-function run_test()
-{
+function run_test() {
   setup();
 
   test_bug429521();
-    
+
   cleanup();
 }
--- a/storage/test/unit/test_bug-444233.js
+++ b/storage/test/unit/test_bug-444233.js
@@ -1,51 +1,51 @@
 /* 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/. */
 
 function setup() {
-    // Create the table
-    getOpenedDatabase().createTable("test_bug444233",
-                                    "id INTEGER PRIMARY KEY, value TEXT");
+  // Create the table
+  getOpenedDatabase().createTable("test_bug444233",
+                                  "id INTEGER PRIMARY KEY, value TEXT");
 
-    // Insert dummy data, using wrapper methods
-    var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
-    stmt.params.value = "value1"
-    stmt.execute();
-    stmt.finalize();
-    
-    stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
-    stmt.params.value = "value2"
-    stmt.execute();
-    stmt.finalize();
+  // Insert dummy data, using wrapper methods
+  var stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
+  stmt.params.value = "value1";
+  stmt.execute();
+  stmt.finalize();
+
+  stmt = createStatement("INSERT INTO test_bug444233 (value) VALUES (:value)");
+  stmt.params.value = "value2";
+  stmt.execute();
+  stmt.finalize();
 }
 
 function test_bug444233() {
-    print("*** test_bug444233: started");
-    
-    // Check that there are 2 results
-    var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
-    do_check_true(stmt.executeStep());
-    do_check_eq(2, stmt.row.number);
-    stmt.reset();
-    stmt.finalize();
+  print("*** test_bug444233: started");
+
+  // Check that there are 2 results
+  var stmt = createStatement("SELECT COUNT(*) AS number FROM test_bug444233");
+  do_check_true(stmt.executeStep());
+  do_check_eq(2, stmt.row.number);
+  stmt.reset();
+  stmt.finalize();
+
+  print("*** test_bug444233: doing delete");
 
-    print("*** test_bug444233: doing delete");
-    
-    // Now try to delete using IN
-    // Cheating since we know ids are 1,2
-    try {
-        var ids = [1, 2];
-        stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
-        stmt.params.ids = ids;
-    } catch (e) {
-        print("*** test_bug444233: successfully caught exception");
-    }
-    stmt.finalize();
+  // Now try to delete using IN
+  // Cheating since we know ids are 1,2
+  try {
+    var ids = [1, 2];
+    stmt = createStatement("DELETE FROM test_bug444233 WHERE id IN (:ids)");
+    stmt.params.ids = ids;
+  } catch (e) {
+    print("*** test_bug444233: successfully caught exception");
+  }
+  stmt.finalize();
 }
 
 function run_test() {
-    setup();
-    test_bug444233();
-    cleanup();
+  setup();
+  test_bug444233();
+  cleanup();
 }
 
--- a/storage/test/unit/test_chunk_growth.js
+++ b/storage/test/unit/test_chunk_growth.js
@@ -1,55 +1,52 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
 // This file tests SQLITE_FCNTL_CHUNK_SIZE behaves as expected
 
 function run_sql(d, sql) {
-  var stmt = d.createStatement(sql)
-  stmt.execute()
+  var stmt = d.createStatement(sql);
+  stmt.execute();
   stmt.finalize();
 }
 
-function new_file(name)
-{
+function new_file(name) {
   var file = dirSvc.get("ProfD", Ci.nsIFile);
   file.append(name);
   return file;
 }
 
 function get_size(name) {
-  return new_file(name).fileSize
+  return new_file(name).fileSize;
 }
 
-function run_test()
-{
+function run_test() {
   const filename = "chunked.sqlite";
   const CHUNK_SIZE = 512 * 1024;
   var d = getDatabase(new_file(filename));
   try {
     d.setGrowthIncrement(CHUNK_SIZE, "");
-  } catch (e if e.result == Cr.NS_ERROR_FILE_TOO_BIG) {
+  } catch (e) {
+    if (e.result != Cr.NS_ERROR_FILE_TOO_BIG) {
+      throw e;
+    }
     print("Too little free space to set CHUNK_SIZE!");
     return;
   }
   run_sql(d, "CREATE TABLE bloat(data varchar)");
 
   var orig_size = get_size(filename);
   /* Dump in at least 32K worth of data.
    * While writing ensure that the file size growth in chunksize set above.
    */
   const str1024 = new Array(1024).join("T");
-  for(var i = 0; i < 32; i++) {
+  for (var i = 0; i < 32; i++) {
     run_sql(d, "INSERT INTO bloat VALUES('" + str1024 + "')");
-    var size = get_size(filename)
+    var size = get_size(filename);
     // Must not grow in small increments.
     do_check_true(size == orig_size || size >= CHUNK_SIZE);
   }
   /* In addition to growing in chunk-size increments, the db
    * should shrink in chunk-size increments too.
    */
-  run_sql(d, "DELETE FROM bloat")
-  run_sql(d, "VACUUM")
-  do_check_true(get_size(filename) >= CHUNK_SIZE)
+  run_sql(d, "DELETE FROM bloat");
+  run_sql(d, "VACUUM");
+  do_check_true(get_size(filename) >= CHUNK_SIZE);
 }
 
--- a/storage/test/unit/test_connection_executeAsync.js
+++ b/storage/test/unit/test_connection_executeAsync.js
@@ -7,18 +7,17 @@
  * both mozIStorageStatement and mozIStorageAsyncStatement.
  */
 
 const INTEGER = 1;
 const TEXT = "this is test text";
 const REAL = 3.23;
 const BLOB = [1, 2];
 
-function test_create_and_add()
-{
+add_test(function test_create_and_add() {
   getOpenedDatabase().executeSimpleSQL(
     "CREATE TABLE test (" +
       "id INTEGER, " +
       "string TEXT, " +
       "number REAL, " +
       "nuller NULL, " +
       "blober BLOB" +
     ")"
@@ -37,29 +36,27 @@ function test_create_and_add()
     "INSERT INTO test (string, number, nuller, blober) VALUES (?, ?, ?, ?)"
   );
   stmts[1].bindByIndex(0, TEXT);
   stmts[1].bindByIndex(1, REAL);
   stmts[1].bindByIndex(2, null);
   stmts[1].bindBlobByIndex(3, BLOB, BLOB.length);
 
   getOpenedDatabase().executeAsync(stmts, stmts.length, {
-    handleResult: function(aResultSet)
-    {
-      dump("handleResult("+aResultSet+")\n");
+    handleResult: function (aResultSet) {
+      dump("handleResult(" + aResultSet + ")\n");
       do_throw("unexpected results obtained!");
     },
-    handleError: function(aError)
+    handleError: function (aError)
     {
-      dump("handleError("+aError.result+")\n");
+      dump("handleError(" + aError.result + ")\n");
       do_throw("unexpected error!");
     },
-    handleCompletion: function(aReason)
-    {
-      dump("handleCompletion("+aReason+")\n");
+    handleCompletion: function (aReason) {
+      dump("handleCompletion(" + aReason + ")\n");
       do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, aReason);
 
       // Check that the result is in the table
       let stmt = getOpenedDatabase().createStatement(
         "SELECT string, number, nuller, blober FROM test WHERE id = ?"
       );
       stmt.bindByIndex(0, INTEGER);
       try {
@@ -91,20 +88,19 @@ function test_create_and_add()
       }
 
       // Run the next test.
       run_next_test();
     }
   });
   stmts[0].finalize();
   stmts[1].finalize();
-}
+});
 
-function test_multiple_bindings_on_statements()
-{
+add_test(function test_multiple_bindings_on_statements() {
   // This tests to make sure that we pass all the statements multiply bound
   // parameters when we call executeAsync.
   const AMOUNT_TO_ADD = 5;
   const ITERATIONS = 5;
 
   let stmts = [];
   let db = getOpenedDatabase();
   let sqlString = "INSERT INTO test (id, string, number, nuller, blober) " +
@@ -140,28 +136,25 @@ function test_multiple_bindings_on_state
     currentRows = countStmt.row.count;
   }
   finally {
     countStmt.reset();
   }
 
   // Execute asynchronously.
   getOpenedDatabase().executeAsync(stmts, stmts.length, {
-    handleResult: function(aResultSet)
-    {
+    handleResult: function (aResultSet) {
       do_throw("Unexpected call to handleResult!");
     },
-    handleError: function(aError)
-    {
+    handleError: function (aError) {
       print("Error code " + aError.result + " with message '" +
             aError.message + "' returned.");
       do_throw("Unexpected error!");
     },
-    handleCompletion: function(aReason)
-    {
+    handleCompletion: function (aReason) {
       print("handleCompletion(" + aReason +
             ") for test_multiple_bindings_on_statements");
       do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, aReason);
 
       // Check to make sure we added all of our rows.
       try {
         do_check_true(countStmt.executeStep());
         do_check_eq(currentRows + (ITERATIONS * AMOUNT_TO_ADD),
@@ -171,90 +164,72 @@ function test_multiple_bindings_on_state
         countStmt.finalize();
       }
 
       // Run the next test.
       run_next_test();
     }
   });
   stmts.forEach(stmt => stmt.finalize());
-}
+});
 
-function test_asyncClose_does_not_complete_before_statements()
-{
+add_test(function test_asyncClose_does_not_complete_before_statements() {
   let stmt = createStatement("SELECT * FROM sqlite_master");
   let executed = false;
   stmt.executeAsync({
-    handleResult: function(aResultSet)
-    {
-    },
-    handleError: function(aError)
-    {
+    handleResult(aResultSet) {},
+    handleError(aError) {
       print("Error code " + aError.result + " with message '" +
             aError.message + "' returned.");
       do_throw("Unexpected error!");
     },
-    handleCompletion: function(aReason)
-    {
+    handleCompletion(aReason) {
       print("handleCompletion(" + aReason +
             ") for test_asyncClose_does_not_complete_before_statements");
       do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, aReason);
       executed = true;
     }
   });
   stmt.finalize();
 
-  getOpenedDatabase().asyncClose(function() {
+  getOpenedDatabase().asyncClose(function () {
     // Ensure that the statement executed to completion.
     do_check_true(executed);
 
     // Reset gDBConn so that later tests will get a new connection object.
     gDBConn = null;
     run_next_test();
   });
-}
+});
 
-function test_asyncClose_does_not_throw_no_callback()
-{
+add_test(function test_asyncClose_does_not_throw_no_callback() {
   getOpenedDatabase().asyncClose();
 
   // Reset gDBConn so that later tests will get a new connection object.
   gDBConn = null;
   run_next_test();
-}
+});
 
-function test_double_asyncClose_throws()
-{
+add_test(function test_double_asyncClose_throws() {
   let conn = getOpenedDatabase();
   conn.asyncClose();
   try {
     conn.asyncClose();
     do_throw("should have thrown");
     // There is a small race condition here, which can cause either of
     // Cr.NS_ERROR_NOT_INITIALIZED or Cr.NS_ERROR_UNEXPECTED to be thrown.
-  } catch (e if "result" in e && e.result == Cr.NS_ERROR_NOT_INITIALIZED) {
-    do_print("NS_ERROR_NOT_INITIALIZED");
-  } catch (e if "result" in e && e.result == Cr.NS_ERROR_UNEXPECTED) {
-    do_print("NS_ERROR_UNEXPECTED");
   } catch (e) {
+    if ("result" in e && e.result == Cr.NS_ERROR_NOT_INITIALIZED) {
+      do_print("NS_ERROR_NOT_INITIALIZED");
+    } else if ("result" in e && e.result == Cr.NS_ERROR_UNEXPECTED) {
+      do_print("NS_ERROR_UNEXPECTED");
+    }
   }
 
   // Reset gDBConn so that later tests will get a new connection object.
   gDBConn = null;
   run_next_test();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//// Test Runner
+});
 
-[
-  test_create_and_add,
-  test_multiple_bindings_on_statements,
-  test_asyncClose_does_not_complete_before_statements,
-  test_asyncClose_does_not_throw_no_callback,
-  test_double_asyncClose_throws,
-].forEach(add_test);
-
-function run_test()
-{
+function run_test() {
   cleanup();
   run_next_test();
 }
--- a/storage/test/unit/test_connection_executeSimpleSQLAsync.js
+++ b/storage/test/unit/test_connection_executeSimpleSQLAsync.js
@@ -8,59 +8,59 @@
  */
 
 const INTEGER = 1;
 const TEXT = "this is test text";
 const REAL = 3.23;
 
 function asyncClose(db) {
   let deferred = Promise.defer();
-  db.asyncClose(function(status) {
+  db.asyncClose(function (status) {
     if (Components.isSuccessCode(status)) {
       deferred.resolve();
     } else {
       deferred.reject(status);
     }
   });
   return deferred.promise;
 }
 
 function openAsyncDatabase(file) {
   let deferred = Promise.defer();
-  getService().openAsyncDatabase(file, null, function(status, db) {
+  getService().openAsyncDatabase(file, null, function (status, db) {
     if (Components.isSuccessCode(status)) {
       deferred.resolve(db.QueryInterface(Ci.mozIStorageAsyncConnection));
     } else {
       deferred.reject(status);
     }
   });
   return deferred.promise;
 }
 
 function executeSimpleSQLAsync(db, query, onResult) {
   let deferred = Promise.defer();
   db.executeSimpleSQLAsync(query, {
-    handleError: function(error) {
+    handleError(error) {
       deferred.reject(error);
     },
-    handleResult: function(result) {
+    handleResult(result) {
       if (onResult) {
         onResult(result);
       } else {
         do_throw("No results were expected");
       }
     },
-    handleCompletion: function(result) {
+    handleCompletion(result) {
       deferred.resolve(result);
     }
   });
   return deferred.promise;
 }
 
-add_task(function test_create_and_add() {
+add_task(function* test_create_and_add() {
   let adb = yield openAsyncDatabase(getTestDB());
 
   let completion = yield executeSimpleSQLAsync(adb,
     "CREATE TABLE test (id INTEGER, string TEXT, number REAL)");
 
   do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, completion);
 
   completion = yield executeSimpleSQLAsync(adb,
@@ -68,46 +68,46 @@ add_task(function test_create_and_add() 
     "VALUES (" + INTEGER + ", \"" + TEXT + "\", " + REAL + ")");
 
   do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, completion);
 
   let result = null;
 
   completion = yield executeSimpleSQLAsync(adb,
     "SELECT string, number FROM test WHERE id = 1",
-    function(aResultSet) {
+    function (aResultSet) {
       result = aResultSet.getNextRow();
       do_check_eq(2, result.numEntries);
       do_check_eq(TEXT, result.getString(0));
       do_check_eq(REAL, result.getDouble(1));
     }
   );
 
   do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, completion);
   do_check_neq(result, null);
   result = null;
 
   yield executeSimpleSQLAsync(adb, "SELECT COUNT(0) FROM test",
-    function(aResultSet) {
+    function (aResultSet) {
       result = aResultSet.getNextRow();
       do_check_eq(1, result.getInt32(0));
     });
 
   do_check_neq(result, null);
 
   yield asyncClose(adb);
 });
 
 
-add_task(function test_asyncClose_does_not_complete_before_statement() {
+add_task(function* test_asyncClose_does_not_complete_before_statement() {
   let adb = yield openAsyncDatabase(getTestDB());
   let executed = false;
 
   let reason = yield executeSimpleSQLAsync(adb, "SELECT * FROM test",
-    function(aResultSet) {
+    function (aResultSet) {
       let result = aResultSet.getNextRow();
 
       do_check_neq(result, null);
       do_check_eq(3, result.numEntries);
       do_check_eq(INTEGER, result.getInt32(0));
       do_check_eq(TEXT, result.getString(1));
       do_check_eq(REAL, result.getDouble(2));
       executed = true;
@@ -116,16 +116,8 @@ add_task(function test_asyncClose_does_n
 
   do_check_eq(Ci.mozIStorageStatementCallback.REASON_FINISHED, reason);
 
   // Ensure that the statement executed to completion.
   do_check_true(executed);
 
   yield asyncClose(adb);
 });
-
-////////////////////////////////////////////////////////////////////////////////
-//// Test Runner
-
-function run_test()
-{
-  run_next_test();
-}
--- a/storage/test/unit/test_js_helpers.js
+++ b/storage/test/unit/test_js_helpers.js
@@ -18,17 +18,17 @@ function test_params_enumerate()
     "SELECT * FROM test WHERE id IN (:a, :b, :c)"
   );
 
   // Make sure they are right.
   let expected = ["a", "b", "c"];
   let index = 0;
   for (let name in stmt.params) {
     if (name == "QueryInterface")
-        continue;
+      continue;
     do_check_eq(name, expected[index++]);
   }
 }
 
 function test_params_prototype()
 {
   let stmt = createStatement(
     "SELECT * FROM sqlite_master"
--- a/storage/test/unit/test_levenshtein.js
+++ b/storage/test/unit/test_levenshtein.js
@@ -25,18 +25,17 @@ function createUtf16Database()
 function check_levenshtein(db, s, t, expectedDistance)
 {
   var stmt = db.createStatement("SELECT levenshteinDistance(:s, :t) AS result");
   stmt.params.s = s;
   stmt.params.t = t;
   try {
     do_check_true(stmt.executeStep());
     do_check_eq(expectedDistance, stmt.row.result);
-  } 
-  finally {
+  } finally {
     stmt.reset();
     stmt.finalize();
   }
 }
 
 function testLevenshtein(db)
 {
   // Basic tests.
@@ -51,17 +50,17 @@ function testLevenshtein(db)
   check_levenshtein(db, "kitten", "sitting", 3);
   check_levenshtein(db, "Saturday", "Sunday", 3);
   check_levenshtein(db, "YHCQPGK", "LAHYQQKPGKA", 6);
 
   // Test SQL NULL handling.
   check_levenshtein(db, "foo", null, null);
   check_levenshtein(db, null, "bar", null);
   check_levenshtein(db, null, null, null);
-  
+
   // The levenshteinDistance function allocates temporary memory on the stack
   // if it can.  Test some strings long enough to force a heap allocation.
   var dots1000 = Array(1001).join(".");
   var dashes1000 = Array(1001).join("-");
   check_levenshtein(db, dots1000, dashes1000, 1000);
 }
 
 function run_test()
--- a/storage/test/unit/test_like.js
+++ b/storage/test/unit/test_like.js
@@ -88,31 +88,31 @@ function test_like_2()
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_false(stmt.executeStep());
   stmt.reset();
   stmt.finalize();
 }
-    
+
 function test_like_3()
 {
   var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?;");
   stmt.bindByIndex(0, 'aBc');
   var solutions = ["abc", "ABC"];
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_false(stmt.executeStep());
   stmt.reset();
   stmt.finalize();
 }
-   
+
 function test_like_4()
 {
   var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?;");
   stmt.bindByIndex(0, 'abc%');
   var solutions = ["abc", "abcd", "ABC", "ABC abc xyz"];
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_true(stmt.executeStep());
@@ -148,17 +148,17 @@ function test_like_6()
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_false(stmt.executeStep());
   stmt.reset();
   stmt.finalize();
 }
-    
+
 function test_like_7()
 {
   var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?;");
   stmt.bindByIndex(0, 'a_c%');
   var solutions = ["abc", "abcd", "ABC", "ABC abc xyz"];
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_true(stmt.executeStep());
@@ -180,22 +180,23 @@ function test_like_8()
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_true(stmt.executeStep());
   do_check_true(solutions.indexOf(stmt.getString(0)) != -1);
   do_check_false(stmt.executeStep());
   stmt.reset();
   stmt.finalize();
 }
-    
-var tests = [test_count, test_like_1, test_like_2, test_like_3, test_like_4, 
+
+var tests = [test_count, test_like_1, test_like_2, test_like_3, test_like_4,
              test_like_5, test_like_6, test_like_7, test_like_8];
 
 function run_test()
 {
   setup();
 
-  for (var i = 0; i < tests.length; i++)
+  for (var i = 0; i < tests.length; i++) {
     tests[i]();
-    
+  }
+
   cleanup();
 }
 
--- a/storage/test/unit/test_like_escape.js
+++ b/storage/test/unit/test_like_escape.js
@@ -1,38 +1,38 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const LATIN1_AE = "\xc6";
-const LATIN1_ae = "\xe6"; 
+const LATIN1_ae = "\xe6";
 
 function setup()
 {
   getOpenedDatabase().createTable("t1", "x TEXT");
 
   var stmt = createStatement("INSERT INTO t1 (x) VALUES ('foo/bar_baz%20cheese')");
   stmt.execute();
   stmt.finalize();
 
   stmt = createStatement("INSERT INTO t1 (x) VALUES (?1)");
   // insert LATIN_ae, but search on LATIN_AE
   stmt.bindByIndex(0, "foo%20" + LATIN1_ae + "/_bar");
   stmt.execute();
   stmt.finalize();
 }
-    
+
 function test_escape_for_like_ascii()
 {
   var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?1 ESCAPE '/'");
   var paramForLike = stmt.escapeStringForLIKE("oo/bar_baz%20chees", '/');
   // verify that we escaped / _ and %
   do_check_eq(paramForLike, "oo//bar/_baz/%20chees");
   // prepend and append with % for "contains"
-  stmt.bindByIndex(0, "%" + paramForLike + "%"); 
+  stmt.bindByIndex(0, "%" + paramForLike + "%");
   stmt.executeStep();
   do_check_eq("foo/bar_baz%20cheese", stmt.getString(0));
   stmt.finalize();
 }
 
 function test_escape_for_like_non_ascii()
 {
   var stmt = createStatement("SELECT x FROM t1 WHERE x LIKE ?1 ESCAPE '/'");
@@ -47,13 +47,14 @@ function test_escape_for_like_non_ascii(
 }
 
 var tests = [test_escape_for_like_ascii, test_escape_for_like_non_ascii];
 
 function run_test()
 {
   setup();
 
-  for (var i = 0; i < tests.length; i++)
+  for (var i = 0; i < tests.length; i++) {
     tests[i]();
-    
+  }
+
   cleanup();
 }
--- a/storage/test/unit/test_locale_collation.js
+++ b/storage/test/unit/test_locale_collation.js
@@ -135,31 +135,31 @@ function initTableWithStrings(aStrings, 
  *         strength is computed from this value.
  * @return A function to use as a sorting callback.
  */
 function localeCompare(aCollation)
 {
   var strength;
 
   switch (aCollation) {
-  case "locale":
-    strength = Ci.nsICollation.kCollationCaseInSensitive;
-    break;
-  case "locale_case_sensitive":
-    strength = Ci.nsICollation.kCollationAccentInsenstive;
-    break;
-  case "locale_accent_sensitive":
-    strength = Ci.nsICollation.kCollationCaseInsensitiveAscii;
-    break;
-  case "locale_case_accent_sensitive":
-    strength = Ci.nsICollation.kCollationCaseSensitive;
-    break;
-  default:
-    do_throw("Error in test: unknown collation '" + aCollation + "'");
-    break;
+    case "locale":
+      strength = Ci.nsICollation.kCollationCaseInSensitive;
+      break;
+    case "locale_case_sensitive":
+      strength = Ci.nsICollation.kCollationAccentInsenstive;
+      break;
+    case "locale_accent_sensitive":
+      strength = Ci.nsICollation.kCollationCaseInsensitiveAscii;
+      break;
+    case "locale_case_accent_sensitive":
+      strength = Ci.nsICollation.kCollationCaseSensitive;
+      break;
+    default:
+      do_throw("Error in test: unknown collation '" + aCollation + "'");
+      break;
   }
   return function (aStr1, aStr2) {
     return gLocaleCollation.compareString(strength, aStr1, aStr2);
   };
 }
 
 /**
  * Reads in the test data from the file DATA_BASENAME and returns it as an array
@@ -175,18 +175,19 @@ function readTestData()
 
   let istream = Cc["@mozilla.org/network/file-input-stream;1"].
                 createInstance(Ci.nsIFileInputStream);
   istream.init(file, -1, -1, 0);
   istream.QueryInterface(Components.interfaces.nsILineInputStream);
 
   let line = {};
   let lines = [];
-  while (istream.readLine(line))
-    lines.push(line.value); 
+  while (istream.readLine(line)) {
+    lines.push(line.value);
+  }
   istream.close();
 
   return lines;
 }
 
 /**
  * Gets the results from the given database using the given collation and
  * ensures that they match gStrings sorted by the same collation.
--- a/storage/test/unit/test_sqlite_secure_delete.js
+++ b/storage/test/unit/test_sqlite_secure_delete.js
@@ -29,18 +29,17 @@ function getFileContents(aFile)
                 createInstance(Ci.nsIBinaryInputStream);
   bstream.setInputStream(fstream);
   return bstream.readBytes(bstream.available());
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Tests
 
-function test_delete_removes_data()
-{
+add_test(function test_delete_removes_data() {
   const TEST_STRING = "SomeRandomStringToFind";
 
   let file = getTestDB();
   let db = getService().openDatabase(file);
 
   // Create the table and insert the data.
   db.createTable("test", "data TEXT");
   let stmt = db.createStatement("INSERT INTO test VALUES(:data)");
@@ -69,22 +68,15 @@ function test_delete_removes_data()
   }
   db.close();
 
   // Check the file to see if the string can be found.
   contents = getFileContents(file);
   do_check_eq(-1, contents.indexOf(TEST_STRING));
 
   run_next_test();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//// Test Runner
-
-[
-  test_delete_removes_data,
- ].forEach(add_test);
+});
 
 function run_test()
 {
   cleanup();
   run_next_test();
 }
--- a/storage/test/unit/test_statement_executeAsync.js
+++ b/storage/test/unit/test_statement_executeAsync.js
@@ -48,25 +48,25 @@ function execAsync(aStmt, aOptions, aRes
   if (aOptions == null)
     aOptions = {};
 
   let resultsExpected;
   let resultsChecker;
   if (aResults == null) {
     resultsExpected = 0;
   }
-  else if (typeof(aResults) == "number") {
+  else if (typeof aResults == "number") {
     resultsExpected = aResults;
   }
-  else if (typeof(aResults) == "function") {
+  else if (typeof aResults == "function") {
     resultsChecker = aResults;
   }
   else { // array
     resultsExpected = aResults.length;
-    resultsChecker = function(aResultNum, aTup, aCaller) {
+    resultsChecker = function (aResultNum, aTup, aCaller) {
       aResults[aResultNum](aTup, aCaller);
     };
   }
   let resultsSeen = 0;
 
   let errorCodeExpected = false;
   let reasonExpected = Ci.mozIStorageStatementCallback.REASON_FINISHED;
   let altReasonExpected = null;
@@ -78,36 +78,36 @@ function execAsync(aStmt, aOptions, aRes
   let errorCodeSeen = false;
 
   if ("cancel" in aOptions && aOptions.cancel)
     altReasonExpected = Ci.mozIStorageStatementCallback.REASON_CANCELED;
 
   let completed = false;
 
   let listener = {
-    handleResult: function(aResultSet)
+    handleResult(aResultSet)
     {
       let row, resultsSeenThisCall = 0;
       while ((row = aResultSet.getNextRow()) != null) {
         if (resultsChecker)
           resultsChecker(resultsSeen, row, caller);
         resultsSeen++;
         resultsSeenThisCall++;
       }
 
       if (!resultsSeenThisCall)
         do_throw("handleResult invoked with 0 result rows!");
     },
-    handleError: function(aError)
+    handleError(aError)
     {
       if (errorCodeSeen != false)
         do_throw("handleError called when we already had an error!");
       errorCodeSeen = aError.result;
     },
-    handleCompletion: function(aReason)
+    handleCompletion(aReason)
     {
       if (completed) // paranoia check
         do_throw("Received a second handleCompletion notification!", caller);
 
       if (resultsSeen != resultsExpected)
         do_throw("Expected " + resultsExpected + " rows of results but " +
                  "got " + resultsSeen + " rows!", caller);
 
@@ -221,18 +221,17 @@ function test_add_data()
 
 function test_get_data()
 {
   var stmt = makeTestStatement(
     "SELECT string, number, nuller, blober, id FROM test WHERE id = ?"
   );
   stmt.bindByIndex(0, INTEGER);
   execAsync(stmt, {}, [
-    function(tuple)
-    {
+    function (tuple) {
       do_check_neq(null, tuple);
 
       // Check that it's what we expect
       do_check_false(tuple.getIsNull(0));
       do_check_eq(tuple.getResultByName("string"), tuple.getResultByIndex(0));
       do_check_eq(TEXT, tuple.getResultByName("string"));
       do_check_eq(Ci.mozIStorageValueArray.VALUE_TYPE_TEXT,
                   tuple.getTypeOfIndex(0));
@@ -249,25 +248,25 @@ function test_get_data()
       do_check_eq(Ci.mozIStorageValueArray.VALUE_TYPE_NULL,
                   tuple.getTypeOfIndex(2));
 
       do_check_false(tuple.getIsNull(3));
       var blobByName = tuple.getResultByName("blober");
       do_check_eq(BLOB.length, blobByName.length);
       var blobByIndex = tuple.getResultByIndex(3);
       do_check_eq(BLOB.length, blobByIndex.length);
-      for (var i = 0; i < BLOB.length; i++) {
+      for (let i = 0; i < BLOB.length; i++) {
         do_check_eq(BLOB[i], blobByName[i]);
         do_check_eq(BLOB[i], blobByIndex[i]);
       }
       var count = { value: 0 };
       var blob = { value: null };
       tuple.getBlob(3, count, blob);
       do_check_eq(BLOB.length, count.value);
-      for (var i = 0; i < BLOB.length; i++)
+      for (let i = 0; i < BLOB.length; i++)
         do_check_eq(BLOB[i], blob.value[i]);
       do_check_eq(Ci.mozIStorageValueArray.VALUE_TYPE_BLOB,
                   tuple.getTypeOfIndex(3));
 
       do_check_false(tuple.getIsNull(4));
       do_check_eq(tuple.getResultByName("id"), tuple.getResultByIndex(4));
       do_check_eq(INTEGER, tuple.getResultByName("id"));
       do_check_eq(Ci.mozIStorageValueArray.VALUE_TYPE_INTEGER,
@@ -278,17 +277,17 @@ function test_get_data()
 }
 
 function test_tuple_out_of_bounds()
 {
   var stmt = makeTestStatement(
     "SELECT string FROM test"
   );
   execAsync(stmt, {}, [
-    function(tuple) {
+    function (tuple) {
       do_check_neq(null, tuple);
 
       // Check all out of bounds - should throw
       var methods = [
         "getTypeOfIndex",
         "getInt32",
         "getInt64",
         "getDouble",
@@ -362,29 +361,23 @@ function test_no_listener_works_on_error
 
 function test_partial_listener_works()
 {
   var stmt = makeTestStatement(
     "DELETE FROM test WHERE id = ?"
   );
   stmt.bindByIndex(0, 0);
   stmt.executeAsync({
-    handleResult: function(aResultSet)
-    {
-    }
+    handleResult(aResultSet) {}
   });
   stmt.executeAsync({
-    handleError: function(aError)
-    {
-    }
+    handleError(aError) {}
   });
   stmt.executeAsync({
-    handleCompletion: function(aReason)
-    {
-    }
+    handleCompletion(aReason) {}
   });
   stmt.finalize();
 
   // Run the next test.
   run_next_test();
 }
 
 /**
@@ -462,18 +455,19 @@ function test_finalized_statement_does_n
 {
   var stmt = makeTestStatement(
     "SELECT * FROM TEST"
   );
   stmt.finalize();
   // we are concerned about a crash here; an error is fine.
   try {
     stmt.executeAsync();
+  } catch (ex) {
+    // Do nothing.
   }
-  catch (ex) {}
 
   // Run the next test.
   run_next_test();
 }
 
 /**
  * Bind by mozIStorageBindingParams on the mozIStorageBaseStatement by index.
  */
@@ -900,24 +894,23 @@ var testPass = TEST_PASS_SYNC;
 /**
  * Create a statement of the type under test per testPass.
  *
  * @param aSQL
  *        The SQL string from which to build a statement.
  * @return a statement of the type under test per testPass.
  */
 function makeTestStatement(aSQL) {
-  if (testPass == TEST_PASS_SYNC)
+  if (testPass == TEST_PASS_SYNC) {
     return getOpenedDatabase().createStatement(aSQL);
-  else
-    return getOpenedDatabase().createAsyncStatement(aSQL);
+  }
+  return getOpenedDatabase().createAsyncStatement(aSQL);
 }
 
-var tests =
-[
+var tests = [
   test_illegal_sql_async_deferred,
   test_create_table,
   test_add_data,
   test_get_data,
   test_tuple_out_of_bounds,
   test_no_listener_works_on_success,
   test_no_listener_works_on_results,
   test_no_listener_works_on_error,
--- a/storage/test/unit/test_statement_wrapper_automatically.js
+++ b/storage/test/unit/test_statement_wrapper_automatically.js
@@ -124,22 +124,19 @@ function insertAndCheckMultipleParams(aV
  * A convenience function that prints out a description of aVal using
  * aVal.toString and aVal.toSource.  Output is useful when the test fails.
  *
  * @param aVal
  *        a value inserted or to be inserted into our test table
  */
 function printValDesc(aVal)
 {
-  try
-  {
+  try {
     var toSource = aVal.toSource();
-  }
-  catch (exc)
-  {
+  } catch (ex) {
     toSource = "";
   }
   print("Testing value: toString=" + aVal +
         (toSource ? " toSource=" + toSource : ""));
 }
 
 function run_test()
 {
@@ -158,13 +155,13 @@ function run_test()
   ];
 
   vals.forEach(function (val)
   {
     printValDesc(val);
     print("Single parameter");
     insertAndCheckSingleParam(val);
     print("Multiple parameters");
-    insertAndCheckMultipleParams(val)
+    insertAndCheckMultipleParams(val);
   });
 
   cleanup();
 }
--- a/storage/test/unit/test_storage_aggregates.js
+++ b/storage/test/unit/test_storage_aggregates.js
@@ -6,39 +6,39 @@
 
 var testNums = [1, 2, 3, 4];
 
 function setup()
 {
   getOpenedDatabase().createTable("function_tests", "id INTEGER PRIMARY KEY");
 
   var stmt = createStatement("INSERT INTO function_tests (id) VALUES(?1)");
-  for(var i = 0; i < testNums.length; ++i) {
+  for (let i = 0; i < testNums.length; ++i) {
     stmt.bindByIndex(0, testNums[i]);
     stmt.execute();
   }
   stmt.reset();
   stmt.finalize();
 }
 
 var testSquareAndSumFunction = {
   calls: 0,
   _sas: 0,
 
-  reset: function() {
+  reset() {
     this.calls = 0;
-    this._sas  = 0;
+    this._sas = 0;
   },
 
-  onStep: function(val) {
+  onStep(val) {
     ++this.calls;
     this._sas += val.getInt32(0) * val.getInt32(0);
   },
 
-  onFinal: function() {
+  onFinal() {
     var retval = this._sas;
     this._sas = 0; // Prepare for next group
     return retval;
   }
 };
 
 function test_aggregate_registration()
 {
@@ -74,26 +74,28 @@ function test_aggregate_no_aliases()
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_FAILURE, e.result);
   }
 }
 
 function test_aggregate_call()
 {
   var stmt = createStatement("SELECT test_sas_aggr(id) FROM function_tests");
-  while(stmt.executeStep());
+  while (stmt.executeStep()) {
+    // Do nothing.
+  }
   do_check_eq(testNums.length, testSquareAndSumFunction.calls);
   testSquareAndSumFunction.reset();
   stmt.finalize();
 }
 
 function test_aggregate_result()
 {
   var sas = 0;
-  for(var i = 0; i < testNums.length; ++i) {
+  for (var i = 0; i < testNums.length; ++i) {
     sas += testNums[i] * testNums[i];
   }
   var stmt = createStatement("SELECT test_sas_aggr(id) FROM function_tests");
   stmt.executeStep();
   do_check_eq(sas, stmt.getInt32(0));
   testSquareAndSumFunction.reset();
   stmt.finalize();
 }
--- a/storage/test/unit/test_storage_connection.js
+++ b/storage/test/unit/test_storage_connection.js
@@ -4,29 +4,29 @@
 
 // This file tests the functions of mozIStorageConnection
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Test Functions
 
 function asyncClone(db, readOnly) {
   let deferred = Promise.defer();
-  db.asyncClone(readOnly, function(status, db2) {
+  db.asyncClone(readOnly, function (status, db2) {
     if (Components.isSuccessCode(status)) {
       deferred.resolve(db2);
     } else {
       deferred.reject(status);
     }
   });
   return deferred.promise;
 }
 
 function asyncClose(db) {
   let deferred = Promise.defer();
-  db.asyncClose(function(status) {
+  db.asyncClose(function (status) {
     if (Components.isSuccessCode(status)) {
       deferred.resolve();
     } else {
       deferred.reject(status);
     }
   });
   return deferred.promise;
 }
@@ -36,270 +36,259 @@ function openAsyncDatabase(file, options
   let properties;
   if (options) {
     properties = Cc["@mozilla.org/hash-property-bag;1"].
         createInstance(Ci.nsIWritablePropertyBag);
     for (let k in options) {
       properties.setProperty(k, options[k]);
     }
   }
-  getService().openAsyncDatabase(file, properties, function(status, db) {
+  getService().openAsyncDatabase(file, properties, function (status, db) {
     if (Components.isSuccessCode(status)) {
       deferred.resolve(db.QueryInterface(Ci.mozIStorageAsyncConnection));
     } else {
       deferred.reject(status);
     }
   });
   return deferred.promise;
 }
 
 function executeAsync(statement, onResult) {
   let deferred = Promise.defer();
   statement.executeAsync({
-    handleError: function(error) {
+    handleError: function (error) {
       deferred.reject(error);
     },
-    handleResult: function(result) {
+    handleResult: function (result) {
       if (onResult) {
         onResult(result);
       }
     },
-    handleCompletion: function(result) {
+    handleCompletion: function (result) {
       deferred.resolve(result);
     }
   });
   return deferred.promise;
 }
 
-add_task(function test_connectionReady_open()
-{
+add_task(function* test_connectionReady_open() {
   // there doesn't seem to be a way for the connection to not be ready (unless
   // we close it with mozIStorageConnection::Close(), but we don't for this).
   // It can only fail if GetPath fails on the database file, or if we run out
   // of memory trying to use an in-memory database
 
   var msc = getOpenedDatabase();
   do_check_true(msc.connectionReady);
 });
 
-add_task(function test_connectionReady_closed()
-{
+add_task(function* test_connectionReady_closed() {
   // This also tests mozIStorageConnection::Close()
 
   var msc = getOpenedDatabase();
   msc.close();
   do_check_false(msc.connectionReady);
   gDBConn = null; // this is so later tests don't start to fail.
 });
 
-add_task(function test_databaseFile()
-{
+add_task(function* test_databaseFile() {
   var msc = getOpenedDatabase();
   do_check_true(getTestDB().equals(msc.databaseFile));
 });
 
-add_task(function test_tableExists_not_created()
-{
+add_task(function* test_tableExists_not_created() {
   var msc = getOpenedDatabase();
   do_check_false(msc.tableExists("foo"));
 });
 
-add_task(function test_indexExists_not_created()
-{
+add_task(function* test_indexExists_not_created() {
   var msc = getOpenedDatabase();
   do_check_false(msc.indexExists("foo"));
 });
 
-add_task(function test_temp_tableExists_and_indexExists()
-{
+add_task(function* test_temp_tableExists_and_indexExists() {
   var msc = getOpenedDatabase();
   msc.executeSimpleSQL("CREATE TEMP TABLE test_temp(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");
   do_check_true(msc.tableExists("test_temp"));
 
   msc.executeSimpleSQL("CREATE INDEX test_temp_ind ON test_temp (name)");
   do_check_true(msc.indexExists("test_temp_ind"));
 
   msc.executeSimpleSQL("DROP INDEX test_temp_ind");
   msc.executeSimpleSQL("DROP TABLE test_temp");
 });
 
-add_task(function test_createTable_not_created()
-{
+add_task(function* test_createTable_not_created() {
   var msc = getOpenedDatabase();
   msc.createTable("test", "id INTEGER PRIMARY KEY, name TEXT");
   do_check_true(msc.tableExists("test"));
 });
 
-add_task(function test_indexExists_created()
-{
+add_task(function* test_indexExists_created() {
   var msc = getOpenedDatabase();
   msc.executeSimpleSQL("CREATE INDEX name_ind ON test (name)");
   do_check_true(msc.indexExists("name_ind"));
 });
 
-add_task(function test_createTable_already_created()
-{
+add_task(function* test_createTable_already_created() {
   var msc = getOpenedDatabase();
   do_check_true(msc.tableExists("test"));
   try {
     msc.createTable("test", "id INTEGER PRIMARY KEY, name TEXT");
     do_throw("We shouldn't get here!");
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_FAILURE, e.result);
   }
 });
 
-add_task(function test_attach_createTable_tableExists_indexExists()
-{
+add_task(function* test_attach_createTable_tableExists_indexExists() {
   var msc = getOpenedDatabase();
   var file = do_get_file("storage_attach.sqlite", true);
   var msc2 = getDatabase(file);
   msc.executeSimpleSQL("ATTACH DATABASE '" + file.path + "' AS sample");
 
   do_check_false(msc.tableExists("sample.test"));
   msc.createTable("sample.test", "id INTEGER PRIMARY KEY, name TEXT");
   do_check_true(msc.tableExists("sample.test"));
   try {
     msc.createTable("sample.test", "id INTEGER PRIMARY KEY, name TEXT");
     do_throw("We shouldn't get here!");
-  } catch (e if e.result == Components.results.NS_ERROR_FAILURE) {
+  } catch (e) {
+    if (e.result != Components.results.NS_ERROR_FAILURE) {
+      throw e;
+    }
     // we expect to fail because this table should exist already.
   }
 
   do_check_false(msc.indexExists("sample.test_ind"));
   msc.executeSimpleSQL("CREATE INDEX sample.test_ind ON test (name)");
   do_check_true(msc.indexExists("sample.test_ind"));
 
   msc.executeSimpleSQL("DETACH DATABASE sample");
   msc2.close();
-  try { file.remove(false); } catch(e) { }
+  try {
+    file.remove(false);
+  } catch (e) {
+    // Do nothing.
+  }
 });
 
-add_task(function test_lastInsertRowID()
-{
+add_task(function* test_lastInsertRowID() {
   var msc = getOpenedDatabase();
   msc.executeSimpleSQL("INSERT INTO test (name) VALUES ('foo')");
   do_check_eq(1, msc.lastInsertRowID);
 });
 
-add_task(function test_transactionInProgress_no()
-{
+add_task(function* test_transactionInProgress_no() {
   var msc = getOpenedDatabase();
   do_check_false(msc.transactionInProgress);
 });
 
-add_task(function test_transactionInProgress_yes()
-{
+add_task(function* test_transactionInProgress_yes() {
   var msc = getOpenedDatabase();
   msc.beginTransaction();
   do_check_true(msc.transactionInProgress);
   msc.commitTransaction();
   do_check_false(msc.transactionInProgress);
 
   msc.beginTransaction();
   do_check_true(msc.transactionInProgress);
   msc.rollbackTransaction();
   do_check_false(msc.transactionInProgress);
 });
 
-add_task(function test_commitTransaction_no_transaction()
-{
+add_task(function* test_commitTransaction_no_transaction() {
   var msc = getOpenedDatabase();
   do_check_false(msc.transactionInProgress);
   try {
     msc.commitTransaction();
     do_throw("We should not get here!");
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_UNEXPECTED, e.result);
   }
 });
 
-add_task(function test_rollbackTransaction_no_transaction()
-{
+add_task(function* test_rollbackTransaction_no_transaction() {
   var msc = getOpenedDatabase();
   do_check_false(msc.transactionInProgress);
   try {
     msc.rollbackTransaction();
     do_throw("We should not get here!");
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_UNEXPECTED, e.result);
   }
 });
 
-add_task(function test_get_schemaVersion_not_set()
-{
+add_task(function* test_get_schemaVersion_not_set() {
   do_check_eq(0, getOpenedDatabase().schemaVersion);
 });
 
-add_task(function test_set_schemaVersion()
-{
+add_task(function* test_set_schemaVersion() {
   var msc = getOpenedDatabase();
   const version = 1;
   msc.schemaVersion = version;
   do_check_eq(version, msc.schemaVersion);
 });
 
-add_task(function test_set_schemaVersion_same()
-{
+add_task(function* test_set_schemaVersion_same() {
   var msc = getOpenedDatabase();
   const version = 1;
   msc.schemaVersion = version; // should still work ok
   do_check_eq(version, msc.schemaVersion);
 });
 
-add_task(function test_set_schemaVersion_negative()
-{
+add_task(function* test_set_schemaVersion_negative() {
   var msc = getOpenedDatabase();
   const version = -1;
   msc.schemaVersion = version;
   do_check_eq(version, msc.schemaVersion);
 });
 
-add_task(function test_createTable(){
+add_task(function* test_createTable() {
   var temp = getTestDB().parent;
   temp.append("test_db_table");
   try {
     var con = getService().openDatabase(temp);
-    con.createTable("a","");
+    con.createTable("a", "");
   } catch (e) {
-    if (temp.exists()) try {
-      temp.remove(false);
-    } catch (e2) {}
-    do_check_true(e.result==Cr.NS_ERROR_NOT_INITIALIZED ||
-                  e.result==Cr.NS_ERROR_FAILURE);
+    if (temp.exists()) {
+      try {
+        temp.remove(false);
+      } catch (e2) {
+        // Do nothing.
+      }
+    }
+    do_check_true(e.result == Cr.NS_ERROR_NOT_INITIALIZED ||
+                  e.result == Cr.NS_ERROR_FAILURE);
   } finally {
     if (con) {
       con.close();
     }
   }
 });
 
-add_task(function test_defaultSynchronousAtNormal()
-{
+add_task(function* test_defaultSynchronousAtNormal() {
   var msc = getOpenedDatabase();
   var stmt = createStatement("PRAGMA synchronous;");
   try {
     stmt.executeStep();
     do_check_eq(1, stmt.getInt32(0));
   }
   finally {
     stmt.reset();
     stmt.finalize();
   }
 });
 
 // must be ran before executeAsync tests
-add_task(function test_close_does_not_spin_event_loop()
-{
+add_task(function* test_close_does_not_spin_event_loop() {
   // We want to make sure that the event loop on the calling thread does not
   // spin when close is called.
   let event = {
     ran: false,
-    run: function()
-    {
+    run() {
       this.ran = true;
     },
   };
 
   // Post the event before we call close, so it would run if the event loop was
   // spun during close.
   let thread = Cc["@mozilla.org/thread-manager;1"].
                getService(Ci.nsIThreadManager).
@@ -310,88 +299,85 @@ add_task(function test_close_does_not_sp
   do_check_false(event.ran);
   getOpenedDatabase().close();
   do_check_false(event.ran);
 
   // Reset gDBConn so that later tests will get a new connection object.
   gDBConn = null;
 });
 
-add_task(function test_asyncClose_succeeds_with_finalized_async_statement()
-{
+add_task(function* test_asyncClose_succeeds_with_finalized_async_statement() {
   // XXX this test isn't perfect since we can't totally control when events will
   //     run.  If this paticular function fails randomly, it means we have a
   //     real bug.
 
   // We want to make sure we create a cached async statement to make sure that
   // when we finalize our statement, we end up finalizing the async one too so
   // close will succeed.
   let stmt = createStatement("SELECT * FROM test");
   stmt.executeAsync();
   stmt.finalize();
 
   yield asyncClose(getOpenedDatabase());
   // Reset gDBConn so that later tests will get a new connection object.
   gDBConn = null;
 });
 
-add_task(function test_close_then_release_statement() {
+add_task(function* test_close_then_release_statement() {
   // Testing the behavior in presence of a bad client that finalizes
   // statements after the database has been closed (typically by
   // letting the gc finalize the statement).
   let db = getOpenedDatabase();
   let stmt = createStatement("SELECT * FROM test -- test_close_then_release_statement");
   db.close();
   stmt.finalize(); // Finalize too late - this should not crash
 
   // Reset gDBConn so that later tests will get a new connection object.
   gDBConn = null;
 });
 
-add_task(function test_asyncClose_then_release_statement() {
+add_task(function* test_asyncClose_then_release_statement() {
   // Testing the behavior in presence of a bad client that finalizes
   // statements after the database has been async closed (typically by
   // letting the gc finalize the statement).
   let db = getOpenedDatabase();
   let stmt = createStatement("SELECT * FROM test -- test_asyncClose_then_release_statement");
   yield asyncClose(db);
   stmt.finalize(); // Finalize too late - this should not crash
 
   // Reset gDBConn so that later tests will get a new connection object.
   gDBConn = null;
 });
 
-add_task(function test_close_fails_with_async_statement_ran()
-{
+add_task(function* test_close_fails_with_async_statement_ran() {
   let deferred = Promise.defer();
   let stmt = createStatement("SELECT * FROM test");
   stmt.executeAsync();
   stmt.finalize();
 
   let db = getOpenedDatabase();
   try {
     db.close();
     do_throw("should have thrown");
   }
   catch (e) {
     do_check_eq(e.result, Cr.NS_ERROR_UNEXPECTED);
   }
   finally {
     // Clean up after ourselves.
-    db.asyncClose(function() {
+    db.asyncClose(function () {
       // Reset gDBConn so that later tests will get a new connection object.
       gDBConn = null;
       deferred.resolve();
     });
   }
   yield deferred.promise;
 });
 
-add_task(function test_clone_optional_param()
-{
+add_task(function* test_clone_optional_param() {
   let db1 = getService().openUnsharedDatabase(getTestDB());
   let db2 = db1.clone();
   do_check_true(db2.connectionReady);
 
   // A write statement should not fail here.
   let stmt = db2.createStatement("INSERT INTO test (name) VALUES (:name)");
   stmt.params.name = "dwitte";
   stmt.execute();
@@ -404,17 +390,17 @@ add_task(function test_clone_optional_pa
 
   // Additionally check that it is a connection on the same database.
   do_check_true(db1.databaseFile.equals(db2.databaseFile));
 
   db1.close();
   db2.close();
 });
 
-function standardAsyncTest(promisedDB, name, shouldInit = false) {
+function* standardAsyncTest(promisedDB, name, shouldInit = false) {
   do_print("Performing standard async test " + name);
 
   let adb = yield promisedDB;
   do_check_true(adb instanceof Ci.mozIStorageAsyncConnection);
   do_check_false(adb instanceof Ci.mozIStorageConnection);
 
   if (shouldInit) {
     let stmt = adb.createAsyncStatement("CREATE TABLE test(name TEXT)");
@@ -429,34 +415,33 @@ function standardAsyncTest(promisedDB, n
   stmt.params.name = name;
   let result = yield executeAsync(stmt);
   do_print("Request complete");
   stmt.finalize();
   do_check_true(Components.isSuccessCode(result));
   do_print("Extracting data");
   stmt = adb.createAsyncStatement("SELECT * FROM test");
   let found = false;
-  yield executeAsync(stmt, function(result) {
+  yield executeAsync(stmt, function (results) {
     do_print("Data has been extracted");
-
-    for (let row = result.getNextRow(); row != null; row = result.getNextRow()) {
+    for (let row = results.getNextRow(); row != null; row = results.getNextRow()) {
       if (row.getResultByName("name") == name) {
         found = true;
-      break;
+        break;
       }
     }
   });
   do_check_true(found);
   stmt.finalize();
   yield asyncClose(adb);
 
   do_print("Standard async test " + name + " complete");
 }
 
-add_task(function test_open_async() {
+add_task(function* test_open_async() {
   yield standardAsyncTest(openAsyncDatabase(getTestDB(), null), "default");
   yield standardAsyncTest(openAsyncDatabase(getTestDB()), "no optional arg");
   yield standardAsyncTest(openAsyncDatabase(getTestDB(),
     {shared: false, growthIncrement: 54}), "non-default options");
   yield standardAsyncTest(openAsyncDatabase("memory"),
     "in-memory database", true);
   yield standardAsyncTest(openAsyncDatabase("memory",
     {shared: false, growthIncrement: 54}),
@@ -487,59 +472,56 @@ add_task(function test_open_async() {
     if (adb) {
       yield asyncClose(adb);
     }
   }
   do_check_true(raised);
 });
 
 
-add_task(function test_async_open_with_shared_cache() {
+add_task(function* test_async_open_with_shared_cache() {
   do_print("Testing that opening with a shared cache doesn't break stuff");
   let adb = yield openAsyncDatabase(getTestDB(), {shared: true});
 
   let stmt = adb.createAsyncStatement("INSERT INTO test (name) VALUES (:name)");
   stmt.params.name = "clockworker";
   let result = yield executeAsync(stmt);
   do_print("Request complete");
   stmt.finalize();
   do_check_true(Components.isSuccessCode(result));
   do_print("Extracting data");
   stmt = adb.createAsyncStatement("SELECT * FROM test");
   let found = false;
-  yield executeAsync(stmt, function(result) {
+  yield executeAsync(stmt, function (results) {
     do_print("Data has been extracted");
-
-    for (let row = result.getNextRow(); row != null; row = result.getNextRow()) {
+    for (let row = results.getNextRow(); row != null; row = results.getNextRow()) {
       if (row.getResultByName("name") == "clockworker") {
         found = true;
-      break;
+        break;
       }
     }
   });
   do_check_true(found);
   stmt.finalize();
   yield asyncClose(adb);
 });
 
-add_task(function test_clone_trivial_async()
-{
+add_task(function* test_clone_trivial_async() {
   let db1 = getService().openDatabase(getTestDB());
   do_print("Opened adb1");
   do_check_true(db1 instanceof Ci.mozIStorageAsyncConnection);
   let adb2 = yield asyncClone(db1, true);
   do_check_true(adb2 instanceof Ci.mozIStorageAsyncConnection);
   do_print("Cloned to adb2");
   db1.close();
   do_print("Closed db1");
   yield asyncClose(adb2);
 });
 
-add_task(function test_clone_no_optional_param_async()
-{
+add_task(function* test_clone_no_optional_param_async() {
   "use strict";
   do_print("Testing async cloning");
   let adb1 = yield openAsyncDatabase(getTestDB(), null);
   do_check_true(adb1 instanceof Ci.mozIStorageAsyncConnection);
 
   do_print("Cloning database");
 
   let adb2 = yield asyncClone(adb1);
@@ -555,38 +537,36 @@ add_task(function test_clone_no_optional
   stmt.params.name = "yoric";
   let result = yield executeAsync(stmt);
   do_print("Request complete");
   stmt.finalize();
   do_check_true(Components.isSuccessCode(result));
   do_print("Extracting data from clone db");
   stmt = adb2.createAsyncStatement("SELECT * FROM test");
   let found = false;
-  yield executeAsync(stmt, function(result) {
+  yield executeAsync(stmt, function (results) {
     do_print("Data has been extracted");
-
-    for (let row = result.getNextRow(); row != null; row = result.getNextRow()) {
+    for (let row = results.getNextRow(); row != null; row = results.getNextRow()) {
       if (row.getResultByName("name") == "yoric") {
         found = true;
-      break;
+        break;
       }
     }
   });
   do_check_true(found);
   stmt.finalize();
   do_print("Closing databases");
   yield asyncClose(adb2);
   do_print("First db closed");
 
   yield asyncClose(adb1);
   do_print("Second db closed");
 });
 
-add_task(function test_clone_readonly()
-{
+add_task(function* test_clone_readonly() {
   let db1 = getService().openUnsharedDatabase(getTestDB());
   let db2 = db1.clone(true);
   do_check_true(db2.connectionReady);
 
   // A write statement should fail here.
   let stmt = db2.createStatement("INSERT INTO test (name) VALUES (:name)");
   stmt.params.name = "reed";
   expectError(Cr.NS_ERROR_FILE_READ_ONLY, () => stmt.execute());
@@ -596,18 +576,17 @@ add_task(function test_clone_readonly()
   stmt = db2.createStatement("SELECT * FROM test");
   do_check_true(stmt.executeStep());
   stmt.finalize();
 
   db1.close();
   db2.close();
 });
 
-add_task(function test_clone_shared_readonly()
-{
+add_task(function* test_clone_shared_readonly() {
   let db1 = getService().openDatabase(getTestDB());
   let db2 = db1.clone(true);
   do_check_true(db2.connectionReady);
 
   let stmt = db2.createStatement("INSERT INTO test (name) VALUES (:name)");
   stmt.params.name = "parker";
   // TODO currently SQLite does not actually work correctly here.  The behavior
   //      we want is commented out, and the current behavior is being tested
@@ -621,50 +600,47 @@ add_task(function test_clone_shared_read
   stmt = db2.createStatement("SELECT * FROM test");
   do_check_true(stmt.executeStep());
   stmt.finalize();
 
   db1.close();
   db2.close();
 });
 
-add_task(function test_close_clone_fails()
-{
+add_task(function* test_close_clone_fails() {
   let calls = [
     "openDatabase",
     "openUnsharedDatabase",
   ];
-  calls.forEach(function(methodName) {
+  calls.forEach(function (methodName) {
     let db = getService()[methodName](getTestDB());
     db.close();
     expectError(Cr.NS_ERROR_NOT_INITIALIZED, () => db.clone());
   });
 });
 
-add_task(function test_memory_clone_fails()
-{
+add_task(function* test_memory_clone_fails() {
   let db = getService().openSpecialDatabase("memory");
   db.close();
   expectError(Cr.NS_ERROR_NOT_INITIALIZED, () => db.clone());
 });
 
-add_task(function test_clone_copies_functions()
-{
+add_task(function* test_clone_copies_functions() {
   const FUNC_NAME = "test_func";
   let calls = [
     "openDatabase",
     "openUnsharedDatabase",
   ];
   let functionMethods = [
     "createFunction",
     "createAggregateFunction",
   ];
-  calls.forEach(function(methodName) {
-    [true, false].forEach(function(readOnly) {
-      functionMethods.forEach(function(functionMethod) {
+  calls.forEach(function (methodName) {
+    [true, false].forEach(function (readOnly) {
+      functionMethods.forEach(function (functionMethod) {
         let db1 = getService()[methodName](getTestDB());
         // Create a function for db1.
         db1[functionMethod](FUNC_NAME, 1, {
           onFunctionCall: () => 0,
           onStep: () => 0,
           onFinal: () => 0,
         });
 
@@ -675,43 +651,42 @@ add_task(function test_clone_copies_func
         stmt.finalize();
         db1.close();
         db2.close();
       });
     });
   });
 });
 
-add_task(function test_clone_copies_overridden_functions()
-{
+add_task(function* test_clone_copies_overridden_functions() {
   const FUNC_NAME = "lower";
   function test_func() {
     this.called = false;
   }
   test_func.prototype = {
-    onFunctionCall: function() {
+    onFunctionCall() {
       this.called = true;
     },
-    onStep: function() {
+    onStep() {
       this.called = true;
     },
     onFinal: () => 0,
   };
 
   let calls = [
     "openDatabase",
     "openUnsharedDatabase",
   ];
   let functionMethods = [
     "createFunction",
     "createAggregateFunction",
   ];
-  calls.forEach(function(methodName) {
-    [true, false].forEach(function(readOnly) {
-      functionMethods.forEach(function(functionMethod) {
+  calls.forEach(function (methodName) {
+    [true, false].forEach(function (readOnly) {
+      functionMethods.forEach(function (functionMethod) {
         let db1 = getService()[methodName](getTestDB());
         // Create a function for db1.
         let func = new test_func();
         db1[functionMethod](FUNC_NAME, 1, func);
         do_check_false(func.called);
 
         // Clone it, and make sure the function gets called.
         let db2 = db1.clone(readOnly);
@@ -721,18 +696,17 @@ add_task(function test_clone_copies_over
         stmt.finalize();
         db1.close();
         db2.close();
       });
     });
   });
 });
 
-add_task(function test_clone_copies_pragmas()
-{
+add_task(function* test_clone_copies_pragmas() {
   const PRAGMAS = [
     { name: "cache_size", value: 500, copied: true },
     { name: "temp_store", value: 2, copied: true },
     { name: "foreign_keys", value: 1, copied: true },
     { name: "journal_size_limit", value: 524288, copied: true },
     { name: "synchronous", value: 2, copied: true },
     { name: "wal_autocheckpoint", value: 16, copied: true },
     { name: "busy_timeout", value: 50, copied: true },
@@ -764,18 +738,17 @@ add_task(function test_clone_copies_prag
     validate(pragma.value, stmt.getInt32(0));
     stmt.finalize();
   });
 
   db1.close();
   db2.close();
 });
 
-add_task(function test_readonly_clone_copies_pragmas()
-{
+add_task(function* test_readonly_clone_copies_pragmas() {
   const PRAGMAS = [
     { name: "cache_size", value: 500, copied: true },
     { name: "temp_store", value: 2, copied: true },
     { name: "foreign_keys", value: 1, copied: false },
     { name: "journal_size_limit", value: 524288, copied: false },
     { name: "synchronous", value: 2, copied: false },
     { name: "wal_autocheckpoint", value: 16, copied: false },
     { name: "busy_timeout", value: 50, copied: false },
@@ -807,26 +780,24 @@ add_task(function test_readonly_clone_co
     validate(pragma.value, stmt.getInt32(0));
     stmt.finalize();
   });
 
   db1.close();
   db2.close();
 });
 
-add_task(function test_getInterface()
-{
+add_task(function* test_getInterface() {
   let db = getOpenedDatabase();
   let target = db.QueryInterface(Ci.nsIInterfaceRequestor)
                  .getInterface(Ci.nsIEventTarget);
   // Just check that target is non-null.  Other tests will ensure that it has
   // the correct value.
   do_check_true(target != null);
 
   yield asyncClose(db);
   gDBConn = null;
 });
 
 
-function run_test()
-{
+function run_test() {
   run_next_test();
 }
--- a/storage/test/unit/test_storage_function.js
+++ b/storage/test/unit/test_storage_function.js
@@ -6,28 +6,28 @@
 
 var testNums = [1, 2, 3, 4];
 
 function setup()
 {
   getOpenedDatabase().createTable("function_tests", "id INTEGER PRIMARY KEY");
 
   var stmt = createStatement("INSERT INTO function_tests (id) VALUES(?1)");
-  for(var i = 0; i < testNums.length; ++i) {
+  for (let i = 0; i < testNums.length; ++i) {
     stmt.bindByIndex(0, testNums[i]);
     stmt.execute();
   }
   stmt.reset();
   stmt.finalize();
 }
 
 var testSquareFunction = {
   calls: 0,
 
-  onFunctionCall: function(val) {
+  onFunctionCall(val) {
     ++this.calls;
     return val.getInt32(0) * val.getInt32(0);
   }
 };
 
 function test_function_registration()
 {
   var msc = getOpenedDatabase();
@@ -57,27 +57,29 @@ function test_function_aliases()
 {
   var msc = getOpenedDatabase();
   msc.createFunction("test_square2", 1, testSquareFunction);
 }
 
 function test_function_call()
 {
   var stmt = createStatement("SELECT test_square(id) FROM function_tests");
-  while(stmt.executeStep());
+  while (stmt.executeStep()) {
+    // Do nothing.
+  }
   do_check_eq(testNums.length, testSquareFunction.calls);
   testSquareFunction.calls = 0;
   stmt.finalize();
 }
 
 function test_function_result()
 {
   var stmt = createStatement("SELECT test_square(42) FROM function_tests");
   stmt.executeStep();
-  do_check_eq(42*42, stmt.getInt32(0));
+  do_check_eq(42 * 42, stmt.getInt32(0));
   testSquareFunction.calls = 0;
   stmt.finalize();
 }
 
 var tests = [test_function_registration, test_function_no_double_registration,
              test_function_removal, test_function_aliases, test_function_call,
              test_function_result];
 
--- a/storage/test/unit/test_storage_progresshandler.js
+++ b/storage/test/unit/test_storage_progresshandler.js
@@ -6,31 +6,31 @@
 
 function setup()
 {
   var msc = getOpenedDatabase();
   msc.createTable("handler_tests", "id INTEGER PRIMARY KEY, num INTEGER");
   msc.beginTransaction();
 
   var stmt = createStatement("INSERT INTO handler_tests (id, num) VALUES(?1, ?2)");
-  for(var i = 0; i < 100; ++i) {
+  for (let i = 0; i < 100; ++i) {
     stmt.bindByIndex(0, i);
-    stmt.bindByIndex(1, Math.floor(Math.random()*1000));
+    stmt.bindByIndex(1, Math.floor(Math.random() * 1000));
     stmt.execute();
   }
   stmt.reset();
   msc.commitTransaction();
   stmt.finalize();
 }
 
 var testProgressHandler = {
   calls: 0,
   abort: false,
 
-  onProgress: function(comm) {
+  onProgress(comm) {
     ++this.calls;
     return this.abort;
   }
 };
 
 function test_handler_registration()
 {
   var msc = getOpenedDatabase();
@@ -54,33 +54,37 @@ function test_handler_removal()
 
 function test_handler_call()
 {
   var msc = getOpenedDatabase();
   msc.setProgressHandler(50, testProgressHandler);
   // Some long-executing request
   var stmt = createStatement(
     "SELECT SUM(t1.num * t2.num) FROM handler_tests AS t1, handler_tests AS t2");
-  while(stmt.executeStep());
+  while (stmt.executeStep()) {
+    // Do nothing.
+  }
   do_check_true(testProgressHandler.calls > 0);
   stmt.finalize();
 }
 
 function test_handler_abort()
 {
   var msc = getOpenedDatabase();
   testProgressHandler.abort = true;
   msc.setProgressHandler(50, testProgressHandler);
   // Some long-executing request
   var stmt = createStatement(
     "SELECT SUM(t1.num * t2.num) FROM handler_tests AS t1, handler_tests AS t2");
 
   const SQLITE_INTERRUPT = 9;
   try {
-    while(stmt.executeStep());
+    while (stmt.executeStep()) {
+      // Do nothing.
+    }
     do_throw("We shouldn't get here!");
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_ABORT, e.result);
     do_check_eq(SQLITE_INTERRUPT, msc.lastError);
   }
   try {
     stmt.finalize();
     do_throw("We shouldn't get here!");
--- a/storage/test/unit/test_storage_service.js
+++ b/storage/test/unit/test_storage_service.js
@@ -92,27 +92,27 @@ function test_backup_not_new_filename()
 
   backup.remove(false);
 }
 
 function test_backup_new_filename()
 {
   var backup = getService().backupDatabaseFile(getTestDB(), BACKUP_FILE_NAME);
   do_check_eq(BACKUP_FILE_NAME, backup.leafName);
-  
+
   backup.remove(false);
 }
 
 function test_backup_new_folder()
 {
   var parentDir = getTestDB().parent;
   parentDir.append("test_storage_temp");
   if (parentDir.exists())
     parentDir.remove(true);
-  parentDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
+  parentDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
   do_check_true(parentDir.exists());
 
   var backup = getService().backupDatabaseFile(getTestDB(), BACKUP_FILE_NAME,
                                                parentDir);
   do_check_eq(BACKUP_FILE_NAME, backup.leafName);
   do_check_true(parentDir.equals(backup.parent));
 
   parentDir.remove(true);
@@ -128,14 +128,15 @@ var tests = [
   test_fake_db_throws_with_openDatabase,
   test_backup_not_new_filename,
   test_backup_new_filename,
   test_backup_new_folder,
 ];
 
 function run_test()
 {
-  for (var i = 0; i < tests.length; i++)
+  for (var i = 0; i < tests.length; i++) {
     tests[i]();
-    
+  }
+
   cleanup();
 }
 
--- a/storage/test/unit/test_storage_service_unshared.js
+++ b/storage/test/unit/test_storage_service_unshared.js
@@ -24,12 +24,12 @@ function test_openUnsharedDatabase_file_
 
 var tests = [test_openUnsharedDatabase_file_DNE,
              test_openUnsharedDatabase_file_exists];
 
 function run_test()
 {
   for (var i = 0; i < tests.length; i++)
     tests[i]();
-    
+
   cleanup();
 }
 
--- a/storage/test/unit/test_storage_statement.js
+++ b/storage/test/unit/test_storage_statement.js
@@ -81,17 +81,17 @@ function test_getColumnIndex_different_c
   var stmt = createStatement("SELECT name, id FROM test");
   try {
     do_check_eq(0, stmt.getColumnIndex("NaMe"));
     do_throw("should not get here");
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_INVALID_ARG, e.result);
   }
   try {
-  do_check_eq(1, stmt.getColumnIndex("Id"));
+    do_check_eq(1, stmt.getColumnIndex("Id"));
     do_throw("should not get here");
   } catch (e) {
     do_check_eq(Cr.NS_ERROR_INVALID_ARG, e.result);
   }
   stmt.reset();
   stmt.finalize();
 }
 
@@ -174,14 +174,15 @@ var tests = [test_parameterCount_none, t
              test_getColumnDecltype,
              test_failed_execute,
 ];
 
 function run_test()
 {
   setup();
 
-  for (var i = 0; i < tests.length; i++)
+  for (var i = 0; i < tests.length; i++) {
     tests[i]();
-    
+  }
+
   cleanup();
 }
 
--- a/storage/test/unit/test_storage_value_array.js
+++ b/storage/test/unit/test_storage_value_array.js
@@ -3,39 +3,39 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // This file tests the functions of mozIStorageValueArray
 
 function setup()
 {
   getOpenedDatabase().createTable("test", "id INTEGER PRIMARY KEY, name TEXT," +
                                           "number REAL, nuller NULL, blobber BLOB");
-  
+
   var stmt = createStatement("INSERT INTO test (name, number, blobber) " +
                              "VALUES (?1, ?2, ?3)");
   stmt.bindByIndex(0, "foo");
   stmt.bindByIndex(1, 2.34);
   stmt.bindBlobByIndex(2, [], 0);
   stmt.execute();
-  
+
   stmt.bindByIndex(0, "");
   stmt.bindByIndex(1, 1.23);
   stmt.bindBlobByIndex(2, [1, 2], 2);
   stmt.execute();
 
   stmt.reset();
   stmt.finalize();
 }
 
 function test_getIsNull_for_null()
 {
   var stmt = createStatement("SELECT nuller, blobber FROM test WHERE id = ?1");
   stmt.bindByIndex(0, 1);
   do_check_true(stmt.executeStep());
-  
+
   do_check_true(stmt.getIsNull(0)); // null field
   do_check_true(stmt.getIsNull(1)); // data is null if size is 0
   stmt.reset();
   stmt.finalize();
 }
 
 function test_getIsNull_for_non_null()
 {
@@ -197,14 +197,15 @@ var tests = [test_getIsNull_for_null, te
              test_value_type_float, test_value_type_text, test_value_type_blob,
              test_numEntries_one, test_numEntries_all, test_getInt,
              test_getDouble, test_getUTF8String, test_getString, test_getBlob];
 
 function run_test()
 {
   setup();
 
-  for (var i = 0; i < tests.length; i++)
+  for (var i = 0; i < tests.length; i++) {
     tests[i]();
-    
+  }
+
   cleanup();
 }
 
--- a/storage/test/unit/test_telemetry_vfs.js
+++ b/storage/test/unit/test_telemetry_vfs.js
@@ -1,17 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Make sure that there are telemetry entries created by sqlite io
 
 function run_sql(d, sql) {
-  var stmt = d.createStatement(sql)
-  stmt.execute()
+  var stmt = d.createStatement(sql);
+  stmt.execute();
   stmt.finalize();
 }
 
 function new_file(name)
 {
   var file = dirSvc.get("ProfD", Ci.nsIFile);
   file.append(name);
   return file;
@@ -19,12 +19,12 @@ function new_file(name)
 function run_test()
 {
   const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
   let read_hgram = Telemetry.getHistogramById("MOZ_SQLITE_OTHER_READ_B");
   let old_sum = read_hgram.snapshot().sum;
   const file = new_file("telemetry.sqlite");
   var d = getDatabase(file);
   run_sql(d, "CREATE TABLE bloat(data varchar)");
-  run_sql(d, "DROP TABLE bloat")
-  do_check_true(read_hgram.snapshot().sum > old_sum)
+  run_sql(d, "DROP TABLE bloat");
+  do_check_true(read_hgram.snapshot().sum > old_sum);
 }
 
--- a/storage/test/unit/test_unicode.js
+++ b/storage/test/unit/test_unicode.js
@@ -90,14 +90,15 @@ function test_like_search_same()
 var tests = [test_upper_ascii, test_upper_non_ascii, test_lower_ascii,
              test_lower_non_ascii, test_like_search_different,
              test_like_search_same];
 
 function run_test()
 {
   setup();
 
-  for (var i = 0; i < tests.length; i++)
+  for (var i = 0; i < tests.length; i++) {
     tests[i]();
-    
+  }
+
   cleanup();
 }
 
--- a/storage/test/unit/test_vacuum.js
+++ b/storage/test/unit/test_vacuum.js
@@ -82,254 +82,254 @@ function run_test()
     stmt.finalize();
   }
 
   load_test_vacuum_component();
 
   run_next_test();
 }
 
+const TESTS = [
+
+  function test_common_vacuum()
+  {
+    print("\n*** Test that a VACUUM correctly happens and all notifications are fired.");
+    // Wait for VACUUM begin.
+    let beginVacuumReceived = false;
+    Services.obs.addObserver(function onVacuum(aSubject, aTopic, aData) {
+      Services.obs.removeObserver(onVacuum, aTopic);
+      beginVacuumReceived = true;
+    }, "test-begin-vacuum", false);
+
+    // Wait for heavy IO notifications.
+    let heavyIOTaskBeginReceived = false;
+    let heavyIOTaskEndReceived = false;
+    Services.obs.addObserver(function onVacuum(aSubject, aTopic, aData) {
+      if (heavyIOTaskBeginReceived && heavyIOTaskEndReceived) {
+        Services.obs.removeObserver(onVacuum, aTopic);
+      }
+
+      if (aData == "vacuum-begin") {
+        heavyIOTaskBeginReceived = true;
+      }
+      else if (aData == "vacuum-end") {
+        heavyIOTaskEndReceived = true;
+      }
+    }, "heavy-io-task", false);
+
+    // Wait for VACUUM end.
+    Services.obs.addObserver(function onVacuum(aSubject, aTopic, aData) {
+      Services.obs.removeObserver(onVacuum, aTopic);
+      print("Check we received onBeginVacuum");
+      do_check_true(beginVacuumReceived);
+      print("Check we received heavy-io-task notifications");
+      do_check_true(heavyIOTaskBeginReceived);
+      do_check_true(heavyIOTaskEndReceived);
+      print("Received onEndVacuum");
+      run_next_test();
+    }, "test-end-vacuum", false);
+
+    synthesize_idle_daily();
+  },
+
+  function test_skipped_if_recent_vacuum()
+  {
+    print("\n*** Test that a VACUUM is skipped if it was run recently.");
+    Services.prefs.setIntPref("storage.vacuum.last.testVacuum.sqlite",
+                              parseInt(Date.now() / 1000));
+
+    // Wait for VACUUM begin.
+    let vacuumObserver = {
+      gotNotification: false,
+      observe: function VO_observe(aSubject, aTopic, aData) {
+        this.gotNotification = true;
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+    };
+    Services.obs.addObserver(vacuumObserver, "test-begin-vacuum", false);
+
+    // Check after a couple seconds that no VACUUM has been run.
+    do_timeout(2000, function () {
+      print("Check VACUUM did not run.");
+      do_check_false(vacuumObserver.gotNotification);
+      Services.obs.removeObserver(vacuumObserver, "test-begin-vacuum");
+      run_next_test();
+    });
+
+    synthesize_idle_daily();
+  },
+
+  function test_page_size_change()
+  {
+    print("\n*** Test that a VACUUM changes page_size");
+
+    // We did setup the database with a small page size, the previous vacuum
+    // should have updated it.
+    print("Check that page size was updated.");
+    let conn = getDatabase(new_db_file("testVacuum"));
+    let stmt = conn.createStatement("PRAGMA page_size");
+    try {
+      while (stmt.executeStep()) {
+        do_check_eq(stmt.row.page_size, conn.defaultPageSize);
+      }
+    }
+    finally {
+      stmt.finalize();
+    }
+
+    run_next_test();
+  },
+
+  function test_skipped_optout_vacuum()
+  {
+    print("\n*** Test that a VACUUM is skipped if the participant wants to opt-out.");
+    Services.obs.notifyObservers(null, "test-options", "opt-out");
+
+    // Wait for VACUUM begin.
+    let vacuumObserver = {
+      gotNotification: false,
+      observe: function VO_observe(aSubject, aTopic, aData) {
+        this.gotNotification = true;
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+    };
+    Services.obs.addObserver(vacuumObserver, "test-begin-vacuum", false);
+
+    // Check after a couple seconds that no VACUUM has been run.
+    do_timeout(2000, function () {
+      print("Check VACUUM did not run.");
+      do_check_false(vacuumObserver.gotNotification);
+      Services.obs.removeObserver(vacuumObserver, "test-begin-vacuum");
+      run_next_test();
+    });
+
+    synthesize_idle_daily();
+  },
+
+  /* Changing page size on WAL is not supported till Bug 634374 is properly fixed.
+  function test_page_size_change_with_wal()
+  {
+    print("\n*** Test that a VACUUM changes page_size with WAL mode");
+    Services.obs.notifyObservers(null, "test-options", "wal");
+
+    // Set a small page size.
+    let conn = getDatabase(new_db_file("testVacuum2"));
+    conn.executeSimpleSQL("PRAGMA page_size = 1024");
+    let stmt = conn.createStatement("PRAGMA page_size");
+    try {
+      while (stmt.executeStep()) {
+        do_check_eq(stmt.row.page_size, 1024);
+      }
+    }
+    finally {
+      stmt.finalize();
+    }
+
+    // Use WAL journal mode.
+    conn.executeSimpleSQL("PRAGMA journal_mode = WAL");
+    stmt = conn.createStatement("PRAGMA journal_mode");
+    try {
+      while (stmt.executeStep()) {
+        do_check_eq(stmt.row.journal_mode, "wal");
+      }
+    }
+    finally {
+      stmt.finalize();
+    }
+
+    // Wait for VACUUM end.
+    let vacuumObserver = {
+      observe: function VO_observe(aSubject, aTopic, aData) {
+        Services.obs.removeObserver(this, aTopic);
+        print("Check page size has been updated.");
+        let stmt = conn.createStatement("PRAGMA page_size");
+        try {
+          while (stmt.executeStep()) {
+            do_check_eq(stmt.row.page_size, Ci.mozIStorageConnection.DEFAULT_PAGE_SIZE);
+          }
+        }
+        finally {
+          stmt.finalize();
+        }
+
+        print("Check journal mode has been restored.");
+        stmt = conn.createStatement("PRAGMA journal_mode");
+        try {
+          while (stmt.executeStep()) {
+            do_check_eq(stmt.row.journal_mode, "wal");
+          }
+        }
+        finally {
+          stmt.finalize();
+        }
+
+        run_next_test();
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+    }
+    Services.obs.addObserver(vacuumObserver, "test-end-vacuum", false);
+
+    synthesize_idle_daily();
+  },
+  */
+
+  function test_memory_database_crash()
+  {
+    print("\n*** Test that we don't crash trying to vacuum a memory database");
+    Services.obs.notifyObservers(null, "test-options", "memory");
+
+    // Wait for VACUUM begin.
+    let vacuumObserver = {
+      gotNotification: false,
+      observe: function VO_observe(aSubject, aTopic, aData) {
+        this.gotNotification = true;
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+    };
+    Services.obs.addObserver(vacuumObserver, "test-begin-vacuum", false);
+
+    // Check after a couple seconds that no VACUUM has been run.
+    do_timeout(2000, function () {
+      print("Check VACUUM did not run.");
+      do_check_false(vacuumObserver.gotNotification);
+      Services.obs.removeObserver(vacuumObserver, "test-begin-vacuum");
+      run_next_test();
+    });
+
+    synthesize_idle_daily();
+  },
+
+  /* Changing page size on WAL is not supported till Bug 634374 is properly fixed.
+  function test_wal_restore_fail()
+  {
+    print("\n*** Test that a failing WAL restoration notifies failure");
+    Services.obs.notifyObservers(null, "test-options", "wal-fail");
+
+    // Wait for VACUUM end.
+    let vacuumObserver = {
+      observe: function VO_observe(aSubject, aTopic, aData) {
+        Services.obs.removeObserver(vacuumObserver, "test-end-vacuum");
+        print("Check WAL restoration failed.");
+        do_check_false(aData);
+        run_next_test();
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
+    }
+    Services.obs.addObserver(vacuumObserver, "test-end-vacuum", false);
+
+    synthesize_idle_daily();
+  },
+  */
+];
+
 function run_next_test()
 {
   if (TESTS.length == 0) {
     Services.obs.notifyObservers(null, "test-options", "dispose");
     do_test_finished();
   }
   else {
     // Set last VACUUM to a date in the past.
     Services.prefs.setIntPref("storage.vacuum.last.testVacuum.sqlite",
                               parseInt(Date.now() / 1000 - 31 * 86400));
     do_execute_soon(TESTS.shift());
   }
 }
-
-const TESTS = [
-
-function test_common_vacuum()
-{
-  print("\n*** Test that a VACUUM correctly happens and all notifications are fired.");
-  // Wait for VACUUM begin.
-  let beginVacuumReceived = false;
-  Services.obs.addObserver(function onVacuum(aSubject, aTopic, aData) {
-    Services.obs.removeObserver(onVacuum, aTopic);
-    beginVacuumReceived = true;
-  }, "test-begin-vacuum", false);
-
-  // Wait for heavy IO notifications.
-  let heavyIOTaskBeginReceived = false;
-  let heavyIOTaskEndReceived = false;
-  Services.obs.addObserver(function onVacuum(aSubject, aTopic, aData) {
-    if (heavyIOTaskBeginReceived && heavyIOTaskEndReceived) {
-      Services.obs.removeObserver(onVacuum, aTopic);
-    }
-
-    if (aData == "vacuum-begin") {
-      heavyIOTaskBeginReceived = true;
-    }
-    else if (aData == "vacuum-end") {
-      heavyIOTaskEndReceived = true;
-    }
-  }, "heavy-io-task", false);
-
-  // Wait for VACUUM end.
-  Services.obs.addObserver(function onVacuum(aSubject, aTopic, aData) {
-    Services.obs.removeObserver(onVacuum, aTopic);
-    print("Check we received onBeginVacuum");
-    do_check_true(beginVacuumReceived);
-    print("Check we received heavy-io-task notifications");
-    do_check_true(heavyIOTaskBeginReceived);
-    do_check_true(heavyIOTaskEndReceived);
-    print("Received onEndVacuum");
-    run_next_test();
-  }, "test-end-vacuum", false);
-
-  synthesize_idle_daily();
-},
-
-function test_skipped_if_recent_vacuum()
-{
-  print("\n*** Test that a VACUUM is skipped if it was run recently.");
-  Services.prefs.setIntPref("storage.vacuum.last.testVacuum.sqlite",
-                            parseInt(Date.now() / 1000));
-
-  // Wait for VACUUM begin.
-  let vacuumObserver = {
-    gotNotification: false,
-    observe: function VO_observe(aSubject, aTopic, aData) {
-      this.gotNotification = true;
-    },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
-  }
-  Services.obs.addObserver(vacuumObserver, "test-begin-vacuum", false);
-
-  // Check after a couple seconds that no VACUUM has been run.
-  do_timeout(2000, function () {
-    print("Check VACUUM did not run.");
-    do_check_false(vacuumObserver.gotNotification);
-    Services.obs.removeObserver(vacuumObserver, "test-begin-vacuum");
-    run_next_test();
-  });
-
-  synthesize_idle_daily();
-},
-
-function test_page_size_change()
-{
-  print("\n*** Test that a VACUUM changes page_size");
-
-  // We did setup the database with a small page size, the previous vacuum
-  // should have updated it.
-  print("Check that page size was updated.");
-  let conn = getDatabase(new_db_file("testVacuum"));
-  let stmt = conn.createStatement("PRAGMA page_size");
-  try {
-    while (stmt.executeStep()) {
-      do_check_eq(stmt.row.page_size,  conn.defaultPageSize);
-    }
-  }
-  finally {
-    stmt.finalize();
-  }
-
-  run_next_test();
-},
-
-function test_skipped_optout_vacuum()
-{
-  print("\n*** Test that a VACUUM is skipped if the participant wants to opt-out.");
-  Services.obs.notifyObservers(null, "test-options", "opt-out");
-
-  // Wait for VACUUM begin.
-  let vacuumObserver = {
-    gotNotification: false,
-    observe: function VO_observe(aSubject, aTopic, aData) {
-      this.gotNotification = true;
-    },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
-  }
-  Services.obs.addObserver(vacuumObserver, "test-begin-vacuum", false);
-
-  // Check after a couple seconds that no VACUUM has been run.
-  do_timeout(2000, function () {
-    print("Check VACUUM did not run.");
-    do_check_false(vacuumObserver.gotNotification);
-    Services.obs.removeObserver(vacuumObserver, "test-begin-vacuum");
-    run_next_test();
-  });
-
-  synthesize_idle_daily();
-},
-
-/* Changing page size on WAL is not supported till Bug 634374 is properly fixed.
-function test_page_size_change_with_wal()
-{
-  print("\n*** Test that a VACUUM changes page_size with WAL mode");
-  Services.obs.notifyObservers(null, "test-options", "wal");
-
-  // Set a small page size.
-  let conn = getDatabase(new_db_file("testVacuum2"));
-  conn.executeSimpleSQL("PRAGMA page_size = 1024");
-  let stmt = conn.createStatement("PRAGMA page_size");
-  try {
-    while (stmt.executeStep()) {
-      do_check_eq(stmt.row.page_size, 1024);
-    }
-  }
-  finally {
-    stmt.finalize();
-  }
-
-  // Use WAL journal mode.
-  conn.executeSimpleSQL("PRAGMA journal_mode = WAL");
-  stmt = conn.createStatement("PRAGMA journal_mode");
-  try {
-    while (stmt.executeStep()) {
-      do_check_eq(stmt.row.journal_mode, "wal");
-    }
-  }
-  finally {
-    stmt.finalize();
-  }
-
-  // Wait for VACUUM end.
-  let vacuumObserver = {
-    observe: function VO_observe(aSubject, aTopic, aData) {
-      Services.obs.removeObserver(this, aTopic);
-      print("Check page size has been updated.");
-      let stmt = conn.createStatement("PRAGMA page_size");
-      try {
-        while (stmt.executeStep()) {
-          do_check_eq(stmt.row.page_size, Ci.mozIStorageConnection.DEFAULT_PAGE_SIZE);
-        }
-      }
-      finally {
-        stmt.finalize();
-      }
-
-      print("Check journal mode has been restored.");
-      stmt = conn.createStatement("PRAGMA journal_mode");
-      try {
-        while (stmt.executeStep()) {
-          do_check_eq(stmt.row.journal_mode, "wal");
-        }
-      }
-      finally {
-        stmt.finalize();
-      }
-
-      run_next_test();
-    },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
-  }
-  Services.obs.addObserver(vacuumObserver, "test-end-vacuum", false);
-
-  synthesize_idle_daily();
-},
-*/
-
-function test_memory_database_crash()
-{
-  print("\n*** Test that we don't crash trying to vacuum a memory database");
-  Services.obs.notifyObservers(null, "test-options", "memory");
-
-  // Wait for VACUUM begin.
-  let vacuumObserver = {
-    gotNotification: false,
-    observe: function VO_observe(aSubject, aTopic, aData) {
-      this.gotNotification = true;
-    },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
-  }
-  Services.obs.addObserver(vacuumObserver, "test-begin-vacuum", false);
-
-  // Check after a couple seconds that no VACUUM has been run.
-  do_timeout(2000, function () {
-    print("Check VACUUM did not run.");
-    do_check_false(vacuumObserver.gotNotification);
-    Services.obs.removeObserver(vacuumObserver, "test-begin-vacuum");
-    run_next_test();
-  });
-
-  synthesize_idle_daily();
-},
-
-/* Changing page size on WAL is not supported till Bug 634374 is properly fixed.
-function test_wal_restore_fail()
-{
-  print("\n*** Test that a failing WAL restoration notifies failure");
-  Services.obs.notifyObservers(null, "test-options", "wal-fail");
-
-  // Wait for VACUUM end.
-  let vacuumObserver = {
-    observe: function VO_observe(aSubject, aTopic, aData) {
-      Services.obs.removeObserver(vacuumObserver, "test-end-vacuum");
-      print("Check WAL restoration failed.");
-      do_check_false(aData);
-      run_next_test();
-    },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
-  }
-  Services.obs.addObserver(vacuumObserver, "test-end-vacuum", false);
-
-  synthesize_idle_daily();
-},
-*/
-];
--- a/storage/test/unit/vacuumParticipant.js
+++ b/storage/test/unit/vacuumParticipant.js
@@ -71,51 +71,55 @@ vacuumParticipant.prototype =
   observe: function TVP_observe(aSubject, aTopic, aData)
   {
     if (aData == "opt-out") {
       this._grant = false;
     }
     else if (aData == "wal") {
       try {
         this._dbConn.close();
+      } catch (e) {
+        // Do nothing.
       }
-      catch(e) {}
       this._dbConn = getDatabase(new_db_file("testVacuum2"));
     }
     else if (aData == "wal-fail") {
       try {
         this._dbConn.close();
+      } catch (e) {
+        // Do nothing.
       }
-      catch(e) {}
       this._dbConn = getDatabase(new_db_file("testVacuum3"));
       // Use WAL journal mode.
       this._dbConn.executeSimpleSQL("PRAGMA journal_mode = WAL");
       // Create a not finalized statement.
       this._stmt = this._dbConn.createStatement("SELECT :test");
       this._stmt.params.test = 1;
       this._stmt.executeStep();
     }
     else if (aData == "memory") {
       try {
         this._dbConn.asyncClose();
+      } catch (e) {
+        // Do nothing.
       }
-      catch(e) {}
       this._dbConn = Cc["@mozilla.org/storage/service;1"].
                      getService(Ci.mozIStorageService).
                      openSpecialDatabase("memory");
     }
     else if (aData == "dispose") {
       Services.obs.removeObserver(this, "test-options");
       try {
         this._dbConn.asyncClose();
+      } catch (e) {
+        // Do nothing.
       }
-      catch(e) {}
     }
   },
 
   QueryInterface: XPCOMUtils.generateQI([
-    Ci.mozIStorageVacuumParticipant
-  , Ci.nsIObserver
+    Ci.mozIStorageVacuumParticipant,
+    Ci.nsIObserver,
   ])
 };
 
 var gComponentsArray = [vacuumParticipant];
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory(gComponentsArray);
--- a/toolkit/.eslintrc
+++ b/toolkit/.eslintrc
@@ -150,17 +150,17 @@
 
     // No expressions where a statement is expected
     // "no-unused-expressions": 2,
 
     // No declaring variables that are never used
     // "no-unused-vars": [2, {"vars": "all", "args": "none"}],
 
     // No using variables before defined
-    // "no-use-before-define": 2,
+    // "no-use-before-define": [2, "nofunc"],
 
     // No using with
     // "no-with": 2,
 
     // Always require semicolon at end of statement
     // "semi": [2, "always"],
 
     // Require space after keywords
--- a/toolkit/components/aboutperformance/content/aboutPerformance.js
+++ b/toolkit/components/aboutperformance/content/aboutPerformance.js
@@ -556,17 +556,17 @@ var View = {
         throw new TypeError();
       }
       let cachedElements = this._grabOrCreateElements(delta, nature);
       toAdd.push(cachedElements);
       cachedElements.eltTitle.textContent = delta.readableName;
       cachedElements.eltName.textContent = `Full name: ${delta.fullName}.`;
       cachedElements.eltLoaded.textContent = `Measure start: ${Math.round(delta.age/1000)} seconds ago.`
 
-      let processes = [for (proc of delta.diff.processes) `${proc.processId} (${proc.isChildProcess?"child":"parent"})`];
+      let processes = delta.diff.processes.map(proc => `${proc.processId} (${proc.isChildProcess?"child":"parent"})`);
       cachedElements.eltProcess.textContent = `Processes: ${processes.join(", ")}`;
       let jankSuffix = "";
       let cpowSuffix = "";
       if (watcherAlerts) {
         let deltaAlerts = watcherAlerts.get(delta.diff.addonId);
         if (deltaAlerts) {
           jankSuffix = ` (${deltaAlerts.alerts.longestDuration || 0} alerts)`;
           cpowSuffix = ` (${deltaAlerts.alerts.totalCPOWTime || 0} alerts)`;
--- a/toolkit/components/aboutperformance/tests/browser/browser_aboutperformance.js
+++ b/toolkit/components/aboutperformance/tests/browser/browser_aboutperformance.js
@@ -159,18 +159,18 @@ function frameScript() {
       try {
         let eltWeb = content.document.getElementById("webpages");
         let eltAddons = content.document.getElementById("addons");
         if (!eltWeb || !eltAddons) {
           dump(`aboutperformance-test:hasItems: the page is not ready yet webpages:${eltWeb}, addons:${eltAddons}\n`);
           return;
         }
 
-        let addonTitles = [for (eltContent of eltAddons.querySelectorAll("span.title")) eltContent.textContent];
-        let webTitles = [for (eltContent of eltWeb.querySelectorAll("span.title")) eltContent.textContent];
+        let addonTitles = Array.from(eltAddons.querySelectorAll("span.title"), elt => elt.textContent);
+        let webTitles = Array.from(eltWeb.querySelectorAll("span.title"), elt => elt.textContent);
 
         hasTitleInAddons = addonTitles.includes(title);
         hasTitleInWebpages = webTitles.includes(title);
       } catch (ex) {
         Cu.reportError("Error in content: " + ex);
         Cu.reportError(ex.stack);
       } finally {
         sendAsyncMessage("aboutperformance-test:hasItems", {hasTitleInAddons, hasTitleInWebpages, mode});
--- a/toolkit/components/apppicker/content/appPicker.js
+++ b/toolkit/components/apppicker/content/appPicker.js
@@ -1,13 +1,13 @@
-# -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-#
-# 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/.
+/* 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/. */
+
+Components.utils.import("resource://gre/modules/AppConstants.jsm");
 
 function AppPicker() {};
 
 var g_dialog = null;
 
 AppPicker.prototype = 
 {
     // Class members
@@ -112,30 +112,29 @@ AppPicker.prototype =
       var urlSpec = fph.getURLSpecFromFile(file);
       return "moz-icon://" + urlSpec + "?size=32";
     },
 
     /** 
     * Retrieve the pretty description from the file
     */ 
     getFileDisplayName: function getFileDisplayName(file) {
-#ifdef XP_WIN
-      if (file instanceof Components.interfaces.nsILocalFileWin) {
-        try {
-          return file.getVersionInfoField("FileDescription");
-        } catch (e) {}
+      if (AppConstants.platform == "win") {
+        if (file instanceof Components.interfaces.nsILocalFileWin) {
+          try {
+            return file.getVersionInfoField("FileDescription");
+          } catch (e) {}
+        }
+      } else if (AppConstants.platform == "macosx") {
+        if (file instanceof Components.interfaces.nsILocalFileMac) {
+          try {
+            return file.bundleDisplayName;
+          } catch (e) {}
+        }
       }
-#endif
-#ifdef XP_MACOSX
-      if (file instanceof Components.interfaces.nsILocalFileMac) {
-        try {
-          return file.bundleDisplayName;
-        } catch (e) {}
-      }
-#endif
       return file.leafName;
     },
 
     /**
     * Double click accepts an app
     */
     appDoubleClick: function appDoubleClick() {
       var list = document.getElementById("app-picker-listbox");
@@ -181,25 +180,23 @@ AppPicker.prototype =
                createInstance(nsIFilePicker);
 
       fp.init(window, this._incomingParams.title, nsIFilePicker.modeOpen);
       fp.appendFilters(nsIFilePicker.filterApps);
       
       var fileLoc = Components.classes["@mozilla.org/file/directory_service;1"]
                             .getService(Components.interfaces.nsIProperties);
       var startLocation;
-#ifdef XP_WIN
-    startLocation = "ProgF"; // Program Files
-#else
-#ifdef XP_MACOSX
-    startLocation = "LocApp"; // Local Applications
-#else
-    startLocation = "Home";
-#endif
-#endif
+      if (AppConstants.platform == "win") {
+        startLocation = "ProgF"; // Program Files
+      } else if (AppConstants.platform == "macosx") {
+        startLocation = "LocApp"; // Local Applications
+      } else {
+        startLocation = "Home";
+      }
       fp.displayDirectory = 
         fileLoc.get(startLocation, Components.interfaces.nsILocalFile);
       
       if (fp.show() == nsIFilePicker.returnOK && fp.file) {
           var localHandlerApp = 
             Components.classes["@mozilla.org/uriloader/local-handler-app;1"].
             createInstance(Components.interfaces.nsILocalHandlerApp);
           localHandlerApp.executable = fp.file;
--- a/toolkit/components/apppicker/jar.mn
+++ b/toolkit/components/apppicker/jar.mn
@@ -1,8 +1,8 @@
 # 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/.
 
 toolkit.jar:
   content/global/appPicker.xul                     (content/appPicker.xul)
-* content/global/appPicker.js                      (content/appPicker.js)
+  content/global/appPicker.js                      (content/appPicker.js)
 
copy from devtools/.eslintrc
copy to toolkit/components/extensions/.eslintrc
--- a/devtools/.eslintrc
+++ b/toolkit/components/extensions/.eslintrc
@@ -1,413 +1,499 @@
 {
+  "extends": "../../.eslintrc",
+
   "globals": {
     "Cc": true,
     "Ci": true,
     "Components": true,
-    "console": true,
     "Cr": true,
     "Cu": true,
-    "devtools": true,
     "dump": true,
-    "EventEmitter": true,
-    "exports": true,
-    "loader": true,
-    "module": true,
-    "require": true,
+    "TextDecoder": false,
+    "TextEncoder": false,
+    // Specific to WebExtensions:
+    "extensions": true,
+    "global": true,
+    "Extension": true,
+    "ExtensionManagement": true,
+    "ExtensionPage": true,
+    "GlobalManager": true,
+    "runSafe": true,
+    "runSafeSync": true,
+    "runSafeSyncWithoutClone": true,
     "Services": true,
-    "Task": true,
-    "XPCNativeWrapper": true,
+    "TabManager": true,
     "XPCOMUtils": true,
   },
+
   "rules": {
-    // These are the rules that have been configured so far to match the
-    // devtools coding style.
-
     // Rules from the mozilla plugin
     "mozilla/balanced-listeners": 2,
     "mozilla/components-imports": 1,
     "mozilla/import-headjs-globals": 1,
     "mozilla/mark-test-function-used": 1,
     "mozilla/no-aArgs": 1,
     "mozilla/no-cpows-in-tests": 1,
     "mozilla/var-only-at-top-level": 1,
 
-    // Disallow using variables outside the blocks they are defined (especially
-    // since only let and const are used, see "no-var").
-    "block-scoped-var": 2,
+    // Braces only needed for multi-line arrow function blocks
+    // "arrow-body-style": [2, "as-needed"],
+
+    // Require spacing around =>
+    "arrow-spacing": 2,
+
+    // Always require spacing around a single line block
+    "block-spacing": 1,
+
     // Enforce one true brace style (opening brace on the same line) and avoid
     // start and end braces on the same line.
-    "brace-style": [2, "1tbs", {"allowSingleLine": false}],
-    // Require camel case names
-    "camelcase": 2,
-    // Allow trailing commas for easy list extension.  Having them does not
-    // impair readability, but also not required either.
-    "comma-dangle": 0,
-    // Enforce spacing before and after comma
+    "brace-style": [2, "1tbs", { "allowSingleLine": true }],
+
+    // No space before always a space after a comma
     "comma-spacing": [2, {"before": false, "after": true}],
-    // Enforce one true comma style.
-    "comma-style": [2, "last"],
-    // Warn about cyclomatic complexity in functions.
-    "complexity": 1,
-    // Require return statements to either always or never specify values.
-    "consistent-return": 2,
-    // Don't warn for inconsistent naming when capturing this (not so important
-    // with auto-binding fat arrow functions).
-    "consistent-this": 0,
-    // Enforce curly brace conventions for all control statements.
-    "curly": 2,
-    // Don't require a default case in switch statements. Avoid being forced to
-    // add a bogus default when you know all possible cases are handled.
-    "default-case": 0,
-    // Enforce dots on the next line with property name.
-    "dot-location": [1, "property"],
-    // Encourage the use of dot notation whenever possible.
-    "dot-notation": 2,
-    // Enforce newline at the end of file, with no multiple empty lines.
+
+    // Commas at the end of the line not the start
+    "comma-style": 2,
+
+    // Don't require spaces around computed properties
+    "computed-property-spacing": [1, "never"],
+
+    // Functions are not required to consistently return something or nothing
+    "consistent-return": 0,
+
+    // Require braces around blocks that start a new line
+    "curly": [2, "multi-line"],
+
+    // Always require a trailing EOL
     "eol-last": 2,
-    // Allow using == instead of ===, in the interest of landing something since
-    // the devtools codebase is split on convention here.
-    "eqeqeq": 0,
-    // Don't require function expressions to have a name.
-    // This makes the code more verbose and hard to read. Our engine already
-    // does a fantastic job assigning a name to the function, which includes
-    // the enclosing function name, and worst case you have a line number that
-    // you can just look up.
-    "func-names": 0,
-    // Allow use of function declarations and expressions.
-    "func-style": 0,
-    // Deprecated, will be removed in 1.0.
-    "generator-star": 0,
-    // Enforce the spacing around the * in generator functions.
-    "generator-star-spacing": [1, "after"],
-    // Deprecated, will be removed in 1.0.
-    "global-strict": 0,
-    // Only useful in a node environment.
-    "handle-callback-err": 0,
-    // Tab width.
-    "indent": [2, 2, {"SwitchCase": 1}],
-    // Enforces spacing between keys and values in object literal properties.
-    "key-spacing": [1, {"beforeColon": false, "afterColon": true}],
-    // Allow mixed 'LF' and 'CRLF' as linebreaks.
-    "linebreak-style": 0,
-    // Don't enforce the maximum depth that blocks can be nested. The complexity
-    // rule is a better rule to check this.
-    "max-depth": 0,
-    // Maximum length of a line.
-    "max-len": [1, 80],
-    // Maximum depth callbacks can be nested.
-    "max-nested-callbacks": [2, 3],
-    // Don't limit the number of parameters that can be used in a function.
-    "max-params": 0,
-    // Don't limit the maximum number of statement allowed in a function. We
-    // already have the complexity rule that's a better measurement.
-    "max-statements": 0,
-    // Require a capital letter for constructors, only check if all new
-    // operators are followed by a capital letter. Don't warn when capitalized
-    // functions are used without the new operator.
-    "new-cap": [2, {"capIsNew": false}],
-    // Disallow the omission of parentheses when invoking a constructor with no
-    // arguments.
+
+    // Require function* name()
+    "generator-star-spacing": [2, {"before": false, "after": true}],
+
+    // Two space indent
+    "indent": [2, 2, { "SwitchCase": 1 }],
+
+    // Space after colon not before in property declarations
+    "key-spacing": [2, { "beforeColon": false, "afterColon": true, "mode": "minimum" }],
+
+    // Unix linebreaks
+    "linebreak-style": [2, "unix"],
+
+    // Always require parenthesis for new calls
     "new-parens": 2,
-    // Disallow use of the Array constructor.
+
+    // Use [] instead of Array()
     "no-array-constructor": 2,
-    // Allow use of bitwise operators.
-    "no-bitwise": 0,
-    // Disallow use of arguments.caller or arguments.callee.
-    "no-caller": 2,
-    // Disallow the catch clause parameter name being the same as a variable in
-    // the outer scope, to avoid confusion.
-    "no-catch-shadow": 1,
-    // Deprecated, will be removed in 1.0.
-    "no-comma-dangle": 0,
-    // Disallow assignment in conditional expressions.
-    "no-cond-assign": 2,
-    // Allow using the console API.
-    "no-console": 0,
-    // Allow using constant expressions in conditions like while (true)
-    "no-constant-condition": 0,
-    // Allow use of the continue statement.
-    "no-continue": 0,
-    // Disallow control characters in regular expressions.
-    "no-control-regex": 2,
-    // Disallow use of debugger.
-    "no-debugger": 2,
-    // Disallow deletion of variables (deleting properties is fine).
-    "no-delete-var": 2,
-    // Allow division operators explicitly at beginning of regular expression.
-    "no-div-regex": 0,
-    // Disallow duplicate arguments in functions.
+
+    // No duplicate arguments in function declarations
     "no-dupe-args": 2,
-    // Disallow duplicate keys when creating object literals.
+
+    // No duplicate keys in object declarations
     "no-dupe-keys": 2,
-    // Disallow a duplicate case label.
+
+    // No duplicate cases in switch statements
     "no-duplicate-case": 2,
-    // Disallow else after a return in an if. The else around the second return
-    // here is useless:
-    // if (something) { return false; } else { return true; }
-    "no-else-return": 2,
+
+    // No labels
+    // "no-labels": 2,
+
+    // If an if block ends with a return no need for an else block
+    // "no-else-return": 2,
+
     // Disallow empty statements. This will report an error for:
     // try { something(); } catch (e) {}
     // but will not report it for:
     // try { something(); } catch (e) { /* Silencing the error because ...*/ }
     // which is a valid use case.
     "no-empty": 2,
-    // Disallow the use of empty character classes in regular expressions.
+
+    // No empty character classes in regex
     "no-empty-character-class": 2,
-    // Disallow use of labels for anything other then loops and switches.
-    "no-empty-label": 2,
-    // Disallow use of eval(). We have other APIs to evaluate code in content.
-    "no-eval": 2,
-    // Disallow assigning to the exception in a catch block.
+
+    // Disallow empty destructuring
+    "no-empty-pattern": 2,
+
+    // No assiging to exception variable
     "no-ex-assign": 2,
-    // Disallow adding to native types
-    "no-extend-native": 2,
-    // Disallow unnecessary function binding.
-    "no-extra-bind": 2,
-    // Disallow double-negation boolean casts in a boolean context.
-    "no-extra-boolean-cast": 2,
-    // Allow unnecessary parentheses, as they may make the code more readable.
-    "no-extra-parens": 0,
-    // Disallow unnecessary semicolons.
+
+    // No using !! where casting to boolean is already happening
+    "no-extra-boolean-cast": 1,
+
+    // No double semicolon
     "no-extra-semi": 2,
-    // Deprecated, will be removed in 1.0.
-    "no-extra-strict": 0,
-    // Disallow fallthrough of case statements, except if there is a comment.
-    "no-fallthrough": 2,
-    // Allow the use of leading or trailing decimal points in numeric literals.
-    "no-floating-decimal": 0,
-    // Disallow comments inline after code.
-    "no-inline-comments": 1,
-    // Disallow if as the only statement in an else block.
-    "no-lonely-if": 2,
-    // Allow mixing regular variable and require declarations (not a node env).
-    "no-mixed-requires": 0,
-    // Disallow mixed spaces and tabs for indentation.
-    "no-mixed-spaces-and-tabs": 2,
+
+    // No overwriting defined functions
+    "no-func-assign": 2,
+
+    // No invalid regular expresions
+    "no-invalid-regexp": 2,
+
+    // No odd whitespace characters
+    "no-irregular-whitespace": 2,
+
+    // No single if block inside an else block
+    "no-lonely-if": 1,
+
+    // No mixing spaces and tabs in indent
+    "no-mixed-spaces-and-tabs": [2, "smart-tabs"],
+
     // Disallow use of multiple spaces (sometimes used to align const values,
     // array or object items, etc.). It's hard to maintain and doesn't add that
     // much benefit.
     "no-multi-spaces": 1,
+
+    // No reassigning native JS objects
+    "no-native-reassign": 2,
+
+    // No (!foo in bar)
+    "no-negated-in-lhs": 2,
+
+    // Nested ternary statements are confusing
+    "no-nested-ternary": 2,
+
+    // Use {} instead of new Object()
+    "no-new-object": 2,
+
+    // No Math() or JSON()
+    "no-obj-calls": 2,
+
+    // No octal literals
+    "no-octal": 2,
+
+    // No redeclaring variables
+    "no-redeclare": 2,
+
+    // No unnecessary comparisons
+    "no-self-compare": 2,
+
+    // No declaring variables from an outer scope
+    "no-shadow": 1,
+
+    // No declaring variables that hide things like arguments
+    "no-shadow-restricted-names": 2,
+
+    // No spaces between function name and parentheses
+    "no-spaced-func": 1,
+
+    // No trailing whitespace
+    "no-trailing-spaces": 2,
+
+    // No using undeclared variables
+    "no-undef": 2,
+
+    // Error on newline where a semicolon is needed
+    "no-unexpected-multiline": 2,
+
+    // No unreachable statements
+    "no-unreachable": 2,
+
+    // No expressions where a statement is expected
+    "no-unused-expressions": 2,
+
+    // No declaring variables that are never used
+    "no-unused-vars": [2, { "args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$" }],
+
+    // No using variables before defined
+    "no-use-before-define": 2,
+
+    // No using with
+    "no-with": 2,
+
+    // Always require semicolon at end of statement
+    "semi": [2, "always"],
+
+    // Require space after keywords
+    "space-after-keywords": 2,
+
+    // Require space before blocks
+    "space-before-blocks": 2,
+
+    // Never use spaces before function parentheses
+    "space-before-function-paren": [2, { "anonymous": "never", "named": "never" }],
+
+    // Require spaces before finally, catch, etc.
+    "space-before-keywords": [2, "always"],
+
+    // No space padding in parentheses
+    "space-in-parens": [2, "never"],
+
+    // Require spaces around operators, except for a|0.
+    "space-infix-ops": [2, {"int32Hint": true}],
+
+
+    // Require spaces after return, throw and case
+    "space-return-throw-case": 2,
+
+    // ++ and -- should not need spacing
+    "space-unary-ops": [1, { "nonwords": false }],
+
+    // No comparisons to NaN
+    "use-isnan": 2,
+
+    // Only check typeof against valid results
+    "valid-typeof": 2,
+
+    // Disallow using variables outside the blocks they are defined (especially
+    // since only let and const are used, see "no-var").
+    "block-scoped-var": 2,
+
+    // Allow trailing commas for easy list extension.  Having them does not
+    // impair readability, but also not required either.
+    "comma-dangle": [1, "always-multiline"],
+
+    // Warn about cyclomatic complexity in functions.
+    "complexity": 1,
+
+    // Don't warn for inconsistent naming when capturing this (not so important
+    // with auto-binding fat arrow functions).
+    // "consistent-this": [2, "self"],
+
+    // Don't require a default case in switch statements. Avoid being forced to
+    // add a bogus default when you know all possible cases are handled.
+    "default-case": 0,
+
+    // Enforce dots on the next line with property name.
+    "dot-location": [1, "property"],
+
+    // Encourage the use of dot notation whenever possible.
+    "dot-notation": 2,
+
+    // Allow using == instead of ===, in the interest of landing something since
+    // the devtools codebase is split on convention here.
+    "eqeqeq": 0,
+
+    // Don't require function expressions to have a name.
+    // This makes the code more verbose and hard to read. Our engine already
+    // does a fantastic job assigning a name to the function, which includes
+    // the enclosing function name, and worst case you have a line number that
+    // you can just look up.
+    "func-names": 0,
+
+    // Allow use of function declarations and expressions.
+    "func-style": 0,
+
+    // Don't enforce the maximum depth that blocks can be nested. The complexity
+    // rule is a better rule to check this.
+    "max-depth": 0,
+
+    // Maximum length of a line.
+    // Disabled because we exceed this in too many places.
+    "max-len": [0, 80],
+
+    // Maximum depth callbacks can be nested.
+    "max-nested-callbacks": [2, 4],
+
+    // Don't limit the number of parameters that can be used in a function.
+    "max-params": 0,
+
+    // Don't limit the maximum number of statement allowed in a function. We
+    // already have the complexity rule that's a better measurement.
+    "max-statements": 0,
+
+    // Don't require a capital letter for constructors, only check if all new
+    // operators are followed by a capital letter. Don't warn when capitalized
+    // functions are used without the new operator.
+    "new-cap": [0, {"capIsNew": false}],
+
+    // Allow use of bitwise operators.
+    "no-bitwise": 0,
+
+    // Disallow use of arguments.caller or arguments.callee.
+    "no-caller": 2,
+
+    // Disallow the catch clause parameter name being the same as a variable in
+    // the outer scope, to avoid confusion.
+    "no-catch-shadow": 0,
+
+    // Disallow assignment in conditional expressions.
+    "no-cond-assign": 2,
+
+    // Disallow using the console API.
+    "no-console": 2,
+
+    // Allow using constant expressions in conditions like while (true)
+    "no-constant-condition": 0,
+
+    // Allow use of the continue statement.
+    "no-continue": 0,
+
+    // Disallow control characters in regular expressions.
+    "no-control-regex": 2,
+
+    // Disallow use of debugger.
+    "no-debugger": 2,
+
+    // Disallow deletion of variables (deleting properties is fine).
+    "no-delete-var": 2,
+
+    // Allow division operators explicitly at beginning of regular expression.
+    "no-div-regex": 0,
+
+    // Disallow use of labels for anything other then loops and switches.
+    "no-empty-label": 2,
+
+    // Disallow use of eval(). We have other APIs to evaluate code in content.
+    "no-eval": 2,
+
+    // Disallow adding to native types
+    "no-extend-native": 2,
+
+    // Disallow unnecessary function binding.
+    "no-extra-bind": 2,
+
+    // Allow unnecessary parentheses, as they may make the code more readable.
+    "no-extra-parens": 0,
+
+    // Disallow fallthrough of case statements, except if there is a comment.
+    "no-fallthrough": 2,
+
+    // Allow the use of leading or trailing decimal points in numeric literals.
+    "no-floating-decimal": 0,
+
+    // Allow comments inline after code.
+    "no-inline-comments": 0,
+
     // Disallow use of multiline strings (use template strings instead).
     "no-multi-str": 1,
+
     // Disallow multiple empty lines.
-    "no-multiple-empty-lines": [1, {"max": 1}],
-    // Disallow reassignments of native objects.
-    "no-native-reassign": 2,
-    // Disallow nested ternary expressions, they make the code hard to read.
-    "no-nested-ternary": 2,
-    // Allow use of new operator with the require function.
-    "no-new-require": 0,
-    // Disallow use of octal literals.
-    "no-octal": 1,
+    "no-multiple-empty-lines": [1, {"max": 2}],
+
     // Allow reassignment of function parameters.
     "no-param-reassign": 0,
+
     // Allow string concatenation with __dirname and __filename (not a node env).
     "no-path-concat": 0,
+
     // Allow use of unary operators, ++ and --.
     "no-plusplus": 0,
+
     // Allow using process.env (not a node environment).
     "no-process-env": 0,
+
     // Allow using process.exit (not a node environment).
     "no-process-exit": 0,
+
     // Disallow usage of __proto__ property.
     "no-proto": 2,
-    // Disallow declaring the same variable more than once (we use let anyway).
-    "no-redeclare": 2,
+
     // Disallow multiple spaces in a regular expression literal.
     "no-regex-spaces": 2,
+
     // Allow reserved words being used as object literal keys.
     "no-reserved-keys": 0,
+
     // Don't restrict usage of specified node modules (not a node environment).
     "no-restricted-modules": 0,
+
     // Disallow use of assignment in return statement. It is preferable for a
     // single line of code to have only one easily predictable effect.
     "no-return-assign": 2,
-    // Allow use of javascript: urls.
-    "no-script-url": 0,
-    // Disallow comparisons where both sides are exactly the same.
-    "no-self-compare": 2,
-    // Disallow use of comma operator.
-    "no-sequences": 2,
-    // Warn about declaration of variables already declared in the outer scope.
-    // This isn't an error because it sometimes is useful to use the same name
-    // in a small helper function rather than having to come up with another
-    // random name.
-    // Still, making this a warning can help people avoid being confused.
-    "no-shadow": 1,
+
+    // Don't warn about declaration of variables already declared in the outer scope.
+    "no-shadow": 0,
+
     // Disallow shadowing of names such as arguments.
     "no-shadow-restricted-names": 2,
-    // Deprecated, will be removed in 1.0.
-    "no-space-before-semi": 0,
-    // Disallow space between function identifier and application.
-    "no-spaced-func": 1,
-    // Disallow sparse arrays, eg. let arr = [,,2].
-    // Array destructuring is fine though:
-    // for (let [, breakpointPromise] of aPromises)
-    "no-sparse-arrays": 2,
+
     // Allow use of synchronous methods (not a node environment).
     "no-sync": 0,
+
     // Allow the use of ternary operators.
     "no-ternary": 0,
+
     // Disallow throwing literals (eg. throw "error" instead of
     // throw new Error("error")).
     "no-throw-literal": 2,
-    // Disallow trailing whitespace at the end of lines.
-    "no-trailing-spaces": 2,
-    // Disallow use of undeclared variables unless mentioned in a /*global */
+
+    // Disallow use of undeclared variables unless mentioned in a /* global */
     // block. Note that globals from head.js are automatically imported in tests
     // by the import-headjs-globals rule form the mozilla eslint plugin.
     "no-undef": 2,
+
     // Allow dangling underscores in identifiers (for privates).
     "no-underscore-dangle": 0,
+
     // Allow use of undefined variable.
     "no-undefined": 0,
+
     // Disallow the use of Boolean literals in conditional expressions.
     "no-unneeded-ternary": 2,
-    // Disallow unreachable statements after a return, throw, continue, or break
-    // statement.
-    "no-unreachable": 2,
-    // Disallow declaration of variables that are not used in the code
-    "no-unused-vars": 2,
-    // Allow using variables before they are defined.
-    "no-use-before-define": 0,
+
     // We use var-only-at-top-level instead of no-var as we allow top level
     // vars.
     "no-var": 0,
+
     // Allow using TODO/FIXME comments.
     "no-warning-comments": 0,
-    // Disallow use of the with statement.
-    "no-with": 2,
+
     // Don't require method and property shorthand syntax for object literals.
     // We use this in the code a lot, but not consistently, and this seems more
     // like something to check at code review time.
     "object-shorthand": 0,
+
     // Allow more than one variable declaration per function.
     "one-var": 0,
+
     // Disallow padding within blocks.
     "padded-blocks": [1, "never"],
+
     // Don't require quotes around object literal property names.
     "quote-props": 0,
+
     // Double quotes should be used.
     "quotes": [1, "double", "avoid-escape"],
+
     // Require use of the second argument for parseInt().
     "radix": 2,
-    // Always require use of semicolons wherever they are valid.
-    "semi": [1, "always"],
+
     // Enforce spacing after semicolons.
-    "semi-spacing": [1, {"before": false, "after": true}],
+    "semi-spacing": [2, {"before": false, "after": true}],
+
     // Don't require to sort variables within the same declaration block.
     // Anyway, one-var is disabled.
     "sort-vars": 0,
-    // Deprecated, will be removed in 1.0.
-    "space-after-function-name": 0,
+
     // Require a space after keywords.
     "space-after-keywords": [1, "always"],
-    // Deprecated, will be removed in 1.0.
-    "space-after-function-name": 0,
-    // Require a space before the start brace of a block.
-    "space-before-blocks": [1, "always"],
-    // Deprecated, will be removed in 1.0.
-    "space-before-function-parentheses": 0,
-    // Disallow space before function opening parenthesis.
-    "space-before-function-paren": [1, "never"],
-    // Disable the rule that checks if spaces inside {} and [] are there or not.
-    // Our code is split on conventions, and it'd be nice to have 2 rules
-    // instead, one for [] and one for {}. So, disabling until we write them.
-    "space-in-brackets": 0,
-    // Disallow spaces inside parentheses.
-    "space-in-parens": [1, "never"],
-    // Require spaces around operators, except for a|0.
-    "space-infix-ops": [1, {"int32Hint": true}],
-    // Require a space after return, throw, and case.
-    "space-return-throw-case": 1,
-    // Require spaces before/after unary operators (words on by default,
-    // nonwords off by default).
-    "space-unary-ops": [1, { "words": true, "nonwords": false }],
-    // Deprecated, will be removed in 1.0.
-    "space-unary-word-ops": 0,
+
     // Require a space immediately following the // in a line comment.
-    "spaced-comment": [1, "always"],
+    "spaced-comment": [2, "always"],
+
     // Require "use strict" to be defined globally in the script.
     "strict": [2, "global"],
-    // Disallow comparisons with the value NaN.
-    "use-isnan": 2,
+
     // Warn about invalid JSDoc comments.
-    // Disabled for now because of https://github.com/eslint/eslint/issues/2270
-    // The rule fails on some jsdoc comments like in:
-    // devtools/client/webconsole/console-output.js
     "valid-jsdoc": 0,
-    // Ensure that the results of typeof are compared against a valid string.
-    "valid-typeof": 2,
+
     // Allow vars to be declared anywhere in the scope.
     "vars-on-top": 0,
+
     // Don't require immediate function invocation to be wrapped in parentheses.
     "wrap-iife": 0,
+
     // Don't require regex literals to be wrapped in parentheses (which
     // supposedly prevent them from being mistaken for division operators).
     "wrap-regex": 0,
+
     // Disallow Yoda conditions (where literal value comes first).
     "yoda": 2,
 
-    // And these are the rules that haven't been discussed so far, and that are
-    // disabled for now until we introduce them, one at a time.
+    // disallow use of eval()-like methods
+    "no-implied-eval": 2,
+
+    // Disallow function or variable declarations in nested blocks
+    "no-inner-declarations": 2,
+
+    // Disallow usage of __iterator__ property
+    "no-iterator": 2,
 
-    // Require for-in loops to have an if statement.
-    "guard-for-in": 0,
-    // allow/disallow an empty newline after var statement
-    "newline-after-var": 0,
-    // disallow the use of alert, confirm, and prompt
-    "no-alert": 0,
-    // disallow comparisons to null without a type-checking operator
-    "no-eq-null": 0,
-    // disallow overwriting functions written as function declarations
-    "no-func-assign": 0,
-    // disallow use of eval()-like methods
-    "no-implied-eval": 0,
-    // disallow function or variable declarations in nested blocks
-    "no-inner-declarations": 0,
-    // disallow invalid regular expression strings in the RegExp constructor
-    "no-invalid-regexp": 0,
-    // disallow irregular whitespace outside of strings and comments
-    "no-irregular-whitespace": 0,
-    // disallow usage of __iterator__ property
-    "no-iterator": 0,
-    // disallow labels that share a name with a variable
-    "no-label-var": 0,
-    // disallow use of labeled statements
-    "no-labels": 0,
-    // disallow unnecessary nested blocks
-    "no-lone-blocks": 0,
-    // disallow creation of functions within loops
-    "no-loop-func": 0,
-    // disallow negation of the left operand of an in expression
-    "no-negated-in-lhs": 0,
-    // disallow use of new operator when not part of the assignment or
-    // comparison
-    "no-new": 0,
-    // disallow use of new operator for Function object
-    "no-new-func": 0,
-    // disallow use of the Object constructor
-    "no-new-object": 0,
-    // disallows creating new instances of String,Number, and Boolean
-    "no-new-wrappers": 0,
-    // disallow the use of object properties of the global object (Math and
-    // JSON) as functions
-    "no-obj-calls": 0,
-    // disallow use of octal escape sequences in string literals, such as
-    // var foo = "Copyright \251";
-    "no-octal-escape": 0,
-    // disallow use of undefined when initializing variables
-    "no-undef-init": 0,
-    // disallow usage of expressions in statement position
-    "no-unused-expressions": 0,
-    // disallow use of void operator
-    "no-void": 0,
-    // disallow wrapping of non-IIFE statements in parens
-    "no-wrap-func": 0,
-    // require assignment operator shorthand where possible or prohibit it
-    // entirely
-    "operator-assignment": 0,
-    // enforce operators to be placed before or after line breaks
-    "operator-linebreak": 0,
+    // Disallow labels that share a name with a variable
+    "no-label-var": 2,
+
+    // Disallow negation of the left operand of an in expression
+    "no-negated-in-lhs": 2,
+
+    // Disallow creating new instances of String, Number, and Boolean
+    "no-new-wrappers": 2,
   }
 }
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -1,33 +1,36 @@
 /* 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";
 
 this.EXPORTED_SYMBOLS = ["Extension", "ExtensionData"];
 
+/* globals Extension ExtensionData */
+
 /*
  * This file is the main entry point for extensions. When an extension
  * loads, its bootstrap.js file creates a Extension instance
  * and calls .startup() on it. It calls .shutdown() when the extension
  * unloads. Extension manages any extension-specific state in
  * the chrome process.
  */
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cu = Components.utils;
 const Cr = Components.results;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://devtools/shared/event-emitter.js");
 
+XPCOMUtils.defineLazyModuleGetter(this, "EventEmitter",
+                                  "resource://devtools/shared/event-emitter.js");
 XPCOMUtils.defineLazyModuleGetter(this, "Locale",
                                   "resource://gre/modules/Locale.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Log",
                                   "resource://gre/modules/Log.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MatchPattern",
                                   "resource://gre/modules/MatchPattern.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
@@ -62,23 +65,24 @@ ExtensionManagement.registerScript("chro
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
   LocaleData,
   MessageBroker,
   Messenger,
   injectAPI,
   extend,
   flushJarCache,
-  instanceOf,
 } = ExtensionUtils;
 
 const LOGGER_ID_BASE = "addons.webextension.";
 
 var scriptScope = this;
 
+var ExtensionPage, GlobalManager;
+
 // This object loads the ext-*.js scripts that define the extension API.
 var Management = {
   initialized: false,
   scopes: [],
   apis: [],
   emitter: new EventEmitter(),
 
   // Loads all the ext-*.js scripts currently registered.
@@ -160,17 +164,17 @@ var Management = {
   // Ask to run all the callbacks that are registered for a given hook.
   emit(hook, ...args) {
     this.lazyInit();
     this.emitter.emit(hook, ...args);
   },
 
   off(hook, callback) {
     this.emitter.off(hook, callback);
-  }
+  },
 };
 
 // A MessageBroker that's used to send and receive messages for
 // extension pages (which run in the chrome process).
 var globalBroker = new MessageBroker([Services.mm, Services.ppmm]);
 
 // An extension page is an execution context for any extension content
 // that runs in the chrome process. It's used for background pages
@@ -178,19 +182,18 @@ var globalBroker = new MessageBroker([Se
 // content loaded into browser tabs (type="tab").
 //
 // |params| is an object with the following properties:
 // |type| is one of "background", "popup", or "tab".
 // |contentWindow| is the DOM window the content runs in.
 // |uri| is the URI of the content (optional).
 // |docShell| is the docshell the content runs in (optional).
 // |incognito| is the content running in a private context (default: false).
-function ExtensionPage(extension, params)
-{
-  let {type, contentWindow, uri, docShell} = params;
+ExtensionPage = function(extension, params) {
+  let {type, contentWindow, uri} = params;
   this.extension = extension;
   this.type = type;
   this.contentWindow = contentWindow || null;
   this.uri = uri || extension.baseURI;
   this.incognito = params.incognito || false;
   this.onClose = new Set();
 
   // This is the sender property passed to the Messenger for this
@@ -201,17 +204,17 @@ function ExtensionPage(extension, params
   }
   let delegate = {};
   Management.emit("page-load", this, params, sender, delegate);
 
   let filter = {id: extension.id};
   this.messenger = new Messenger(this, globalBroker, sender, filter, delegate);
 
   this.extension.views.add(this);
-}
+};
 
 ExtensionPage.prototype = {
   get cloneScope() {
     return this.contentWindow;
   },
 
   get principal() {
     return this.contentWindow.document.nodePrincipal;
@@ -259,17 +262,17 @@ ExtensionPage.prototype = {
 
     for (let obj of this.onClose) {
       obj.close();
     }
   },
 };
 
 // Responsible for loading extension APIs into the right globals.
-var GlobalManager = {
+GlobalManager = {
   // Number of extensions currently enabled.
   count: 0,
 
   // Map[docShell -> {extension, context}] where context is an ExtensionPage.
   docShells: new Map(),
 
   // Map[extension ID -> Extension]. Determines which extension is
   // responsible for content under a particular extension ID.
@@ -360,27 +363,26 @@ var GlobalManager = {
 // Represents the data contained in an extension, contained either
 // in a directory or a zip file, which may or may not be installed.
 // This class implements the functionality of the Extension class,
 // primarily related to manifest parsing and localization, which is
 // useful prior to extension installation or initialization.
 //
 // No functionality of this class is guaranteed to work before
 // |readManifest| has been called, and completed.
-this.ExtensionData = function(rootURI)
-{
+this.ExtensionData = function(rootURI) {
   this.rootURI = rootURI;
 
   this.manifest = null;
   this.id = null;
   this.localeData = null;
   this._promiseLocales = null;
 
   this.errors = [];
-}
+};
 
 ExtensionData.prototype = {
   get logger() {
     let id = this.id || "<unknown>";
     return Log.repository.getLogger(LOGGER_ID_BASE + id);
   },
 
   // Report an error about the extension's manifest file.
@@ -401,21 +403,22 @@ ExtensionData.prototype = {
 
       let iter = new OS.File.DirectoryIterator(fullPath);
       let results = [];
 
       try {
         yield iter.forEach(entry => {
           results.push(entry);
         });
-      } catch (e) {}
+      } catch (e) {
+        // Always return a list, even if the directory does not exist (or is
+        // not a directory) for symmetry with the ZipReader behavior.
+      }
       iter.close();
 
-      // Always return a list, even if the directory does not exist (or is
-      // not a directory) for symmetry with the ZipReader behavior.
       return results;
     }
 
     if (!(this.rootURI instanceof Ci.nsIJARURI &&
           this.rootURI.JARFile instanceof Ci.nsIFileURL)) {
       // This currently happens for app:// URLs passed to us by
       // UserCustomizations.jsm
       return [];
@@ -483,17 +486,19 @@ ExtensionData.prototype = {
   // Reads the extension's |manifest.json| file, and stores its
   // parsed contents in |this.manifest|.
   readManifest() {
     return this.readJSON("manifest.json").then(manifest => {
       this.manifest = manifest;
 
       try {
         this.id = this.manifest.applications.gecko.id;
-      } catch (e) {}
+      } catch (e) {
+        // Errors are handled by the type check below.
+      }
 
       if (typeof this.id != "string") {
         this.manifestError("Missing required `applications.gecko.id` property");
       }
 
       return manifest;
     });
   },
@@ -621,18 +626,17 @@ ExtensionData.prototype = {
 };
 
 // All moz-extension URIs use a machine-specific UUID rather than the
 // extension's own ID in the host component. This makes it more
 // difficult for web pages to detect whether a user has a given add-on
 // installed (by trying to load a moz-extension URI referring to a
 // web_accessible_resource from the extension). getExtensionUUID
 // returns the UUID for a given add-on ID.
-function getExtensionUUID(id)
-{
+function getExtensionUUID(id) {
   const PREF_NAME = "extensions.webextensions.uuids";
 
   let pref = Preferences.get(PREF_NAME, "{}");
   let map = {};
   try {
     map = JSON.parse(pref);
   } catch (e) {
     Cu.reportError(`Error parsing ${PREF_NAME}.`);
@@ -648,18 +652,17 @@ function getExtensionUUID(id)
 
   map[id] = uuid;
   Preferences.set(PREF_NAME, JSON.stringify(map));
   return uuid;
 }
 
 // We create one instance of this class per extension. |addonData|
 // comes directly from bootstrap.js when initializing.
-this.Extension = function(addonData)
-{
+this.Extension = function(addonData) {
   ExtensionData.call(this, addonData.resourceURI);
 
   this.uuid = getExtensionUUID(addonData.id);
 
   if (addonData.cleanupFile) {
     Services.obs.addObserver(this, "xpcom-shutdown", false);
     this.cleanupFile = addonData.cleanupFile || null;
     delete addonData.cleanupFile;
@@ -678,17 +681,17 @@ this.Extension = function(addonData)
   this.hasShutdown = false;
   this.onShutdown = new Set();
 
   this.permissions = new Set();
   this.whiteListedHosts = null;
   this.webAccessibleResources = new Set();
 
   this.emitter = new EventEmitter();
-}
+};
 
 /**
  * This code is designed to make it easy to test a WebExtension
  * without creating a bunch of files. Everything is contained in a
  * single JSON blob.
  *
  * Properties:
  *   "background": "<JS code>"
@@ -705,18 +708,17 @@ this.Extension = function(addonData)
  *     to file names)
  *
  * To make things easier, the value of "background" and "files"[] can
  * be a function, which is converted to source that is run.
  *
  * The generated extension is stored in the system temporary directory,
  * and an nsIFile object pointing to it is returned.
  */
-this.Extension.generateXPI = function(id, data)
-{
+this.Extension.generateXPI = function(id, data) {
   let manifest = data.manifest;
   if (!manifest) {
     manifest = {};
   }
 
   let files = data.files;
   if (!files) {
     files = {};
@@ -794,30 +796,29 @@ this.Extension.generateXPI = function(id
 
   return file;
 };
 
 /**
  * Generates a new extension using |Extension.generateXPI|, and initializes a
  * new |Extension| instance which will execute it.
  */
-this.Extension.generate = function(id, data)
-{
+this.Extension.generate = function(id, data) {
   let file = this.generateXPI(id, data);
 
   flushJarCache(file);
   Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path});
 
   let fileURI = Services.io.newFileURI(file);
   let jarURI = Services.io.newURI("jar:" + fileURI.spec + "!/", null, null);
 
   return new Extension({
     id,
     resourceURI: jarURI,
-    cleanupFile: file
+    cleanupFile: file,
   });
 };
 
 Extension.prototype = extend(Object.create(ExtensionData.prototype), {
   on(hook, f) {
     return this.emitter.on(hook, f);
   },
 
@@ -851,17 +852,17 @@ Extension.prototype = extend(Object.crea
   // need.
   serialize() {
     return {
       id: this.id,
       uuid: this.uuid,
       manifest: this.manifest,
       resourceURL: this.addonData.resourceURI.spec,
       baseURL: this.baseURI.spec,
-      content_scripts: this.manifest.content_scripts || [],
+      content_scripts: this.manifest.content_scripts || [],  // eslint-disable-line camelcase
       webAccessibleResources: this.webAccessibleResources,
       whiteListedHosts: this.whiteListedHosts.serialize(),
       localeData: this.localeData.serialize(),
     };
   },
 
   broadcast(msg, data) {
     return new Promise(resolve => {
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -1,16 +1,18 @@
 /* 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";
 
 this.EXPORTED_SYMBOLS = ["ExtensionContent"];
 
+/* globals ExtensionContent */
+
 /*
  * This file handles the content process side of extensions. It mainly
  * takes care of content script injection, content script APIs, and
  * messaging.
  */
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
@@ -33,83 +35,84 @@ var {
   runSafeSyncWithoutClone,
   LocaleData,
   MessageBroker,
   Messenger,
   injectAPI,
   flushJarCache,
 } = ExtensionUtils;
 
-function isWhenBeforeOrSame(when1, when2)
-{
+function isWhenBeforeOrSame(when1, when2) {
   let table = {"document_start": 0,
                "document_end": 1,
                "document_idle": 2};
   return table[when1] <= table[when2];
 }
 
 // This is the fairly simple API that we inject into content
 // scripts.
-var api = context => { return {
-  runtime: {
-    connect: function(extensionId, connectInfo) {
-      if (!connectInfo) {
-        connectInfo = extensionId;
-        extensionId = null;
-      }
-      let name = connectInfo && connectInfo.name || "";
-      let recipient = extensionId ? {extensionId} : {extensionId: context.extensionId};
-      return context.messenger.connect(context.messageManager, name, recipient);
-    },
+var api = context => {
+  return {
+    runtime: {
+      connect: function(extensionId, connectInfo) {
+        if (!connectInfo) {
+          connectInfo = extensionId;
+          extensionId = null;
+        }
+        let name = connectInfo && connectInfo.name || "";
+        let recipient = extensionId ? {extensionId} : {extensionId: context.extensionId};
+        return context.messenger.connect(context.messageManager, name, recipient);
+      },
+
+      getManifest: function() {
+        return Cu.cloneInto(context.extension.manifest, context.cloneScope);
+      },
 
-    getManifest: function() {
-      return Cu.cloneInto(context.extension.manifest, context.cloneScope);
-    },
+      getURL: function(url) {
+        return context.extension.baseURI.resolve(url);
+      },
+
+      onConnect: context.messenger.onConnect("runtime.onConnect"),
+
+      onMessage: context.messenger.onMessage("runtime.onMessage"),
 
-    getURL: function(url) {
-      return context.extension.baseURI.resolve(url);
+      sendMessage: function(...args) {
+        let options; // eslint-disable-line no-unused-vars
+        let extensionId, message, responseCallback;
+        if (args.length == 1) {
+          message = args[0];
+        } else if (args.length == 2) {
+          [message, responseCallback] = args;
+        } else {
+          [extensionId, message, options, responseCallback] = args;
+        }
+
+        let recipient = extensionId ? {extensionId} : {extensionId: context.extensionId};
+        context.messenger.sendMessage(context.messageManager, message, recipient, responseCallback);
+      },
     },
 
-    onConnect: context.messenger.onConnect("runtime.onConnect"),
-
-    onMessage: context.messenger.onMessage("runtime.onMessage"),
+    extension: {
+      getURL: function(url) {
+        return context.extension.baseURI.resolve(url);
+      },
 
-    sendMessage: function(...args) {
-      let extensionId, message, options, responseCallback;
-      if (args.length == 1) {
-        message = args[0];
-      } else if (args.length == 2) {
-        [message, responseCallback] = args;
-      } else {
-        [extensionId, message, options, responseCallback] = args;
-      }
-
-      let recipient = extensionId ? {extensionId} : {extensionId: context.extensionId};
-      context.messenger.sendMessage(context.messageManager, message, recipient, responseCallback);
-    },
-  },
-
-  extension: {
-    getURL: function(url) {
-      return context.extension.baseURI.resolve(url);
+      inIncognitoContext: PrivateBrowsingUtils.isContentWindowPrivate(context.contentWindow),
     },
 
-    inIncognitoContext: PrivateBrowsingUtils.isContentWindowPrivate(context.contentWindow),
-  },
-
-  i18n: {
-    getMessage: function(messageName, substitutions) {
-      return context.extension.localizeMessage(messageName, substitutions);
+    i18n: {
+      getMessage: function(messageName, substitutions) {
+        return context.extension.localizeMessage(messageName, substitutions);
+      },
     },
-  },
-}};
+  };
+};
 
 // Represents a content script.
-function Script(options)
-{
+function Script(options) {
   this.options = options;
   this.run_at = this.options.run_at;
   this.js = this.options.js || [];
   this.css = this.options.css || [];
 
   this.matches_ = new MatchPattern(this.options.matches);
   this.exclude_matches_ = new MatchPattern(this.options.exclude_matches || null);
   // TODO: MatchPattern should pre-mangle host-only patterns so that we
@@ -150,18 +153,18 @@ Script.prototype = {
   },
 
   tryInject(extension, window, sandbox, shouldRun) {
     if (!this.matches(window)) {
       return;
     }
 
     if (shouldRun("document_start")) {
-      let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor).
-        getInterface(Ci.nsIDOMWindowUtils);
+      let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                           .getInterface(Ci.nsIDOMWindowUtils);
 
       for (let url of this.css) {
         url = extension.baseURI.resolve(url);
         runSafeSyncWithoutClone(winUtils.loadSheetUsingURIString, url, winUtils.AUTHOR_SHEET);
       }
 
       if (this.options.cssCode) {
         let url = "data:text/css;charset=utf-8," + encodeURIComponent(this.options.cssCode);
@@ -178,46 +181,46 @@ Script.prototype = {
         if (AppConstants.platform == "gonk" && scheduled != "document_idle") {
           Cu.reportError(`Script injection: ignoring ${url} at ${scheduled}`);
         }
         url = extension.baseURI.resolve(url);
 
         let options = {
           target: sandbox,
           charset: "UTF-8",
-          async: AppConstants.platform == "gonk"
-        }
+          async: AppConstants.platform == "gonk",
+        };
         runSafeSyncWithoutClone(Services.scriptloader.loadSubScriptWithOptions, url, options);
       }
 
       if (this.options.jsCode) {
         Cu.evalInSandbox(this.options.jsCode, sandbox, "latest");
       }
     }
   },
 };
 
-function getWindowMessageManager(contentWindow)
-{
+function getWindowMessageManager(contentWindow) {
   let ir = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                         .getInterface(Ci.nsIDocShell)
                         .QueryInterface(Ci.nsIInterfaceRequestor);
   try {
     return ir.getInterface(Ci.nsIContentFrameMessageManager);
   } catch (e) {
     // Some windows don't support this interface (hidden window).
     return null;
   }
 }
 
+var ExtensionManager;
+
 // Scope in which extension content script code can run. It uses
 // Cu.Sandbox to run the code. There is a separate scope for each
 // frame.
-function ExtensionContext(extensionId, contentWindow)
-{
+function ExtensionContext(extensionId, contentWindow) {
   this.extension = ExtensionManager.get(extensionId);
   this.extensionId = extensionId;
   this.contentWindow = contentWindow;
 
   this.onClose = new Set();
 
   let utils = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                            .getInterface(Ci.nsIDOMWindowUtils);
@@ -234,17 +237,17 @@ function ExtensionContext(extensionId, c
     prin = Cc["@mozilla.org/nullprincipal;1"].createInstance(Ci.nsIPrincipal);
   }
 
   this.sandbox = Cu.Sandbox(prin, {sandboxPrototype: contentWindow, wantXrays: true, isWebExtensionContentScript: true});
 
   let delegate = {
     getSender(context, target, sender) {
       // Nothing to do here.
-    }
+    },
   };
 
   let url = contentWindow.location.href;
   let broker = ExtensionContent.getBroker(mm);
   this.messenger = new Messenger(this, broker, {id: extensionId, frameId, url},
                                  {id: extensionId, frameId}, delegate);
 
   let chromeObj = Cu.createObjectIn(this.sandbox, {defineAs: "browser"});
@@ -275,18 +278,17 @@ ExtensionContext.prototype = {
   close() {
     for (let obj of this.onClose) {
       obj.close();
     }
     Cu.nukeSandbox(this.sandbox);
   },
 };
 
-function windowId(window)
-{
+function windowId(window) {
   return window.QueryInterface(Ci.nsIInterfaceRequestor)
                .getInterface(Ci.nsIDOMWindowUtils)
                .currentInnerWindowID;
 }
 
 // Responsible for creating ExtensionContexts and injecting content
 // scripts into them when new documents are created.
 var DocumentManager = {
@@ -327,26 +329,28 @@ var DocumentManager = {
       // Make sure we only load into frames that ExtensionContent.init
       // was called on (i.e., not frames for social or sidebars).
       let mm = getWindowMessageManager(window);
       if (!mm || !ExtensionContent.globals.has(mm)) {
         return;
       }
 
       this.trigger("document_start", window);
+      /* eslint-disable mozilla/balanced-listeners */
       window.addEventListener("DOMContentLoaded", this, true);
       window.addEventListener("load", this, true);
+      /* eslint-enable mozilla/balanced-listeners */
     } else if (topic == "inner-window-destroyed") {
       let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
       if (!this.windows.has(id)) {
         return;
       }
 
       let extensions = this.windows.get(id);
-      for (let [extensionId, context] of extensions) {
+      for (let [, context] of extensions) {
         context.close();
       }
 
       this.windows.delete(id);
     }
   },
 
   handleEvent: function(event) {
@@ -380,17 +384,17 @@ var DocumentManager = {
     // FIXME: Script should be executed only if current state has
     // already reached its run_at state, or we have to keep it around
     // somewhere to execute later.
     context.execute(script, scheduled => true);
   },
 
   enumerateWindows: function*(docShell) {
     let window = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
-                         .getInterface(Ci.nsIDOMWindow)
+                         .getInterface(Ci.nsIDOMWindow);
     yield [window, this.getWindowState(window)];
 
     for (let i = 0; i < docShell.childCount; i++) {
       let child = docShell.getChildAt(i).QueryInterface(Ci.nsIDocShell);
       yield* this.enumerateWindows(child);
     }
   },
 
@@ -425,17 +429,17 @@ var DocumentManager = {
             context.execute(script, scheduled => isWhenBeforeOrSame(scheduled, state));
           }
         }
       }
     }
   },
 
   shutdownExtension(extensionId) {
-    for (let [windowId, extensions] of this.windows) {
+    for (let [, extensions] of this.windows) {
       let context = extensions.get(extensionId);
       if (context) {
         context.close();
         extensions.delete(extensionId);
       }
     }
 
     this.extensionCount--;
@@ -453,18 +457,17 @@ var DocumentManager = {
           context.execute(script, scheduled => scheduled == state);
         }
       }
     }
   },
 };
 
 // Represents a browser extension in the content process.
-function BrowserExtensionContent(data)
-{
+function BrowserExtensionContent(data) {
   this.id = data.id;
   this.uuid = data.uuid;
   this.data = data;
   this.scripts = data.content_scripts.map(scriptData => new Script(scriptData));
   this.webAccessibleResources = data.webAccessibleResources;
   this.whiteListedHosts = data.whiteListedHosts;
 
   this.localeData = new LocaleData(data.localeData);
@@ -473,17 +476,17 @@ function BrowserExtensionContent(data)
   this.baseURI = Services.io.newURI(data.baseURL, null, null);
 
   let uri = Services.io.newURI(data.resourceURL, null, null);
 
   if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
     // Extension.jsm takes care of this in the parent.
     ExtensionManagement.startupExtension(this.uuid, uri, this);
   }
-};
+}
 
 BrowserExtensionContent.prototype = {
   shutdown() {
     if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
       ExtensionManagement.shutdownExtension(this.uuid);
     }
   },
 
@@ -491,17 +494,17 @@ BrowserExtensionContent.prototype = {
     return this.localeData.localizeMessage(...args);
   },
 
   localize(...args) {
     return this.localeData.localize(...args);
   },
 };
 
-var ExtensionManager = {
+ExtensionManager = {
   // Map[extensionId, BrowserExtensionContent]
   extensions: new Map(),
 
   init() {
     Services.cpmm.addMessageListener("Extension:Startup", this);
     Services.cpmm.addMessageListener("Extension:Shutdown", this);
     Services.cpmm.addMessageListener("Extension:FlushJarCache", this);
 
@@ -541,17 +544,17 @@ var ExtensionManager = {
         let nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
                                              "initWithPath");
         let file = new nsIFile(data.path);
         flushJarCache(file);
         Services.cpmm.sendAsyncMessage("Extension:FlushJarCacheComplete");
         break;
       }
     }
-  }
+  },
 };
 
 this.ExtensionContent = {
   globals: new Map(),
 
   init(global) {
     let broker = new MessageBroker([global]);
     this.globals.set(global, broker);
@@ -576,18 +579,18 @@ this.ExtensionContent = {
   },
 
   getBroker(messageManager) {
     return this.globals.get(messageManager);
   },
 
   receiveMessage({target, name, data}) {
     switch (name) {
-    case "Extension:Execute":
-      let script = new Script(data.options);
-      let {extensionId} = data;
-      DocumentManager.executeScript(target, extensionId, script);
-      break;
+      case "Extension:Execute":
+        let script = new Script(data.options);
+        let {extensionId} = data;
+        DocumentManager.executeScript(target, extensionId, script);
+        break;
     }
   },
 };
 
 ExtensionManager.init();
--- a/toolkit/components/extensions/ExtensionManagement.jsm
+++ b/toolkit/components/extensions/ExtensionManagement.jsm
@@ -65,25 +65,25 @@ var Frames = {
     }
 
     // Not a top-level window. Just return the ID as normal.
     return this.getId(parentWindowId);
   },
 
   receiveMessage({name, data}) {
     switch (name) {
-    case "Extension:TopWindowID":
-      // FIXME: Need to handle the case where the content process
-      // crashes. Right now we leak its top window IDs.
-      this.topWindowIds.add(data.windowId);
-      break;
+      case "Extension:TopWindowID":
+        // FIXME: Need to handle the case where the content process
+        // crashes. Right now we leak its top window IDs.
+        this.topWindowIds.add(data.windowId);
+        break;
 
-    case "Extension:RemoveTopWindowID":
-      this.topWindowIds.delete(data.windowId);
-      break;
+      case "Extension:RemoveTopWindowID":
+        this.topWindowIds.delete(data.windowId);
+        break;
     }
   },
 };
 Frames.init();
 
 // Manage the collection of ext-*.js scripts that define the extension API.
 var Scripts = {
   scripts: new Set(),
@@ -156,17 +156,17 @@ var Service = {
   extensionURILoadableByAnyone(uri) {
     let uuid = uri.host;
     let extension = this.uuidMap.get(uuid);
     if (!extension) {
       return false;
     }
 
     let path = uri.path;
-    if (path.length > 0 && path[0] == '/') {
+    if (path.length > 0 && path[0] == "/") {
       path = path.substr(1);
     }
     return extension.webAccessibleResources.has(path);
   },
 
   // Checks whether a given extension can load this URI (typical