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
|
<!DOCTYPE html>
<!--
[%provenance%]
-->
<html lang="en">
<meta charset="utf-8">
{%- if subtests|length > 10 %}
<meta name="timeout" content="long">
{%- endif %}
<title>HTTP headers on request for CSS image-accepting properties</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/fetch/metadata/resources/helper.sub.js"></script>
<body>
<script>
'use strict';
/**
* The subtests in this file use an iframe to induce requests for CSS
* resources because an iframe's `onload` event is the most direct and
* generic mechanism to detect loading of CSS resources. As an optimization,
* the subtests share the same iframe and document.
*/
const declarations = [];
const iframe = document.createElement('iframe');
const whenIframeReady = new Promise((resolve, reject) => {
iframe.onload = resolve;
iframe.onerror = reject;
});
{%- for subtest in subtests %}
async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, [% subtest.origins %]);
declarations.push(`background-image: url("${url}");`);
whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
{%- if subtest.expected == none %}
assert_not_own_property(headers, '[%subtest.headerName%]');
{%- else %}
assert_own_property(headers, '[%subtest.headerName%]');
assert_equals(headers['[%subtest.headerName%]'], '[%subtest.expected%]');
{%- endif %}
})
.then(t.step_func_done(), (error) => t.unreached_func());
}, 'background-image [%subtest.headerName%][%subtest.description | pad("start", " - ")%]');
async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, [% subtest.origins %]);
declarations.push(`border-image: url("${url}");`);
whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
{%- if subtest.expected == none %}
assert_not_own_property(headers, '[%subtest.headerName%]');
{%- else %}
assert_own_property(headers, '[%subtest.headerName%]');
assert_array_equals(headers['[%subtest.headerName%]'], ['[%subtest.expected%]']);
{%- endif %}
})
.then(t.step_func_done(), t.unreached_func());
}, 'border-image [%subtest.headerName%][%subtest.description | pad("start", " - ")%]');
async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, [% subtest.origins %]);
declarations.push(`content: url("${url}");`);
whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
{%- if subtest.expected == none %}
assert_not_own_property(headers, '[%subtest.headerName%]');
{%- else %}
assert_own_property(headers, '[%subtest.headerName%]');
assert_array_equals(headers['[%subtest.headerName%]'], ['[%subtest.expected%]']);
{%- endif %}
})
.then(t.step_func_done(), t.unreached_func());
}, 'content [%subtest.headerName%][%subtest.description | pad("start", " - ")%]');
async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, [% subtest.origins %]);
declarations.push(`cursor: url("${url}"), auto;`);
whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
{%- if subtest.expected == none %}
assert_not_own_property(headers, '[%subtest.headerName%]');
{%- else %}
assert_own_property(headers, '[%subtest.headerName%]');
assert_array_equals(headers['[%subtest.headerName%]'], ['[%subtest.expected%]']);
{%- endif %}
})
.then(t.step_func_done(), t.unreached_func());
}, 'cursor [%subtest.headerName%][%subtest.description | pad("start", " - ")%]');
async_test((t) => {
const key = '{{uuid()}}';
const url = makeRequestURL(key, [% subtest.origins %]);
declarations.push(`list-style-image: url("${url}");`);
whenIframeReady
.then(() => retrieve(key))
.then((headers) => {
{%- if subtest.expected == none %}
assert_not_own_property(headers, '[%subtest.headerName%]');
{%- else %}
assert_own_property(headers, '[%subtest.headerName%]');
assert_array_equals(headers['[%subtest.headerName%]'], ['[%subtest.expected%]']);
{%- endif %}
})
.then(t.step_func_done(), t.unreached_func());
}, 'list-style-image [%subtest.headerName%][%subtest.description | pad("start", " - ")%]');
{%- endfor %}
iframe.srcdoc = declarations.map((declaration, index) => `
<style>.el${index} { ${declaration} }</style><div class="el${index}"></div>`
).join('');
document.body.appendChild(iframe);
</script>
</body>
</html>
|