4 https://bugzilla.mozilla.org/show_bug.cgi?id=
8 <title>Test for Bug
</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" href=
"/tests/SimpleTest/test.css"/>
11 <script src=
"common.js"></script>
14 * Image object's purpose member
15 * https://w3c.github.io/manifest/#purpose-member
19 const testManifest
= {
25 const invalidPurposeTypes
= [
32 invalidPurposeTypes
.forEach(invalidType
=> {
33 const expected
= `Invalid types get treated as 'any'.`;
34 testManifest
.icons
[0].purpose
= invalidType
;
35 data
.jsonText
= JSON
.stringify(testManifest
);
36 const result
= processor
.process(data
);
37 is(result
.icons
.length
, 1, expected
);
38 is(result
.icons
[0].purpose
.length
, 1, expected
);
39 is(result
.icons
[0].purpose
[0], "any", expected
);
42 const invalidPurposes
= [
43 "not-known-test-purpose",
44 "invalid-purpose invalid-purpose",
45 "no-purpose invalid-purpose some-other-non-valid-purpose",
48 invalidPurposes
.forEach(invalidPurpose
=> {
49 const expected
= `Expect invalid purposes to invalidate the icon.`;
50 testManifest
.icons
[0].purpose
= invalidPurpose
;
51 data
.jsonText
= JSON
.stringify(testManifest
);
52 const result
= processor
.process(data
);
53 is(result
.icons
.length
, 0, expected
);
56 const mixedMaskableAndInvalidPurposes
= [
57 "not-known-test-purpose maskable",
58 "maskable invalid-purpose invalid-purpose",
59 "no-purpose invalid-purpose maskable some-other-non-valid-purpose",
62 mixedMaskableAndInvalidPurposes
.forEach(mixedPurpose
=> {
63 const expected
= `Expect on 'maskable' to remain.`;
64 testManifest
.icons
[0].purpose
= mixedPurpose
;
65 data
.jsonText
= JSON
.stringify(testManifest
);
66 const result
= processor
.process(data
);
67 is(result
.icons
.length
, 1, expected
);
68 is(result
.icons
[0].purpose
.join(), "maskable", expected
);
71 const mixedMonochromeAndInvalidPurposes
= [
72 "not-known-test-purpose monochrome",
73 "monochrome invalid-purpose invalid-purpose",
74 "no-purpose invalid-purpose monochrome some-other-non-valid-purpose",
77 mixedMonochromeAndInvalidPurposes
.forEach(mixedPurpose
=> {
78 const expected
= `Expect on 'monochrome' to remain.`;
79 testManifest
.icons
[0].purpose
= mixedPurpose
;
80 data
.jsonText
= JSON
.stringify(testManifest
);
81 const result
= processor
.process(data
);
82 is(result
.icons
.length
, 1, expected
);
83 is(result
.icons
[0].purpose
.join(), "monochrome", expected
);
86 const validPurposes
= [
94 "maskable monochrome any",
98 validPurposes
.forEach(purpose
=> {
99 testManifest
.icons
[0].purpose
= purpose
;
100 data
.jsonText
= JSON
.stringify(testManifest
);
101 var manifest
= processor
.process(data
);
102 is(manifest
.icons
[0].purpose
.join(" "), purpose
, `Expected "${purpose}" as purpose.`);
105 const validWhiteSpace
= [
107 whiteSpace
, // defined in common.js
110 `${whiteSpace}any${whiteSpace}`,
113 validWhiteSpace
.forEach(purpose
=> {
114 testManifest
.icons
[0].purpose
= purpose
;
115 data
.jsonText
= JSON
.stringify(testManifest
);
116 var manifest
= processor
.process(data
);
117 is(manifest
.icons
[0].purpose
.join(), "any");