OLD | NEW |
| (Empty) |
1 if (self.importScripts) { | |
2 importScripts('../resources/fetch-test-helpers.js'); | |
3 importScripts('../resources/fetch-access-control-util.js'); | |
4 } | |
5 | |
6 // Tests for CORS check and CORS filtered response. | |
7 | |
8 var TEST_TARGETS = [ | |
9 // CORS test | |
10 | |
11 [OTHER_BASE_URL + 'mode=same-origin&method=GET', [fetchRejected]], | |
12 [OTHER_BASE_URL + 'mode=same-origin&method=POST', [fetchRejected]], | |
13 [OTHER_BASE_URL + 'mode=same-origin&method=PUT', [fetchRejected]], | |
14 [OTHER_BASE_URL + 'mode=same-origin&method=XXX', [fetchRejected]], | |
15 | |
16 // method=GET | |
17 | |
18 // CORS check | |
19 // https://fetch.spec.whatwg.org/#concept-cors-check | |
20 // Tests for Access-Control-Allow-Origin header. | |
21 [OTHER_BASE_URL + 'mode=cors&method=GET', | |
22 [fetchRejected]], | |
23 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*', | |
24 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | |
25 [methodIsGET, authCheckNone]], | |
26 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=' + BASE_ORIGIN, | |
27 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | |
28 [methodIsGET]], | |
29 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=' + BASE_ORIGIN + | |
30 ',http://www.example.com', | |
31 [fetchRejected]], | |
32 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://www.example.com', | |
33 [fetchRejected]], | |
34 | |
35 // CORS filtered response | |
36 // https://fetch.spec.whatwg.org/#concept-filtered-response-cors | |
37 // Tests for Access-Control-Expose-Headers header. | |
38 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=X-ServiceWorker
-ServerHeader', | |
39 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], | |
40 [methodIsGET]], | |
41 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=' + BASE_ORIGIN + | |
42 '&ACEHeaders=X-ServiceWorker-ServerHeader', | |
43 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], | |
44 [methodIsGET]], | |
45 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=Content-Length,
X-ServiceWorker-ServerHeader', | |
46 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], | |
47 [methodIsGET]], | |
48 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=' + BASE_ORIGIN + | |
49 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader', | |
50 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], | |
51 [methodIsGET]], | |
52 | |
53 // method=POST | |
54 | |
55 // CORS check | |
56 // https://fetch.spec.whatwg.org/#concept-cors-check | |
57 // Tests for Access-Control-Allow-Origin header. | |
58 [OTHER_BASE_URL + 'mode=cors&method=POST', | |
59 [fetchRejected]], | |
60 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*', | |
61 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | |
62 [methodIsPOST]], | |
63 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=' + BASE_ORIGIN, | |
64 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | |
65 [methodIsPOST]], | |
66 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=' + BASE_ORIGIN + | |
67 ',http://www.example.com', | |
68 [fetchRejected]], | |
69 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=http://www.example.com', | |
70 [fetchRejected]], | |
71 | |
72 // CORS filtered response | |
73 // https://fetch.spec.whatwg.org/#concept-filtered-response-cors | |
74 // Tests for Access-Control-Expose-Headers header. | |
75 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*&ACEHeaders=X-ServiceWorke
r-ServerHeader', | |
76 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], | |
77 [methodIsPOST]], | |
78 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=' + BASE_ORIGIN + | |
79 '&ACEHeaders=X-ServiceWorker-ServerHeader', | |
80 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], | |
81 [methodIsPOST]], | |
82 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*&ACEHeaders=Content-Length
, X-ServiceWorker-ServerHeader', | |
83 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], | |
84 [methodIsPOST]], | |
85 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=' + BASE_ORIGIN + | |
86 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader', | |
87 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], | |
88 [methodIsPOST]], | |
89 ]; | |
90 | |
91 if (self.importScripts) { | |
92 executeTests(TEST_TARGETS); | |
93 done(); | |
94 } | |
OLD | NEW |