Bug 1532934 - Enable ESLint for dom/url (manual changes). r=Standard8,baku

Differential Revision: https://phabricator.services.mozilla.com/D22737

--HG--
extra : moz-landing-system : lando
This commit is contained in:
danielleleb 2019-03-12 22:00:01 +00:00
parent 65d7066adf
commit 85f131dba4
10 changed files with 42 additions and 27 deletions

View file

@ -204,7 +204,6 @@ dom/svg/**
dom/tests/html/** dom/tests/html/**
dom/tests/mochitest/** dom/tests/mochitest/**
dom/u2f/** dom/u2f/**
dom/url/**
dom/vr/** dom/vr/**
dom/webauthn/** dom/webauthn/**
dom/webgpu/** dom/webgpu/**

View file

@ -13,11 +13,11 @@ function test() {
function downloadOnLoad() { function downloadOnLoad() {
domwindow.removeEventListener("load", downloadOnLoad, true); 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); gBrowser.removeTab(gBrowser.selectedTab);
finish(); finish();
} }
var domwindow = aXULWindow.docShell.domWindow; var domwindow = aXULWindow.docShell.domWindow;

View file

@ -10,7 +10,7 @@ function checkFromJSM(ok, is) {
is(url2.href, "http://www.example.com/foobar", "JSM should have URL - based on another URL"); is(url2.href, "http://www.example.com/foobar", "JSM should have URL - based on another URL");
var blob = new Blob(["a"]); var blob = new Blob(["a"]);
var url = URL.createObjectURL(blob); url = URL.createObjectURL(blob);
ok(url, "URL is created!"); ok(url, "URL is created!");
var u = new URL(url); var u = new URL(url);

View file

@ -1,15 +1,17 @@
/* eslint-env worker */
onmessage = function(event) { onmessage = function(event) {
if (event.data != 0) { if (event.data != 0) {
var worker = new Worker("jsm_url_worker.js"); var worker = new Worker("jsm_url_worker.js");
worker.onmessage = function(event) { worker.onmessage = function(ev) {
postMessage(event.data); postMessage(ev.data);
}; };
worker.postMessage(event.data - 1); worker.postMessage(event.data - 1);
return; return;
} }
status = false; let status = false;
try { try {
if ((URL instanceof Object)) { if ((URL instanceof Object)) {
status = true; status = true;
@ -49,7 +51,7 @@ onmessage = function(event) {
postMessage({type: "status", status, msg: "Blob Revoke URL"}); postMessage({type: "status", status, msg: "Blob Revoke URL"});
status = false; status = false;
var url = null; url = null;
try { try {
url = URL.createObjectURL(true); url = URL.createObjectURL(true);
} catch (e) { } catch (e) {
@ -59,7 +61,7 @@ onmessage = function(event) {
postMessage({type: "status", status, msg: "CreateObjectURL should fail if the arg is not a blob"}); postMessage({type: "status", status, msg: "CreateObjectURL should fail if the arg is not a blob"});
status = false; status = false;
var url = null; url = null;
try { try {
url = URL.createObjectURL(blob); url = URL.createObjectURL(blob);
status = true; status = true;
@ -70,7 +72,7 @@ onmessage = function(event) {
status = false; status = false;
try { try {
URL.createObjectURL(new Object()); URL.createObjectURL({});
} catch (e) { } catch (e) {
status = true; status = true;
} }

View file

@ -292,7 +292,7 @@
if ("search" in test) is(url.search, test.search, "search"); if ("search" in test) is(url.search, test.search, "search");
if ("hash" in test) is(url.hash, test.hash, "hash"); 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); info("Skip setter methods for URL: " + test);
continue; continue;
} }
@ -431,8 +431,8 @@
<script> <script>
/** Test for Bug 1275746 **/ /** Test for Bug 1275746 **/
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(() => { var url = 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:"); var url = new URL("file:");
is(url.href, "file:///", "Parsing file: should work."); is(url.href, "file:///", "Parsing file: should work.");

View file

@ -16,8 +16,10 @@ var base = new URL("data:text/plain,");
base.protocol = "chrome:"; base.protocol = "chrome:";
is(base.protocol, "data:", "The protocol should not change from data to chrome."); is(base.protocol, "data:", "The protocol should not change from data to chrome.");
let relative;
try { try {
var relative = new URL("a", base); relative = new URL("a", base);
ok(false, "Relative URL from a data:text/plain should not work."); ok(false, "Relative URL from a data:text/plain should not work.");
} catch (e) { } catch (e) {
ok(true, "Relative URL from a data:text/plain should not work."); ok(true, "Relative URL from a data:text/plain should not work.");
@ -27,7 +29,7 @@ base.protocol = "http:";
ok(true, "Protocol: http changed"); ok(true, "Protocol: http changed");
is(base.href, "http://text/plain,", "Base URL is correct"); 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."); ok(relative, "This works.");
is(relative.href, "http://text/a", "Relative URL is correct"); is(relative.href, "http://text/a", "Relative URL is correct");

View file

@ -1,3 +1,6 @@
/* eslint-env worker */
function ok(a, msg) { function ok(a, msg) {
dump("OK: " + !!a + " => " + a + " " + msg + "\n"); dump("OK: " + !!a + " => " + a + " " + msg + "\n");
postMessage({type: "status", status: !!a, msg: a + ": " + msg }); postMessage({type: "status", status: !!a, msg: a + ": " + msg });
@ -8,8 +11,9 @@ function is(a, b, msg) {
postMessage({type: "status", status: a === b, msg: a + " === " + b + ": " + msg }); postMessage({type: "status", status: a === b, msg: a + " === " + b + ": " + msg });
} }
// eslint-disable-next-line complexity
onmessage = function() { onmessage = function() {
status = false; let status = false;
try { try {
if ((URL instanceof Object)) { if ((URL instanceof Object)) {
status = true; status = true;
@ -17,6 +21,8 @@ onmessage = function() {
} catch (e) { } catch (e) {
} }
ok(status, "URL in workers \\o/");
var tests = [ var tests = [
{ url: "http://www.abc.com", { url: "http://www.abc.com",
base: undefined, base: undefined,

View file

@ -1,3 +1,5 @@
/* import-globals-from urlSearchParams_worker.js */
function testSimpleURLSearchParams() { function testSimpleURLSearchParams() {
var u = new URLSearchParams(); var u = new URLSearchParams();
ok(u, "URLSearchParams created"); ok(u, "URLSearchParams created");
@ -92,7 +94,7 @@ function testParserURLSearchParams() {
var count = 0; var count = 0;
for (var key in checks[i].data) { for (var key in checks[i].data) {
++count; count = count + 1;
ok(u.has(key), "key " + key + " found"); ok(u.has(key), "key " + key + " found");
var all = u.getAll(key); var all = u.getAll(key);

View file

@ -1,3 +1,5 @@
/* eslint-env worker */
importScripts("urlSearchParams_commons.js"); importScripts("urlSearchParams_commons.js");
function ok(a, msg) { function ok(a, msg) {
@ -30,7 +32,7 @@ function runTest() {
} }
onmessage = function() { onmessage = function() {
status = false; let status = false;
try { try {
if ((URLSearchParams instanceof Object)) { if ((URLSearchParams instanceof Object)) {
status = true; status = true;

View file

@ -1,15 +1,17 @@
/* eslint-env worker */
onmessage = function(event) { onmessage = function(event) {
if (event.data != 0) { if (event.data != 0) {
var worker = new Worker("url_worker.js"); var worker = new Worker("url_worker.js");
worker.onmessage = function(event) { worker.onmessage = function(ev) {
postMessage(event.data); postMessage(ev.data);
}; };
worker.postMessage(event.data - 1); worker.postMessage(event.data - 1);
return; return;
} }
status = false; let status = false;
try { try {
if ((URL instanceof Object)) { if ((URL instanceof Object)) {
status = true; status = true;
@ -30,7 +32,7 @@ onmessage = function(event) {
postMessage({type: "status", status, msg: "Blob:" + blob}); postMessage({type: "status", status, msg: "Blob:" + blob});
status = false; status = false;
var url = null; let url = null;
try { try {
url = URL.createObjectURL(blob); url = URL.createObjectURL(blob);
status = true; status = true;
@ -49,7 +51,7 @@ onmessage = function(event) {
postMessage({type: "status", status, msg: "Blob Revoke URL"}); postMessage({type: "status", status, msg: "Blob Revoke URL"});
status = false; status = false;
var url = null; url = null;
try { try {
url = URL.createObjectURL(true); url = URL.createObjectURL(true);
} catch (e) { } catch (e) {
@ -59,7 +61,7 @@ onmessage = function(event) {
postMessage({type: "status", status, msg: "CreateObjectURL should fail if the arg is not a blob"}); postMessage({type: "status", status, msg: "CreateObjectURL should fail if the arg is not a blob"});
status = false; status = false;
var url = null; url = null;
try { try {
url = URL.createObjectURL(blob); url = URL.createObjectURL(blob);
status = true; status = true;
@ -71,14 +73,14 @@ onmessage = function(event) {
status = false; status = false;
try { try {
URL.createObjectURL(new Object()); URL.createObjectURL({});
} catch (e) { } catch (e) {
status = true; status = true;
} }
postMessage({type: "status", status, msg: "Exception wanted" }); postMessage({type: "status", status, msg: "Exception wanted" });
var blob = new Blob([123]); blob = new Blob([123]);
var uri = URL.createObjectURL(blob); var uri = URL.createObjectURL(blob);
postMessage({type: "status", status: !!uri, postMessage({type: "status", status: !!uri,
msg: "The URI has been generated from the blob"}); msg: "The URI has been generated from the blob"});