Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/fetch-access-control-cors-preflight2.js

Issue 1267263003: Rename fetch layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 preflight fetch (non-simple methods).
7 // Spec: https://fetch.spec.whatwg.org/#cors-preflight-fetch
8
9 var TEST_TARGETS = [];
10
11 ['PUT', 'XXX'].forEach(function(method) {
12 var checkMethod = checkJsonpMethod.bind(this, method);
13 TEST_TARGETS.push(
14 // CORS check
15 // https://fetch.spec.whatwg.org/#concept-cors-check
16 // Tests for Access-Control-Allow-Origin header.
17 // CORS preflight fetch
18 // https://fetch.spec.whatwg.org/#cors-preflight-fetch
19 // Tests for Access-Control-Allow-Methods header.
20 // Tests for Access-Control-Allow-Headers header.
21 [OTHER_BASE_URL + 'mode=cors&method=' + method,
22 [fetchRejected]],
23 [OTHER_BASE_URL + 'mode=cors&method=' + method + '&ACAMethods=' + method,
24 [fetchRejected]],
25 [OTHER_BASE_URL + 'mode=cors&method=' + method + '&ACAOrigin=*',
26 [fetchRejected]],
27 [OTHER_BASE_URL + 'mode=cors&method=' + method +
28 '&ACAOrigin=*&ACAMethods=' + method,
29 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
30 [checkMethod]],
31 [OTHER_BASE_URL + 'mode=cors&method=' + method +
32 '&ACAOrigin=*&headers=CUSTOM&ACAMethods=' + method,
33 [fetchRejected]],
34 [OTHER_BASE_URL + 'mode=cors&method=' + method +
35 '&ACAOrigin=*&headers=CUSTOM&ACAMethods=' + method +
36 '&ACAHeaders=x-serviceworker-test',
37 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
38 [checkMethod, hasCustomHeader]],
39 [OTHER_BASE_URL + 'mode=cors&method=' + method +
40 '&ACAOrigin=*&headers=CUSTOM&ACAMethods=' + method +
41 '&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWor ker-ServerHeader',
42 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
43 [checkMethod, hasCustomHeader]],
44 [OTHER_BASE_URL + 'mode=cors&method=' + method +
45 '&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX',
46 [fetchRejected]],
47 [OTHER_BASE_URL + 'mode=cors&method=' + method +
48 '&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-servicework er-test',
49 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
50 [checkMethod, hasCustomHeader]],
51 [OTHER_BASE_URL + 'mode=cors&method=' + method +
52 '&ACAOrigin=*&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-servicework er-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
53 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
54 [checkMethod, hasCustomHeader]],
55 [OTHER_BASE_URL + 'mode=cors&method=' + method +
56 '&ACAOrigin=' + BASE_ORIGIN,
57 [fetchRejected]],
58 [OTHER_BASE_URL + 'mode=cors&method=' + method +
59 '&ACAOrigin=' + BASE_ORIGIN + '&ACAMethods=' + method,
60 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
61 [checkMethod]],
62 [OTHER_BASE_URL + 'mode=cors&method=' + method +
63 '&ACAOrigin=' + BASE_ORIGIN + '&headers=CUSTOM&ACAMethods=' + method,
64 [fetchRejected]],
65 [OTHER_BASE_URL + 'mode=cors&method=' + method +
66 '&ACAOrigin=' + BASE_ORIGIN + '&headers=CUSTOM&ACAMethods=' + method +
67 '&ACAHeaders=x-serviceworker-test',
68 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
69 [checkMethod, hasCustomHeader]],
70 [OTHER_BASE_URL + 'mode=cors&method=' + method +
71 '&ACAOrigin=' + BASE_ORIGIN + '&headers=CUSTOM&ACAMethods=' + method +
72 '&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWor ker-ServerHeader',
73 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
74 [checkMethod, hasCustomHeader]],
75 [OTHER_BASE_URL + 'mode=cors&method=' + method +
76 '&ACAOrigin=' + BASE_ORIGIN + '&headers=CUSTOM&ACAMethods=PUT, XXX',
77 [fetchRejected]],
78 [OTHER_BASE_URL + 'mode=cors&method=' + method +
79 '&ACAOrigin=' + BASE_ORIGIN +
80 '&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
81 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
82 [checkMethod, hasCustomHeader]],
83 [OTHER_BASE_URL + 'mode=cors&method=' + method +
84 '&ACAOrigin=' + BASE_ORIGIN +
85 '&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEH eaders=Content-Length, X-ServiceWorker-ServerHeader',
86 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
87 [checkMethod, hasCustomHeader]],
88
89 // Test that Access-Control-Allow-Methods is checked in
90 // CORS preflight fetch.
91 [OTHER_BASE_URL + 'mode=cors&method=' + method +
92 '&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method + '&PreflightTest=200',
93 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
94 [checkMethod]],
95 [OTHER_BASE_URL + 'mode=cors&method=' + method +
96 '&ACAOrigin=*&PACAOrigin=*&ACAMethods=' + method + '&PreflightTest=200',
97 [fetchRejected]],
98
99 // Test that Access-Control-Allow-Headers is checked in
100 // CORS preflight fetch.
101 [OTHER_BASE_URL + 'mode=cors&method=' + method +
102 '&headers=CUSTOM&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
103 '&PACAHeaders=x-serviceworker-test&PreflightTest=200',
104 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
105 [checkMethod, hasCustomHeader]],
106 [OTHER_BASE_URL + 'mode=cors&method=' + method +
107 '&headers=CUSTOM&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
108 '&ACAHeaders=x-serviceworker-test&PreflightTest=200',
109 [fetchRejected]],
110
111 // Test that CORS check is done in both preflight and main fetch.
112 [OTHER_BASE_URL + 'mode=cors&method=' + method +
113 '&ACAOrigin=*&PACAMethods=' + method + '&PreflightTest=200',
114 [fetchRejected]],
115 [OTHER_BASE_URL + 'mode=cors&method=' + method +
116 '&PACAOrigin=*&PACAMethods=' + method + '&PreflightTest=200',
117 [fetchRejected]],
118
119 // Test that Access-Control-Expose-Headers of CORS preflight is ignored.
120 [OTHER_BASE_URL + 'mode=cors&method=' + method +
121 '&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
122 '&PACEHeaders=Content-Length, X-ServiceWorker-ServerHeader&PreflightTest= 200',
123 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
124 [checkMethod]],
125
126 // Test that CORS preflight with Status 2XX succeeds.
127 [OTHER_BASE_URL + 'mode=cors&method=' + method +
128 '&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method + '&PreflightTest=201',
129 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
130 [checkMethod]],
131
132 // Test that CORS preflight with Status other than 2XX fails.
133 // https://crbug.com/452394
134 [OTHER_BASE_URL + 'mode=cors&method=' + method +
135 '&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method + '&PreflightTest=301',
136 [fetchRejected]],
137 [OTHER_BASE_URL + 'mode=cors&method=' + method +
138 '&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method + '&PreflightTest=401',
139 [fetchRejected]],
140 [OTHER_BASE_URL + 'mode=cors&method=' + method +
141 '&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method + '&PreflightTest=500',
142 [fetchRejected]],
143
144 // Test CORS preflight with multiple request headers.
145 [OTHER_BASE_URL + 'mode=cors&method=' + method +
146 '&headers=CUSTOM2&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
147 '&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicewOrker-test , x-sErviceworker-s, x-sErviceworker-v&PreflightTest=200',
148 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
149 [checkMethod, hasCustomHeader2]],
150 [OTHER_BASE_URL + 'mode=cors&method=' + method +
151 '&headers=CUSTOM2&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
152 '&PACAHeaders=x-servicewOrker-test&PreflightTest=200',
153 [fetchRejected]],
154
155 // Test request headers sent in CORS preflight requests.
156 [OTHER_BASE_URL + 'mode=cors&method=' + method +
157 '&headers=CUSTOM&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
158 '&PACAHeaders=x-serviceworker-test&PACRMethod=' + method +
159 '&PACRHeaders=x-serviceworker-test&PreflightTest=200',
160 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
161 [checkMethod, hasCustomHeader]],
162 // Test Access-Control-Request-Headers is sorted https://crbug.com/452391
163 [OTHER_BASE_URL + 'mode=cors&method=' + method +
164 '&headers=CUSTOM2&ACAOrigin=*&PACAOrigin=*&PACAMethods=' + method +
165 '&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicewOrker-test , x-sErviceworker-s, x-sErviceworker-v&PACRMethod=' + method +
166 '&PACRHeaders=x-serviceworker-s, x-serviceworker-test, x-serviceworker-u, x-serviceworker-ua, x-serviceworker-v&PreflightTest=200',
167 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
168 [checkMethod, hasCustomHeader2]]);
169 });
170
171 if (self.importScripts) {
172 executeTests(TEST_TARGETS);
173 done();
174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698