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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/redirect/redirect-origin.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("/common/utils.js");
3 importScripts("/resources/testharness.js");
4 importScripts("../resources/utils.js");
5 importScripts("/common/get-host-info.sub.js");
6 }
7
8 function testOriginAfterRedirection(desc, redirectUrl, redirectLocation, redirec tStatus, expectedOrigin) {
9 var uuid_token = token();
10 var url = redirectUrl;
11 var urlParameters = "?token=" + uuid_token + "&max_age=0";
12 urlParameters += "&redirect_status=" + redirectStatus;
13 urlParameters += "&location=" + encodeURIComponent(redirectLocation);
14
15 var requestInit = {"mode": "cors", "redirect": "follow"};
16
17 promise_test(function(test) {
18 return fetch(RESOURCES_DIR + "clean-stash.py?token=" + uuid_token).then( function(resp) {
19 assert_equals(resp.status, 200, "Clean stash response's status is 20 0");
20 return fetch(url + urlParameters, requestInit).then(function(respons e) {
21 assert_equals(response.status, 200, "Inspect header response's s tatus is 200");
22 assert_equals(response.headers.get("x-request-origin"), expected Origin, "Check origin header");
23 });
24 });
25 }, desc);
26 }
27
28 var redirectUrl = RESOURCES_DIR + "redirect.py";
29 var corsRedirectUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.path name) + RESOURCES_DIR + "redirect.py";
30 var locationUrl = get_host_info().HTTP_ORIGIN + dirname(location.pathname) + RE SOURCES_DIR + "inspect-headers.py?headers=origin";
31 var corsLocationUrl = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pat hname) + RESOURCES_DIR + "inspect-headers.py?cors&headers=origin";
32
33 for (var code of [301, 302, 303, 307, 308]) {
34 testOriginAfterRedirection("Same origin to same origin redirection " + code, redirectUrl, locationUrl, code, null);
35 testOriginAfterRedirection("Same origin to other origin redirection " + code , redirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
36 testOriginAfterRedirection("Other origin to other origin redirection " + cod e, corsRedirectUrl, corsLocationUrl, code, get_host_info().HTTP_ORIGIN);
37 testOriginAfterRedirection("Other origin to same origin redirection " + code , corsRedirectUrl, locationUrl + "&cors", code, "null");
38 }
39
40 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698