Bug 1506042 - Enable ESLint for docshell/resources and docshell/test/chrome (automatic fixes). r=smaug
authorMark Banner <standard8@mozilla.com>
Fri, 09 Nov 2018 10:54:04 +0000
changeset 445402 8f6702639abc0d48d610facf3002a2a2dc1114f9
parent 445401 abe810b08dc6805ac03290c5940b43c1d86878c9
child 445403 ea9a6719f0c7244a7d63316b1d0cb7dc41f9a0c3
push id35015
push userdluca@mozilla.com
push dateFri, 09 Nov 2018 17:45:20 +0000
treeherdermozilla-central@2f1158e5e0ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1506042
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1506042 - Enable ESLint for docshell/resources and docshell/test/chrome (automatic fixes). r=smaug Differential Revision: https://phabricator.services.mozilla.com/D11441
docshell/resources/content/netError.js
docshell/test/chrome/bug303267.html
docshell/test/chrome/bug909218.js
docshell/test/chrome/docshell_helpers.js
docshell/test/chrome/test_allowContentRetargeting.html
docshell/test/chrome/test_bug428288.html
docshell/test/chrome/test_bug909218.html
docshell/test/chrome/test_private_hidden_window.html
--- a/docshell/resources/content/netError.js
+++ b/docshell/resources/content/netError.js
@@ -7,96 +7,88 @@
       //   moz-neterror:page?e=error&u=url&s=classname&d=desc
 
       // Note that this file uses document.documentURI to get
       // the URL (with the format from above). This is because
       // document.location.href gets the current URI off the docshell,
       // which is the URL displayed in the location bar, i.e.
       // the URI that the user attempted to load.
 
-      function getErrorCode()
-      {
+      function getErrorCode() {
         var url = document.documentURI;
         var error = url.search(/e\=/);
         var duffUrl = url.search(/\&u\=/);
         return decodeURIComponent(url.slice(error + 2, duffUrl));
       }
 
-      function getCSSClass()
-      {
+      function getCSSClass() {
         var url = document.documentURI;
         var matches = url.match(/s\=([^&]+)\&/);
         // s is optional, if no match just return nothing
         if (!matches || matches.length < 2)
           return "";
 
         // parenthetical match is the second entry
         return decodeURIComponent(matches[1]);
       }
 
-      function getDescription()
-      {
+      function getDescription() {
         var url = document.documentURI;
         var desc = url.search(/d\=/);
 
         // desc == -1 if not found; if so, return an empty string
         // instead of what would turn out to be portions of the URI
         if (desc == -1)
           return "";
 
         return decodeURIComponent(url.slice(desc + 2));
       }
 
-      function retryThis(buttonEl)
-      {
+      function retryThis(buttonEl) {
         // Note: The application may wish to handle switching off "offline mode"
         // before this event handler runs, but using a capturing event handler.
 
         // Session history has the URL of the page that failed
         // to load, not the one of the error page. So, just call
         // reload(), which will also repost POST data correctly.
         try {
           location.reload();
         } catch (e) {
           // We probably tried to reload a URI that caused an exception to
           // occur;  e.g. a nonexistent file.
         }
 
         buttonEl.disabled = true;
       }
 
-      function initPage()
-      {
+      function initPage() {
         var err = getErrorCode();
 
         // if it's an unknown error or there's no title or description
         // defined, get the generic message
         var errTitle = document.getElementById("et_" + err);
         var errDesc  = document.getElementById("ed_" + err);
-        if (!errTitle || !errDesc)
-        {
+        if (!errTitle || !errDesc) {
           errTitle = document.getElementById("et_generic");
           errDesc  = document.getElementById("ed_generic");
         }
 
         var title = document.getElementById("errorTitleText");
-        if (title)
-        {
+        if (title) {
           title.parentNode.replaceChild(errTitle, title);
           // change id to the replaced child's id so styling works
           errTitle.id = "errorTitleText";
         }
 
         var sd = document.getElementById("errorShortDescText");
         if (sd)
           sd.textContent = getDescription();
 
         var ld = document.getElementById("errorLongDesc");
-        if (ld)
-        {
+        if (ld) {
           ld.parentNode.replaceChild(errDesc, ld);
           // change id to the replaced child's id so styling works
           errDesc.id = "errorLongDesc";
         }
 
         // remove undisplayed errors to avoid bug 39098
         var errContainer = document.getElementById("errorContainer");
         errContainer.remove();
@@ -134,18 +126,17 @@
         }
 
         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 {
+        } 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.remove();
         }
 
         if (err == "inadequateSecurityError" || err == "blockedByPolicy") {
           // Remove the "Try again" button from pages that don't need it.
@@ -160,18 +151,18 @@
         }
 
         if (document.getElementById("errorTryAgain").style.display != "none")
           addAutofocus("errorTryAgain");
       }
 
       function showSecuritySection() {
         // Swap link out, content in
-        document.getElementById('securityOverrideContent').style.display = '';
-        document.getElementById('securityOverrideLink').style.display = 'none';
+        document.getElementById("securityOverrideContent").style.display = "";
+        document.getElementById("securityOverrideLink").style.display = "none";
       }
 
       /* 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
       */
@@ -182,17 +173,17 @@
           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)
+          if (!result)
             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)));
 
@@ -202,17 +193,17 @@
           anchorEl.setAttribute("title", result[1]);
           anchorEl.appendChild(document.createTextNode(result[1]));
           sd.appendChild(anchorEl);
 
           // Finally, append text for anything after the closing </a>
           sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length)));
         }
 
