forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client-hint-request-headers-2.tentative.htm
47 lines (42 loc) · 1.7 KB
/
client-hint-request-headers-2.tentative.htm
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
<!DOCTYPE html>
<meta charset=utf-8>
<title>CORS and Client Hints, potentially</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=support.js?pipe=sub></script>
<h1>Request headers</h1>
<div id=log></div>
<script>
test(function() {
var client = new XMLHttpRequest()
client.open('GET', CROSSDOMAIN + 'resources/cors-makeheader.py?headers=x-print,', false)
client.setRequestHeader('x-print', 'unicorn')
client.setRequestHeader('content-type', 'text/plain')
client.setRequestHeader('accept', 'test')
client.setRequestHeader('accept-language', 'nn')
client.setRequestHeader('content-language', 'nn')
client.setRequestHeader('save-data', 'on')
client.setRequestHeader('device-memory', '1.0')
client.setRequestHeader('dpr', '2.0')
client.setRequestHeader('width', '35')
client.setRequestHeader('viewport-width', '42')
client.setRequestHeader('rtt', '1')
client.setRequestHeader('downlink', '1.0')
client.setRequestHeader('ect', '2g')
client.send(null)
const res = JSON.parse(client.response)
assert_equals(res['x-print'], 'unicorn')
assert_equals(res['content-type'], 'text/plain')
assert_equals(res['accept'], 'test')
assert_equals(res['accept-language'], 'nn')
assert_equals(res['content-language'], 'nn')
assert_equals(res['save-data'], 'on')
assert_equals(res['device-memory'], '1.0')
assert_equals(res['dpr'], '2.0')
assert_equals(res['width'], '35')
assert_equals(res['viewport-width'], '42')
assert_equals(res['rtt'], '1')
assert_equals(res['downlink'], '1.0')
assert_equals(res['ect'], '2g')
}, 'Client hint headers are simple headers')
</script>