From 632c7423fcb59d51ef8ef7794984c142967a793b Mon Sep 17 00:00:00 2001 From: mordax Date: Wed, 12 Dec 2018 14:56:54 +0000 Subject: [PATCH] Bug 1508983 - Enable ESLint for dom/base/test/chrome/ (manual changes) r=Standard8,smaug Differential Revision: https://phabricator.services.mozilla.com/D13129 --HG-- extra : moz-landing-system : lando --- .eslintignore | 6 +++++- dom/base/test/chrome/bug418986-1.js | 5 +++-- dom/base/test/chrome/cpows_child.js | 13 +++++++------ dom/base/test/chrome/custom_element_ep.js | 1 + dom/base/test/chrome/test_bug1339722.html | 6 +++--- dom/base/test/chrome/test_bug682305.html | 7 +++---- dom/base/test/chrome/test_bug914381.html | 6 +++--- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.eslintignore b/.eslintignore index c52c9c490948..7fa97c239d35 100644 --- a/.eslintignore +++ b/.eslintignore @@ -169,8 +169,12 @@ devtools/server/tests/unit/xpcshell_debugging_script.js dom/abort/** dom/animation/** dom/asmjscache/** -dom/base/** dom/battery/** +dom/base/*.* +dom/base/test/*.* +dom/base/test/unit/test_serializers_entities*.js +dom/base/test/unit_ipc/** +dom/base/test/jsmodules/** dom/bindings/** dom/broadcastchannel/** dom/browser-element/** diff --git a/dom/base/test/chrome/bug418986-1.js b/dom/base/test/chrome/bug418986-1.js index 1045891a2717..dbd74e62c055 100644 --- a/dom/base/test/chrome/bug418986-1.js +++ b/dom/base/test/chrome/bug418986-1.js @@ -1,9 +1,9 @@ +/* globals chromeWindow */ // The main test function. var test = function(isContent) { SimpleTest.waitForExplicitFinish(); - SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", - true]]}); + SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", true]]}); let { ww } = SpecialPowers.Services; window.chromeWindow = ww.activeWindow; @@ -33,6 +33,7 @@ var test = function(isContent) { // checkPair: tests if members of pair [a, b] are equal when evaluated. let checkPair = function(a, b) { + // eslint-disable-next-line no-eval is(eval(a), eval(b), a + " should be equal to " + b); }; diff --git a/dom/base/test/chrome/cpows_child.js b/dom/base/test/chrome/cpows_child.js index 248caf66d433..945d428d0eb3 100644 --- a/dom/base/test/chrome/cpows_child.js +++ b/dom/base/test/chrome/cpows_child.js @@ -1,6 +1,8 @@ +/* eslint-env mozilla/frame-script */ dump("loaded child cpow test\n"); Cu.importGlobalProperties(["XMLHttpRequest"]); +var is_remote; (function start() { [is_remote] = sendRpcMessage("cpows:is_remote"); @@ -175,17 +177,16 @@ function compartment_test(finish) { function testParentObject(obj) { let results = []; function is(a, b, msg) { results.push({ result: a === b ? "PASS" : "FAIL", message: msg }); } - function ok(x, msg) { results.push({ result: x ? "PASS" : "FAIL", message: msg }); } - + function ok1(x, msg) { results.push({ result: x ? "PASS" : "FAIL", message: msg }); } let cpowLocation = Cu.getRealmLocation(obj); - ok(/shared JSM global/.test(cpowLocation), + ok1(/shared JSM global/.test(cpowLocation), "child->parent CPOWs should live in the privileged junk scope: " + cpowLocation); is(obj(), 42, "child->parent CPOW is invokable"); try { obj.expando; - ok(false, "child->parent CPOW cannot access properties"); + ok1(false, "child->parent CPOW cannot access properties"); } catch (e) { - ok(true, "child->parent CPOW cannot access properties"); + ok1(true, "child->parent CPOW cannot access properties"); } return results; @@ -316,7 +317,7 @@ function cancel_test2(finish) { req.open("get", "http://example.com", false); req.send(null); - ok(fin == true, "XHR happened"); + ok(fin === true, "XHR happened"); fin1 = true; if (fin1 && fin2) finish(); diff --git a/dom/base/test/chrome/custom_element_ep.js b/dom/base/test/chrome/custom_element_ep.js index c9be76bef4d4..d933ecbbabb8 100644 --- a/dom/base/test/chrome/custom_element_ep.js +++ b/dom/base/test/chrome/custom_element_ep.js @@ -1,3 +1,4 @@ +/* globals finishTest */ class XFoo extends HTMLElement { constructor() { super(); diff --git a/dom/base/test/chrome/test_bug1339722.html b/dom/base/test/chrome/test_bug1339722.html index fec5f6bb7aec..0cc6d208c72e 100644 --- a/dom/base/test/chrome/test_bug1339722.html +++ b/dom/base/test/chrome/test_bug1339722.html @@ -23,6 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1339722 ChromeUtils.import("resource://gre/modules/Services.jsm"); const TOPIC = "http-on-useragent-request"; + let win; Services.obs.addObserver({ observe(subject, topic, data) { info("Got " + topic); @@ -30,13 +31,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1339722 // Query window proxy so it triggers DOMWindowCreated. let channel = subject.QueryInterface(Ci.nsIHttpChannel); - let win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy); + win = channel.notificationCallbacks.getInterface(Ci.mozIDOMWindowProxy); }, }, TOPIC); let docShell = SpecialPowers.wrap(window).docShell; docShell.chromeEventHandler.addEventListener("DOMWindowCreated", function handler(e) { - docShell.chromeEventHandler.removeEventListener("DOMWindowCreated", handler); let iframe = document.getElementById("testFrame"); is(e.target, iframe.contentDocument, "verify event target"); @@ -46,7 +46,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1339722 ok(!document.getElementById("testFrame"), "verify iframe removed"); SimpleTest.finish(); }, 0); - }); + }, {once: true}); SimpleTest.waitForExplicitFinish(); diff --git a/dom/base/test/chrome/test_bug682305.html b/dom/base/test/chrome/test_bug682305.html index 87c56c5a76bf..39ef45a1c1a9 100644 --- a/dom/base/test/chrome/test_bug682305.html +++ b/dom/base/test/chrome/test_bug682305.html @@ -27,8 +27,7 @@ SimpleTest.waitForExplicitFinish(); */ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -var ios = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService); + var contentSecManager = Cc["@mozilla.org/contentsecuritymanager;1"] .getService(Ci.nsIContentSecurityManager); @@ -36,7 +35,7 @@ var PROTOCOL_SCHEME = "jsproto"; function CustomChannel(uri, loadInfo) { - this.URI = this.originalURI = uri; + this.URI = this.originalURI = uri; this.loadInfo = loadInfo; } CustomChannel.prototype = { @@ -123,7 +122,7 @@ CustomProtocol.prototype = { return new CustomChannel(URI, loadInfo); }, newChannel: function newChannel(URI) { - return newChannel2(URI); + return this.newChannel2(URI); }, QueryInterface: ChromeUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIProtocolHandler]), }; diff --git a/dom/base/test/chrome/test_bug914381.html b/dom/base/test/chrome/test_bug914381.html index ad32dac67ba6..87e0c17bee3d 100644 --- a/dom/base/test/chrome/test_bug914381.html +++ b/dom/base/test/chrome/test_bug914381.html @@ -16,15 +16,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650776