Bug 1532934 - Enable ESLint for dom/url (manual changes). r=Standard8,baku
authordanielleleb <danielleleb12@gmail.com>
Tue, 12 Mar 2019 22:00:01 +0000
changeset 524607 e263d6805e145e9ad6d290dd2f8f8d7d2bbb2ae5
parent 524606 f87b1c69a88d995473d2351fa55247774be9c395
child 524608 79dd6b92c913d33ee1ac7b41d49f3459e6decfa1
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, baku
bugs1532934
milestone67.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 1532934 - Enable ESLint for dom/url (manual changes). r=Standard8,baku Differential Revision: https://phabricator.services.mozilla.com/D22737
.eslintignore
dom/url/tests/browser_download_after_revoke.js
dom/url/tests/file_url.jsm
dom/url/tests/jsm_url_worker.js
dom/url/tests/test_url.html
dom/url/tests/test_url_data.html
dom/url/tests/urlApi_worker.js
dom/url/tests/urlSearchParams_commons.js
dom/url/tests/urlSearchParams_worker.js
dom/url/tests/url_worker.js
--- a/.eslintignore
+++ b/.eslintignore
@@ -199,17 +199,16 @@ dom/security/test/mixedcontentblocker/**
 dom/security/test/sri/**
 dom/serviceworkers/**
 dom/smil/**
 dom/svg/**
 
 dom/tests/html/**
 dom/tests/mochitest/**
 dom/u2f/**
-dom/url/**
 dom/vr/**
 dom/webauthn/**
 dom/webgpu/**
 dom/websocket/**
 dom/workers/**
 dom/worklet/**
 dom/xbl/**
 dom/xhr/**
--- a/dom/url/tests/browser_download_after_revoke.js
+++ b/dom/url/tests/browser_download_after_revoke.js
@@ -8,21 +8,21 @@ function test() {
     var listener = {
       onOpenWindow(aXULWindow) {
         info("Download window shown...");
         Services.wm.removeListener(listener);
 
         function downloadOnLoad() {
           domwindow.removeEventListener("load", downloadOnLoad, true);
 
-	  is(domwindow.document.location.href, "chrome://mozapps/content/downloads/unknownContentType.xul", "Download page appeared");
+          is(domwindow.document.location.href, "chrome://mozapps/content/downloads/unknownContentType.xul", "Download page appeared");
 
-	  domwindow.close();
+          domwindow.close();
           gBrowser.removeTab(gBrowser.selectedTab);
-	  finish();
+          finish();
         }
 
         var domwindow = aXULWindow.docShell.domWindow;
         domwindow.addEventListener("load", downloadOnLoad, true);
       },
       onCloseWindow(aXULWindow) {},
     };
 
--- a/dom/url/tests/file_url.jsm
+++ b/dom/url/tests/file_url.jsm
@@ -5,17 +5,17 @@ function checkFromJSM(ok, is) {
 
   var url = new URL("http://www.example.com");
   is(url.href, "http://www.example.com/", "JSM should have URL");
 
   var url2 = new URL("/foobar", url);
   is(url2.href, "http://www.example.com/foobar", "JSM should have URL - based on another URL");
 
   var blob = new Blob(["a"]);
-  var url = URL.createObjectURL(blob);
+  url = URL.createObjectURL(blob);
   ok(url, "URL is created!");
 
   var u = new URL(url);
   ok(u, "URL created");
   is(u.origin, "null", "Url doesn't have an origin if created in a JSM");
 
   URL.revokeObjectURL(url);
   ok(true, "URL is revoked");
--- a/dom/url/tests/jsm_url_worker.js
+++ b/dom/url/tests/jsm_url_worker.js
@@ -1,20 +1,22 @@
+/* eslint-env worker */
+
 onmessage = function(event) {
   if (event.data != 0) {
     var worker = new Worker("jsm_url_worker.js");
-    worker.onmessage = function(event) {
-      postMessage(event.data);
+    worker.onmessage = function(ev) {
+      postMessage(ev.data);
     };
 
     worker.postMessage(event.data - 1);
     return;
   }
 
-  status = false;
+  let status = false;
   try {
     if ((URL instanceof Object)) {
       status = true;
     }
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "URL object:" + URL});
@@ -44,38 +46,38 @@ onmessage = function(event) {
     URL.revokeObjectURL(url);
     status = true;
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "Blob Revoke URL"});
 
   status = false;
