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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-preflight-status.js

Issue 2778753002: Import //fetch from Web Platform Tests. (Closed)
Patch Set: Baselines. Created 3 years, 8 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
OLDNEW
(Empty)
1 if (this.document === undefined) {
2 importScripts("/resources/testharness.js");
3 importScripts("../resources/utils.js");
4 importScripts("/common/utils.js");
5 importScripts("/common/get-host-info.sub.js");
6 }
7
8 /* Check preflight is ok if status is ok status (200 to 299)*/
9 function corsPreflightStatus(desc, corsUrl, preflightStatus) {
10 var uuid_token = token();
11 var url = corsUrl;
12 var requestInit = {"mode": "cors"};
13 /* Force preflight */
14 requestInit["headers"] = {"x-force-preflight": ""};
15
16 var urlParameters = "?token=" + uuid_token + "&max_age=0";
17 urlParameters += "&allow_headers=x-force-preflight";
18 urlParameters += "&preflight_status=" + preflightStatus;
19
20 promise_test(function(test) {
21 fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token).then(function(re sp) {
22 assert_equals(resp.status, 200, "Clean stash response's status is 200");
23 if (200 <= preflightStatus && 299 >= preflightStatus) {
24 return fetch(url + urlParameters, requestInit).then(function(resp) {
25 assert_equals(resp.status, 200, "Response's status is 200");
26 assert_equals(resp.headers.get("x-did-preflight"), "1", "Preflight req uest has been made");
27 });
28 } else {
29 return promise_rejects(test, new TypeError(), fetch(url + urlParameters, requestInit));
30 }
31 });
32 }, desc);
33 }
34
35 var corsUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
36 for (status of [200, 201, 202, 203, 204, 205, 206,
37 300, 301, 302, 303, 304, 305, 306, 307, 308,
38 400, 401, 402, 403, 404, 405,
39 501, 502, 503, 504, 505])
40 corsPreflightStatus("Preflight answered with status " + status, corsUrl, statu s);
41
42 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698