diff --git a/dom/manifest/ManifestProcessor.jsm b/dom/manifest/ManifestProcessor.jsm index d9e39ac4d337..ef7e2bdd99b9 100644 --- a/dom/manifest/ManifestProcessor.jsm +++ b/dom/manifest/ManifestProcessor.jsm @@ -101,14 +101,18 @@ ManifestProcessor.prototype = { // * manifestURL: the URL of the manifest, to resolve URLs. // * docURL: the URL of the owner doc, for security checks. process({ - jsonText, manifestURL, docURL + jsonText: aJsonText, + manifestURL: aManifestURL, + docURL: aDocURL }) { + const manifestURL = new URL(aManifestURL); + const docURL = new URL(aDocURL); const console = new ConsoleAPI({ prefix: 'Web Manifest: ' }); let rawManifest = {}; try { - rawManifest = JSON.parse(jsonText); + rawManifest = JSON.parse(aJsonText); } catch (e) {} if (typeof rawManifest !== 'object' || rawManifest === null) { let msg = 'Manifest needs to be an object.'; @@ -124,7 +128,8 @@ ManifestProcessor.prototype = { short_name: processShortNameMember(rawManifest), }; processedManifest.scope = processScopeMember(rawManifest, manifestURL, - docURL, processedManifest.start_url); + docURL, new URL(processedManifest.start_url)); + return processedManifest; function processNameMember(aManifest) { @@ -188,8 +193,11 @@ ManifestProcessor.prototype = { expectedType: 'string', trim: false }; - const value = extractValue(spec, console); let scopeURL; + const value = extractValue(spec, console); + if (value === undefined || value === '') { + return undefined; + } try { scopeURL = new URL(value, aManifestURL); } catch (e) { @@ -210,7 +218,7 @@ ManifestProcessor.prototype = { console.warn(msg); return undefined; } - return scopeURL; + return scopeURL.href; } function processStartURLMember(aManifest, aManifestURL, aDocURL) { @@ -221,7 +229,7 @@ ManifestProcessor.prototype = { expectedType: 'string', trim: false }; - let result = new URL(aDocURL); + let result = new URL(aDocURL).href; const value = extractValue(spec, console); if (value === undefined || value === '') { return result; @@ -237,7 +245,7 @@ ManifestProcessor.prototype = { let msg = 'start_url must be same origin as document.'; console.warn(msg); } else { - result = potentialResult; + result = potentialResult.href; } return result; } @@ -248,7 +256,7 @@ this.ManifestProcessor = ManifestProcessor; function IconsProcessor() {} // Static getters -Object.defineProperties(IconsProcessor,{ +Object.defineProperties(IconsProcessor, { 'onlyDecimals': { get: function() { return /^\d+$/; @@ -324,7 +332,7 @@ IconsProcessor.process = function(aManifest, aBaseURL, console) { let url; if (value && value.length) { try { - url = new URL(value, aBaseURL); + url = new URL(value, aBaseURL).href; } catch (e) {} } return url; diff --git a/dom/manifest/test/mochitest.ini b/dom/manifest/test/mochitest.ini index 87fe83a9cab1..de725fe96087 100644 --- a/dom/manifest/test/mochitest.ini +++ b/dom/manifest/test/mochitest.ini @@ -1,5 +1,4 @@ [DEFAULT] -skip-if = e10s support-files = common.js diff --git a/dom/manifest/test/test_IconsProcessor_src.html b/dom/manifest/test/test_IconsProcessor_src.html index 3b298be126ea..7bf0f58a1534 100644 --- a/dom/manifest/test/test_IconsProcessor_src.html +++ b/dom/manifest/test/test_IconsProcessor_src.html @@ -61,7 +61,7 @@ data.jsonText = JSON.stringify(noSrc); var result = processor.process(data); ise(result.icons.length, 0, expected); -var expected = `Expect icon's src to be an instance of URL.`; +var expected = `Expect icon's src to be a string.`; var withSrc = { icons: [{ src: 'pass' @@ -69,7 +69,7 @@ var withSrc = { }; data.jsonText = JSON.stringify(withSrc); var result = processor.process(data); -ise(SpecialPowers.unwrap(result.icons[0].src) instanceof URL, true, expected); +ise(typeof result.icons[0].src, "string", expected); var expected = `Expect only icons with a src prop to be kept.`; var withSrc = { diff --git a/dom/manifest/test/test_ManifestProcessor_JSON.html b/dom/manifest/test/test_ManifestProcessor_JSON.html index 90bfcba0c362..419504000764 100644 --- a/dom/manifest/test/test_ManifestProcessor_JSON.html +++ b/dom/manifest/test/test_ManifestProcessor_JSON.html @@ -20,7 +20,7 @@ invalidJson.forEach((testString) => { var expected = `Expect to recover from invalid JSON: ${testString}`; data.jsonText = testString; var result = processor.process(data); - SimpleTest.ok(result.start_url.href === docURL.href, true, expected); + SimpleTest.ise(result.start_url, docURL.href, expected); }); var validButUnhelpful = ["1", 1, "", "[{}]", "null"]; @@ -28,7 +28,7 @@ validButUnhelpful.forEach((testString) => { var expected = `Expect to recover from invalid JSON: ${testString}`; data.jsonText = testString; var result = processor.process(data); - SimpleTest.ok(result.start_url.href === docURL.href, true, expected); + SimpleTest.ise(result.start_url, docURL.href, expected); }); diff --git a/dom/manifest/test/test_ManifestProcessor_scope.html b/dom/manifest/test/test_ManifestProcessor_scope.html index 51badd7daa9c..ef23998cd25a 100644 --- a/dom/manifest/test/test_ManifestProcessor_scope.html +++ b/dom/manifest/test/test_ManifestProcessor_scope.html @@ -47,8 +47,7 @@ URLs.forEach((url) => { }); var absURL = new URL(url, manifestURL).toString(); var result = processor.process(data); - console.log(result); - ise(String(result.scope), absURL, expected); + ise(result.scope, absURL, expected); }); var expected = 'If start URL is not in scope, return undefined.';