forked from mirrors/gecko-dev
Bug 1508991 - Enable ESLint for dom/manifest/ (automatic changes) r=Standard8,Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D13207 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
725ceeccf7
commit
d252be35ef
29 changed files with 560 additions and 560 deletions
|
|
@ -17,19 +17,19 @@
|
|||
* .process(aManifest, aBaseURL, aMemberName);
|
||||
*
|
||||
*/
|
||||
/*exported EXPORTED_SYMBOLS*/
|
||||
/*globals Components */
|
||||
'use strict';
|
||||
/* exported EXPORTED_SYMBOLS*/
|
||||
/* globals Components */
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu,
|
||||
interfaces: Ci,
|
||||
classes: Cc
|
||||
classes: Cc,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ['URL']);
|
||||
const netutil = Cc['@mozilla.org/network/util;1']
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
|
||||
const netutil = Cc["@mozilla.org/network/util;1"]
|
||||
.getService(Ci.nsINetUtil);
|
||||
|
||||
function ImageObjectProcessor(aConsole, aExtractor) {
|
||||
|
|
@ -39,27 +39,27 @@ function ImageObjectProcessor(aConsole, aExtractor) {
|
|||
|
||||
// Static getters
|
||||
Object.defineProperties(ImageObjectProcessor, {
|
||||
'decimals': {
|
||||
get: function() {
|
||||
"decimals": {
|
||||
get() {
|
||||
return /^\d+$/;
|
||||
}
|
||||
},
|
||||
},
|
||||
"anyRegEx": {
|
||||
get() {
|
||||
return new RegExp("any", "i");
|
||||
},
|
||||
},
|
||||
'anyRegEx': {
|
||||
get: function() {
|
||||
return new RegExp('any', 'i');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ImageObjectProcessor.prototype.process = function(
|
||||
aManifest, aBaseURL, aMemberName
|
||||
) {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: aManifest,
|
||||
property: aMemberName,
|
||||
expectedType: 'array',
|
||||
trim: false
|
||||
expectedType: "array",
|
||||
trim: false,
|
||||
};
|
||||
const extractor = this.extractor;
|
||||
const images = [];
|
||||
|
|
@ -74,9 +74,9 @@ ImageObjectProcessor.prototype.process = function(
|
|||
|
||||
function toImageObject(aImageSpec) {
|
||||
return {
|
||||
'src': processSrcMember(aImageSpec, aBaseURL),
|
||||
'type': processTypeMember(aImageSpec),
|
||||
'sizes': processSizesMember(aImageSpec),
|
||||
"src": processSrcMember(aImageSpec, aBaseURL),
|
||||
"type": processTypeMember(aImageSpec),
|
||||
"sizes": processSizesMember(aImageSpec),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -84,11 +84,11 @@ ImageObjectProcessor.prototype.process = function(
|
|||
const charset = {};
|
||||
const hadCharset = {};
|
||||
const spec = {
|
||||
objectName: 'image',
|
||||
objectName: "image",
|
||||
object: aImage,
|
||||
property: 'type',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "type",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
let value = extractor.extractValue(spec);
|
||||
if (value) {
|
||||
|
|
@ -99,11 +99,11 @@ ImageObjectProcessor.prototype.process = function(
|
|||
|
||||
function processSrcMember(aImage, aBaseURL) {
|
||||
const spec = {
|
||||
objectName: 'image',
|
||||
objectName: "image",
|
||||
object: aImage,
|
||||
property: 'src',
|
||||
expectedType: 'string',
|
||||
trim: false
|
||||
property: "src",
|
||||
expectedType: "string",
|
||||
trim: false,
|
||||
};
|
||||
const value = extractor.extractValue(spec);
|
||||
let url;
|
||||
|
|
@ -118,11 +118,11 @@ ImageObjectProcessor.prototype.process = function(
|
|||
function processSizesMember(aImage) {
|
||||
const sizes = new Set();
|
||||
const spec = {
|
||||
objectName: 'image',
|
||||
objectName: "image",
|
||||
object: aImage,
|
||||
property: 'sizes',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "sizes",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
const value = extractor.extractValue(spec);
|
||||
if (value) {
|
||||
|
|
@ -138,17 +138,17 @@ ImageObjectProcessor.prototype.process = function(
|
|||
if (ImageObjectProcessor.anyRegEx.test(aSize)) {
|
||||
return true;
|
||||
}
|
||||
if (!size.includes('x') || size.indexOf('x') !== size.lastIndexOf('x')) {
|
||||
if (!size.includes("x") || size.indexOf("x") !== size.lastIndexOf("x")) {
|
||||
return false;
|
||||
}
|
||||
// Split left of x for width, after x for height.
|
||||
const widthAndHeight = size.split('x');
|
||||
const widthAndHeight = size.split("x");
|
||||
const w = widthAndHeight.shift();
|
||||
const h = widthAndHeight.join('x');
|
||||
const validStarts = !w.startsWith('0') && !h.startsWith('0');
|
||||
const h = widthAndHeight.join("x");
|
||||
const validStarts = !w.startsWith("0") && !h.startsWith("0");
|
||||
const validDecimals = ImageObjectProcessor.decimals.test(w + h);
|
||||
return (validStarts && validDecimals);
|
||||
}
|
||||
}
|
||||
};
|
||||
var EXPORTED_SYMBOLS = ['ImageObjectProcessor']; // jshint ignore:line
|
||||
var EXPORTED_SYMBOLS = ["ImageObjectProcessor"]; // jshint ignore:line
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class Manifest {
|
|||
const data = {
|
||||
installed: false,
|
||||
manifest: manifestData,
|
||||
cached_icon: icon
|
||||
cached_icon: icon,
|
||||
};
|
||||
return data;
|
||||
}
|
||||
|
|
@ -90,14 +90,14 @@ class Manifest {
|
|||
const manifestData = await ManifestObtainer.browserObtainManifest(this._browser);
|
||||
this._store.data = {
|
||||
installed: true,
|
||||
manifest: manifestData
|
||||
manifest: manifestData,
|
||||
};
|
||||
Manifests.manifestInstalled(this);
|
||||
this._store.saveSoon();
|
||||
}
|
||||
|
||||
async icon(expectedSize) {
|
||||
if ('cached_icon' in this._store.data) {
|
||||
if ("cached_icon" in this._store.data) {
|
||||
return this._store.data.cached_icon;
|
||||
}
|
||||
const icon = await ManifestIcons
|
||||
|
|
@ -142,7 +142,7 @@ class Manifest {
|
|||
*/
|
||||
var Manifests = {
|
||||
|
||||
async initialise () {
|
||||
async initialise() {
|
||||
|
||||
if (this.started) {
|
||||
return this.started;
|
||||
|
|
@ -219,7 +219,7 @@ var Manifests = {
|
|||
this.manifestObjs[manifestUrl] = new Manifest(browser, manifestUrl);
|
||||
await this.manifestObjs[manifestUrl].initialise();
|
||||
return this.manifestObjs[manifestUrl];
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
/* globals Components, Task, PromiseMessage */
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ var ManifestFinder = {// jshint ignore:line
|
|||
const mm = aBrowser.messageManager;
|
||||
const reply = await PromiseMessage.send(mm, msgKey);
|
||||
return reply.data.result;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function isXULBrowser(aBrowser) {
|
||||
|
|
@ -61,5 +61,5 @@ function checkForManifest(aWindow) {
|
|||
}
|
||||
|
||||
var EXPORTED_SYMBOLS = [// jshint ignore:line
|
||||
"ManifestFinder"
|
||||
"ManifestFinder",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
const {
|
||||
utils: Cu,
|
||||
classes: Cc,
|
||||
interfaces: Ci
|
||||
interfaces: Ci,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm");
|
||||
|
|
@ -23,7 +23,7 @@ var ManifestIcons = {
|
|||
|
||||
async contentFetchIcon(aWindow, manifest, iconSize) {
|
||||
return await getIcon(aWindow, toIconArray(manifest.icons), iconSize);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function parseIconSize(size) {
|
||||
|
|
|
|||
|
|
@ -23,17 +23,17 @@
|
|||
*
|
||||
* exported ManifestObtainer
|
||||
*/
|
||||
/*globals Components, Task, PromiseMessage, XPCOMUtils, ManifestProcessor, BrowserUtils*/
|
||||
/* globals Components, Task, PromiseMessage, XPCOMUtils, ManifestProcessor, BrowserUtils*/
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu,
|
||||
classes: Cc,
|
||||
interfaces: Ci
|
||||
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
|
||||
ChromeUtils.defineModuleGetter(this, "BrowserUtils", // jshint ignore:line
|
||||
"resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
var ManifestObtainer = { // jshint ignore:line
|
||||
|
|
@ -72,7 +72,7 @@ var ManifestObtainer = { // jshint ignore:line
|
|||
throw err;
|
||||
}
|
||||
return manifest;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function toError(aErrorClone) {
|
||||
|
|
@ -115,7 +115,7 @@ const processResponse = async function(aResp, aContentWindow) {
|
|||
const args = {
|
||||
jsonText: text,
|
||||
manifestURL: aResp.url,
|
||||
docURL: aContentWindow.location.href
|
||||
docURL: aContentWindow.location.href,
|
||||
};
|
||||
const manifest = ManifestProcessor.process(args);
|
||||
return manifest;
|
||||
|
|
@ -139,7 +139,7 @@ const fetchManifest = async function(aWindow) {
|
|||
// Throws on malformed URLs
|
||||
const manifestURL = new aWindow.URL(elem.href, elem.baseURI);
|
||||
const reqInit = {
|
||||
mode: "cors"
|
||||
mode: "cors",
|
||||
};
|
||||
if (elem.crossOrigin === "use-credentials") {
|
||||
reqInit.credentials = "include";
|
||||
|
|
|
|||
|
|
@ -19,33 +19,33 @@
|
|||
* TODO: The constructor should accept the UA's supported display modes.
|
||||
* TODO: hook up developer tools to console. (1086997).
|
||||
*/
|
||||
/*globals Components, ValueExtractor, ImageObjectProcessor, ConsoleAPI*/
|
||||
'use strict';
|
||||
/* globals Components, ValueExtractor, ImageObjectProcessor, ConsoleAPI*/
|
||||
"use strict";
|
||||
const {
|
||||
utils: Cu
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ['URL']);
|
||||
const displayModes = new Set(['fullscreen', 'standalone', 'minimal-ui',
|
||||
'browser'
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
|
||||
const displayModes = new Set(["fullscreen", "standalone", "minimal-ui",
|
||||
"browser",
|
||||
]);
|
||||
const orientationTypes = new Set(['any', 'natural', 'landscape', 'portrait',
|
||||
'portrait-primary', 'portrait-secondary', 'landscape-primary',
|
||||
'landscape-secondary'
|
||||
const orientationTypes = new Set(["any", "natural", "landscape", "portrait",
|
||||
"portrait-primary", "portrait-secondary", "landscape-primary",
|
||||
"landscape-secondary",
|
||||
]);
|
||||
const textDirections = new Set(['ltr', 'rtl', 'auto']);
|
||||
const textDirections = new Set(["ltr", "rtl", "auto"]);
|
||||
|
||||
ChromeUtils.import('resource://gre/modules/Console.jsm');
|
||||
ChromeUtils.import("resource://gre/modules/Console.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
// ValueExtractor is used by the various processors to get values
|
||||
// from the manifest and to report errors.
|
||||
ChromeUtils.import('resource://gre/modules/ValueExtractor.jsm');
|
||||
ChromeUtils.import("resource://gre/modules/ValueExtractor.jsm");
|
||||
// ImageObjectProcessor is used to process things like icons and images
|
||||
ChromeUtils.import('resource://gre/modules/ImageObjectProcessor.jsm');
|
||||
ChromeUtils.import("resource://gre/modules/ImageObjectProcessor.jsm");
|
||||
|
||||
var ManifestProcessor = { // jshint ignore:line
|
||||
get defaultDisplayMode() {
|
||||
return 'browser';
|
||||
return "browser";
|
||||
},
|
||||
get displayModes() {
|
||||
return displayModes;
|
||||
|
|
@ -65,12 +65,12 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
process({
|
||||
jsonText,
|
||||
manifestURL: aManifestURL,
|
||||
docURL: aDocURL
|
||||
docURL: aDocURL,
|
||||
}) {
|
||||
const domBundle = Services.strings.createBundle("chrome://global/locale/dom/dom.properties");
|
||||
|
||||
const console = new ConsoleAPI({
|
||||
prefix: 'Web Manifest'
|
||||
prefix: "Web Manifest",
|
||||
});
|
||||
const manifestURL = new URL(aManifestURL);
|
||||
const docURL = new URL(aDocURL);
|
||||
|
|
@ -78,73 +78,73 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
try {
|
||||
rawManifest = JSON.parse(jsonText);
|
||||
} catch (e) {}
|
||||
if (typeof rawManifest !== 'object' || rawManifest === null) {
|
||||
console.warn(domBundle.GetStringFromName('ManifestShouldBeObject'));
|
||||
if (typeof rawManifest !== "object" || rawManifest === null) {
|
||||
console.warn(domBundle.GetStringFromName("ManifestShouldBeObject"));
|
||||
rawManifest = {};
|
||||
}
|
||||
const extractor = new ValueExtractor(console, domBundle);
|
||||
const imgObjProcessor = new ImageObjectProcessor(console, extractor);
|
||||
const processedManifest = {
|
||||
'dir': processDirMember.call(this),
|
||||
'lang': processLangMember(),
|
||||
'start_url': processStartURLMember(),
|
||||
'display': processDisplayMember.call(this),
|
||||
'orientation': processOrientationMember.call(this),
|
||||
'name': processNameMember(),
|
||||
'icons': imgObjProcessor.process(
|
||||
rawManifest, manifestURL, 'icons'
|
||||
"dir": processDirMember.call(this),
|
||||
"lang": processLangMember(),
|
||||
"start_url": processStartURLMember(),
|
||||
"display": processDisplayMember.call(this),
|
||||
"orientation": processOrientationMember.call(this),
|
||||
"name": processNameMember(),
|
||||
"icons": imgObjProcessor.process(
|
||||
rawManifest, manifestURL, "icons"
|
||||
),
|
||||
'short_name': processShortNameMember(),
|
||||
'theme_color': processThemeColorMember(),
|
||||
'background_color': processBackgroundColorMember(),
|
||||
"short_name": processShortNameMember(),
|
||||
"theme_color": processThemeColorMember(),
|
||||
"background_color": processBackgroundColorMember(),
|
||||
};
|
||||
processedManifest.scope = processScopeMember();
|
||||
return processedManifest;
|
||||
|
||||
function processDirMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'dir',
|
||||
expectedType: 'string',
|
||||
property: "dir",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
const value = extractor.extractValue(spec);
|
||||
if (this.textDirections.has(value)) {
|
||||
return value;
|
||||
}
|
||||
return 'auto';
|
||||
return "auto";
|
||||
}
|
||||
|
||||
function processNameMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'name',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "name",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
return extractor.extractValue(spec);
|
||||
}
|
||||
|
||||
function processShortNameMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'short_name',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "short_name",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
return extractor.extractValue(spec);
|
||||
}
|
||||
|
||||
function processOrientationMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'orientation',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "orientation",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
const value = extractor.extractValue(spec);
|
||||
if (value && typeof value === "string" && this.orientationTypes.has(value.toLowerCase())) {
|
||||
|
|
@ -155,11 +155,11 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
|
||||
function processDisplayMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'display',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "display",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
const value = extractor.extractValue(spec);
|
||||
if (value && typeof value === "string" && displayModes.has(value.toLowerCase())) {
|
||||
|
|
@ -170,32 +170,32 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
|
||||
function processScopeMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'scope',
|
||||
expectedType: 'string',
|
||||
trim: false
|
||||
property: "scope",
|
||||
expectedType: "string",
|
||||
trim: false,
|
||||
};
|
||||
let scopeURL;
|
||||
const startURL = new URL(processedManifest.start_url);
|
||||
const value = extractor.extractValue(spec);
|
||||
if (value === undefined || value === '') {
|
||||
if (value === undefined || value === "") {
|
||||
return undefined;
|
||||
}
|
||||
try {
|
||||
scopeURL = new URL(value, manifestURL);
|
||||
} catch (e) {
|
||||
console.warn(domBundle.GetStringFromName('ManifestScopeURLInvalid'));
|
||||
console.warn(domBundle.GetStringFromName("ManifestScopeURLInvalid"));
|
||||
return undefined;
|
||||
}
|
||||
if (scopeURL.origin !== docURL.origin) {
|
||||
console.warn(domBundle.GetStringFromName('ManifestScopeNotSameOrigin'));
|
||||
console.warn(domBundle.GetStringFromName("ManifestScopeNotSameOrigin"));
|
||||
return undefined;
|
||||
}
|
||||
// If start URL is not within scope of scope URL:
|
||||
let isSameOrigin = startURL && startURL.origin !== scopeURL.origin;
|
||||
if (isSameOrigin || !startURL.pathname.startsWith(scopeURL.pathname)) {
|
||||
console.warn(domBundle.GetStringFromName('ManifestStartURLOutsideScope'));
|
||||
console.warn(domBundle.GetStringFromName("ManifestStartURLOutsideScope"));
|
||||
return undefined;
|
||||
}
|
||||
return scopeURL.href;
|
||||
|
|
@ -203,26 +203,26 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
|
||||
function processStartURLMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'start_url',
|
||||
expectedType: 'string',
|
||||
trim: false
|
||||
property: "start_url",
|
||||
expectedType: "string",
|
||||
trim: false,
|
||||
};
|
||||
let result = new URL(docURL).href;
|
||||
const value = extractor.extractValue(spec);
|
||||
if (value === undefined || value === '') {
|
||||
if (value === undefined || value === "") {
|
||||
return result;
|
||||
}
|
||||
let potentialResult;
|
||||
try {
|
||||
potentialResult = new URL(value, manifestURL);
|
||||
} catch (e) {
|
||||
console.warn(domBundle.GetStringFromName('ManifestStartURLInvalid'))
|
||||
console.warn(domBundle.GetStringFromName("ManifestStartURLInvalid"));
|
||||
return result;
|
||||
}
|
||||
if (potentialResult.origin !== docURL.origin) {
|
||||
console.warn(domBundle.GetStringFromName('ManifestStartURLShouldBeSameOrigin'));
|
||||
console.warn(domBundle.GetStringFromName("ManifestStartURLShouldBeSameOrigin"));
|
||||
} else {
|
||||
result = potentialResult.href;
|
||||
}
|
||||
|
|
@ -231,32 +231,32 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
|
||||
function processThemeColorMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'theme_color',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "theme_color",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
return extractor.extractColorValue(spec);
|
||||
}
|
||||
|
||||
function processBackgroundColorMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'background_color',
|
||||
expectedType: 'string',
|
||||
trim: true
|
||||
property: "background_color",
|
||||
expectedType: "string",
|
||||
trim: true,
|
||||
};
|
||||
return extractor.extractColorValue(spec);
|
||||
}
|
||||
|
||||
function processLangMember() {
|
||||
const spec = {
|
||||
objectName: 'manifest',
|
||||
objectName: "manifest",
|
||||
object: rawManifest,
|
||||
property: 'lang',
|
||||
expectedType: 'string', trim: true
|
||||
property: "lang",
|
||||
expectedType: "string", trim: true,
|
||||
};
|
||||
let tag = extractor.extractValue(spec);
|
||||
// TODO: Check if tag is structurally valid.
|
||||
|
|
@ -269,6 +269,6 @@ var ManifestProcessor = { // jshint ignore:line
|
|||
// https://github.com/tc39/ecma402/issues/5
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
var EXPORTED_SYMBOLS = ['ManifestProcessor']; // jshint ignore:line
|
||||
var EXPORTED_SYMBOLS = ["ManifestProcessor"]; // jshint ignore:line
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
* Helper functions extract values from manifest members
|
||||
* and reports conformance violations.
|
||||
*/
|
||||
/*globals Components*/
|
||||
'use strict';
|
||||
/* globals Components*/
|
||||
"use strict";
|
||||
const {
|
||||
classes: Cc,
|
||||
interfaces: Ci,
|
||||
utils: Cu
|
||||
utils: Cu,
|
||||
} = Components;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
|
@ -35,9 +35,9 @@ ValueExtractor.prototype = {
|
|||
const value = object[property];
|
||||
const isArray = Array.isArray(value);
|
||||
// We need to special-case "array", as it's not a JS primitive.
|
||||
const type = (isArray) ? 'array' : typeof value;
|
||||
const type = (isArray) ? "array" : typeof value;
|
||||
if (type !== expectedType) {
|
||||
if (type !== 'undefined') {
|
||||
if (type !== "undefined") {
|
||||
this.console.warn(this.domBundle.formatStringFromName("ManifestInvalidType",
|
||||
[objectName, property, expectedType],
|
||||
3));
|
||||
|
|
@ -45,7 +45,7 @@ ValueExtractor.prototype = {
|
|||
return undefined;
|
||||
}
|
||||
// Trim string and returned undefined if the empty string.
|
||||
const shouldTrim = expectedType === 'string' && value && trim;
|
||||
const shouldTrim = expectedType === "string" && value && trim;
|
||||
if (shouldTrim) {
|
||||
return value.trim() || undefined;
|
||||
}
|
||||
|
|
@ -62,6 +62,6 @@ ValueExtractor.prototype = {
|
|||
2));
|
||||
}
|
||||
return color;
|
||||
}
|
||||
},
|
||||
};
|
||||
var EXPORTED_SYMBOLS = ['ValueExtractor']; // jshint ignore:line
|
||||
var EXPORTED_SYMBOLS = ["ValueExtractor"]; // jshint ignore:line
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//Used by JSHint:
|
||||
/*global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
// Used by JSHint:
|
||||
/* global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
"use strict";
|
||||
const { ManifestFinder } = ChromeUtils.import("resource://gre/modules/ManifestFinder.jsm", {});
|
||||
const defaultURL = new URL("http://example.org/browser/dom/manifest/test/resource.sjs");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//Used by JSHint:
|
||||
/*global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
// Used by JSHint:
|
||||
/* global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
"use strict";
|
||||
const { ManifestIcons } = ChromeUtils.import("resource://gre/modules/ManifestIcons.jsm", {});
|
||||
const { ManifestObtainer } = ChromeUtils.import("resource://gre/modules/ManifestObtainer.jsm", {});
|
||||
|
|
@ -10,11 +10,11 @@ defaultURL.searchParams.set("Content-Type", "application/manifest+json");
|
|||
const manifest = JSON.stringify({
|
||||
icons: [{
|
||||
sizes: "50x50",
|
||||
src: "red-50.png?Content-type=image/png"
|
||||
src: "red-50.png?Content-type=image/png",
|
||||
}, {
|
||||
sizes: "150x150",
|
||||
src: "blue-150.png?Content-type=image/png"
|
||||
}]
|
||||
src: "blue-150.png?Content-type=image/png",
|
||||
}],
|
||||
});
|
||||
|
||||
function makeTestURL(manifest) {
|
||||
|
|
@ -27,7 +27,7 @@ function makeTestURL(manifest) {
|
|||
|
||||
function getIconColor(icon) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const canvas = content.document.createElement('canvas');
|
||||
const canvas = content.document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
const image = new content.Image();
|
||||
image.onload = function() {
|
||||
|
|
@ -47,10 +47,10 @@ add_task(async function() {
|
|||
const manifest = await ManifestObtainer.browserObtainManifest(browser);
|
||||
let icon = await ManifestIcons.browserFetchIcon(browser, manifest, 25);
|
||||
let color = await ContentTask.spawn(browser, icon, getIconColor);
|
||||
is(color[0], 255, 'Fetched red icon');
|
||||
is(color[0], 255, "Fetched red icon");
|
||||
|
||||
icon = await ManifestIcons.browserFetchIcon(browser, manifest, 500);
|
||||
color = await ContentTask.spawn(browser, icon, getIconColor);
|
||||
is(color[2], 255, 'Fetched blue icon');
|
||||
is(color[2], 255, "Fetched blue icon");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
//Used by JSHint:
|
||||
/*global ok, is, Cu, BrowserTestUtils, add_task, gBrowser, makeTestURL, requestLongerTimeout*/
|
||||
'use strict';
|
||||
const { ManifestObtainer } = ChromeUtils.import('resource://gre/modules/ManifestObtainer.jsm', {});
|
||||
const remoteURL = 'http://mochi.test:8888/browser/dom/manifest/test/resource.sjs';
|
||||
const defaultURL = new URL('http://example.org/browser/dom/manifest/test/resource.sjs');
|
||||
defaultURL.searchParams.set('Content-Type', 'text/html; charset=utf-8');
|
||||
// Used by JSHint:
|
||||
/* global ok, is, Cu, BrowserTestUtils, add_task, gBrowser, makeTestURL, requestLongerTimeout*/
|
||||
"use strict";
|
||||
const { ManifestObtainer } = ChromeUtils.import("resource://gre/modules/ManifestObtainer.jsm", {});
|
||||
const remoteURL = "http://mochi.test:8888/browser/dom/manifest/test/resource.sjs";
|
||||
const defaultURL = new URL("http://example.org/browser/dom/manifest/test/resource.sjs");
|
||||
defaultURL.searchParams.set("Content-Type", "text/html; charset=utf-8");
|
||||
requestLongerTimeout(4);
|
||||
|
||||
const tests = [
|
||||
|
|
@ -15,20 +15,20 @@ const tests = [
|
|||
<link rel="foo bar manifest bar test" href='resource.sjs?body={"name":"pass-1"}'>
|
||||
<link rel="manifest" href='resource.sjs?body={"name":"fail"}'>`,
|
||||
run(manifest) {
|
||||
is(manifest.name, 'pass-1', 'Manifest is first `link` where @rel contains token manifest.');
|
||||
}
|
||||
is(manifest.name, "pass-1", "Manifest is first `link` where @rel contains token manifest.");
|
||||
},
|
||||
}, {
|
||||
body: `
|
||||
<link rel="foo bar manifest bar test" href='resource.sjs?body={"name":"pass-2"}'>
|
||||
<link rel="manifest" href='resource.sjs?body={"name":"fail"}'>
|
||||
<link rel="manifest foo bar test" href='resource.sjs?body={"name":"fail"}'>`,
|
||||
run(manifest) {
|
||||
is(manifest.name, 'pass-2', 'Manifest is first `link` where @rel contains token manifest.');
|
||||
is(manifest.name, "pass-2", "Manifest is first `link` where @rel contains token manifest.");
|
||||
},
|
||||
}, {
|
||||
body: `<link rel="manifest" href='${remoteURL}?body={"name":"pass-3"}'>`,
|
||||
run(err) {
|
||||
is(err.name, 'TypeError', 'By default, manifest cannot load cross-origin.');
|
||||
is(err.name, "TypeError", "By default, manifest cannot load cross-origin.");
|
||||
},
|
||||
},
|
||||
// CORS Tests.
|
||||
|
|
@ -45,12 +45,12 @@ const tests = [
|
|||
return link;
|
||||
},
|
||||
run(manifest) {
|
||||
is(manifest.name, 'pass-4', 'CORS enabled, manifest must be fetched.');
|
||||
is(manifest.name, "pass-4", "CORS enabled, manifest must be fetched.");
|
||||
},
|
||||
}, {
|
||||
get body() {
|
||||
const body = 'body={"name": "fail"}';
|
||||
const CORS = 'Access-Control-Allow-Origin=http://not-here';
|
||||
const CORS = "Access-Control-Allow-Origin=http://not-here";
|
||||
const link =
|
||||
`<link
|
||||
crossorigin
|
||||
|
|
@ -59,31 +59,31 @@ const tests = [
|
|||
return link;
|
||||
},
|
||||
run(err) {
|
||||
is(err.name, 'TypeError', 'Fetch blocked by CORS - origin does not match.');
|
||||
is(err.name, "TypeError", "Fetch blocked by CORS - origin does not match.");
|
||||
},
|
||||
}, {
|
||||
body: `<link rel="manifest" href='about:whatever'>`,
|
||||
run(err) {
|
||||
is(err.name, 'TypeError', 'Trying to load from about:whatever is TypeError.');
|
||||
is(err.name, "TypeError", "Trying to load from about:whatever is TypeError.");
|
||||
},
|
||||
}, {
|
||||
body: `<link rel="manifest" href='file://manifest'>`,
|
||||
run(err) {
|
||||
is(err.name, 'TypeError', 'Trying to load from file://whatever is a TypeError.');
|
||||
is(err.name, "TypeError", "Trying to load from file://whatever is a TypeError.");
|
||||
},
|
||||
},
|
||||
//URL parsing tests
|
||||
// URL parsing tests
|
||||
{
|
||||
body: `<link rel="manifest" href='http://[12.1212.21.21.12.21.12]'>`,
|
||||
run(err) {
|
||||
is(err.name, 'TypeError', 'Trying to load invalid URL is a TypeError.');
|
||||
is(err.name, "TypeError", "Trying to load invalid URL is a TypeError.");
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
function makeTestURL({ body }) {
|
||||
const url = new URL(defaultURL);
|
||||
url.searchParams.set('body', encodeURIComponent(body));
|
||||
url.searchParams.set("body", encodeURIComponent(body));
|
||||
return url.href;
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ add_task(async function() {
|
|||
.map(test => ({
|
||||
gBrowser,
|
||||
testRunner: testObtainingManifest(test),
|
||||
url: makeTestURL(test)
|
||||
url: makeTestURL(test),
|
||||
}))
|
||||
.reduce((collector, tabOpts) => {
|
||||
const promise = BrowserTestUtils.withNewTab(tabOpts, tabOpts.testRunner);
|
||||
|
|
@ -120,7 +120,7 @@ add_task(async function() {
|
|||
* in each tab. They should all return pass.
|
||||
*/
|
||||
add_task(async function() {
|
||||
const defaultPath = '/browser/dom/manifest/test/manifestLoader.html';
|
||||
const defaultPath = "/browser/dom/manifest/test/manifestLoader.html";
|
||||
const tabURLs = [
|
||||
`http://example.com:80${defaultPath}`,
|
||||
`http://example.org:80${defaultPath}`,
|
||||
|
|
@ -155,26 +155,26 @@ add_task(async function() {
|
|||
let browsers = tabURLs.map(url => BrowserTestUtils.addTab(gBrowser, url).linkedBrowser);
|
||||
|
||||
// Once all the pages have loaded, run a bunch of tests in "parallel".
|
||||
await Promise.all((function*() {
|
||||
await Promise.all((function* () {
|
||||
for (let browser of browsers) {
|
||||
yield BrowserTestUtils.browserLoaded(browser);
|
||||
}
|
||||
})());
|
||||
// Flood random browsers with requests. Once promises settle, check that
|
||||
// responses all pass.
|
||||
const results = await Promise.all((function*() {
|
||||
const results = await Promise.all((function* () {
|
||||
for (let browser of randBrowsers(browsers, 50)) {
|
||||
yield ManifestObtainer.browserObtainManifest(browser);
|
||||
}
|
||||
})());
|
||||
const pass = results.every(manifest => manifest.name === 'pass');
|
||||
ok(pass, 'Expect every manifest to have name equal to `pass`.');
|
||||
//cleanup
|
||||
const pass = results.every(manifest => manifest.name === "pass");
|
||||
ok(pass, "Expect every manifest to have name equal to `pass`.");
|
||||
// cleanup
|
||||
browsers
|
||||
.map(browser => gBrowser.getTabForBrowser(browser))
|
||||
.forEach(tab => gBrowser.removeTab(tab));
|
||||
|
||||
//Helper generator, spits out random browsers
|
||||
// Helper generator, spits out random browsers
|
||||
function* randBrowsers(aBrowsers, aMax) {
|
||||
for (let i = 0; i < aMax; i++) {
|
||||
const randNum = Math.round(Math.random() * (aBrowsers.length - 1));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//Used by JSHint:
|
||||
/*global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
// Used by JSHint:
|
||||
/* global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
"use strict";
|
||||
|
||||
const { Manifests } = ChromeUtils.import("resource://gre/modules/Manifest.jsm", {});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//Used by JSHint:
|
||||
/*global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
// Used by JSHint:
|
||||
/* global Cu, BrowserTestUtils, ok, add_task, gBrowser */
|
||||
"use strict";
|
||||
const { PromiseMessage } = ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm", {});
|
||||
const testPath = "/browser/dom/manifest/test/file_reg_appinstalled_event.html";
|
||||
|
|
@ -39,7 +39,7 @@ async function theTest(aBrowser) {
|
|||
add_task(async function() {
|
||||
await enableOnAppInstalledPref();
|
||||
let tabOptions = {
|
||||
gBrowser: gBrowser,
|
||||
gBrowser,
|
||||
url: testURL.href,
|
||||
};
|
||||
await BrowserTestUtils.withNewTab(
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
/**
|
||||
* Common infrastructure for manifest tests.
|
||||
**/
|
||||
/*globals SpecialPowers, ManifestProcessor*/
|
||||
'use strict';
|
||||
/* globals SpecialPowers, ManifestProcessor*/
|
||||
"use strict";
|
||||
const {
|
||||
ManifestProcessor
|
||||
} = SpecialPowers.Cu.import('resource://gre/modules/ManifestProcessor.jsm');
|
||||
ManifestProcessor,
|
||||
} = SpecialPowers.Cu.import("resource://gre/modules/ManifestProcessor.jsm");
|
||||
const processor = ManifestProcessor;
|
||||
const manifestURL = new URL(document.location.origin + '/manifest.json');
|
||||
const manifestURL = new URL(document.location.origin + "/manifest.json");
|
||||
const docURL = document.location;
|
||||
const seperators = '\u2028\u2029\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000';
|
||||
const lineTerminators = '\u000D\u000A\u2028\u2029';
|
||||
const seperators = "\u2028\u2029\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000";
|
||||
const lineTerminators = "\u000D\u000A\u2028\u2029";
|
||||
const whiteSpace = `${seperators}${lineTerminators}`;
|
||||
const typeTests = [1, null, {},
|
||||
[], false
|
||||
[], false,
|
||||
];
|
||||
const data = {
|
||||
jsonText: '{}',
|
||||
manifestURL: manifestURL,
|
||||
docURL: docURL
|
||||
jsonText: "{}",
|
||||
manifestURL,
|
||||
docURL,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ window.addEventListener("appinstalled", () => {
|
|||
.innerHTML = "event received!";
|
||||
// Send a custom event back to the browser
|
||||
// to acknowledge that we got this
|
||||
const detail = { result: true }
|
||||
const detail = { result: true };
|
||||
const ev = new CustomEvent("dom.manifest.onappinstalled", { detail });
|
||||
document.dispatchEvent(ev);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,47 +14,47 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* Image object's sizes member
|
||||
* https://w3c.github.io/manifest/#sizes-member
|
||||
**/
|
||||
'use strict';
|
||||
"use strict";
|
||||
var validSizes = [{
|
||||
test: '16x16',
|
||||
expect: ['16x16']
|
||||
test: "16x16",
|
||||
expect: ["16x16"],
|
||||
}, {
|
||||
test: 'hello 16x16 16x16',
|
||||
expect: ['16x16']
|
||||
test: "hello 16x16 16x16",
|
||||
expect: ["16x16"],
|
||||
}, {
|
||||
test: '32x32 16 48x48 12',
|
||||
expect: ['32x32', '48x48']
|
||||
test: "32x32 16 48x48 12",
|
||||
expect: ["32x32", "48x48"],
|
||||
}, {
|
||||
test: `${whiteSpace}128x128${whiteSpace}512x512 8192x8192 32768x32768${whiteSpace}`,
|
||||
expect: ['128x128', '512x512', '8192x8192', '32768x32768']
|
||||
expect: ["128x128", "512x512", "8192x8192", "32768x32768"],
|
||||
}, {
|
||||
test: 'any',
|
||||
expect: ['any']
|
||||
test: "any",
|
||||
expect: ["any"],
|
||||
}, {
|
||||
test: 'Any',
|
||||
expect: ['Any']
|
||||
test: "Any",
|
||||
expect: ["Any"],
|
||||
}, {
|
||||
test: '16x32',
|
||||
expect: ['16x32']
|
||||
test: "16x32",
|
||||
expect: ["16x32"],
|
||||
}, {
|
||||
test: '17x33',
|
||||
expect: ['17x33']
|
||||
test: "17x33",
|
||||
expect: ["17x33"],
|
||||
}, {
|
||||
test: '32x32 32x32',
|
||||
expect: ['32x32']
|
||||
test: "32x32 32x32",
|
||||
expect: ["32x32"],
|
||||
}, {
|
||||
test: '32X32',
|
||||
expect: ['32X32']
|
||||
test: "32X32",
|
||||
expect: ["32X32"],
|
||||
}, {
|
||||
test: 'any 32x32',
|
||||
expect: ['any', '32x32']
|
||||
test: "any 32x32",
|
||||
expect: ["any", "32x32"],
|
||||
}];
|
||||
|
||||
var testIcon = {
|
||||
icons: [{
|
||||
src: 'test',
|
||||
sizes: undefined
|
||||
}]
|
||||
src: "test",
|
||||
sizes: undefined,
|
||||
}],
|
||||
};
|
||||
|
||||
validSizes.forEach(({test, expect}) => {
|
||||
|
|
@ -68,14 +68,14 @@ validSizes.forEach(({test, expect}) => {
|
|||
|
||||
var testIcon = {
|
||||
icons: [{
|
||||
src: 'test',
|
||||
sizes: undefined
|
||||
}]
|
||||
src: "test",
|
||||
sizes: undefined,
|
||||
}],
|
||||
};
|
||||
|
||||
var invalidSizes = ['invalid', '', ' ', '16 x 16', '32', '21', '16xx16', '16 x x 6'];
|
||||
var invalidSizes = ["invalid", "", " ", "16 x 16", "32", "21", "16xx16", "16 x x 6"];
|
||||
invalidSizes.forEach((invalidSize) => {
|
||||
var expected = 'Expect invalid sizes to return undefined.';
|
||||
var expected = "Expect invalid sizes to return undefined.";
|
||||
testIcon.icons[0].sizes = invalidSize;
|
||||
data.jsonText = JSON.stringify(testIcon);
|
||||
var result = processor.process(data);
|
||||
|
|
|
|||
|
|
@ -14,22 +14,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* Image object's src member
|
||||
* https://w3c.github.io/manifest/#src-member
|
||||
**/
|
||||
'use strict';
|
||||
"use strict";
|
||||
var noSrc = {
|
||||
icons: [{}, {
|
||||
src: []
|
||||
src: [],
|
||||
}, {
|
||||
src: {}
|
||||
src: {},
|
||||
}, {
|
||||
src: null
|
||||
src: null,
|
||||
}, {
|
||||
type: 'image/jpg'
|
||||
type: "image/jpg",
|
||||
}, {
|
||||
sizes: '1x1,2x2'
|
||||
sizes: "1x1,2x2",
|
||||
}, {
|
||||
sizes: 'any',
|
||||
type: 'image/jpg'
|
||||
}]
|
||||
sizes: "any",
|
||||
type: "image/jpg",
|
||||
}],
|
||||
};
|
||||
|
||||
var expected = `Expect icons without a src prop to be filtered out.`;
|
||||
|
|
@ -39,18 +39,18 @@ is(result.icons.length, 0, expected);
|
|||
|
||||
var invalidSrc = {
|
||||
icons: [{
|
||||
src: null
|
||||
src: null,
|
||||
}, {
|
||||
src: 1
|
||||
src: 1,
|
||||
}, {
|
||||
src: []
|
||||
src: [],
|
||||
}, {
|
||||
src: {}
|
||||
src: {},
|
||||
}, {
|
||||
src: true
|
||||
src: true,
|
||||
}, {
|
||||
src: ''
|
||||
}]
|
||||
src: "",
|
||||
}],
|
||||
};
|
||||
|
||||
var expected = `Expect icons with invalid src prop to be filtered out.`;
|
||||
|
|
@ -61,8 +61,8 @@ is(result.icons.length, 0, expected);
|
|||
var expected = `Expect icon's src to be a string.`;
|
||||
var withSrc = {
|
||||
icons: [{
|
||||
src: 'pass'
|
||||
}]
|
||||
src: "pass",
|
||||
}],
|
||||
};
|
||||
data.jsonText = JSON.stringify(withSrc);
|
||||
var result = processor.process(data);
|
||||
|
|
@ -71,32 +71,32 @@ is(typeof result.icons[0].src, "string", expected);
|
|||
var expected = `Expect only icons with a src prop to be kept.`;
|
||||
var withSrc = {
|
||||
icons: [{
|
||||
src: 'pass'
|
||||
src: "pass",
|
||||
}, {
|
||||
src: 'pass',
|
||||
src: "pass",
|
||||
}, {}, {
|
||||
foo: 'foo'
|
||||
}]
|
||||
foo: "foo",
|
||||
}],
|
||||
};
|
||||
data.jsonText = JSON.stringify(withSrc);
|
||||
var result = processor.process(data);
|
||||
is(result.icons.length, 2, expected);
|
||||
|
||||
var expectedURL = new URL('pass', manifestURL);
|
||||
var expectedURL = new URL("pass", manifestURL);
|
||||
for (var icon of result.icons) {
|
||||
var 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'];
|
||||
// Resolve URLs relative to manfiest
|
||||
var URLs = ["path", "/path", "../../path"];
|
||||
|
||||
URLs.forEach((url) => {
|
||||
var expected = `Resolve icon src URLs relative to manifest.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
icons: [{
|
||||
src: url
|
||||
}]
|
||||
src: url,
|
||||
}],
|
||||
});
|
||||
var absURL = new URL(url, manifestURL).toString();
|
||||
var result = processor.process(data);
|
||||
|
|
|
|||
|
|
@ -15,20 +15,20 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* https://w3c.github.io/manifest/#type-member
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
var testIcon = {
|
||||
icons: [{
|
||||
src: 'test',
|
||||
type: undefined
|
||||
}]
|
||||
src: "test",
|
||||
type: undefined,
|
||||
}],
|
||||
};
|
||||
|
||||
var invalidMimeTypes = [
|
||||
'application / text',
|
||||
'test;test',
|
||||
';test?test',
|
||||
'application\\text',
|
||||
'image/jpeg, image/gif'
|
||||
"application / text",
|
||||
"test;test",
|
||||
";test?test",
|
||||
"application\\text",
|
||||
"image/jpeg, image/gif",
|
||||
];
|
||||
invalidMimeTypes.forEach((invalidMime) => {
|
||||
var expected = `Expect invalid mime to be treated like undefined.`;
|
||||
|
|
@ -39,11 +39,11 @@ invalidMimeTypes.forEach((invalidMime) => {
|
|||
});
|
||||
|
||||
var validTypes = [
|
||||
'image/jpeg',
|
||||
'IMAGE/jPeG',
|
||||
"image/jpeg",
|
||||
"IMAGE/jPeG",
|
||||
`${whiteSpace}image/jpeg${whiteSpace}`,
|
||||
'image/JPEG; whatever=something',
|
||||
'image/JPEG;whatever'
|
||||
"image/JPEG; whatever=something",
|
||||
"image/JPEG;whatever",
|
||||
];
|
||||
|
||||
validTypes.forEach((validMime) => {
|
||||
|
|
@ -51,7 +51,7 @@ validTypes.forEach((validMime) => {
|
|||
testIcon.icons[0].type = validMime;
|
||||
data.jsonText = JSON.stringify(testIcon);
|
||||
var result = processor.process(data);
|
||||
is(result.icons[0].type, 'image/jpeg', expected);
|
||||
is(result.icons[0].type, "image/jpeg", expected);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* JSON parsing/processing tests
|
||||
* https://w3c.github.io/manifest/#processing
|
||||
**/
|
||||
'use strict';
|
||||
var invalidJson = ['', ` \t \n ${whiteSpace} `, '{', '{[[}'];
|
||||
"use strict";
|
||||
var invalidJson = ["", ` \t \n ${whiteSpace} `, "{", "{[[}"];
|
||||
invalidJson.forEach((testString) => {
|
||||
var expected = `Expect to recover from invalid JSON: ${testString}`;
|
||||
data.jsonText = testString;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1195018
|
|||
* background_color member
|
||||
* https://w3c.github.io/manifest/#background_color-member
|
||||
**/
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
typeTests.forEach(type => {
|
||||
data.jsonText = JSON.stringify({
|
||||
background_color: type
|
||||
background_color: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
@ -26,52 +26,52 @@ typeTests.forEach(type => {
|
|||
});
|
||||
|
||||
var validThemeColors = [
|
||||
'maroon',
|
||||
'#f00',
|
||||
'#ff0000',
|
||||
'rgb(255,0,0)',
|
||||
'rgb(255,0,0,1)',
|
||||
'rgb(255,0,0,1.0)',
|
||||
'rgb(255,0,0,100%)',
|
||||
'rgb(255 0 0)',
|
||||
'rgb(255 0 0 / 1)',
|
||||
'rgb(255 0 0 / 1.0)',
|
||||
'rgb(255 0 0 / 100%)',
|
||||
'rgb(100%, 0%, 0%)',
|
||||
'rgb(100%, 0%, 0%, 1)',
|
||||
'rgb(100%, 0%, 0%, 1.0)',
|
||||
'rgb(100%, 0%, 0%, 100%)',
|
||||
'rgb(100% 0% 0%)',
|
||||
'rgb(100% 0% 0% / 1)',
|
||||
'rgb(100%, 0%, 0%, 1.0)',
|
||||
'rgb(100%, 0%, 0%, 100%)',
|
||||
'rgb(300,0,0)',
|
||||
'rgb(300 0 0)',
|
||||
'rgb(255,-10,0)',
|
||||
'rgb(110%, 0%, 0%)',
|
||||
'rgba(255,0,0)',
|
||||
'rgba(255,0,0,1)',
|
||||
'rgba(255 0 0 / 1)',
|
||||
'rgba(100%,0%,0%,1)',
|
||||
'rgba(0,0,255,0.5)',
|
||||
'rgba(100%, 50%, 0%, 0.1)',
|
||||
'hsl(120, 100%, 50%)',
|
||||
'hsl(120 100% 50%)',
|
||||
'hsl(120, 100%, 50%, 1.0)',
|
||||
'hsl(120 100% 50% / 1.0)',
|
||||
'hsla(120, 100%, 50%)',
|
||||
'hsla(120 100% 50%)',
|
||||
'hsla(120, 100%, 50%, 1.0)',
|
||||
'hsla(120 100% 50% / 1.0)',
|
||||
'hsl(120deg, 100%, 50%)',
|
||||
'hsl(133.33333333grad, 100%, 50%)',
|
||||
'hsl(2.0943951024rad, 100%, 50%)',
|
||||
'hsl(0.3333333333turn, 100%, 50%)',
|
||||
"maroon",
|
||||
"#f00",
|
||||
"#ff0000",
|
||||
"rgb(255,0,0)",
|
||||
"rgb(255,0,0,1)",
|
||||
"rgb(255,0,0,1.0)",
|
||||
"rgb(255,0,0,100%)",
|
||||
"rgb(255 0 0)",
|
||||
"rgb(255 0 0 / 1)",
|
||||
"rgb(255 0 0 / 1.0)",
|
||||
"rgb(255 0 0 / 100%)",
|
||||
"rgb(100%, 0%, 0%)",
|
||||
"rgb(100%, 0%, 0%, 1)",
|
||||
"rgb(100%, 0%, 0%, 1.0)",
|
||||
"rgb(100%, 0%, 0%, 100%)",
|
||||
"rgb(100% 0% 0%)",
|
||||
"rgb(100% 0% 0% / 1)",
|
||||
"rgb(100%, 0%, 0%, 1.0)",
|
||||
"rgb(100%, 0%, 0%, 100%)",
|
||||
"rgb(300,0,0)",
|
||||
"rgb(300 0 0)",
|
||||
"rgb(255,-10,0)",
|
||||
"rgb(110%, 0%, 0%)",
|
||||
"rgba(255,0,0)",
|
||||
"rgba(255,0,0,1)",
|
||||
"rgba(255 0 0 / 1)",
|
||||
"rgba(100%,0%,0%,1)",
|
||||
"rgba(0,0,255,0.5)",
|
||||
"rgba(100%, 50%, 0%, 0.1)",
|
||||
"hsl(120, 100%, 50%)",
|
||||
"hsl(120 100% 50%)",
|
||||
"hsl(120, 100%, 50%, 1.0)",
|
||||
"hsl(120 100% 50% / 1.0)",
|
||||
"hsla(120, 100%, 50%)",
|
||||
"hsla(120 100% 50%)",
|
||||
"hsla(120, 100%, 50%, 1.0)",
|
||||
"hsla(120 100% 50% / 1.0)",
|
||||
"hsl(120deg, 100%, 50%)",
|
||||
"hsl(133.33333333grad, 100%, 50%)",
|
||||
"hsl(2.0943951024rad, 100%, 50%)",
|
||||
"hsl(0.3333333333turn, 100%, 50%)",
|
||||
];
|
||||
|
||||
validThemeColors.forEach(background_color => {
|
||||
data.jsonText = JSON.stringify({
|
||||
background_color: background_color
|
||||
background_color,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
@ -79,25 +79,25 @@ validThemeColors.forEach(background_color => {
|
|||
});
|
||||
|
||||
var invalidThemeColors = [
|
||||
'marooon',
|
||||
'f000000',
|
||||
'#ff00000',
|
||||
'rgb(100, 0%, 0%)',
|
||||
'rgb(255,0)',
|
||||
'rbg(255,-10,0)',
|
||||
'rgb(110, 0%, 0%)',
|
||||
'(255,0,0) }',
|
||||
'rgba(255)',
|
||||
' rgb(100%,0%,0%) }',
|
||||
'hsl(120, 100%, 50)',
|
||||
'hsl(120, 100%, 50.0)',
|
||||
'hsl 120, 100%, 50%',
|
||||
'hsla{120, 100%, 50%, 1}',
|
||||
]
|
||||
"marooon",
|
||||
"f000000",
|
||||
"#ff00000",
|
||||
"rgb(100, 0%, 0%)",
|
||||
"rgb(255,0)",
|
||||
"rbg(255,-10,0)",
|
||||
"rgb(110, 0%, 0%)",
|
||||
"(255,0,0) }",
|
||||
"rgba(255)",
|
||||
" rgb(100%,0%,0%) }",
|
||||
"hsl(120, 100%, 50)",
|
||||
"hsl(120, 100%, 50.0)",
|
||||
"hsl 120, 100%, 50%",
|
||||
"hsla{120, 100%, 50%, 1}",
|
||||
];
|
||||
|
||||
invalidThemeColors.forEach(background_color => {
|
||||
data.jsonText = JSON.stringify({
|
||||
background_color: background_color
|
||||
background_color,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ invalidThemeColors.forEach(background_color => {
|
|||
validThemeColors.forEach(background_color => {
|
||||
var expandedThemeColor = `${seperators}${lineTerminators}${background_color}${lineTerminators}${seperators}`;
|
||||
data.jsonText = JSON.stringify({
|
||||
background_color: expandedThemeColor
|
||||
background_color: expandedThemeColor,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,19 +14,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1258899
|
|||
* dir member
|
||||
* https://w3c.github.io/manifest/#dir-member
|
||||
**/
|
||||
'use strict';
|
||||
//Type checks
|
||||
"use strict";
|
||||
// Type checks
|
||||
typeTests.forEach((type) => {
|
||||
var expected = `Expect non - string dir to default to "auto".`;
|
||||
data.jsonText = JSON.stringify({
|
||||
dir: type
|
||||
dir: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.dir, 'auto', expected);
|
||||
is(result.dir, "auto", expected);
|
||||
});
|
||||
|
||||
/*Test valid values*/
|
||||
var validDirs = ['ltr', 'rtl', 'auto']
|
||||
/* Test valid values*/
|
||||
var validDirs = ["ltr", "rtl", "auto"];
|
||||
validDirs.forEach((dir) => {
|
||||
var expected = `Expect dir value to be ${dir}.`;
|
||||
data.jsonText = JSON.stringify({dir});
|
||||
|
|
@ -34,24 +34,24 @@ validDirs.forEach((dir) => {
|
|||
is(result.dir, dir, expected);
|
||||
});
|
||||
|
||||
//trim tests
|
||||
// trim tests
|
||||
validDirs.forEach((dir) => {
|
||||
var expected = `Expect trimmed dir to be returned.`;
|
||||
var expandeddir = seperators + lineTerminators + dir + lineTerminators + seperators;
|
||||
data.jsonText = JSON.stringify({
|
||||
dir: expandeddir
|
||||
dir: expandeddir,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.dir, dir, expected);
|
||||
});
|
||||
|
||||
//Unknown/Invalid directions
|
||||
var invalidDirs = ['LTR', 'RtL', `fooo${whiteSpace}rtl`, '', 'bar baz, some value', 'ltr rtl auto', 'AuTo'];
|
||||
// Unknown/Invalid directions
|
||||
var invalidDirs = ["LTR", "RtL", `fooo${whiteSpace}rtl`, "", "bar baz, some value", "ltr rtl auto", "AuTo"];
|
||||
invalidDirs.forEach((dir) => {
|
||||
var expected = `Expect default dir "auto" to be returned: '${dir}'`;
|
||||
data.jsonText = JSON.stringify({dir});
|
||||
var result = processor.process(data);
|
||||
is(result.dir, 'auto', expected);
|
||||
is(result.dir, "auto", expected);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -14,65 +14,65 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* display member
|
||||
* https://w3c.github.io/manifest/#display-member
|
||||
**/
|
||||
'use strict';
|
||||
//Type checks
|
||||
"use strict";
|
||||
// Type checks
|
||||
typeTests.forEach((type) => {
|
||||
var expected = `Expect non - string display to default to "browser".`;
|
||||
data.jsonText = JSON.stringify({
|
||||
display: type
|
||||
display: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.display, 'browser', expected);
|
||||
is(result.display, "browser", expected);
|
||||
});
|
||||
|
||||
/*Test valid modes - case insensitive*/
|
||||
/* Test valid modes - case insensitive*/
|
||||
var validModes = [
|
||||
'fullscreen',
|
||||
'standalone',
|
||||
'minimal-ui',
|
||||
'browser',
|
||||
'FullScreen',
|
||||
'standAlone',
|
||||
'minimal-UI',
|
||||
'BROWSER',
|
||||
]
|
||||
"fullscreen",
|
||||
"standalone",
|
||||
"minimal-ui",
|
||||
"browser",
|
||||
"FullScreen",
|
||||
"standAlone",
|
||||
"minimal-UI",
|
||||
"BROWSER",
|
||||
];
|
||||
validModes.forEach((mode) => {
|
||||
var expected = `Expect display mode to be ${mode.toLowerCase()}.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
display: mode
|
||||
display: mode,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.display, mode.toLowerCase(), expected);
|
||||
});
|
||||
|
||||
//trim tests
|
||||
// trim tests
|
||||
validModes.forEach((display) => {
|
||||
var expected = `Expect trimmed display mode to be returned.`;
|
||||
var expandedDisplay = seperators + lineTerminators + display + lineTerminators + seperators;
|
||||
data.jsonText = JSON.stringify({
|
||||
display: expandedDisplay
|
||||
display: expandedDisplay,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.display, display.toLowerCase(), expected);
|
||||
});
|
||||
|
||||
//Unknown modes
|
||||
// Unknown modes
|
||||
var invalidModes = [
|
||||
'foo',
|
||||
"foo",
|
||||
`fooo${whiteSpace}`,
|
||||
'',
|
||||
'fullscreen,standalone',
|
||||
'standalone fullscreen',
|
||||
'FULLSCreENS',
|
||||
"",
|
||||
"fullscreen,standalone",
|
||||
"standalone fullscreen",
|
||||
"FULLSCreENS",
|
||||
];
|
||||
|
||||
invalidModes.forEach((invalidMode) => {
|
||||
var expected = `Expect default display mode "browser" to be returned: '${invalidMode}'`;
|
||||
data.jsonText = JSON.stringify({
|
||||
display: invalidMode
|
||||
display: invalidMode,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.display, 'browser', expected);
|
||||
is(result.display, "browser", expected);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* https://w3c.github.io/manifest/#icons-member
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
typeTests.forEach((type) => {
|
||||
var expected = `Expect non-array icons to be empty array: ${typeof type}.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
icons: type
|
||||
icons: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
var y = SpecialPowers.unwrap(result.icons);
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1143879
|
|||
* lang member
|
||||
* https://w3c.github.io/manifest/#lang-member
|
||||
**/
|
||||
/*globals is, typeTests, data, processor, seperators, lineTerminators, todo_is*/
|
||||
'use strict';
|
||||
/* 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({
|
||||
lang: type
|
||||
lang: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.lang, undefined, expected);
|
||||
|
|
@ -28,34 +28,34 @@ for (var type of typeTests) {
|
|||
// Test valid language tags - derived from IANA and BCP-47 spec
|
||||
// and our Intl.js implementation.
|
||||
var validTags = [
|
||||
'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az',
|
||||
'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce',
|
||||
'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee',
|
||||
'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr',
|
||||
'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr',
|
||||
'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ik', 'in', 'io',
|
||||
'is', 'it', 'iu', 'iw', 'ja', 'ji', 'jv', 'jw', 'ka', 'kg', 'ki', 'kj',
|
||||
'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la',
|
||||
'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk',
|
||||
'ml', 'mn', 'mo', 'mr', 'ms', 'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng',
|
||||
'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa',
|
||||
'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc',
|
||||
'sd', 'se', 'sg', 'sh', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr',
|
||||
'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl',
|
||||
'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've',
|
||||
'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'za', 'zh', 'zu', 'en-US',
|
||||
'jp-JS', 'pt-PT', 'pt-BR', 'de-CH', 'de-DE-1901', 'es-419', 'sl-IT-nedis',
|
||||
'en-US-boont', 'mn-Cyrl-MN', 'x-fr-CH', 'sr-Cyrl', 'sr-Latn',
|
||||
'hy-Latn-IT-arevela', 'zh-TW', 'en-GB-boont-r-extended-sequence-x-private',
|
||||
'zh-nan-hans-bu-variant2-variant1-u-ca-chinese-t-zh-latn-x-private',
|
||||
'zh-cmn-Hans-CN', 'cmn-Hans-CN', 'zh-yue-HK', 'yue-HK',
|
||||
'de-CH-x-phonebk', 'az-Arab-x-AZE-derbend', 'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern'
|
||||
"aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az",
|
||||
"ba", "be", "bg", "bh", "bi", "bm", "bn", "bo", "br", "bs", "ca", "ce",
|
||||
"ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee",
|
||||
"el", "en", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr",
|
||||
"fy", "ga", "gd", "gl", "gn", "gu", "gv", "ha", "he", "hi", "ho", "hr",
|
||||
"ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ik", "in", "io",
|
||||
"is", "it", "iu", "iw", "ja", "ji", "jv", "jw", "ka", "kg", "ki", "kj",
|
||||
"kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky", "la",
|
||||
"lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk",
|
||||
"ml", "mn", "mo", "mr", "ms", "mt", "my", "na", "nb", "nd", "ne", "ng",
|
||||
"nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa",
|
||||
"pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc",
|
||||
"sd", "se", "sg", "sh", "si", "sk", "sl", "sm", "sn", "so", "sq", "sr",
|
||||
"ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl",
|
||||
"tn", "to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve",
|
||||
"vi", "vo", "wa", "wo", "xh", "yi", "yo", "za", "zh", "zu", "en-US",
|
||||
"jp-JS", "pt-PT", "pt-BR", "de-CH", "de-DE-1901", "es-419", "sl-IT-nedis",
|
||||
"en-US-boont", "mn-Cyrl-MN", "x-fr-CH", "sr-Cyrl", "sr-Latn",
|
||||
"hy-Latn-IT-arevela", "zh-TW", "en-GB-boont-r-extended-sequence-x-private",
|
||||
"zh-nan-hans-bu-variant2-variant1-u-ca-chinese-t-zh-latn-x-private",
|
||||
"zh-cmn-Hans-CN", "cmn-Hans-CN", "zh-yue-HK", "yue-HK",
|
||||
"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}.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: tag
|
||||
lang: tag,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.lang, tag, expected);
|
||||
|
|
@ -67,21 +67,21 @@ for (var tag of validTags) {
|
|||
var expandedtag = seperators + lineTerminators + tag;
|
||||
expandedtag += lineTerminators + seperators;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: expandedtag
|
||||
lang: expandedtag,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.lang, tag, expected);
|
||||
}
|
||||
|
||||
//Invalid language tags, derived from BCP-47 and made up.
|
||||
// Invalid language tags, derived from BCP-47 and made up.
|
||||
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'
|
||||
"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.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: item
|
||||
lang: item,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
todo_is(result.lang, undefined, expected);
|
||||
|
|
@ -91,19 +91,19 @@ for (var item of invalidTags) {
|
|||
// canonical form, to upper case and expect the processor to return them
|
||||
// in canonical form.
|
||||
var canonicalTags = [
|
||||
'jp-JS', 'pt-PT', 'pt-BR', 'de-CH', 'de-DE-1901', 'es-419', 'sl-IT-nedis',
|
||||
'en-US-boont', 'mn-Cyrl-MN', 'x-fr-CH', 'sr-Cyrl', 'sr-Latn',
|
||||
'hy-Latn-IT-arevela', 'zh-TW', 'en-GB-boont-r-extended-sequence-x-private',
|
||||
'zh-cmn-Hans-CN', 'cmn-Hans-CN', 'zh-yue-HK', 'yue-HK',
|
||||
'de-CH-x-phonebk', 'az-Arab-x-AZE-derbend', 'x-whatever',
|
||||
'qaa-Qaaa-QM-x-southern'
|
||||
"jp-JS", "pt-PT", "pt-BR", "de-CH", "de-DE-1901", "es-419", "sl-IT-nedis",
|
||||
"en-US-boont", "mn-Cyrl-MN", "x-fr-CH", "sr-Cyrl", "sr-Latn",
|
||||
"hy-Latn-IT-arevela", "zh-TW", "en-GB-boont-r-extended-sequence-x-private",
|
||||
"zh-cmn-Hans-CN", "cmn-Hans-CN", "zh-yue-HK", "yue-HK",
|
||||
"de-CH-x-phonebk", "az-Arab-x-AZE-derbend", "x-whatever",
|
||||
"qaa-Qaaa-QM-x-southern",
|
||||
];
|
||||
|
||||
for (var tag of canonicalTags) {
|
||||
var uppedTag = tag.toUpperCase();
|
||||
var expected = `Expect tag (${uppedTag}) to be in canonical form (${tag}).`;
|
||||
data.jsonText = JSON.stringify({
|
||||
lang: uppedTag
|
||||
lang: uppedTag,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
todo_is(result.lang, tag, expected);
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* https://w3c.github.io/manifest/#short_name-member
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
var trimNamesTests = [
|
||||
`${seperators}pass${seperators}`,
|
||||
`${lineTerminators}pass${lineTerminators}`,
|
||||
`${whiteSpace}pass${whiteSpace}`,
|
||||
//BOM
|
||||
`\uFEFFpass\uFEFF`
|
||||
// BOM
|
||||
`\uFEFFpass\uFEFF`,
|
||||
];
|
||||
var props = ['name', 'short_name'];
|
||||
var props = ["name", "short_name"];
|
||||
|
||||
props.forEach((prop) => {
|
||||
trimNamesTests.forEach((trimmableString) => {
|
||||
|
|
@ -34,7 +34,7 @@ props.forEach((prop) => {
|
|||
obj[prop] = trimmableString;
|
||||
data.jsonText = JSON.stringify(obj);
|
||||
var result = processor.process(data);
|
||||
is(result[prop], 'pass', assetion);
|
||||
is(result[prop], "pass", assetion);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -56,13 +56,13 @@ props.forEach((prop) => {
|
|||
* acceptable names - including long names
|
||||
*/
|
||||
var acceptableNames = [
|
||||
'pass',
|
||||
"pass",
|
||||
`pass pass pass pass pass pass pass pass pass pass pass pass pass pass
|
||||
pass pass pass pass pass pass pass pass pass pass pass pass pass pass
|
||||
pass pass pass pass pass pass pass pass pass pass pass pass pass pass
|
||||
pass pass pass pass pass pass pass pass pass pass pass pass`,
|
||||
'これは許容できる名前です',
|
||||
'ນີ້ແມ່ນຊື່ທີ່ຍອມຮັບໄດ້'
|
||||
"これは許容できる名前です",
|
||||
"ນີ້ແມ່ນຊື່ທີ່ຍອມຮັບໄດ້",
|
||||
];
|
||||
|
||||
props.forEach((prop) => {
|
||||
|
|
|
|||
|
|
@ -14,34 +14,34 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* orientation member
|
||||
* https://w3c.github.io/manifest/#orientation-member
|
||||
**/
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
typeTests.forEach((type) => {
|
||||
var expected = `Expect non-string orientation to be empty string : ${typeof type}.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
orientation: type
|
||||
orientation: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.orientation, undefined, expected);
|
||||
});
|
||||
|
||||
var validOrientations = [
|
||||
'any',
|
||||
'natural',
|
||||
'landscape',
|
||||
'portrait',
|
||||
'portrait-primary',
|
||||
'portrait-secondary',
|
||||
'landscape-primary',
|
||||
'landscape-secondary',
|
||||
'aNy',
|
||||
'NaTuRal',
|
||||
'LANDsCAPE',
|
||||
'PORTRAIT',
|
||||
'portrait-PRIMARY',
|
||||
'portrait-SECONDARY',
|
||||
'LANDSCAPE-primary',
|
||||
'LANDSCAPE-secondary',
|
||||
"any",
|
||||
"natural",
|
||||
"landscape",
|
||||
"portrait",
|
||||
"portrait-primary",
|
||||
"portrait-secondary",
|
||||
"landscape-primary",
|
||||
"landscape-secondary",
|
||||
"aNy",
|
||||
"NaTuRal",
|
||||
"LANDsCAPE",
|
||||
"PORTRAIT",
|
||||
"portrait-PRIMARY",
|
||||
"portrait-SECONDARY",
|
||||
"LANDSCAPE-primary",
|
||||
"LANDSCAPE-secondary",
|
||||
];
|
||||
|
||||
validOrientations.forEach((orientation) => {
|
||||
|
|
@ -52,17 +52,17 @@ validOrientations.forEach((orientation) => {
|
|||
});
|
||||
|
||||
var invalidOrientations = [
|
||||
'all',
|
||||
'ANYMany',
|
||||
'NaTuRalle',
|
||||
'portrait-primary portrait-secondary',
|
||||
'portrait-primary,portrait-secondary',
|
||||
'any-natural',
|
||||
'portrait-landscape',
|
||||
'primary-portrait',
|
||||
'secondary-portrait',
|
||||
'landscape-landscape',
|
||||
'secondary-primary'
|
||||
"all",
|
||||
"ANYMany",
|
||||
"NaTuRalle",
|
||||
"portrait-primary portrait-secondary",
|
||||
"portrait-primary,portrait-secondary",
|
||||
"any-natural",
|
||||
"portrait-landscape",
|
||||
"primary-portrait",
|
||||
"secondary-portrait",
|
||||
"landscape-landscape",
|
||||
"secondary-primary",
|
||||
];
|
||||
|
||||
invalidOrientations.forEach((orientation) => {
|
||||
|
|
@ -72,12 +72,12 @@ invalidOrientations.forEach((orientation) => {
|
|||
is(result.orientation, undefined, expected);
|
||||
});
|
||||
|
||||
//Trim tests
|
||||
// Trim tests
|
||||
validOrientations.forEach((orientation) => {
|
||||
var expected = `Expect trimmed orientation to be returned.`;
|
||||
var expandedOrientation = `${seperators}${lineTerminators}${orientation}${lineTerminators}${seperators}`;
|
||||
data.jsonText = JSON.stringify({
|
||||
orientation: expandedOrientation
|
||||
orientation: expandedOrientation,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.orientation, orientation.toLowerCase(), expected);
|
||||
|
|
|
|||
|
|
@ -14,76 +14,76 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* Manifest scope
|
||||
* https://w3c.github.io/manifest/#scope-member
|
||||
**/
|
||||
'use strict';
|
||||
var expected = 'Expect non-string scope to be undefined';
|
||||
"use strict";
|
||||
var expected = "Expect non-string scope to be undefined";
|
||||
typeTests.forEach((type) => {
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: type
|
||||
scope: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope, undefined, expected);
|
||||
});
|
||||
|
||||
var expected = 'Expect different origin to be treated as undefined';
|
||||
var expected = "Expect different origin to be treated as undefined";
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: 'http://not-same-origin'
|
||||
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.';
|
||||
var expected = "Expect the empty string to be treated as undefined.";
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: ''
|
||||
scope: "",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope, undefined, expected);
|
||||
|
||||
var expected = 'Resolve URLs relative to manifest.';
|
||||
var URLs = ['path', '/path', '../../path'];
|
||||
var expected = "Resolve URLs relative to manifest.";
|
||||
var URLs = ["path", "/path", "../../path"];
|
||||
URLs.forEach((url) => {
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: url,
|
||||
start_url: "/path"
|
||||
start_url: "/path",
|
||||
});
|
||||
var absURL = new URL(url, manifestURL).toString();
|
||||
var result = processor.process(data);
|
||||
is(result.scope, absURL, expected);
|
||||
});
|
||||
|
||||
var expected = 'If start URL is not in scope, return undefined.';
|
||||
var expected = "If start URL is not in scope, return undefined.";
|
||||
data.jsonText = JSON.stringify({
|
||||
scope: 'foo',
|
||||
start_url: 'bar'
|
||||
scope: "foo",
|
||||
start_url: "bar",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope, undefined, expected);
|
||||
|
||||
var expected = 'If start URL is in scope, use the scope.';
|
||||
var expected = "If start URL is in scope, use the scope.";
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: 'foobar',
|
||||
scope: 'foo'
|
||||
start_url: "foobar",
|
||||
scope: "foo",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope.toString(), new URL('foo', manifestURL).toString(), expected);
|
||||
is(result.scope.toString(), new URL("foo", manifestURL).toString(), expected);
|
||||
|
||||
var expected = 'Expect start_url to be ' + new URL('foobar', manifestURL).toString();
|
||||
is(result.start_url.toString(), new URL('foobar', manifestURL).toString(), expected);
|
||||
var 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.';
|
||||
var expected = "If start URL is in scope, use the scope.";
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: '/foo/',
|
||||
scope: '/foo/'
|
||||
start_url: "/foo/",
|
||||
scope: "/foo/",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope.toString(), new URL('/foo/', manifestURL).toString(), expected);
|
||||
is(result.scope.toString(), new URL("/foo/", manifestURL).toString(), expected);
|
||||
|
||||
var expected = 'If start URL is in scope, use the scope.';
|
||||
var expected = "If start URL is in scope, use the scope.";
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: '.././foo/',
|
||||
scope: '../foo/'
|
||||
start_url: ".././foo/",
|
||||
scope: "../foo/",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.scope.toString(), new URL('/foo/', manifestURL).toString(), expected);
|
||||
is(result.scope.toString(), new URL("/foo/", manifestURL).toString(), expected);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -14,42 +14,42 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
|
|||
* Manifest start_url
|
||||
* https://w3c.github.io/manifest/#start_url-member
|
||||
**/
|
||||
'use strict';
|
||||
"use strict";
|
||||
typeTests.forEach((type) => {
|
||||
var expected = `Expect non - string start_url to be doc's url: ${typeof type}.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: type
|
||||
start_url: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.start_url.toString(), docURL.toString(), expected);
|
||||
});
|
||||
|
||||
//Not same origin
|
||||
// Not same origin
|
||||
var expected = `Expect different origin URLs to become document's URL.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: 'http://not-same-origin'
|
||||
start_url: "http://not-same-origin",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.start_url.toString(), docURL.toString(), expected);
|
||||
|
||||
//Empty string test
|
||||
// Empty string test
|
||||
var expected = `Expect empty string for start_url to become document's URL.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: ''
|
||||
start_url: "",
|
||||
});
|
||||
var result = processor.process(data);
|
||||
is(result.start_url.toString(), docURL.toString(), expected);
|
||||
|
||||
//Resolve URLs relative to manfiest
|
||||
var URLs = ['path', '/path', '../../path',
|
||||
// Resolve URLs relative to manfiest
|
||||
var URLs = ["path", "/path", "../../path",
|
||||
`${whiteSpace}path${whiteSpace}`,
|
||||
`${whiteSpace}/path`,
|
||||
`${whiteSpace}../../path`
|
||||
`${whiteSpace}../../path`,
|
||||
];
|
||||
URLs.forEach((url) => {
|
||||
var expected = `Resolve URLs relative to manifest.`;
|
||||
data.jsonText = JSON.stringify({
|
||||
start_url: url
|
||||
start_url: url,
|
||||
});
|
||||
var absURL = new URL(url, manifestURL).toString();
|
||||
var result = processor.process(data);
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1195018
|
|||
* theme_color member
|
||||
* https://w3c.github.io/manifest/#theme_color-member
|
||||
**/
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
typeTests.forEach(type => {
|
||||
data.jsonText = JSON.stringify({
|
||||
theme_color: type
|
||||
theme_color: type,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
@ -26,52 +26,52 @@ typeTests.forEach(type => {
|
|||
});
|
||||
|
||||
var validThemeColors = [
|
||||
'maroon',
|
||||
'#f00',
|
||||
'#ff0000',
|
||||
'rgb(255,0,0)',
|
||||
'rgb(255,0,0,1)',
|
||||
'rgb(255,0,0,1.0)',
|
||||
'rgb(255,0,0,100%)',
|
||||
'rgb(255 0 0)',
|
||||
'rgb(255 0 0 / 1)',
|
||||
'rgb(255 0 0 / 1.0)',
|
||||
'rgb(255 0 0 / 100%)',
|
||||
'rgb(100%, 0%, 0%)',
|
||||
'rgb(100%, 0%, 0%, 1)',
|
||||
'rgb(100%, 0%, 0%, 1.0)',
|
||||
'rgb(100%, 0%, 0%, 100%)',
|
||||
'rgb(100% 0% 0%)',
|
||||
'rgb(100% 0% 0% / 1)',
|
||||
'rgb(100%, 0%, 0%, 1.0)',
|
||||
'rgb(100%, 0%, 0%, 100%)',
|
||||
'rgb(300,0,0)',
|
||||
'rgb(300 0 0)',
|
||||
'rgb(255,-10,0)',
|
||||
'rgb(110%, 0%, 0%)',
|
||||
'rgba(255,0,0)',
|
||||
'rgba(255,0,0,1)',
|
||||
'rgba(255 0 0 / 1)',
|
||||
'rgba(100%,0%,0%,1)',
|
||||
'rgba(0,0,255,0.5)',
|
||||
'rgba(100%, 50%, 0%, 0.1)',
|
||||
'hsl(120, 100%, 50%)',
|
||||
'hsl(120 100% 50%)',
|
||||
'hsl(120, 100%, 50%, 1.0)',
|
||||
'hsl(120 100% 50% / 1.0)',
|
||||
'hsla(120, 100%, 50%)',
|
||||
'hsla(120 100% 50%)',
|
||||
'hsla(120, 100%, 50%, 1.0)',
|
||||
'hsla(120 100% 50% / 1.0)',
|
||||
'hsl(120deg, 100%, 50%)',
|
||||
'hsl(133.33333333grad, 100%, 50%)',
|
||||
'hsl(2.0943951024rad, 100%, 50%)',
|
||||
'hsl(0.3333333333turn, 100%, 50%)',
|
||||
"maroon",
|
||||
"#f00",
|
||||
"#ff0000",
|
||||
"rgb(255,0,0)",
|
||||
"rgb(255,0,0,1)",
|
||||
"rgb(255,0,0,1.0)",
|
||||
"rgb(255,0,0,100%)",
|
||||
"rgb(255 0 0)",
|
||||
"rgb(255 0 0 / 1)",
|
||||
"rgb(255 0 0 / 1.0)",
|
||||
"rgb(255 0 0 / 100%)",
|
||||
"rgb(100%, 0%, 0%)",
|
||||
"rgb(100%, 0%, 0%, 1)",
|
||||
"rgb(100%, 0%, 0%, 1.0)",
|
||||
"rgb(100%, 0%, 0%, 100%)",
|
||||
"rgb(100% 0% 0%)",
|
||||
"rgb(100% 0% 0% / 1)",
|
||||
"rgb(100%, 0%, 0%, 1.0)",
|
||||
"rgb(100%, 0%, 0%, 100%)",
|
||||
"rgb(300,0,0)",
|
||||
"rgb(300 0 0)",
|
||||
"rgb(255,-10,0)",
|
||||
"rgb(110%, 0%, 0%)",
|
||||
"rgba(255,0,0)",
|
||||
"rgba(255,0,0,1)",
|
||||
"rgba(255 0 0 / 1)",
|
||||
"rgba(100%,0%,0%,1)",
|
||||
"rgba(0,0,255,0.5)",
|
||||
"rgba(100%, 50%, 0%, 0.1)",
|
||||
"hsl(120, 100%, 50%)",
|
||||
"hsl(120 100% 50%)",
|
||||
"hsl(120, 100%, 50%, 1.0)",
|
||||
"hsl(120 100% 50% / 1.0)",
|
||||
"hsla(120, 100%, 50%)",
|
||||
"hsla(120 100% 50%)",
|
||||
"hsla(120, 100%, 50%, 1.0)",
|
||||
"hsla(120 100% 50% / 1.0)",
|
||||
"hsl(120deg, 100%, 50%)",
|
||||
"hsl(133.33333333grad, 100%, 50%)",
|
||||
"hsl(2.0943951024rad, 100%, 50%)",
|
||||
"hsl(0.3333333333turn, 100%, 50%)",
|
||||
];
|
||||
|
||||
validThemeColors.forEach(theme_color => {
|
||||
data.jsonText = JSON.stringify({
|
||||
theme_color: theme_color
|
||||
theme_color,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
@ -79,25 +79,25 @@ validThemeColors.forEach(theme_color => {
|
|||
});
|
||||
|
||||
var invalidThemeColors = [
|
||||
'marooon',
|
||||
'f000000',
|
||||
'#ff00000',
|
||||
'rgb(100, 0%, 0%)',
|
||||
'rgb(255,0)',
|
||||
'rbg(255,-10,0)',
|
||||
'rgb(110, 0%, 0%)',
|
||||
'(255,0,0) }',
|
||||
'rgba(255)',
|
||||
' rgb(100%,0%,0%) }',
|
||||
'hsl(120, 100%, 50)',
|
||||
'hsl(120, 100%, 50.0)',
|
||||
'hsl 120, 100%, 50%',
|
||||
'hsla{120, 100%, 50%, 1}',
|
||||
]
|
||||
"marooon",
|
||||
"f000000",
|
||||
"#ff00000",
|
||||
"rgb(100, 0%, 0%)",
|
||||
"rgb(255,0)",
|
||||
"rbg(255,-10,0)",
|
||||
"rgb(110, 0%, 0%)",
|
||||
"(255,0,0) }",
|
||||
"rgba(255)",
|
||||
" rgb(100%,0%,0%) }",
|
||||
"hsl(120, 100%, 50)",
|
||||
"hsl(120, 100%, 50.0)",
|
||||
"hsl 120, 100%, 50%",
|
||||
"hsla{120, 100%, 50%, 1}",
|
||||
];
|
||||
|
||||
invalidThemeColors.forEach(theme_color => {
|
||||
data.jsonText = JSON.stringify({
|
||||
theme_color: theme_color
|
||||
theme_color,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ invalidThemeColors.forEach(theme_color => {
|
|||
validThemeColors.forEach(theme_color => {
|
||||
var expandedThemeColor = `${seperators}${lineTerminators}${theme_color}${lineTerminators}${seperators}`;
|
||||
data.jsonText = JSON.stringify({
|
||||
theme_color: expandedThemeColor
|
||||
theme_color: expandedThemeColor,
|
||||
});
|
||||
var result = processor.process(data);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1086997
|
|||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script src="common.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ConsoleAPI
|
||||
} = SpecialPowers.Cu.import('resource://gre/modules/Console.jsm');
|
||||
ConsoleAPI,
|
||||
} = SpecialPowers.Cu.import("resource://gre/modules/Console.jsm");
|
||||
|
||||
var warning = null;
|
||||
|
||||
|
|
@ -26,59 +26,59 @@ ConsoleAPI.prototype.warn = function(aWarning) {
|
|||
[
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify(1),
|
||||
warning: 'Manifest should be an object.',
|
||||
warning: "Manifest should be an object.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify(null),
|
||||
warning: 'Manifest should be an object.',
|
||||
warning: "Manifest should be an object.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify('a string'),
|
||||
warning: 'Manifest should be an object.',
|
||||
func: () => data.jsonText = JSON.stringify("a string"),
|
||||
warning: "Manifest should be an object.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify({
|
||||
scope: 'https://www.mozilla.org',
|
||||
scope: "https://www.mozilla.org",
|
||||
}),
|
||||
warning: 'The scope URL must be same origin as document.',
|
||||
warning: "The scope URL must be same origin as document.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify({
|
||||
scope: 'foo',
|
||||
start_url: 'bar',
|
||||
scope: "foo",
|
||||
start_url: "bar",
|
||||
}),
|
||||
warning: 'The start URL is outside the scope, so the scope is invalid.',
|
||||
warning: "The start URL is outside the scope, so the scope is invalid.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify({
|
||||
start_url: 'https://www.mozilla.org',
|
||||
start_url: "https://www.mozilla.org",
|
||||
}),
|
||||
warning: 'The start URL must be same origin as document.',
|
||||
warning: "The start URL must be same origin as document.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify({
|
||||
start_url: 42,
|
||||
}),
|
||||
warning: 'Expected the manifest\u2019s start_url member to be a string.',
|
||||
warning: "Expected the manifest\u2019s start_url member to be a string.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify({
|
||||
theme_color: '42',
|
||||
theme_color: "42",
|
||||
}),
|
||||
warning: 'theme_color: 42 is not a valid CSS color.',
|
||||
warning: "theme_color: 42 is not a valid CSS color.",
|
||||
},
|
||||
{
|
||||
func: () => data.jsonText = JSON.stringify({
|
||||
background_color: '42',
|
||||
background_color: "42",
|
||||
}),
|
||||
warning: 'background_color: 42 is not a valid CSS color.',
|
||||
warning: "background_color: 42 is not a valid CSS color.",
|
||||
},
|
||||
].forEach(function(test) {
|
||||
test.func();
|
||||
|
||||
processor.process(data);
|
||||
|
||||
is(warning, test.warning, 'Correct warning.');
|
||||
is(warning, test.warning, "Correct warning.");
|
||||
|
||||
warning = null;
|
||||
data.manifestURL = manifestURL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue