Bug 1315402: Make toolkit/mozapps/update pass no-undef. r=jaws
authorDave Townsend <dtownsend@oxymoronical.com>
Fri, 04 Nov 2016 17:03:01 -0700
changeset 321938 02876b8cf2b0fa790cd608317c54c117a05994cd
parent 321937 677db8d8c8379fed3b2147e313ede8f314394ce3
child 321939 f8636cfef9241541c548e89b0e89f487380f496a
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersjaws
bugs1315402
milestone52.0a1
Bug 1315402: Make toolkit/mozapps/update pass no-undef. r=jaws This is mostly using the import-globals-from rule to pull in globals when the subscript loader is used. For a couple of files I've turned off no-undef altogether, these are files that are loaded by the subscript loader and depend on globals from the parent. MozReview-Commit-ID: 2ZzgpCQTTuu
testing/marionette/marionette.eslintrc.js
toolkit/mozapps/update/content/updates.js
toolkit/mozapps/update/tests/chrome/utils.js
toolkit/mozapps/update/tests/data/shared.js
toolkit/mozapps/update/tests/data/sharedUpdateXML.js
toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
toolkit/mozapps/update/tests/marionette/.eslintrc.js
toolkit/mozapps/update/tests/marionette/update_smoketest_ota_same_version.js
toolkit/mozapps/update/tests/marionette/update_smoketest_ota_simple.js
toolkit/mozapps/update/tests/marionette/update_test_ota_simple.js
toolkit/mozapps/update/tests/marionette/update_test_status.js
toolkit/mozapps/update/tests/unit_aus_update/head_update.js
toolkit/mozapps/update/tests/unit_base_updater/head_update.js
toolkit/mozapps/update/tests/unit_service_updater/head_update.js
new file mode 100644
--- /dev/null
+++ b/testing/marionette/marionette.eslintrc.js
@@ -0,0 +1,8 @@
+// Parent config file for all marionette files.
+module.exports = {
+  // All globals made available in the test environment.
+  "globals": {
+    "ok": false,
+    "is": false,
+  }
+};
--- a/toolkit/mozapps/update/content/updates.js
+++ b/toolkit/mozapps/update/content/updates.js
@@ -1,19 +1,22 @@
 /* -*- 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/. */
 
 'use strict';
 
+/* import-globals-from ../../../content/contentAreaUtils.js */
+
 // Firefox's macBrowserOverlay.xul includes scripts that define Cc, Ci, and Cr
 // so we have to use different names.
 const {classes: CoC, interfaces: CoI, results: CoR, utils: CoU} = Components;
 
+/* globals DownloadUtils, Services, AUSTLMY */
 CoU.import("resource://gre/modules/DownloadUtils.jsm", this);
 CoU.import("resource://gre/modules/Services.jsm", this);
 CoU.import("resource://gre/modules/UpdateTelemetry.jsm", this);
 
 const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 const PREF_APP_UPDATE_BACKGROUNDERRORS    = "app.update.backgroundErrors";
 const PREF_APP_UPDATE_CERT_ERRORS         = "app.update.cert.errors";
--- a/toolkit/mozapps/update/tests/chrome/utils.js
+++ b/toolkit/mozapps/update/tests/chrome/utils.js
@@ -64,16 +64,18 @@
  * prefHasUserValue (optional)
  *   For comparing the expected value defined by this property with the return
  *   value of prefHasUserValue using gPrefToCheck for the preference name in the
  *   checkPrefHasUserValue function.
  */
 
 'use strict';
 
