1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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) => {
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>
|