4 https://bugzilla.mozilla.org/show_bug.cgi?id=1086997
8 <title>Test for Bug
1086997</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
11 <script src=
"common.js"></script>
14 const options
= {...data
, checkConformance
: true } ;
17 func
: () => options
.jsonText
= JSON
.stringify(1),
18 warn
: "Manifest should be an object.",
21 func
: () => options
.jsonText
= JSON
.stringify("a string"),
22 warn
: "Manifest should be an object.",
25 func
: () => options
.jsonText
= JSON
.stringify({
26 scope
: "https://www.mozilla.org",
28 warn
: "The scope URL must be same origin as document.",
31 func
: () => options
.jsonText
= JSON
.stringify({
35 warn
: "The start URL is outside the scope, so the scope is invalid.",
38 func
: () => options
.jsonText
= JSON
.stringify({
39 start_url
: "https://www.mozilla.org",
41 warn
: "The start URL must be same origin as document.",
44 func
: () => options
.jsonText
= JSON
.stringify({
47 warn
: "Expected the manifest\u2019s start_url member to be a string.",
50 func
: () => options
.jsonText
= JSON
.stringify({
53 warn
: "theme_color: 42 is not a valid CSS color.",
56 func
: () => options
.jsonText
= JSON
.stringify({
57 background_color
: "42",
59 warn
: "background_color: 42 is not a valid CSS color.",
62 func
: () => options
.jsonText
= JSON
.stringify({
64 { "src": "http://example.com", "sizes": "48x48"},
65 { "src": "http://:Invalid", "sizes": "48x48"},
68 warn
: "icons item at index 1 is invalid. The src member is an invalid URL http://:Invalid",
70 // testing dom.properties: ManifestImageUnusable
73 return (options
.jsonText
= JSON
.stringify({
75 { src
: "http://example.com", purpose
: "any" }, // valid
76 { src
: "http://example.com", purpose
: "banana" }, // generates error
81 // Returns 2 warnings... array here is just to keep them organized
83 "icons item at index 1 includes unsupported purpose(s): banana.",
84 "icons item at index 1 lacks a usable purpose. It will be ignored.",
88 // testing dom.properties: ManifestImageUnsupportedPurposes
91 return (options
.jsonText
= JSON
.stringify({
93 { src
: "http://example.com", purpose
: "any" }, // valid
94 { src
: "http://example.com", purpose
: "any foo bar baz bar bar baz" }, // generates error
98 warn
: "icons item at index 1 includes unsupported purpose(s): foo bar baz.",
100 // testing dom.properties: ManifestImageRepeatedPurposes
103 return (options
.jsonText
= JSON
.stringify({
105 { src
: "http://example.com", purpose
: "any" }, // valid
107 src
: "http://example.com",
108 purpose
: "any maskable any maskable maskable", // generates error
113 warn
: "icons item at index 1 includes repeated purpose(s): any maskable.",
115 // testing dom.properties: ManifestIdIsInvalid
118 return (options
.jsonText
= JSON
.stringify({
119 id
: "http://test:65536/foo",
122 warn
: "The id member did not resolve to a valid URL.",
124 // testing dom.properties ManifestIdNotSameOrigin
127 return (options
.jsonText
= JSON
.stringify({
128 id
: "https://other.com",
129 start_url
: "/this/place"
132 warn
: "The id member must have the same origin as the start_url member.",
134 ].forEach((test
) => {
136 const result
= processor
.process(options
);
138 // Poking directly at "warn" triggers xray security wrapper.
139 for (const validationError
of result
.moz_validation
) {
140 const { warn
} = validationError
;
143 is(messages
.join(" "), test
.warn
, "Check warning.");
144 options
.manifestURL
= manifestURL
;
145 options
.docURL
= docURL
;