-        var link = document.getElementById('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;
 
         // If okHost is a wildcard domain ("*.example.com") let's
--- a/docshell/test/chrome/bug303267.html
+++ b/docshell/test/chrome/bug303267.html
@@ -2,22 +2,20 @@
 <head>
   <title>
     bug303267.html
     </title>
   </head>
 <body onpageshow="showpageshowcount()">
 <script>
 var pageshowcount = 0;
-function showpageshowcount()
-{
+function showpageshowcount() {
 	pageshowcount++;
 	var div1 = document.getElementById("div1");
-	while (div1.firstChild)
-	{
+	while (div1.firstChild) {
 		div1.firstChild.remove();
 	}
 	div1.appendChild(document.createTextNode(
 	  "pageshowcount: " + pageshowcount));
 }
 </script>
 <div id="div1">
 	</div>
--- a/docshell/test/chrome/bug909218.js
+++ b/docshell/test/chrome/bug909218.js
@@ -1,2 +1,2 @@
-// This file exists just to ensure that we load it with the correct flags.
-dump("bug909218.js loaded\n");
+// This file exists just to ensure that we load it with the correct flags.
+dump("bug909218.js loaded\n");
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -1,9 +1,9 @@
-/**  
+/**
  * Import common SimpleTest methods so that they're usable in this window.
  */
 var imports = [ "SimpleTest", "is", "isnot", "ok", "onerror", "todo",
   "todo_is", "todo_isnot" ];
 for (var name of imports) {
   window[name] = window.opener.wrappedJSObject[name];
 }
 ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
@@ -12,105 +12,105 @@ ChromeUtils.import("resource://testing-c
  * Define global constants and variables.
  */
 const NAV_NONE = 0;
 const NAV_BACK = 1;
 const NAV_FORWARD = 2;
 const NAV_URI = 3;
 const NAV_RELOAD = 4;
 
-var gExpectedEvents;          // an array of events which are expected to
+var gExpectedEvents; // an array of events which are expected to
                               // be triggered by this navigation
-var gUnexpectedEvents;        // an array of event names which are NOT expected
+var gUnexpectedEvents; // an array of event names which are NOT expected
                               // to be triggered by this navigation
-var gFinalEvent;              // true if the last expected event has fired
-var gUrisNotInBFCache = [];   // an array of uri's which shouldn't be stored
+var gFinalEvent; // true if the last expected event has fired
+var gUrisNotInBFCache = []; // an array of uri's which shouldn't be stored
                               // in the bfcache
-var gNavType = NAV_NONE;      // defines the most recent navigation type
+var gNavType = NAV_NONE; // defines the most recent navigation type
                               // executed by doPageNavigation
 var gOrigMaxTotalViewers =    // original value of max_total_viewers,
-  undefined;                  // to be restored at end of test
+  undefined; // to be restored at end of test
 
-var gExtractedPath = null;    //used to cache file path for extracting files from a .jar file
+var gExtractedPath = null; // used to cache file path for extracting files from a .jar file
 
 /**
- * The doPageNavigation() function performs page navigations asynchronously, 
- * listens for specified events, and compares actual events with a list of 
- * expected events.  When all expected events have occurred, an optional 
- * callback can be notified. The parameter passed to this function is an 
+ * The doPageNavigation() function performs page navigations asynchronously,
+ * listens for specified events, and compares actual events with a list of
+ * expected events.  When all expected events have occurred, an optional
+ * callback can be notified. The parameter passed to this function is an
  * object with the following properties:
- * 
+ *
  *                uri: if !undefined, the browser will navigate to this uri
  *
  *               back: if true, the browser will execute goBack()
  *
  *            forward: if true, the browser will execute goForward()
  *
  *             reload: if true, the browser will execute reload()
  *
- *  eventsToListenFor: an array containing one or more of the following event  
+ *  eventsToListenFor: an array containing one or more of the following event
  *                     types to listen for:  "pageshow", "pagehide", "onload",
- *                     "onunload".  If this property is undefined, only a 
- *                     single "pageshow" events will be listened for.  If this 
- *                     property is explicitly empty, [], then no events will 
+ *                     "onunload".  If this property is undefined, only a
+ *                     single "pageshow" events will be listened for.  If this
+ *                     property is explicitly empty, [], then no events will
  *                     be listened for.
  *
- *     expectedEvents: an array of one or more expectedEvent objects, 
- *                     corresponding to the events which are expected to be 
- *                     fired for this navigation.  Each object has the 
+ *     expectedEvents: an array of one or more expectedEvent objects,
+ *                     corresponding to the events which are expected to be
+ *                     fired for this navigation.  Each object has the
  *                     following properties:
  *
  *                          type: one of the event type strings
- *                          title (optional): the title of the window the 
+ *                          title (optional): the title of the window the
  *                              event belongs to
- *                          persisted (optional): the event's expected 
+ *                          persisted (optional): the event's expected
  *                              .persisted attribute
  *
- *                     This function will verify that events with the 
- *                     specified properties are fired in the same order as 
- *                     specified in the array.  If .title or .persisted 
- *                     properties for an expectedEvent are undefined, those 
- *                     properties will not be verified for that particular 
+ *                     This function will verify that events with the
+ *                     specified properties are fired in the same order as
+ *                     specified in the array.  If .title or .persisted
+ *                     properties for an expectedEvent are undefined, those
+ *                     properties will not be verified for that particular
  *                     event.
  *
- *                     This property is ignored if eventsToListenFor is 
+ *                     This property is ignored if eventsToListenFor is
  *                     undefined or [].
  *
- *     preventBFCache: if true, an unload handler will be added to the loaded 
- *                     page to prevent it from being bfcached.  This property 
+ *     preventBFCache: if true, an unload handler will be added to the loaded
+ *                     page to prevent it from being bfcached.  This property
  *                     has no effect when eventsToListenFor is [].
  *
- *      onNavComplete: a callback which is notified after all expected events 
- *                     have occurred, or after a timeout has elapsed.  This 
+ *      onNavComplete: a callback which is notified after all expected events
+ *                     have occurred, or after a timeout has elapsed.  This
  *                     callback is not notified if eventsToListenFor is [].
  *
- * There must be an expectedEvent object for each event of the types in 
- * eventsToListenFor which is triggered by this navigation.  For example, if 
+ * There must be an expectedEvent object for each event of the types in
+ * eventsToListenFor which is triggered by this navigation.  For example, if
  * eventsToListenFor = [ "pagehide", "pageshow" ], then expectedEvents
- * must contain an object for each pagehide and pageshow event which occurs as 
+ * must contain an object for each pagehide and pageshow event which occurs as
  * a result of this navigation.
  */
 function doPageNavigation(params) {
   // Parse the parameters.
   let back = params.back ? params.back : false;
   let forward = params.forward ? params.forward : false;
   let reload = params.reload ? params.reload : false;
   let uri = params.uri ? params.uri : false;
   let eventsToListenFor = typeof(params.eventsToListenFor) != "undefined" ?
     params.eventsToListenFor : ["pageshow"];
-  gExpectedEvents = typeof(params.eventsToListenFor) == "undefined" || 
-    eventsToListenFor.length == 0 ? undefined : params.expectedEvents; 
-  gUnexpectedEvents = typeof(params.eventsToListenFor) == "undefined" || 
-    eventsToListenFor.length == 0 ? undefined : params.unexpectedEvents; 
-  let preventBFCache = (typeof[params.preventBFCache] == "undefined") ? 
+  gExpectedEvents = typeof(params.eventsToListenFor) == "undefined" ||
+    eventsToListenFor.length == 0 ? undefined : params.expectedEvents;
+  gUnexpectedEvents = typeof(params.eventsToListenFor) == "undefined" ||
+    eventsToListenFor.length == 0 ? undefined : params.unexpectedEvents;
+  let preventBFCache = (typeof[params.preventBFCache] == "undefined") ?
     false : params.preventBFCache;
-  let waitOnly = (typeof(params.waitForEventsOnly) == "boolean" 
+  let waitOnly = (typeof(params.waitForEventsOnly) == "boolean"
     && params.waitForEventsOnly);
-  
-  // Do some sanity checking on arguments.  
+
+  // Do some sanity checking on arguments.
   if (back && forward)
     throw "Can't specify both back and forward";
   if (back && uri)
     throw "Can't specify both back and a uri";
   if (forward && uri)
     throw "Can't specify both forward and a uri";
   if (reload && (forward || back || uri))
     throw "Can't specify reload and another navigation type";
@@ -141,187 +141,180 @@ function doPageNavigation(params) {
         if (anExpectedEventType == anEventType)
           eventFound = true;
       }
     }
     if (!eventFound)
       throw "Event type " + anEventType + " is specified in " +
         "eventsToListenFor, but not in expectedEvents";
   }
-  
-  // If the test explicitly sets .eventsToListenFor to [], don't wait for any 
+
+  // If the test explicitly sets .eventsToListenFor to [], don't wait for any
   // events.
-  gFinalEvent = eventsToListenFor.length == 0 ? true : false;
-  
-  // Add an event listener for each type of event in the .eventsToListenFor 
+  gFinalEvent = eventsToListenFor.length == 0;
+
+  // Add an event listener for each type of event in the .eventsToListenFor
   // property of the input parameters.
   for (let eventType of eventsToListenFor) {
     dump("TEST: registering a listener for " + eventType + " events\n");
-    TestWindow.getBrowser().addEventListener(eventType, pageEventListener, 
+    TestWindow.getBrowser().addEventListener(eventType, pageEventListener,
       true);
   }
 
   // Perform the specified navigation.
   if (back) {
     gNavType = NAV_BACK;
     TestWindow.getBrowser().goBack();
-  }
-  else if (forward) {
+  } else if (forward) {
     gNavType = NAV_FORWARD;
     TestWindow.getBrowser().goForward();
-  }
-  else if (uri) {
+  } else if (uri) {
     gNavType = NAV_URI;
     BrowserTestUtils.loadURI(TestWindow.getBrowser(), uri);
-  }
-  else if (reload) {
+  } else if (reload) {
     gNavType = NAV_RELOAD;
     TestWindow.getBrowser().reload();
-  }
-  else if (waitOnly) {
+  } else if (waitOnly) {
     gNavType = NAV_NONE;
-  }
-  else {
+  } else {
     throw "No valid navigation type passed to doPageNavigation!";
   }
-  
-  // If we're listening for events and there is an .onNavComplete callback, 
+
+  // If we're listening for events and there is an .onNavComplete callback,
   // wait for all events to occur, and then call doPageNavigation_complete().
-  if (eventsToListenFor.length > 0 && params.onNavComplete)
-  {
+  if (eventsToListenFor.length > 0 && params.onNavComplete) {
     waitForTrue(
       function() { return gFinalEvent; },
-      function() { 
-        doPageNavigation_complete(eventsToListenFor, params.onNavComplete, 
+      function() {
+        doPageNavigation_complete(eventsToListenFor, params.onNavComplete,
           preventBFCache);
       } );
   }
 }
 
 /**
  * Finish doPageNavigation(), by removing event listeners, adding an unload
- * handler if appropriate, and calling the onNavComplete callback.  This 
- * function is called after all the expected events for this navigation have 
+ * handler if appropriate, and calling the onNavComplete callback.  This
+ * function is called after all the expected events for this navigation have
  * occurred.
  */
-function doPageNavigation_complete(eventsToListenFor, onNavComplete, 
+function doPageNavigation_complete(eventsToListenFor, onNavComplete,
   preventBFCache) {
   // Unregister our event listeners.
   dump("TEST: removing event listeners\n");
   for (let eventType of eventsToListenFor) {
-    TestWindow.getBrowser().removeEventListener(eventType, pageEventListener, 
+    TestWindow.getBrowser().removeEventListener(eventType, pageEventListener,
       true);
   }
-  
-  // If the .preventBFCache property was set, add an empty unload handler to 
+
+  // If the .preventBFCache property was set, add an empty unload handler to
   // prevent the page from being bfcached.
   let uri = TestWindow.getBrowser().currentURI.spec;
   if (preventBFCache) {
-    TestWindow.getWindow().addEventListener("unload", function() { 
+    TestWindow.getWindow().addEventListener("unload", function() {
         dump("TEST: Called dummy unload function to prevent page from " +
-          "being bfcached.\n"); 
+          "being bfcached.\n");
       }, true);
-      
+
     // Save the current uri in an array of uri's which shouldn't be
     // stored in the bfcache, for later verification.
     if (!(uri in gUrisNotInBFCache)) {
       gUrisNotInBFCache.push(uri);
-    }  
+    }
   } else if (gNavType == NAV_URI) {
     // If we're navigating to a uri and .preventBFCache was not
     // specified, splice it out of gUrisNotInBFCache if it's there.
     gUrisNotInBFCache.forEach(
       function(element, index, array) {
         if (element == uri) {
           array.splice(index, 1);
         }
       }, this);
   }
-  
+
   // Notify the callback now that we're done.
   onNavComplete.call();
 }
 
 /**
- * Allows a test to wait for page navigation events, and notify a 
+ * Allows a test to wait for page navigation events, and notify a
  * callback when they've all been received.  This works exactly the
  * same as doPageNavigation(), except that no navigation is initiated.
  */
 function waitForPageEvents(params) {
   params.waitForEventsOnly = true;
   doPageNavigation(params);
 }
 
 /**
  * The event listener which listens for expectedEvents.
  */
 function pageEventListener(event) {
   try {
     dump("TEST: eventListener received a " + event.type + " event for page " +
       event.originalTarget.title + ", persisted=" + event.persisted + "\n");
-  } catch(e) {
+  } catch (e) {
     // Ignore any exception.
   }
-  
+
   // If this page shouldn't be in the bfcache because it was previously
   // loaded with .preventBFCache, make sure that its pageshow event
   // has .persisted = false, even if the test doesn't explicitly test
   // for .persisted.
-  if ( (event.type == "pageshow") && 
+  if ( (event.type == "pageshow") &&
     (gNavType == NAV_BACK || gNavType == NAV_FORWARD) ) {
     let uri = TestWindow.getBrowser().currentURI.spec;
     if (uri in gUrisNotInBFCache) {
       ok(!event.persisted, "pageshow event has .persisted = false, even " +
        "though it was loaded with .preventBFCache previously\n");
     }
   }
 
   if (typeof(gUnexpectedEvents) != "undefined") {
     is(gUnexpectedEvents.indexOf(event.type), -1,
        "Should not get unexpected event " + event.type);
-  }  
+  }
 
-  // If no expected events were specified, mark the final event as having been 
-  // triggered when a pageshow event is fired; this will allow 
+  // If no expected events were specified, mark the final event as having been
+  // triggered when a pageshow event is fired; this will allow
   // doPageNavigation() to return.
-  if ((typeof(gExpectedEvents) == "undefined") && event.type == "pageshow")
-  {
+  if ((typeof(gExpectedEvents) == "undefined") && event.type == "pageshow") {
     waitForNextPaint(function() { gFinalEvent = true; });
     return;
   }
-  
-  // If there are explicitly no expected events, but we receive one, it's an 
+
+  // If there are explicitly no expected events, but we receive one, it's an
   // error.
   if (gExpectedEvents.length == 0) {
     ok(false, "Unexpected event (" + event.type + ") occurred");
     return;
   }
-  
-  // Grab the next expected event, and compare its attributes against the 
+
+  // Grab the next expected event, and compare its attributes against the
   // actual event.
   let expected = gExpectedEvents.shift();
-  
-  is(event.type, expected.type, 
+
+  is(event.type, expected.type,
     "A " + expected.type + " event was expected, but a " +
     event.type + " event occurred");
-    
+
   if (typeof(expected.title) != "undefined") {
     ok(event.originalTarget instanceof HTMLDocument,
-       "originalTarget for last " + event.type + 
+       "originalTarget for last " + event.type +
        " event not an HTMLDocument");
-    is(event.originalTarget.title, expected.title, 
+    is(event.originalTarget.title, expected.title,
       "A " + event.type + " event was expected for page " +
-      expected.title + ", but was fired for page " + 
+      expected.title + ", but was fired for page " +
       event.originalTarget.title);
-  }  
-  
+  }
+
   if (typeof(expected.persisted) != "undefined") {
-    is(event.persisted, expected.persisted, 
+    is(event.persisted, expected.persisted,
       "The persisted property of the " + event.type + " event on page " +
-      event.originalTarget.location + " had an unexpected value"); 
+      event.originalTarget.location + " had an unexpected value");
   }
 
   if ("visibilityState" in expected) {
     is(event.originalTarget.visibilityState, expected.visibilityState,
        "The visibilityState property of the document on page " +
        event.originalTarget.location + " had an unexpected value");
   }
 
@@ -332,23 +325,23 @@ function pageEventListener(event) {
   }
 
   // If we're out of expected events, let doPageNavigation() return.
   if (gExpectedEvents.length == 0)
     waitForNextPaint(function() { gFinalEvent = true; });
 }
 
 /**
- * End a test.  
+ * End a test.
  */
 function finish() {
   // Work around bug 467960.
   var history = TestWindow.getBrowser().webNavigation.sessionHistory;
   history.legacySHistory.PurgeHistory(history.count);
-  
+
   // If the test changed the value of max_total_viewers via a call to
   // enableBFCache(), then restore it now.
   if (typeof(gOrigMaxTotalViewers) != "undefined") {
     var prefs = Cc["@mozilla.org/preferences-service;1"]
                 .getService(Ci.nsIPrefBranch);
     prefs.setIntPref("browser.sessionhistory.max_total_viewers",
       gOrigMaxTotalViewers);
   }
@@ -366,136 +359,135 @@ function finish() {
       SimpleTest.waitForFocus(SimpleTest.finish, opener);
     }
   });
 
   window.close();
 }
 
 /**
- * Helper function which waits until another function returns true, or until a 
+ * Helper function which waits until another function returns true, or until a
  * timeout occurs, and then notifies a callback.
  *
  * Parameters:
  *
- *    fn: a function which is evaluated repeatedly, and when it turns true, 
+ *    fn: a function which is evaluated repeatedly, and when it turns true,
  *        the onWaitComplete callback is notified.
  *
- *    onWaitComplete:  a callback which will be notified when fn() returns 
+ *    onWaitComplete:  a callback which will be notified when fn() returns
  *        true, or when a timeout occurs.
- * 
- *    timeout: a timeout, in seconds or ms, after which waitForTrue() will 
- *        fail an assertion and then return, even if the fn function never 
- *        returns true.  If timeout is undefined, waitForTrue() will never 
+ *
+ *    timeout: a timeout, in seconds or ms, after which waitForTrue() will
+ *        fail an assertion and then return, even if the fn function never
+ *        returns true.  If timeout is undefined, waitForTrue() will never
  *        time out.
  */
 function waitForTrue(fn, onWaitComplete, timeout) {
   var start = new Date().valueOf();
   if (typeof(timeout) != "undefined") {
-    // If timeoutWait is less than 500, assume it represents seconds, and 
+    // If timeoutWait is less than 500, assume it represents seconds, and
     // convert to ms.
     if (timeout < 500)
       timeout *= 1000;
   }
-  
+
   // Loop until the test function returns true, or until a timeout occurs,
   // if a timeout is defined.
   var intervalid;
   intervalid =
     setInterval(
-      function() {  
+      function() {
         var timeoutHit = false;
         if (typeof(timeout) != "undefined") {
-          timeoutHit = new Date().valueOf() - start >= 
-            timeout ? true : false;
+          timeoutHit = new Date().valueOf() - start >=
+            timeout;
           if (timeoutHit) {
             ok(false, "Timed out waiting for condition");
           }
         }
         if (timeoutHit || fn.call()) {
           // Stop calling the test function and notify the callback.
           clearInterval(intervalid);
-          onWaitComplete.call();          
-        } 
+          onWaitComplete.call();
+        }
       }, 20);
 }
 
 function waitForNextPaint(cb) {
   requestAnimationFrame(_ => requestAnimationFrame(cb));
 }
 
 /**
  * Enable or disable the bfcache.
  *
  * Parameters:
  *
- *   enable: if true, set max_total_viewers to -1 (the default); if false, set 
+ *   enable: if true, set max_total_viewers to -1 (the default); if false, set
  *           to 0 (disabled), if a number, set it to that specific number
  */
 function enableBFCache(enable) {
   var prefs = Cc["@mozilla.org/preferences-service;1"]
               .getService(Ci.nsIPrefBranch);
-  
+
   // If this is the first time the test called enableBFCache(),
   // store the original value of max_total_viewers, so it can
   // be restored at the end of the test.
   if (typeof(gOrigMaxTotalViewers) == "undefined") {
     gOrigMaxTotalViewers =
       prefs.getIntPref("browser.sessionhistory.max_total_viewers");
   }
-  
+
   if (typeof(enable) == "boolean") {
     if (enable)
       prefs.setIntPref("browser.sessionhistory.max_total_viewers", -1);
     else
-      prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0);    
-  }
-  else if (typeof(enable) == "number") {
-    prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable);    
+      prefs.setIntPref("browser.sessionhistory.max_total_viewers", 0);
+  } else if (typeof(enable) == "number") {
+    prefs.setIntPref("browser.sessionhistory.max_total_viewers", enable);
   }
 }
 
 /*
- * get http root for local tests.  Use a single extractJarToTmp instead of 
- * extracting for each test.  
+ * get http root for local tests.  Use a single extractJarToTmp instead of
+ * extracting for each test.
  * Returns a file://path if we have a .jar file
  */
 function getHttpRoot() {
   var location = window.location.href;
   location = getRootDirectory(location);
   var jar = getJar(location);
   if (jar != null) {
     if (gExtractedPath == null) {
       var resolved = extractJarToTmp(jar);
       gExtractedPath = resolved.path;
     }
   } else {
     return null;
   }
-  return "file://" + gExtractedPath + '/';
+  return "file://" + gExtractedPath + "/";
 }
 
 /**
- * Returns the full HTTP url for a file in the mochitest docshell test 
+ * Returns the full HTTP url for a file in the mochitest docshell test
  * directory.
  */
 function getHttpUrl(filename) {
   var root = getHttpRoot();
   if (root == null) {
     root = "http://mochi.test:8888/chrome/docshell/test/chrome/";
   }
   return root + filename;
 }
 
 /**
- * A convenience object with methods that return the current test window, 
+ * A convenience object with methods that return the current test window,
  * browser, and document.
  */
 var TestWindow = {};
-TestWindow.getWindow = function () {
+TestWindow.getWindow = function() {
   return document.getElementById("content").contentWindow;
-}
-TestWindow.getBrowser = function () {
+};
+TestWindow.getBrowser = function() {
   return document.getElementById("content");
-}
-TestWindow.getDocument = function () {
+};
+TestWindow.getDocument = function() {
   return document.getElementById("content").contentDocument;
-}
+};
--- a/docshell/test/chrome/test_allowContentRetargeting.html
+++ b/docshell/test/chrome/test_allowContentRetargeting.html
@@ -50,35 +50,26 @@ function loadIframe(iframe) {
   iframe.contentWindow.docShell.
     QueryInterface(Ci.nsIInterfaceRequestor).
     getInterface(Ci.nsIWebProgress).
     addProgressListener(progressListener,
                         Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
 }
 
 var progressListener = {
-  onStateChange: function (webProgress, req, flags, status) {
+  onStateChange(webProgress, req, flags, status) {
     if (!(flags & Ci.nsIWebProgressListener.STATE_STOP))
       return;
     is(Components.isSuccessCode(status), false,
        "Downloadable should have failed to load");
     document.querySelector("iframe").remove();
     runNextTest();
   },
 
-  QueryInterface: function (iid) {
-    var iids = [
-      Ci.nsIWebProgressListener,
-      Ci.nsISupportsWeakReference,
-      Ci.nsISupports,
-    ];
-    if (iids.some(function (i) { return iid.equals(i); }))
-      return this;
-    throw Cr.NS_ERROR_NO_INTERFACE;
-  },
+  QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"]),
 };
 
   </script>
 </head>
 <body>
 <p id="display">
 </p>
 </body>
--- a/docshell/test/chrome/test_bug428288.html
+++ b/docshell/test/chrome/test_bug428288.html
@@ -17,17 +17,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 428288 **/
 
 function makeClick() {
   var event = document.createEvent("MouseEvents");
-  event.initMouseEvent("click", true, true, window, 0, 0,0,0,0,
+  event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null);
   document.getElementById("crashy").dispatchEvent(event);
   return true;
 }
 
 ok(makeClick(), "Crashes if bug 428288 is present");
 
 </script>
--- a/docshell/test/chrome/test_bug909218.html
+++ b/docshell/test/chrome/test_bug909218.html
@@ -1,120 +1,120 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
-
-SimpleTest.waitForExplicitFinish();
-addLoadEvent(test);
-
-ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm');
-
-// The default flags we will stick on the docShell - every request made by the
-// docShell should include those flags.
-const TEST_FLAGS = Ci.nsIRequest.LOAD_ANONYMOUS |
-                   Ci.nsIRequest.LOAD_BYPASS_CACHE |
-                   Ci.nsIRequest.INHIBIT_CACHING |
-                   Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY;
-
-var TEST_URL = "http://mochi.test:8888/chrome/docshell/test/chrome/bug909218.html";
-
-// These are the requests we expect to see loading TEST_URL into our iframe.
-
-// The test entry-point.  The basic outline is:
-// * Create an iframe and set defaultLoadFlags on its docShell.
-// * Add a web progress listener to observe each request as the iframe is
-//   loaded, and check that each request has the flags we specified.
-// * Load our test URL into the iframe and wait for the load to complete.
-function test() {
-  var iframe = document.createElement("iframe");
-  document.body.appendChild(iframe);
-  var docShell = iframe.contentWindow.docShell;
-  // Add our progress listener - when it notices the top-level document is
-  // complete, the test will end.
-  RequestWatcher.init(docShell, SimpleTest.finish);
-  // Set the flags we care about, then load our test URL.
-  docShell.defaultLoadFlags = TEST_FLAGS;
-  iframe.setAttribute("src", TEST_URL);
-}
-
-// an nsIWebProgressListener that checks all requests made by the docShell
-// have the flags we expect.
-RequestWatcher = {
-  init: function(docShell, callback) {
-    this.callback = callback;
-    this.docShell = docShell;
-    docShell.
-          QueryInterface(Ci.nsIInterfaceRequestor).
-          getInterface(Ci.nsIWebProgress).
-          addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
-                                    Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
-    // These are the requests we expect to see - initialize each to have a
-    // count of zero.
-    this.requestCounts = {};
-    for (var url of [
-        TEST_URL,
-        // content loaded by the above test html.
-        "http://mochi.test:8888/chrome/docshell/test/chrome/bug909218.js",
-        "http://mochi.test:8888/tests/SimpleTest/test.css",
-        "http://mochi.test:8888/tests/docshell/test/chrome/red.png",
-        // the content of an iframe in the test html.
-        "http://mochi.test:8888/chrome/docshell/test/chrome/generic.html"
-      ]) {
-      this.requestCounts[url] = 0;
-    }
-  },
-
-  // Finalize the test after we detect a completed load.  We check we saw the
-  // correct requests and make a callback to exit.
-  finalize: function() {
-    ok(Object.keys(this.requestCounts).length, "we expected some requests");
-    for (var url in this.requestCounts) {
-      var count = this.requestCounts[url];
-      // As we are looking at all request states, we expect more than 1 for
-      // each URL - 0 or 1 would imply something went wrong - >1 just means
-      // multiple states for each request were recorded, which we don't care
-      // about (we do care they all have the correct flags though - but we
-      // do that in onStateChange)
-      ok(count > 1, url + " saw " + count + " requests");
-    }
-    this.docShell.
-          QueryInterface(Ci.nsIInterfaceRequestor).
-          getInterface(Ci.nsIWebProgress).
-          removeProgressListener(this);
-    this.callback();
-  },
-
-  onStateChange: function (webProgress, req, flags, status) {
-    // We are checking requests - if there isn't one, ignore it.
-    if (!req) {
-      return;
-    }
-    // We will usually see requests for 'about:document-onload-blocker' not
-    // have the flag, so we just ignore them.
-    // We also see, eg, resource://gre-resources/loading-image.png, so
-    // skip resource:// URLs too.
-    // We may also see, eg, chrome://global/skin/icons/resizer.svg, so
-    // skip chrome:// URLs too.
-    if (req.name.startsWith("about:") || req.name.startsWith("resource:") ||
-      req.name.startsWith("chrome:")) {
-      return;
-    }
-    is(req.loadFlags & TEST_FLAGS, TEST_FLAGS, "request " + req.name + " has the expected flags");
-    this.requestCounts[req.name] += 1;
-    var stopFlags = Ci.nsIWebProgressListener.STATE_STOP |
-                    Ci.nsIWebProgressListener.STATE_IS_DOCUMENT;
-    if (req.name == TEST_URL && (flags & stopFlags) == stopFlags) {
-      this.finalize();
-    }
-  },
-  QueryInterface: ChromeUtils.generateQI([
-    Ci.nsIWebProgressListener,
-    Ci.nsISupportsWeakReference,
-  ])
-}
-
+
+SimpleTest.waitForExplicitFinish();
+addLoadEvent(test);
+
+ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+// The default flags we will stick on the docShell - every request made by the
+// docShell should include those flags.
+const TEST_FLAGS = Ci.nsIRequest.LOAD_ANONYMOUS |
+                   Ci.nsIRequest.LOAD_BYPASS_CACHE |
+                   Ci.nsIRequest.INHIBIT_CACHING |
+                   Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY;
+
+var TEST_URL = "http://mochi.test:8888/chrome/docshell/test/chrome/bug909218.html";
+
+// These are the requests we expect to see loading TEST_URL into our iframe.
+
+// The test entry-point.  The basic outline is:
+// * Create an iframe and set defaultLoadFlags on its docShell.
+// * Add a web progress listener to observe each request as the iframe is
+//   loaded, and check that each request has the flags we specified.
+// * Load our test URL into the iframe and wait for the load to complete.
+function test() {
+  var iframe = document.createElement("iframe");
+  document.body.appendChild(iframe);
+  var docShell = iframe.contentWindow.docShell;
+  // Add our progress listener - when it notices the top-level document is
+  // complete, the test will end.
+  RequestWatcher.init(docShell, SimpleTest.finish);
+  // Set the flags we care about, then load our test URL.
+  docShell.defaultLoadFlags = TEST_FLAGS;
+  iframe.setAttribute("src", TEST_URL);
+}
+
+// an nsIWebProgressListener that checks all requests made by the docShell
+// have the flags we expect.
+RequestWatcher = {
+  init(docShell, callback) {
+    this.callback = callback;
+    this.docShell = docShell;
+    docShell.
+          QueryInterface(Ci.nsIInterfaceRequestor).
+          getInterface(Ci.nsIWebProgress).
+          addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST |
+                                    Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
+    // These are the requests we expect to see - initialize each to have a
+    // count of zero.
+    this.requestCounts = {};
+    for (var url of [
+        TEST_URL,
+        // content loaded by the above test html.
+        "http://mochi.test:8888/chrome/docshell/test/chrome/bug909218.js",
+        "http://mochi.test:8888/tests/SimpleTest/test.css",
+        "http://mochi.test:8888/tests/docshell/test/chrome/red.png",
+        // the content of an iframe in the test html.
+        "http://mochi.test:8888/chrome/docshell/test/chrome/generic.html",
+      ]) {
+      this.requestCounts[url] = 0;
+    }
+  },
+
+  // Finalize the test after we detect a completed load.  We check we saw the
+  // correct requests and make a callback to exit.
+  finalize() {
+    ok(Object.keys(this.requestCounts).length, "we expected some requests");
+    for (var url in this.requestCounts) {
+      var count = this.requestCounts[url];
+      // As we are looking at all request states, we expect more than 1 for
+      // each URL - 0 or 1 would imply something went wrong - >1 just means
+      // multiple states for each request were recorded, which we don't care
+      // about (we do care they all have the correct flags though - but we
+      // do that in onStateChange)
+      ok(count > 1, url + " saw " + count + " requests");
+    }
+    this.docShell.
+          QueryInterface(Ci.nsIInterfaceRequestor).
+          getInterface(Ci.nsIWebProgress).
+          removeProgressListener(this);
+    this.callback();
+  },
+
+  onStateChange(webProgress, req, flags, status) {
+    // We are checking requests - if there isn't one, ignore it.
+    if (!req) {
+      return;
+    }
+    // We will usually see requests for 'about:document-onload-blocker' not
+    // have the flag, so we just ignore them.
+    // We also see, eg, resource://gre-resources/loading-image.png, so
+    // skip resource:// URLs too.
+    // We may also see, eg, chrome://global/skin/icons/resizer.svg, so
+    // skip chrome:// URLs too.
+    if (req.name.startsWith("about:") || req.name.startsWith("resource:") ||
+      req.name.startsWith("chrome:")) {
+      return;
+    }
+    is(req.loadFlags & TEST_FLAGS, TEST_FLAGS, "request " + req.name + " has the expected flags");
+    this.requestCounts[req.name] += 1;
+    var stopFlags = Ci.nsIWebProgressListener.STATE_STOP |
+                    Ci.nsIWebProgressListener.STATE_IS_DOCUMENT;
+    if (req.name == TEST_URL && (flags & stopFlags) == stopFlags) {
+      this.finalize();
+    }
+  },
+  QueryInterface: ChromeUtils.generateQI([
+    Ci.nsIWebProgressListener,
+    Ci.nsISupportsWeakReference,
+  ]),
+};
+
 </script>
 </head>
 </html>
--- a/docshell/test/chrome/test_private_hidden_window.html
+++ b/docshell/test/chrome/test_private_hidden_window.html
@@ -35,18 +35,18 @@ if (isNotLoaded()) {
     }
     onHiddenPrivateWindowReady();
   }, 4);
 } else {
   onHiddenPrivateWindowReady();
 }
 
 function onHiddenPrivateWindowReady() {
-  var iframe = hidden.document.createElement('iframe');
-  iframe.src = 'generic.html';
+  var iframe = hidden.document.createElement("iframe");
+  iframe.src = "generic.html";
   hidden.document.body.appendChild(iframe);
 
   var win = mainWindow.OpenBrowserWindow({private: true});
   win.addEventListener("load", function() {
     win.close();
     win = null;
   }, {once: true});
 }