Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / serviceworker / fetch-access-control-cors.html
1 <!DOCTYPE html>
2 <title>Service Worker: fetch()</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script>
6 <script src="resources/fetch-access-control-util.js"></script>
7 <body>
8 <script>
9 var TEST_TARGETS = [
10   // CORS test
11   [OTHER_BASE_URL + 'method=GET&headers=CUSTOM',
12    [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
13    [methodIsGET, noCustomHeader, authCheck2]],
14   [OTHER_BASE_URL + 'method=POST&headers=CUSTOM',
15    [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
16    [methodIsPOST, noCustomHeader]],
17   [OTHER_BASE_URL + 'method=PUT&headers=CUSTOM',
18    [fetchError]],
19   [OTHER_BASE_URL + 'method=XXX&headers=CUSTOM',
20    [fetchError]],
21
22   [OTHER_BASE_URL + 'mode=same-origin&method=GET', [fetchRejected]],
23   [OTHER_BASE_URL + 'mode=same-origin&method=POST', [fetchRejected]],
24   [OTHER_BASE_URL + 'mode=same-origin&method=PUT', [fetchRejected]],
25   [OTHER_BASE_URL + 'mode=same-origin&method=XXX', [fetchRejected]],
26
27   [OTHER_BASE_URL + 'mode=no-cors&method=GET&headers=CUSTOM',
28    [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
29    [methodIsGET, noCustomHeader, authCheck2]],
30   [OTHER_BASE_URL + 'mode=no-cors&method=POST&headers=CUSTOM',
31    [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
32    [methodIsPOST, noCustomHeader]],
33   [OTHER_BASE_URL + 'mode=no-cors&method=PUT&headers=CUSTOM',
34    [fetchError]],
35   [OTHER_BASE_URL + 'mode=no-cors&method=XXX&headers=CUSTOM',
36    [fetchError]],
37
38   [OTHER_BASE_URL + 'mode=cors&method=GET',
39    [fetchRejected]],
40   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*',
41    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
42    [methodIsGET, authCheckNone]],
43   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000',
44    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
45    [methodIsGET]],
46   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000,http://www.example.com',
47    [fetchRejected]],
48   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://www.example.com',
49    [fetchRejected]],
50   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=X-ServiceWorker-ServerHeader',
51    [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors],
52    [methodIsGET]],
53   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000&ACEHeaders=X-ServiceWorker-ServerHeader',
54    [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors],
55    [methodIsGET]],
56   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
57    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
58    [methodIsGET]],
59   [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=http://127.0.0.1:8000&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
60    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
61    [methodIsGET]],
62   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM',
63    [fetchRejected]],
64   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*',
65    [fetchRejected]],
66   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=http://127.0.0.1:8000',
67    [fetchRejected]],
68   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&ACAHeaders=x-serviceworker-test',
69    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
70    [methodIsGET, hasCustomHeader]],
71   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=http://127.0.0.1:8000&ACAHeaders=x-serviceworker-test',
72    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
73    [methodIsGET, hasCustomHeader]],
74   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
75    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
76    [methodIsGET, hasCustomHeader]],
77   [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=http://127.0.0.1:8000&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
78    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
79    [methodIsGET, hasCustomHeader]],
80
81   [OTHER_BASE_URL + 'mode=cors&method=POST',
82    [fetchRejected]],
83   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*',
84    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
85    [methodIsPOST]],
86   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=http://127.0.0.1:8000',
87    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
88    [methodIsPOST]],
89   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=http://127.0.0.1:8000,http://www.example.com',
90    [fetchRejected]],
91   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=http://www.example.com',
92    [fetchRejected]],
93   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*&ACEHeaders=X-ServiceWorker-ServerHeader',
94    [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors],
95    [methodIsPOST]],
96   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=http://127.0.0.1:8000&ACEHeaders=X-ServiceWorker-ServerHeader',
97    [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors],
98    [methodIsPOST]],
99   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
100    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
101    [methodIsPOST]],
102   [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=http://127.0.0.1:8000&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
103    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
104    [methodIsPOST]],
105   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM',
106    [fetchRejected]],
107   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*',
108    [fetchRejected]],
109   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&ACAHeaders=x-serviceworker-test',
110    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
111    [methodIsPOST, hasCustomHeader]],
112   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
113    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
114    [methodIsPOST, hasCustomHeader]],
115   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=http://127.0.0.1:8000',
116    [fetchRejected]],
117   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=http://127.0.0.1:8000&ACAHeaders=x-serviceworker-test',
118    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
119    [methodIsPOST, hasCustomHeader]],
120   [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=http://127.0.0.1:8000&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
121    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
122    [methodIsPOST, hasCustomHeader]],
123
124   [OTHER_BASE_URL + 'mode=cors&method=PUT',
125    [fetchRejected]],
126   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAMethods=PUT',
127    [fetchRejected]],
128   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*',
129    [fetchRejected]],
130   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&ACAMethods=PUT',
131    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
132    [methodIsPUT]],
133   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT',
134    [fetchRejected]],
135   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT&ACAHeaders=x-serviceworker-test',
136    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
137    [methodIsPUT, hasCustomHeader]],
138   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
139    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
140    [methodIsPUT, hasCustomHeader]],
141   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX',
142    [fetchRejected]],
143   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
144    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
145    [methodIsPUT, hasCustomHeader]],
146   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
147    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
148    [methodIsPUT, hasCustomHeader]],
149   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000',
150    [fetchRejected]],
151   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&ACAMethods=PUT',
152    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
153    [methodIsPUT]],
154   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT',
155    [fetchRejected]],
156   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT&ACAHeaders=x-serviceworker-test',
157    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
158    [methodIsPUT, hasCustomHeader]],
159   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
160    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
161    [methodIsPUT, hasCustomHeader]],
162   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT, XXX',
163    [fetchRejected]],
164   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
165    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
166    [methodIsPUT, hasCustomHeader]],
167   [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
168    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
169    [methodIsPUT, hasCustomHeader]],
170
171   [OTHER_BASE_URL + 'mode=cors&method=XXX',
172    [fetchRejected]],
173   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAMethods=XXX',
174    [fetchRejected]],
175   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*',
176    [fetchRejected]],
177   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&ACAMethods=XXX',
178    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
179    [methodIsXXX]],
180   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods=XXX',
181    [fetchRejected]],
182   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods=XXX&ACAHeaders=x-serviceworker-test',
183    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
184    [methodIsXXX, hasCustomHeader]],
185   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods=XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
186    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
187    [methodIsXXX, hasCustomHeader]],
188   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX',
189    [fetchRejected]],
190   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
191    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
192    [methodIsXXX, hasCustomHeader]],
193   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
194    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
195    [methodIsXXX, hasCustomHeader]],
196   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000',
197    [fetchRejected]],
198   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&ACAMethods=XXX',
199    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
200    [methodIsXXX]],
201   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=XXX',
202    [fetchRejected]],
203   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=XXX&ACAHeaders=x-serviceworker-test',
204    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
205    [methodIsXXX, hasCustomHeader]],
206   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
207    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
208    [methodIsXXX, hasCustomHeader]],
209   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT, XXX',
210    [fetchRejected]],
211   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
212    [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
213    [methodIsXXX, hasCustomHeader]],
214   [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=http://127.0.0.1:8000&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
215    [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
216    [methodIsXXX, hasCustomHeader]]
217 ];
218
219 var test = async_test('Verify access control of fetch() in a Service Worker');
220 executeTests(test, TEST_TARGETS);
221 </script>
222 </body>