Bug 1504890 - Restrict usage of event global r=Standard8,ahal
authorMark Striemer <mstriemer@mozilla.com>
Tue, 06 Nov 2018 16:35:05 -0600
changeset 444987 527bceeb871a6de90e3266fa1e39151467d064a2
parent 444986 cd2a304f5fe93ae879d51a840adf13d493780bae
child 445039 43772d7ccfc4e32ad25283c5e3224995016e7367
push id109660
push usermstriemer@mozilla.com
push dateWed, 07 Nov 2018 21:28:55 +0000
treeherdermozilla-inbound@527bceeb871a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, ahal
bugs1504890
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 1504890 - Restrict usage of event global r=Standard8,ahal The event global is only available on Nightly so it should not be used. Differential Revision: https://phabricator.services.mozilla.com/D10984 Differential Revision: https://phabricator.services.mozilla.com/D11125
testing/marionette/action.js
testing/marionette/event.js
testing/marionette/interaction.js
testing/marionette/listener.js
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
tools/lint/eslint/eslint-plugin-mozilla/package.json
--- a/testing/marionette/action.js
+++ b/testing/marionette/action.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/. */
 
 /* eslint no-dupe-keys:off */
+/* eslint-disable no-restricted-globals */
 
 "use strict";
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.import("chrome://marionette/content/assert.js");
 const {element} = ChromeUtils.import("chrome://marionette/content/element.js", {});
 const {
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -2,16 +2,17 @@
  * 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/. */
 
 /** Provides functionality for creating and sending DOM events. */
 this.event = {};
 
 "use strict";
 /* global content, is */
+/* eslint-disable no-restricted-globals */
 
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.import("chrome://marionette/content/element.js");
 
 const dblclickTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
 
 //  Max interval between two clicks that should result in a dblclick (in ms)
@@ -315,16 +316,17 @@ function computeKeyCodeFromChar_(char, w
     case "\n":
       return KeyboardEvent.DOM_VK_RETURN;
 
     default:
       return 0;
   }
 }
 /* eslint-enable */
+/* eslint-disable no-restricted-globals */
 
 /**
  * Returns true if the given key should cause keypress event when widget
  * handles the native key event.  Otherwise, false.
  *
  * The key code should be one of consts of KeyboardEvent.DOM_VK_*,
  * or a key name begins with "VK_", or a character.
  */
@@ -764,16 +766,17 @@ function expectEvent_(expectedTarget, ex
     is(pass, true, `${testName} ${type} event target ${seenEvent ? "twice" : ""}`);
     seenEvent = true;
   };
 
   expectedTarget.addEventListener(type, handler);
   return handler;
 }
 /* eslint-enable */
+/* eslint-disable no-restricted-globals */
 
 /**
  * Check if the event was fired or not. The provided event handler will
  * be removed.
  */
 function checkExpectedEvent_(
     expectedTarget, expectedEvent, eventHandler, testName) {
 
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.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/. */
 
 "use strict";
+/* eslint-disable no-restricted-globals */
 
 ChromeUtils.import("resource://gre/modules/Preferences.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 ChromeUtils.import("chrome://marionette/content/accessibility.js");
 ChromeUtils.import("chrome://marionette/content/atom.js");
 ChromeUtils.import("chrome://marionette/content/element.js");
 const {
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -1,14 +1,15 @@
 /* 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/. */
 
 /* eslint-env mozilla/frame-script */
 /* global XPCNativeWrapper */
+/* eslint-disable no-restricted-globals */
 
 "use strict";
 
 const winUtil = content.windowUtils;
 
 ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -288,16 +288,19 @@ module.exports = {
     "no-nested-ternary": "error",
 
     // Use {} instead of new Object()
     "no-new-object": "error",
 
     // Dissallow use of new wrappers
     "no-new-wrappers": "error",
 
+    // Disallow use of event global.
+    "no-restricted-globals": ["error", "event"],
+
     // Disallows unnecessary `return await ...`.
     "no-return-await": "error",
 
     // No unnecessary comparisons
     "no-self-compare": "error",
 
     // No comma sequenced statements
     "no-sequences": "error",
--- a/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
@@ -1,11 +1,11 @@
 {
   "name": "eslint-plugin-mozilla",
-  "version": "0.16.1",
+  "version": "0.16.2",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
     "acorn": {
       "version": "5.7.1",
       "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz",
       "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==",
       "dev": true
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -1,11 +1,11 @@
 {
   "name": "eslint-plugin-mozilla",
-  "version": "0.16.1",
+  "version": "0.16.2",
   "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
   "keywords": [
     "eslint",
     "eslintplugin",
     "eslint-plugin",
     "mozilla",
     "firefox"
   ],