+/* globals TESTS, runTest, finishTest */
+
 const { classes: Cc, interfaces: Ci, manager: Cm, results: Cr,
         utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/Services.jsm", this);
 
 const IS_MACOSX = ("nsILocalFileMac" in Ci);
 const IS_WIN = ("@mozilla.org/windows-registry-key;1" in Cc);
 
@@ -141,16 +143,17 @@ var gPrefToCheck;
 var gUseTestUpdater = false;
 
 // Set to true to log additional information for debugging. To log additional
 // information for an individual test set DEBUG_AUS_TEST to true in the test's
 // onload function.
 var DEBUG_AUS_TEST = true;
 
 const DATA_URI_SPEC = "chrome://mochitests/content/chrome/toolkit/mozapps/update/tests/data/";
+/* import-globals-from ../data/shared.js */
 Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
 
 /**
  * The current test in TESTS array.
  */
 this.__defineGetter__("gTest", function() {
   return TESTS[gTestCounter];
 });
--- a/toolkit/mozapps/update/tests/data/shared.js
+++ b/toolkit/mozapps/update/tests/data/shared.js
@@ -1,13 +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/. */
 
 /* Shared code for xpcshell and mochitests-chrome */
+/* eslint-disable no-undef */
 
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const PREF_APP_UPDATE_AUTO                 = "app.update.auto";
 const PREF_APP_UPDATE_BACKGROUNDERRORS     = "app.update.backgroundErrors";
 const PREF_APP_UPDATE_BACKGROUNDMAXERRORS  = "app.update.backgroundMaxErrors";
 const PREF_APP_UPDATE_CERT_REQUIREBUILTIN  = "app.update.cert.requireBuiltIn";
@@ -66,16 +67,17 @@ const UPDATE_SETTINGS_CONTENTS = "[Setti
 const PR_RDWR        = 0x04;
 const PR_CREATE_FILE = 0x08;
 const PR_TRUNCATE    = 0x20;
 
 const DEFAULT_UPDATE_VERSION = "999999.0";
 
 var gChannel;
 
+/* import-globals-from ../data/sharedUpdateXML.js */
 Services.scriptloader.loadSubScript(DATA_URI_SPEC + "sharedUpdateXML.js", this);
 
 const PERMS_FILE      = FileUtils.PERMS_FILE;
 const PERMS_DIRECTORY = FileUtils.PERMS_DIRECTORY;
 
 const MODE_WRONLY   = FileUtils.MODE_WRONLY;
 const MODE_CREATE   = FileUtils.MODE_CREATE;
 const MODE_APPEND   = FileUtils.MODE_APPEND;
--- a/toolkit/mozapps/update/tests/data/sharedUpdateXML.js
+++ b/toolkit/mozapps/update/tests/data/sharedUpdateXML.js
@@ -6,16 +6,18 @@
  * Helper functions for creating xml strings used by application update tests.
  *
  * !IMPORTANT - This file contains everything needed (along with dependencies)
  * by the updates.sjs file used by the mochitest-chrome tests. Since xpcshell
  * used by the http server is launched with -v 170 this file must not use
  * features greater than JavaScript 1.7.
  */
 
+/* eslint-disable no-undef */
+
 const FILE_SIMPLE_MAR = "simple.mar";
 const SIZE_SIMPLE_MAR = "1031";
 const MD5_HASH_SIMPLE_MAR    = "1f8c038577bb6845d94ccec4999113ee";
 const SHA1_HASH_SIMPLE_MAR   = "5d49a672c87f10f31d7e326349564a11272a028b";
 const SHA256_HASH_SIMPLE_MAR = "1aabbed5b1dd6e16e139afc5b43d479e254e0c26" +
                                "3c8fb9249c0a1bb93071c5fb";
 const SHA384_HASH_SIMPLE_MAR = "26615014ea034af32ef5651492d5f493f5a7a1a48522e" +
                                "d24c366442a5ec21d5ef02e23fb58d79729b8ca2f9541" +
--- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
+++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js
@@ -24,20 +24,25 @@
  * nsNSSComponent.cpp due to it using GetNativeCanonicalPath.
  * "!mMainThread" in nsThreadManager.cpp are due to using timers and it might be
  * possible to fix some or all of these in the test itself.
  * "NS_FAILED(rv)" in nsThreadUtils.cpp are due to using timers and it might be
  * possible to fix some or all of these in the test itself.
  */
 
 'use strict';
+/* eslint-disable no-undef */
 
 const { classes: Cc, interfaces: Ci, manager: Cm, results: Cr,
         utils: Cu } = Components;
 
+/* global INSTALL_LOCALE, MOZ_APP_NAME, BIN_SUFFIX, MOZ_APP_VENDOR */
+/* global MOZ_APP_BASENAME, APP_BIN_SUFFIX, APP_INFO_NAME, APP_INFO_VENDOR */
+/* global IS_WIN, IS_MACOSX, IS_UNIX, IS_ANDROID, IS_TOOLKIT_GONK */
+/* global MOZ_VERIFY_MAR_SIGNATURE, MOZ_VERIFY_MAR_SIGNATURE, IS_AUTHENTICODE_CHECK_ENABLED */
 load("../data/xpcshellConstantsPP.js");
 
 function getLogSuffix() {
   if (IS_WIN) {
     return "_win";
   }
   if (IS_MACOSX) {
     return "_mac";
@@ -188,16 +193,17 @@ var gEnvDyldLibraryPath;
 var gEnvLdLibraryPath;
 
 // Set to true to log additional information for debugging. To log additional
 // information for an individual test set DEBUG_AUS_TEST to true in the test's
 // run_test function.
 var DEBUG_AUS_TEST = true;
 
 const DATA_URI_SPEC = Services.io.newFileURI(do_get_file("../data", false)).spec;
+/* import-globals-from ../data/shared.js */
 Services.scriptloader.loadSubScript(DATA_URI_SPEC + "shared.js", this);
 
 var gTestFiles = [];
 var gTestDirs = [];
 
 // Common files for both successful and failed updates.
 var gTestFilesCommon = [
   {
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/update/tests/marionette/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+  "extends": [
+    "../../../../../testing/marionette/marionette.eslintrc.js"
+  ]
+};
--- a/toolkit/mozapps/update/tests/marionette/update_smoketest_ota_same_version.js
+++ b/toolkit/mozapps/update/tests/marionette/update_smoketest_ota_same_version.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* import-globals-from ../../../../../testing/marionette/harness/marionette/atoms/b2g_update_test.js */
+
 function testSameVersion() {
   let mozSettings = window.navigator.mozSettings;
   let forceSent = false;
 
   mozSettings.addObserver("gecko.updateStatus", function statusObserver(setting) {
     if (!forceSent) {
       return;
     }
--- a/toolkit/mozapps/update/tests/marionette/update_smoketest_ota_simple.js
+++ b/toolkit/mozapps/update/tests/marionette/update_smoketest_ota_simple.js
@@ -1,11 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* import-globals-from ../../../../../testing/marionette/harness/marionette/atoms/b2g_update_test.js */
+/* globals Services */
+
 function testForceCheck() {
   addChromeEventListener("update-available", function(evt) {
     isFinishUpdate(evt.detail);
     statusSettingIs("check-complete", testDownload);
     return true;
   });
   sendContentEvent("force-update-check");
 }
--- a/toolkit/mozapps/update/tests/marionette/update_test_ota_simple.js
+++ b/toolkit/mozapps/update/tests/marionette/update_test_ota_simple.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* import-globals-from ../../../../../testing/marionette/harness/marionette/atoms/b2g_update_test.js */
+
 function testForceCheck() {
   addChromeEventListener("update-available", function(evt) {
     let update = evt.detail;
     is(update.displayVersion, "99.0");
     is(update.isOSUpdate, false);
     statusSettingIs("check-complete", testDownload);
     return true;
   });
--- a/toolkit/mozapps/update/tests/marionette/update_test_status.js
+++ b/toolkit/mozapps/update/tests/marionette/update_test_status.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* import-globals-from ../../../../../testing/marionette/harness/marionette/atoms/b2g_update_test.js */
+
 const TEST_URL = "http://localhost";
 
 setPref("b2g.update.apply-idle-timeout", 0);
 setPref("app.update.backgroundErrors", 0);
 setPref("app.update.backgroundMaxErrors", 100);
 
 function forceCheckAndTestStatus(status, next) {
   let mozSettings = window.navigator.mozSettings;
--- a/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
@@ -1,7 +1,8 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const IS_SERVICE_TEST = false;
 
+/* import-globals-from ../data/xpcshellUtilsAUS.js */
 load("../data/xpcshellUtilsAUS.js");
--- a/toolkit/mozapps/update/tests/unit_base_updater/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/head_update.js
@@ -1,7 +1,8 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const IS_SERVICE_TEST = false;
 
+/* import-globals-from ../data/xpcshellUtilsAUS.js */
 load("../data/xpcshellUtilsAUS.js");
--- a/toolkit/mozapps/update/tests/unit_service_updater/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_service_updater/head_update.js
@@ -1,7 +1,8 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const IS_SERVICE_TEST = true;
 
+/* import-globals-from ../data/xpcshellUtilsAUS.js */
 load("../data/xpcshellUtilsAUS.js");