forked from mirrors/gecko-dev
Bug 1508991 - Enable ESLint for dom/manifest/ (manual changes) r=Standard8,Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D13208 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d252be35ef
commit
7e1563241b
18 changed files with 81 additions and 103 deletions
|
|
@ -191,7 +191,6 @@ dom/grid/**
|
|||
dom/html/**
|
||||
dom/jsurl/**
|
||||
dom/localstorage/**
|
||||
dom/manifest/**
|
||||
dom/media/test/**
|
||||
dom/media/tests/**
|
||||
dom/media/webaudio/**
|
||||
|
|
|
|||
|
|
@ -20,17 +20,11 @@
|
|||
/* exported EXPORTED_SYMBOLS*/
|
||||
/* globals Components */
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu,
|
||||
interfaces: Ci,
|
||||
classes: Cc,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
|
||||
const netutil = Cc["@mozilla.org/network/util;1"]
|
||||
.getService(Ci.nsINetUtil);
|
||||
|
||||
function ImageObjectProcessor(aConsole, aExtractor) {
|
||||
this.console = aConsole;
|
||||
|
|
@ -92,7 +86,7 @@ ImageObjectProcessor.prototype.process = function(
|
|||
};
|
||||
let value = extractor.extractValue(spec);
|
||||
if (value) {
|
||||
value = netutil.parseRequestContentType(value, charset, hadCharset);
|
||||
value = Services.netUtils.parseRequestContentType(value, charset, hadCharset);
|
||||
}
|
||||
return value || undefined;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const { ManifestObtainer } =
|
||||
ChromeUtils.import("resource://gre/modules/ManifestObtainer.jsm", {});
|
||||
const { ManifestIcons } =
|
||||
|
|
|
|||
|
|
@ -3,9 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
/* globals Components, Task, PromiseMessage */
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
|
||||
var ManifestFinder = {// jshint ignore:line
|
||||
|
|
|
|||
|
|
@ -1,11 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
const {
|
||||
utils: Cu,
|
||||
classes: Cc,
|
||||
interfaces: Ci,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
|
||||
var ManifestIcons = {
|
||||
|
|
@ -22,7 +16,7 @@ var ManifestIcons = {
|
|||
},
|
||||
|
||||
async contentFetchIcon(aWindow, manifest, iconSize) {
|
||||
return await getIcon(aWindow, toIconArray(manifest.icons), iconSize);
|
||||
return getIcon(aWindow, toIconArray(manifest.icons), iconSize);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,16 +25,9 @@
|
|||
*/
|
||||
/* globals Components, Task, PromiseMessage, XPCOMUtils, ManifestProcessor, BrowserUtils*/
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu,
|
||||
classes: Cc,
|
||||
interfaces: Ci,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/ManifestProcessor.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "BrowserUtils", // jshint ignore:line
|
||||
"resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
var ManifestObtainer = { // jshint ignore:line
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@
|
|||
*/
|
||||
/* globals Components, ValueExtractor, ImageObjectProcessor, ConsoleAPI*/
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
|
||||
const displayModes = new Set(["fullscreen", "standalone", "minimal-ui",
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@
|
|||
*/
|
||||
/* globals Components*/
|
||||
"use strict";
|
||||
const {
|
||||
classes: Cc,
|
||||
interfaces: Ci,
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const { ManifestObtainer } = ChromeUtils.import("resource://gre/modules/Manifest
|
|||
const defaultURL = new URL("http://example.org/browser/dom/manifest/test/resource.sjs");
|
||||
defaultURL.searchParams.set("Content-Type", "application/manifest+json");
|
||||
|
||||
const manifest = JSON.stringify({
|
||||
const manifestMock = JSON.stringify({
|
||||
icons: [{
|
||||
sizes: "50x50",
|
||||
src: "red-50.png?Content-type=image/png",
|
||||
|
|
@ -17,9 +17,9 @@ const manifest = JSON.stringify({
|
|||
}],
|
||||
});
|
||||
|
||||
function makeTestURL(manifest) {
|
||||
function makeTestURL() {
|
||||
const url = new URL(defaultURL);
|
||||
const body = `<link rel="manifest" href='${defaultURL}&body=${manifest}'>`;
|
||||
const body = `<link rel="manifest" href='${defaultURL}&body=${manifestMock}'>`;
|
||||
url.searchParams.set("Content-Type", "text/html; charset=utf-8");
|
||||
url.searchParams.set("body", encodeURIComponent(body));
|
||||
return url.href;
|
||||
|
|
@ -42,7 +42,7 @@ function getIconColor(icon) {
|
|||
}
|
||||
|
||||
add_task(async function() {
|
||||
const tabOptions = {gBrowser, url: makeTestURL(manifest)};
|
||||
const tabOptions = {gBrowser, url: makeTestURL()};
|
||||
await BrowserTestUtils.withNewTab(tabOptions, async function(browser) {
|
||||
const manifest = await ManifestObtainer.browserObtainManifest(browser);
|
||||
let icon = await ManifestIcons.browserFetchIcon(browser, manifest, 25);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ add_task(async function() {
|
|||
return collector;
|
||||
}, []);
|
||||
|
||||
const results = await Promise.all(promises);
|
||||
await Promise.all(promises);
|
||||
|
||||
function testObtainingManifest(aTest) {
|
||||
return async function(aBrowser) {
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ const { Manifests } = ChromeUtils.import("resource://gre/modules/Manifest.jsm",
|
|||
const defaultURL = new URL("http://example.org/browser/dom/manifest/test/resource.sjs");
|
||||
defaultURL.searchParams.set("Content-Type", "application/manifest+json");
|
||||
|
||||
const manifest = JSON.stringify({short_name: "hello World", scope: "/browser/"});
|
||||
const manifestUrl = `${defaultURL}&body=${manifest}`;
|
||||
const manifestMock = JSON.stringify({short_name: "hello World", scope: "/browser/"});
|
||||
const manifestUrl = `${defaultURL}&body=${manifestMock}`;
|
||||
|
||||
function makeTestURL(manifest) {
|
||||
function makeTestURL() {
|
||||
const url = new URL(defaultURL);
|
||||
const body = `<link rel="manifest" href='${manifestUrl}'>`;
|
||||
url.searchParams.set("Content-Type", "text/html; charset=utf-8");
|
||||
|
|
@ -20,7 +20,7 @@ function makeTestURL(manifest) {
|
|||
|
||||
add_task(async function() {
|
||||
|
||||
const tabOptions = {gBrowser, url: makeTestURL(manifest)};
|
||||
const tabOptions = {gBrowser, url: makeTestURL()};
|
||||
|
||||
await BrowserTestUtils.withNewTab(tabOptions, async function(browser) {
|
||||
|
||||
|
|
@ -46,4 +46,3 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -66,13 +66,6 @@ validSizes.forEach(({test, expect}) => {
|
|||
is(sizes, expect.join(" "), expected);
|
||||
});
|
||||
|
||||
var testIcon = {
|
||||
icons: [{
|
||||
src: "test",
|
||||
sizes: undefined,
|
||||
}],
|
||||
};
|
||||
|
||||
var invalidSizes = ["invalid", "", " ", "16 x 16", "32", "21", "16xx16", "16 x x 6"];
|
||||
invalidSizes.forEach((invalidSize) => {
|
||||
var expected = "Expect invalid sizes to return undefined.";
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* https://w3c.github.io/manifest/#src-member
|
||||
**/
|
||||
"use strict";
|
||||
|
||||
var noSrc = {
|
||||
icons: [{}, {
|
||||
src: [],
|
||||
|
|
@ -53,23 +54,24 @@ var invalidSrc = {
|
|||
}],
|
||||
};
|
||||
|
||||
var expected = `Expect icons with invalid src prop to be filtered out.`;
|
||||
data.jsonText = JSON.stringify(noSrc);
|
||||
var result = processor.process(data);
|
||||
expected = `Expect icons with invalid src prop to be filtered out.`;
|
||||
data.jsonText = JSON.stringify(invalidSrc);
|
||||
result = processor.process(data);
|
||||
is(result.icons.length, 0, expected);
|
||||
|
||||
var expected = `Expect icon's src to be a string.`;
|
||||
expected = `Expect icon's src to be a string.`;
|
||||
var withSrc = {
|
||||
icons: [{
|
||||
src: "pass",
|
||||
}],
|
||||
};
|
||||
data.jsonText = JSON.stringify(withSrc);
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(typeof result.icons[0].src, "string", expected);
|
||||
|
||||
var expected = `Expect only icons with a src prop to be kept.`;
|
||||
var withSrc = {
|
||||
|
||||
expected = `Expect only icons with a src prop to be kept.`;
|
||||
withSrc = {
|
||||
icons: [{
|
||||
src: "pass",
|
||||
}, {
|
||||
|
|
@ -79,28 +81,30 @@ var withSrc = {
|
|||
}],
|
||||
};
|
||||
data.jsonText = JSON.stringify(withSrc);
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.icons.length, 2, expected);
|
||||
|
||||
var expectedURL = new URL("pass", manifestURL);
|
||||
for (var icon of result.icons) {
|
||||
var expected = `Expect src prop to be ${expectedURL.toString()}`;
|
||||
expected = `Expect src prop to be ${expectedURL.toString()}`;
|
||||
is(icon.src.toString(), expectedURL.toString(), expected);
|
||||
}
|
||||
|
||||
|
||||
// Resolve URLs relative to manfiest
|
||||
var URLs = ["path", "/path", "../../path"];
|
||||
|
||||
URLs.forEach((url) => {
|
||||
var expected = `Resolve icon src URLs relative to manifest.`;
|
||||
expected = `Resolve icon src URLs relative to manifest.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
icons: [{
|
||||
src: url,
|
||||
}],
|
||||
});
|
||||
var absURL = new URL(url, manifestURL).toString();
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.icons[0].src.toString(), absURL, expected);
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ typeTests.forEach((type) => {
|
|||
icons: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
var y = SpecialPowers.unwrap(result.icons);
|
||||
SpecialPowers.unwrap(result.icons);
|
||||
is(result.icons.length, 0, expected);
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1143879
|
|||
/* globals is, typeTests, data, processor, seperators, lineTerminators, todo_is*/
|
||||
"use strict";
|
||||
// Type checks: checks that only strings are accepted.
|
||||
|
||||
for (var type of typeTests) {
|
||||
var expected = `Expect non-string to be undefined.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
|
|
@ -52,24 +53,28 @@ var validTags = [
|
|||
"de-CH-x-phonebk", "az-Arab-x-AZE-derbend", "x-whatever",
|
||||
"qaa-Qaaa-QM-x-southern",
|
||||
];
|
||||
|
||||
|
||||
for (var tag of validTags) {
|
||||
var expected = `Expect lang to be ${tag}.`;
|
||||
expected = `Expect lang to be ${tag}.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: tag,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.lang, tag, expected);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// trim tests - check that language tags get trimmed properly.
|
||||
for (var tag of validTags) {
|
||||
var expected = `Expect trimmed tag to be returned.`;
|
||||
for (tag of validTags) {
|
||||
expected = `Expect trimmed tag to be returned.`;
|
||||
var expandedtag = seperators + lineTerminators + tag;
|
||||
expandedtag += lineTerminators + seperators;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: expandedtag,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.lang, tag, expected);
|
||||
}
|
||||
|
||||
|
|
@ -78,12 +83,14 @@ var invalidTags = [
|
|||
"de-419-DE", " a-DE ", "ar-a-aaa-b-bbb-a-ccc", "sdafsdfaadsfdsf", "i",
|
||||
"i-phone", "en US", "EN-*-US-JP", "JA-INVALID-TAG", "123123123",
|
||||
];
|
||||
|
||||
|
||||
for (var item of invalidTags) {
|
||||
var expected = `Expect invalid tag (${item}) to be treated as undefined.`;
|
||||
expected = `Expect invalid tag (${item}) to be treated as undefined.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: item,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
todo_is(result.lang, undefined, expected);
|
||||
}
|
||||
|
||||
|
|
@ -99,13 +106,13 @@ var canonicalTags = [
|
|||
"qaa-Qaaa-QM-x-southern",
|
||||
];
|
||||
|
||||
for (var tag of canonicalTags) {
|
||||
for (tag of canonicalTags) {
|
||||
var uppedTag = tag.toUpperCase();
|
||||
var expected = `Expect tag (${uppedTag}) to be in canonical form (${tag}).`;
|
||||
expected = `Expect tag (${uppedTag}) to be in canonical form (${tag}).`;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: uppedTag,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
todo_is(result.lang, tag, expected);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script src="common.js"></script>
|
||||
<script>
|
||||
|
||||
/**
|
||||
* Manifest scope
|
||||
* https://w3c.github.io/manifest/#scope-member
|
||||
**/
|
||||
"use strict";
|
||||
|
||||
var expected = "Expect non-string scope to be undefined";
|
||||
typeTests.forEach((type) => {
|
||||
data.jsonText = JSON.stringify({
|
||||
|
|
@ -24,21 +26,21 @@ typeTests.forEach((type) => {
|
|||
is(result.scope, undefined, expected);
|
||||
});
|
||||
|
||||
var expected = "Expect different origin to be treated as undefined";
|
||||
expected = "Expect different origin to be treated as undefined";
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: "http://not-same-origin",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope, undefined, expected);
|
||||
|
||||
var expected = "Expect the empty string to be treated as undefined.";
|
||||
expected = "Expect the empty string to be treated as undefined.";
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: "",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.scope, undefined, expected);
|
||||
|
||||
var expected = "Resolve URLs relative to manifest.";
|
||||
expected = "Resolve URLs relative to manifest.";
|
||||
var URLs = ["path", "/path", "../../path"];
|
||||
URLs.forEach((url) => {
|
||||
data.jsonText = JSON.stringify({
|
||||
|
|
@ -46,43 +48,43 @@ URLs.forEach((url) => {
|
|||
start_url: "/path",
|
||||
});
|
||||
var absURL = new URL(url, manifestURL).toString();
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.scope, absURL, expected);
|
||||
});
|
||||
|
||||
var expected = "If start URL is not in scope, return undefined.";
|
||||
expected = "If start URL is not in scope, return undefined.";
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: "foo",
|
||||
start_url: "bar",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.scope, undefined, expected);
|
||||
|
||||
var expected = "If start URL is in scope, use the scope.";
|
||||
expected = "If start URL is in scope, use the scope.";
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: "foobar",
|
||||
scope: "foo",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.scope.toString(), new URL("foo", manifestURL).toString(), expected);
|
||||
|
||||
var expected = "Expect start_url to be " + new URL("foobar", manifestURL).toString();
|
||||
expected = "Expect start_url to be " + new URL("foobar", manifestURL).toString();
|
||||
is(result.start_url.toString(), new URL("foobar", manifestURL).toString(), expected);
|
||||
|
||||
var expected = "If start URL is in scope, use the scope.";
|
||||
expected = "If start URL is in scope, use the scope.";
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: "/foo/",
|
||||
scope: "/foo/",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.scope.toString(), new URL("/foo/", manifestURL).toString(), expected);
|
||||
|
||||
var expected = "If start URL is in scope, use the scope.";
|
||||
expected = "If start URL is in scope, use the scope.";
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: ".././foo/",
|
||||
scope: "../foo/",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.scope.toString(), new URL("/foo/", manifestURL).toString(), expected);
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -33,27 +33,30 @@ var result = processor.process(data);
|
|||
is(result.start_url.toString(), docURL.toString(), expected);
|
||||
|
||||
// Empty string test
|
||||
var expected = `Expect empty string for start_url to become document's URL.`;
|
||||
expected = `Expect empty string for start_url to become document's URL.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: "",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.start_url.toString(), docURL.toString(), expected);
|
||||
|
||||
|
||||
// Resolve URLs relative to manfiest
|
||||
var URLs = ["path", "/path", "../../path",
|
||||
`${whiteSpace}path${whiteSpace}`,
|
||||
`${whiteSpace}/path`,
|
||||
`${whiteSpace}../../path`,
|
||||
];
|
||||
|
||||
URLs.forEach((url) => {
|
||||
var expected = `Resolve URLs relative to manifest.`;
|
||||
expected = `Resolve URLs relative to manifest.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: url,
|
||||
});
|
||||
var absURL = new URL(url, manifestURL).toString();
|
||||
var result = processor.process(data);
|
||||
result = processor.process(data);
|
||||
is(result.start_url.toString(), absURL, expected);
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265279
|
|||
// no point in continuing
|
||||
if (!hasOnAppInstalledProp) {
|
||||
const err = new Error("No 'onappinstalled' IDL attribute. Aborting early.");
|
||||
return reject(err);
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
is(ifrWindow.onappinstalled, null, "window install is initially set to null");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue