diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/manifest/test/test_ManifestProcessor_warnings.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/manifest/test/test_ManifestProcessor_warnings.html')
-rw-r--r-- | dom/manifest/test/test_ManifestProcessor_warnings.html | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/dom/manifest/test/test_ManifestProcessor_warnings.html b/dom/manifest/test/test_ManifestProcessor_warnings.html new file mode 100644 index 0000000000..f2092c1dcf --- /dev/null +++ b/dom/manifest/test/test_ManifestProcessor_warnings.html @@ -0,0 +1,149 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1086997 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1086997</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <script src="common.js"></script> + <script> +"use strict"; +const options = {...data, checkConformance: true } ; +[ + { + func: () => options.jsonText = JSON.stringify(1), + warn: "Manifest should be an object.", + }, + { + func: () => options.jsonText = JSON.stringify("a string"), + warn: "Manifest should be an object.", + }, + { + func: () => options.jsonText = JSON.stringify({ + scope: "https://www.mozilla.org", + }), + warn: "The scope URL must be same origin as document.", + }, + { + func: () => options.jsonText = JSON.stringify({ + scope: "foo", + start_url: "bar", + }), + warn: "The start URL is outside the scope, so the scope is invalid.", + }, + { + func: () => options.jsonText = JSON.stringify({ + start_url: "https://www.mozilla.org", + }), + warn: "The start URL must be same origin as document.", + }, + { + func: () => options.jsonText = JSON.stringify({ + start_url: 42, + }), + warn: "Expected the manifest\u2019s start_url member to be a string.", + }, + { + func: () => options.jsonText = JSON.stringify({ + theme_color: "42", + }), + warn: "theme_color: 42 is not a valid CSS color.", + }, + { + func: () => options.jsonText = JSON.stringify({ + background_color: "42", + }), + warn: "background_color: 42 is not a valid CSS color.", + }, + { + func: () => options.jsonText = JSON.stringify({ + icons: [ + { "src": "http://example.com", "sizes": "48x48"}, + { "src": "http://:Invalid", "sizes": "48x48"}, + ], + }), + warn: "icons item at index 1 is invalid. The src member is an invalid URL http://:Invalid", + }, + // testing dom.properties: ManifestImageUnusable + { + func() { + return (options.jsonText = JSON.stringify({ + icons: [ + { src: "http://example.com", purpose: "any" }, // valid + { src: "http://example.com", purpose: "banana" }, // generates error + ], + })); + }, + get warn() { + // Returns 2 warnings... array here is just to keep them organized + return [ + "icons item at index 1 includes unsupported purpose(s): banana.", + "icons item at index 1 lacks a usable purpose. It will be ignored.", + ].join(" "); + }, + }, + // testing dom.properties: ManifestImageUnsupportedPurposes + { + func() { + return (options.jsonText = JSON.stringify({ + icons: [ + { src: "http://example.com", purpose: "any" }, // valid + { src: "http://example.com", purpose: "any foo bar baz bar bar baz" }, // generates error + ], + })); + }, + warn: "icons item at index 1 includes unsupported purpose(s): foo bar baz.", + }, + // testing dom.properties: ManifestImageRepeatedPurposes + { + func() { + return (options.jsonText = JSON.stringify({ + icons: [ + { src: "http://example.com", purpose: "any" }, // valid + { + src: "http://example.com", + purpose: "any maskable any maskable maskable", // generates error + }, + ], + })); + }, + warn: "icons item at index 1 includes repeated purpose(s): any maskable.", + }, + // testing dom.properties: ManifestIdIsInvalid + { + func() { + return (options.jsonText = JSON.stringify({ + id: "http://test:65536/foo", + })); + }, + warn: "The id member did not resolve to a valid URL.", + }, + // testing dom.properties ManifestIdNotSameOrigin + { + func() { + return (options.jsonText = JSON.stringify({ + id: "https://other.com", + start_url: "/this/place" + })); + }, + warn: "The id member must have the same origin as the start_url member.", + } +].forEach((test, index) => { + test.func(); + const result = processor.process(options); + let messages = []; + // Poking directly at "warn" triggers xray security wrapper. + for (const validationError of result.moz_validation) { + const { warn } = validationError; + messages.push(warn); + } + is(messages.join(" "), test.warn, "Check warning."); + options.manifestURL = manifestURL; + options.docURL = docURL; +}); + + </script> +</head> |