OLD | NEW |
1 importScripts("{{location[server]}}/resources/testharness.js"); | 1 importScripts("{{location[server]}}/resources/testharness.js"); |
2 importScripts("{{location[server]}}/content-security-policy/support/testharness-
helper.js"); | 2 importScripts("{{location[server]}}/content-security-policy/support/testharness-
helper.js"); |
3 | 3 |
4 // Same-origin | 4 // Same-origin |
5 async_test(t => { | 5 async_test(t => { |
6 var url = "{{location[server]}}/content-security-policy/support/resource.py?sa
me-origin-fetch"; | 6 var url = "{{location[server]}}/content-security-policy/support/resource.py?sa
me-origin-fetch"; |
7 assert_no_csp_event_for_url(t, url); | 7 assert_no_csp_event_for_url(t, url); |
8 | 8 |
9 fetch(url) | 9 fetch(url) |
10 .then(t.step_func_done(r => assert_equals(r.status, 200))); | 10 .then(t.step_func_done(r => assert_equals(r.status, 200))); |
11 }, "Same-origin 'fetch()' in " + self.location.protocol + self.location.search); | 11 }, "Same-origin 'fetch()' in " + self.location.protocol + self.location.search); |
12 | 12 |
13 async_test(t => { | 13 async_test(t => { |
14 var url = "{{location[server]}}/content-security-policy/support/resource.py?sa
me-origin-xhr"; | 14 var url = "{{location[server]}}/content-security-policy/support/resource.py?sa
me-origin-xhr"; |
15 assert_no_csp_event_for_url(t, url); | 15 assert_no_csp_event_for_url(t, url); |
16 | 16 |
17 var xhr = new XMLHttpRequest(); | 17 var xhr = new XMLHttpRequest(); |
18 try { | 18 xhr.open("GET", url); |
19 xhr.open("GET", url); | 19 xhr.onload = t.step_func_done(); |
20 t.done(); | 20 xhr.onerror = t.unreached_func(); |
21 } catch (e) { | |
22 assert_unreached(); | |
23 } | |
24 xhr.send(); | 21 xhr.send(); |
25 }, "Same-origin XHR in " + self.location.protocol + self.location.search); | 22 }, "Same-origin XHR in " + self.location.protocol + self.location.search); |
26 | 23 |
27 // Cross-origin | 24 // Cross-origin |
28 async_test(t => { | 25 async_test(t => { |
29 var url = "http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/
support/resource.py?cross-origin-fetch"; | 26 var url = "http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/
support/resource.py?cross-origin-fetch"; |
30 assert_no_csp_event_for_url(t, url); | 27 assert_no_csp_event_for_url(t, url); |
31 | 28 |
32 fetch(url) | 29 fetch(url) |
33 .then(t.step_func_done(r => assert_equals(r.status, 200))); | 30 .then(t.step_func_done(r => assert_equals(r.status, 200))); |
34 }, "Cross-origin 'fetch()' in " + self.location.protocol + self.location.search)
; | 31 }, "Cross-origin 'fetch()' in " + self.location.protocol + self.location.search)
; |
35 | 32 |
36 async_test(t => { | 33 async_test(t => { |
37 var url = "http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/
support/resource.py?cross-origin-xhr"; | 34 var url = "http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/
support/resource.py?cross-origin-xhr"; |
38 assert_no_csp_event_for_url(t, url); | 35 assert_no_csp_event_for_url(t, url); |
39 | 36 |
40 var xhr = new XMLHttpRequest(); | 37 var xhr = new XMLHttpRequest(); |
41 try { | 38 xhr.open("GET", url); |
42 xhr.open("GET", url); | 39 xhr.onload = t.step_func_done(); |
43 t.done(); | 40 xhr.onerror = t.unreached_func(); |
44 } catch (e) { | |
45 assert_unreached(); | |
46 } | |
47 xhr.send(); | 41 xhr.send(); |
48 }, "Cross-origin XHR in " + self.location.protocol + self.location.search); | 42 }, "Cross-origin XHR in " + self.location.protocol + self.location.search); |
49 | 43 |
50 // Same-origin redirecting to cross-origin | 44 // Same-origin redirecting to cross-origin |
51 async_test(t => { | 45 async_test(t => { |
52 var url = "{{location[server]}}/common/redirect-opt-in.py?status=307&location=
http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/support/resou
rce.py?cross-origin-fetch"; | 46 var url = "{{location[server]}}/common/redirect-opt-in.py?status=307&location=
http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/support/resou
rce.py?cross-origin-fetch"; |
53 assert_no_csp_event_for_url(t, url); | 47 assert_no_csp_event_for_url(t, url); |
54 | 48 |
55 fetch(url) | 49 fetch(url) |
56 .then(t.step_func_done(r => assert_equals(r.status, 200))); | 50 .then(t.step_func_done(r => assert_equals(r.status, 200))); |
57 }, "Same-origin => cross-origin 'fetch()' in " + self.location.protocol + self.l
ocation.search); | 51 }, "Same-origin => cross-origin 'fetch()' in " + self.location.protocol + self.l
ocation.search); |
58 | 52 |
59 done(); | 53 done(); |
OLD | NEW |