-  var url = null;
+  url = null;
   try {
     url = URL.createObjectURL(true);
   } catch (e) {
     status = true;
   }
 
   postMessage({type: "status", status, msg: "CreateObjectURL should fail if the arg is not a blob"});
 
   status = false;
-  var url = null;
+  url = null;
   try {
     url = URL.createObjectURL(blob);
     status = true;
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "Blob URL2:" + url});
 
   status = false;
   try {
-    URL.createObjectURL(new Object());
+    URL.createObjectURL({});
   } catch (e) {
     status = true;
   }
 
   postMessage({type: "status", status, msg: "Exception wanted" });
 
   postMessage({type: "url", url});
 
--- a/dom/url/tests/test_url.html
+++ b/dom/url/tests/test_url.html
@@ -287,17 +287,17 @@
     if ("password" in test) is(url.password, test.password, "password");
     if ("host" in test) is(url.host, test.host, "host");
     if ("hostname" in test) is(url.hostname, test.hostname, "hostname");
     if ("port" in test) is(url.port, test.port, "port");
     if ("pathname" in test) is(url.pathname, test.pathname, "pathname");
     if ("search" in test) is(url.search, test.search, "search");
     if ("hash" in test) is(url.hash, test.hash, "hash");
 
-    if ("skip_setters" in test && test.skip_setters == false) {
+    if ("skip_setters" in test && test.skip_setters === false) {
       info("Skip setter methods for URL: " + test);
       continue;
     }
 
     url = new URL("https://www.example.net/what#foo?bar");
     ok(url, "Url exists!");
 
     if ("href" in test) url.href = test.href;
@@ -426,18 +426,18 @@
     is(url.href, "ftp://tmp/test");
 
     url = new URL("scheme://tmp\\test", base);
     is(url.href, "scheme://tmp\\test");
   </script>
 
   <script>
     /** Test for Bug 1275746 **/
-    SimpleTest.doesThrow(() => { var url = new URL("http:"); }, "http: is not a valid URL");
-    SimpleTest.doesThrow(() => { var url = new URL("http:///"); }, "http: is not a valid URL");
+    SimpleTest.doesThrow(() => { new URL("http:"); }, "http: is not a valid URL");
+    SimpleTest.doesThrow(() => { new URL("http:///"); }, "http: is not a valid URL");
 
     var url = new URL("file:");
     is(url.href, "file:///", "Parsing file: should work.");
 
     url = new URL("file:///");
     is(url.href, "file:///", "Parsing file:/// should work.");
   </script>
 
--- a/dom/url/tests/test_url_data.html
+++ b/dom/url/tests/test_url_data.html
@@ -11,27 +11,29 @@
 
 <script type="application/javascript">
 
 var base = new URL("data:text/plain,");
 
 base.protocol = "chrome:";
 is(base.protocol, "data:", "The protocol should not change from data to chrome.");
 
+let relative;
+
 try {
-  var relative = new URL("a", base);
+  relative = new URL("a", base);
   ok(false, "Relative URL from a data:text/plain should not work.");
 } catch (e) {
   ok(true, "Relative URL from a data:text/plain should not work.");
 }
 
 base.protocol = "http:";
 ok(true, "Protocol: http changed");
 is(base.href, "http://text/plain,", "Base URL is correct");
 
-var relative = new URL("a", base);
+relative = new URL("a", base);
 ok(relative, "This works.");
 is(relative.href, "http://text/a", "Relative URL is correct");
 
 </script>
 
 </body>
 </html>
--- a/dom/url/tests/urlApi_worker.js
+++ b/dom/url/tests/urlApi_worker.js
@@ -1,27 +1,33 @@
+/* eslint-env worker */
+
+
 function ok(a, msg) {
   dump("OK: " + !!a + "  =>  " + a + " " + msg + "\n");
   postMessage({type: "status", status: !!a, msg: a + ": " + msg });
 }
 
 function is(a, b, msg) {
   dump("IS: " + (a === b) + "  =>  " + a + " | " + b + " " + msg + "\n");
   postMessage({type: "status", status: a === b, msg: a + " === " + b + ": " + msg });
 }
 
+// eslint-disable-next-line complexity
 onmessage = function() {
-  status = false;
+  let status = false;
   try {
     if ((URL instanceof Object)) {
       status = true;
     }
   } catch (e) {
   }
 
+  ok(status, "URL in workers \\o/");
+
   var tests = [
     { url: "http://www.abc.com",
       base: undefined,
       error: false,
       href: "http://www.abc.com/",
       origin: "http://www.abc.com",
       protocol: "http:",
       username: "",
--- a/dom/url/tests/urlSearchParams_commons.js
+++ b/dom/url/tests/urlSearchParams_commons.js
@@ -1,8 +1,10 @@
+/* import-globals-from urlSearchParams_worker.js */
+
 function testSimpleURLSearchParams() {
   var u = new URLSearchParams();
   ok(u, "URLSearchParams created");
   is(u.has("foo"), false, "URLSearchParams.has(foo)");
   is(u.get("foo"), null, "URLSearchParams.get(foo)");
   is(u.getAll("foo").length, 0, "URLSearchParams.getAll(foo)");
 
   u.append("foo", "bar");
@@ -87,17 +89,17 @@ function testParserURLSearchParams() {
     { input: "?=b", data: { "": ["b"] } },
   ];
 
   for (var i = 0; i < checks.length; ++i) {
     var u = new URLSearchParams(checks[i].input);
 
     var count = 0;
     for (var key in checks[i].data) {
-      ++count;
+      count = count + 1;
       ok(u.has(key), "key " + key + " found");
 
       var all = u.getAll(key);
       is(all.length, checks[i].data[key].length, "same number of elements");
 
       for (var k = 0; k < all.length; ++k) {
         is(all[k], checks[i].data[key][k], "value matches");
       }
--- a/dom/url/tests/urlSearchParams_worker.js
+++ b/dom/url/tests/urlSearchParams_worker.js
@@ -1,8 +1,10 @@
+/* eslint-env worker */
+
 importScripts("urlSearchParams_commons.js");
 
 function ok(a, msg) {
   dump("OK: " + !!a + "  =>  " + a + " " + msg + "\n");
   postMessage({type: "status", status: !!a, msg: a + ": " + msg });
 }
 
 function is(a, b, msg) {
@@ -25,17 +27,17 @@ function runTest() {
     return;
   }
 
   var test = tests.shift();
   test();
 }
 
 onmessage = function() {
-  status = false;
+  let status = false;
   try {
     if ((URLSearchParams instanceof Object)) {
       status = true;
     }
   } catch (e) {
   }
   ok(status, "URLSearchParams in workers \\o/");
 
--- a/dom/url/tests/url_worker.js
+++ b/dom/url/tests/url_worker.js
@@ -1,20 +1,22 @@
+/* eslint-env worker */
+
 onmessage = function(event) {
   if (event.data != 0) {
     var worker = new Worker("url_worker.js");
-    worker.onmessage = function(event) {
-      postMessage(event.data);
+    worker.onmessage = function(ev) {
+      postMessage(ev.data);
     };
 
     worker.postMessage(event.data - 1);
     return;
   }
 
-  status = false;
+  let status = false;
   try {
     if ((URL instanceof Object)) {
       status = true;
     }
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "URL object:" + URL});
@@ -25,17 +27,17 @@ onmessage = function(event) {
     blob = new Blob([]);
     status = true;
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "Blob:" + blob});
 
   status = false;
-  var url = null;
+  let url = null;
   try {
     url = URL.createObjectURL(blob);
     status = true;
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "Blob URL:" + url});
 
@@ -44,46 +46,46 @@ onmessage = function(event) {
     URL.revokeObjectURL(url);
     status = true;
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "Blob Revoke URL"});
 
   status = false;
-  var url = null;
+  url = null;
   try {
     url = URL.createObjectURL(true);
   } catch (e) {
     status = true;
   }
 
   postMessage({type: "status", status, msg: "CreateObjectURL should fail if the arg is not a blob"});
 
   status = false;
-  var url = null;
+  url = null;
   try {
     url = URL.createObjectURL(blob);
     status = true;
   } catch (e) {
   }
 
   postMessage({type: "status", status, msg: "Blob URL2:" + url});
   postMessage({type: "url", url});
 
   status = false;
   try {
-    URL.createObjectURL(new Object());
+    URL.createObjectURL({});
   } catch (e) {
     status = true;
   }
 
   postMessage({type: "status", status, msg: "Exception wanted" });
 
-  var blob = new Blob([123]);
+  blob = new Blob([123]);
   var uri = URL.createObjectURL(blob);
   postMessage({type: "status", status: !!uri,
                msg: "The URI has been generated from the blob"});
 
   var u = new URL(uri);
   postMessage({type: "status", status: u.origin == "http://mochi.test:8888",
                msg: "The URL generated from a blob URI has an origin."});