Bug 1313626 - Clean up more issues found by eslint no-undef rule. r=mossop
authorMark Banner <standard8@mozilla.com>
Fri, 28 Oct 2016 11:40:32 +0100
changeset 320108 a3937bf608bc8b5479dcfb1a7bc92b5f9037a430
parent 320107 3c1eddbe382f29d7f377426cf95756563a764b29
child 320144 dc422956242bacfbf88d716f5b967d2c985b913b
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1313626
milestone52.0a1
Bug 1313626 - Clean up more issues found by eslint no-undef rule. r=mossop MozReview-Commit-ID: HGiOmpyN5zV
browser/base/content/browser-places.js
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_bug409624.js
browser/base/content/test/general/browser_bug553455.js
browser/base/content/test/general/browser_sanitize-timespans.js
browser/base/content/test/general/browser_sanitizeDialog.js
browser/base/content/test/general/domplate_test.js
browser/base/content/test/tabPrompts/.eslintrc.js
browser/base/content/test/tabs/.eslintrc.js
browser/base/content/test/urlbar/.eslintrc.js
browser/base/content/test/webrtc/.eslintrc.js
browser/components/places/PlacesUIUtils.jsm
browser/components/preferences/translation.js
browser/components/syncedtabs/test/browser/head.js
browser/components/syncedtabs/test/xpcshell/head.js
browser/modules/SocialService.jsm
testing/xpcshell/xpcshell.eslintrc.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -840,17 +840,17 @@ var BookmarksEventHandler = {
 
     if (aEvent.button == 2 || (aEvent.button == 0 && !modifKey))
       return;
 
     var target = aEvent.originalTarget;
     // If this event bubbled up from a menu or menuitem, close the menus.
     // Do this before opening tabs, to avoid hiding the open tabs confirm-dialog.
     if (target.localName == "menu" || target.localName == "menuitem") {
-      for (node = target.parentNode; node; node = node.parentNode) {
+      for (let node = target.parentNode; node; node = node.parentNode) {
         if (node.localName == "menupopup")
           node.hidePopup();
         else if (node.localName != "menu" &&
                  node.localName != "splitmenu" &&
                  node.localName != "hbox" &&
                  node.localName != "vbox" )
           break;
       }
@@ -1996,9 +1996,8 @@ var AutoShowBookmarksToolbar = {
     let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
     let area = placement && placement.area;
     if (area != CustomizableUI.AREA_BOOKMARKS)
       return;
 
     setToolbarVisibility(toolbar, true);
   }
 };
-
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -24,17 +24,16 @@ support-files =
   bug792517-2.html
   bug792517.html
   bug792517.sjs
   bug839103.css
   clipboard_pastefile.html
   contextmenu_common.js
   ctxmenu-image.png
   discovery.html
-  domplate_test.js
   download_page.html
   dummy_page.html
   feed_tab.html
   file_generic_favicon.ico
   file_with_favicon.html
   file_bug822367_1.html
   file_bug822367_1.js
   file_bug822367_2.html
--- a/browser/base/content/test/general/browser_bug409624.js
+++ b/browser/base/content/test/general/browser_bug409624.js
@@ -3,20 +3,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
                                   "resource://gre/modules/FormHistory.jsm");
 
 add_task(function* test() {
   // This test relies on the form history being empty to start with delete
   // all the items first.
-  yield new Promise(resolve => {
+  yield new Promise((resolve, reject) => {
     FormHistory.update({ op: "remove" },
                        { handleError(error) {
-                           do_throw("Error occurred updating form history: " + error);
+                           reject(error);
                          },
                          handleCompletion(reason) {
                            if (!reason) {
                              resolve();
                            } else {
                              reject();
                            }
                          },
--- a/browser/base/content/test/general/browser_bug553455.js
+++ b/browser/base/content/test/general/browser_bug553455.js
@@ -143,32 +143,32 @@ function waitForInstallDialog() {
   return Task.spawn(function* () {
     if (Preferences.get("xpinstall.customConfirmationUI", false)) {
       yield waitForNotification("addon-install-confirmation");
       return;
     }
 
     info("Waiting for install dialog");
 
-    yield new Promise(resolve => {
+    let window = yield new Promise(resolve => {
       Services.wm.addListener({
         onOpenWindow: function(aXULWindow) {
           Services.wm.removeListener(this);
-          resolve();
+          resolve(aXULWindow);
         },
         onCloseWindow: function(aXULWindow) {
         },
         onWindowTitleChange: function(aXULWindow, aNewTitle) {
         }
       });
     });
     info("Install dialog opened, waiting for focus");
 
-    let domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
-                              .getInterface(Ci.nsIDOMWindow);
+    let domwindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
+                          .getInterface(Ci.nsIDOMWindow);
     yield new Promise(resolve => {
       waitForFocus(function() {
         resolve();
       }, domwindow);
     });
     info("Saw install dialog");
     is(domwindow.document.location.href, XPINSTALL_URL, "Should have seen the right window open");
 
@@ -743,17 +743,16 @@ function test_localFile() {
     let notification = PopupNotifications.panel.childNodes[0];
     is(notification.id, "addon-install-failed-notification", "Should have seen the install fail");
     is(notification.getAttribute("label"),
        "This add-on could not be installed because it appears to be corrupt.",
        "Should have seen the right message");
 
     yield removeTab();
   });
-    path = CHROMEROOT + "corrupt.xpi";
 },
 
 function test_tabClose() {
   return Task.spawn(function* () {
     if (!Preferences.get("xpinstall.customConfirmationUI", false)) {
       runNextTest();
       return;
     }
--- a/browser/base/content/test/general/browser_sanitize-timespans.js
+++ b/browser/base/content/test/general/browser_sanitize-timespans.js
@@ -54,17 +54,17 @@ function countEntries(name, message, che
 
   var obj = {};
   if (name !== null)
     obj.fieldname = name;
 
   let count;
   FormHistory.count(obj, { handleResult: result => count = result,
                            handleError: function (error) {
-                             do_throw("Error occurred searching form history: " + error);
+                             throw new Error("Error occurred searching form history: " + error);
                              deferred.reject(error)
                            },
                            handleCompletion: function (reason) {
                              if (!reason) {
                                check(count, message);
                                deferred.resolve();
                              }
                            },
@@ -489,29 +489,29 @@ function setupHistory() {
 function* setupFormHistory() {
 
   function searchEntries(terms, params) {
     let deferred = Promise.defer();
 
     let results = [];
     FormHistory.search(terms, params, { handleResult: result => results.push(result),
                                         handleError: function (error) {
-                                          do_throw("Error occurred searching form history: " + error);
+                                          throw new Error("Error occurred searching form history: " + error);
                                           deferred.reject(error);
                                         },
                                         handleCompletion: function (reason) { deferred.resolve(results); }
                                       });
     return deferred.promise;
   }
 
   function update(changes)
   {
     let deferred = Promise.defer();
     FormHistory.update(changes, { handleError: function (error) {
-                                    do_throw("Error occurred searching form history: " + error);
+                                    throw new Error("Error occurred searching form history: " + error);
                                     deferred.reject(error);
                                   },
                                   handleCompletion: function (reason) { deferred.resolve(); }
                                 });
     return deferred.promise;
   }
 
   // Make sure we've got a clean DB to start with, then add the entries we'll be testing.
--- a/browser/base/content/test/general/browser_sanitizeDialog.js
+++ b/browser/base/content/test/general/browser_sanitizeDialog.js
@@ -897,17 +897,17 @@ function promiseAddFormEntryWithMinutesA
   let name = aMinutesAgo + "-minutes-ago";
 
   // Artifically age the entry to the proper vintage.
   let timestamp = now_uSec - (aMinutesAgo * kUsecPerMin);
 
   return new Promise((resolve, reject) =>
     FormHistory.update({ op: "add", fieldname: name, value: "dummy", firstUsed: timestamp },
                        { handleError: function (error) {
-                           do_throw("Error occurred updating form history: " + error);
+                           throw new Error("Error occurred updating form history: " + error);
                            reject();
                          },
                          handleCompletion: function (reason) {
                            resolve(name);
                          }
                        })
    )
 }
@@ -917,17 +917,17 @@ function promiseAddFormEntryWithMinutesA
  */
 function formNameExists(name)
 {
   return new Promise((resolve, reject) => {
     let count = 0;
     FormHistory.count({ fieldname: name },
                       { handleResult: result => count = result,
                         handleError: function (error) {
-                          do_throw("Error occurred searching form history: " + error);
+                          throw new Error("Error occurred searching form history: " + error);
                           reject(error);
                         },
                         handleCompletion: function (reason) {
                           if (!reason) {
                             resolve(count);
                           }
                         }
                       });
@@ -948,17 +948,17 @@ function* blankSlate() {
   yield new Promise((resolve, reject) => {
     FormHistory.update({op: "remove"}, {
       handleCompletion(reason) {
         if (!reason) {
           resolve();
         }
       },
       handleError(error) {
-        do_throw("Error occurred updating form history: " + error);
+        throw new Error("Error occurred updating form history: " + error);
         reject(error);
       }
     });
   });
 
   yield PlacesTestUtils.clearHistory();
 }
 
deleted file mode 100644
--- a/browser/base/content/test/general/domplate_test.js
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* 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/. */
-
-var doc;
-var div;
-var plate;
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-Components.utils.import("resource:///modules/domplate.jsm");
-
-function createDocument()
-{
-  doc.body.innerHTML = '<div id="first">no</div>';
-  doc.title = "Domplate Test";
-  setupDomplateTests();
-}
-
-function setupDomplateTests()
-{
-  ok(domplate, "domplate is defined");
-  plate = domplate({tag: domplate.DIV("Hello!")});
-  ok(plate, "template is defined");
-  div = doc.getElementById("first");
-  ok(div, "we have our div");
-  plate.tag.replace({}, div, template);
-  is(div.innerText, "Hello!", "Is the div's innerText replaced?");
-  finishUp();
-}
-
-function finishUp()
-{
-  gBrowser.removeCurrentTab();
-  finish();
-}
-
-function test()
-{
-  waitForExplicitFinish();
-  gBrowser.selectedTab = gBrowser.addTab();
-  gBrowser.selectedBrowser.addEventListener("load", function() {
-    gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
-    doc = content.document;
-    waitForFocus(createDocument, content);
-  }, true);
-
-  content.location = "data:text/html;charset=utf-8,domplate_test.js";
-}
-
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabPrompts/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "../../../../../testing/mochitest/browser.eslintrc.js"
+  ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabs/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "../../../../../testing/mochitest/browser.eslintrc.js"
+  ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/urlbar/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "../../../../../testing/mochitest/browser.eslintrc.js"
+  ]
+};
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/webrtc/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "../../../../../testing/mochitest/browser.eslintrc.js"
+  ]
+};
--- a/browser/components/places/PlacesUIUtils.jsm
+++ b/browser/components/places/PlacesUIUtils.jsm
@@ -975,17 +975,17 @@ this.PlacesUIUtils = {
   },
 
   openLiveMarkNodesInTabs:
   function PUIU_openLiveMarkNodesInTabs(aNode, aEvent, aView) {
     let window = aView.ownerWindow;
 
     PlacesUtils.livemarks.getLivemark({id: aNode.itemId})
       .then(aLivemark => {
-        urlsToOpen = [];
+        let urlsToOpen = [];
 
         let nodes = aLivemark.getNodesForContainer(aNode);
         for (let node of nodes) {
           urlsToOpen.push({uri: node.uri, isBookmark: false});
         }
 
         if (this.confirmOpenInTabs(urlsToOpen.length, window)) {
           this._openTabset(urlsToOpen, aEvent, window);
--- a/browser/components/preferences/translation.js
+++ b/browser/components/preferences/translation.js
@@ -233,17 +233,17 @@ var gTranslationExceptions = {
     this.onSiteSelected();
   },
 
   onSiteKeyPress: function(aEvent) {
     if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE)
       this.onSiteDeleted();
   },
 
-  onLanguageKeyPress: function() {
+  onLanguageKeyPress: function(aEvent) {
     if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE)
       this.onLanguageDeleted();
   },
 
   onWindowKeyPress: function(aEvent) {
     if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE)
       window.close();
   },
--- a/browser/components/syncedtabs/test/browser/head.js
+++ b/browser/components/syncedtabs/test/browser/head.js
@@ -2,16 +2,17 @@ const {classes: Cc, interfaces: Ci, util
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/Promise.jsm");
 
 
 // Load mocking/stubbing library, sinon
 // docs: http://sinonjs.org/docs/
+/* global sinon */
 let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
 loader.loadSubScript("resource://testing-common/sinon-1.16.1.js");
 
 registerCleanupFunction(function*() {
   // Cleanup window or the test runner will throw an error
   delete window.sinon;
   delete window.setImmediate;
   delete window.clearImmediate;
--- a/browser/components/syncedtabs/test/xpcshell/head.js
+++ b/browser/components/syncedtabs/test/xpcshell/head.js
@@ -19,11 +19,11 @@ let window = {
     setInterval: setInterval,
     clearTimeout: clearTimeout,
     clearinterval: clearInterval
 };
 let self = window;
 
 // Load mocking/stubbing library, sinon
 // docs: http://sinonjs.org/docs/
+/* global sinon */
 let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
 loader.loadSubScript("resource://testing-common/sinon-1.16.1.js");
-
--- a/browser/modules/SocialService.jsm
+++ b/browser/modules/SocialService.jsm
@@ -505,17 +505,17 @@ this.SocialService = {
       if (!data['origin']) {
         Cu.reportError("SocialService.manifestFromData directory service provided manifest without origin.");
         return null;
       }
       installOrigin = data.origin;
     }
     // force/fixup origin
     let URI = Services.io.newURI(installOrigin, null, null);
-    principal = Services.scriptSecurityManager.createCodebasePrincipal(URI, {});
+    let principal = Services.scriptSecurityManager.createCodebasePrincipal(URI, {});
     data.origin = principal.origin;
 
     // iconURL and name are required
     let providerHasFeatures = featureURLs.some(url => data[url]);
     if (!providerHasFeatures) {
       Cu.reportError("SocialService.manifestFromData manifest missing required urls.");
       return null;
     }
--- a/testing/xpcshell/xpcshell.eslintrc.js
+++ b/testing/xpcshell/xpcshell.eslintrc.js
@@ -7,25 +7,27 @@ module.exports = {
   // All globals made available in the test environment.
   "globals": {
     "add_task": false,
     "add_test": false,
     "Assert": false,
     "deepEqual": false,
     "do_check_eq": false,
     "do_check_false": false,
+    "do_check_matches": false,
     "do_check_neq": false,
     "do_check_null": false,
     "do_check_true": false,
     "do_execute_soon": false,
     "do_get_cwd": false,
     "do_get_file": false,
     "do_get_idle": false,
     "do_get_profile": false,
     "do_get_tempdir": false,
+    "do_load_manifest": false,
     "do_load_module": false,
     "do_parse_document": false,
     "do_print": false,
     "do_register_cleanup": false,
     "do_report_unexpected_exception": false,
     "do_test_finished": false,
     "do_test_pending": false,
     "do_throw": false,