Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / manifest / test / test_ImageObjectProcessor_purpose.html
blob386c4566d4f0876e9b99c0cf2ff5ffd4e53ff68e
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=
5 -->
6 <head>
7 <meta charset="utf-8">
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>
12 <script>
13 /**
14 * Image object's purpose member
15 * https://w3c.github.io/manifest/#purpose-member
16 **/
18 "use strict";
19 const testManifest = {
20 icons: [{
21 src: "test",
22 }],
25 const invalidPurposeTypes = [
26 [],
27 123,
28 {},
29 null,
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);
40 });
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);
54 });
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);
69 });
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);
84 });
86 const validPurposes = [
87 "maskable",
88 "monochrome",
89 "any",
90 "any maskable",
91 "maskable any",
92 "any monochrome",
93 "monochrome any",
94 "maskable monochrome any",
95 "monochrome maskable"
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
108 `${whiteSpace}any`,
109 `any${whiteSpace}`,
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");
119 </script>
120 </head>