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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/basic/mode-same-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("/resources/testharness.js");
3 importScripts("../resources/utils.js");
4 importScripts("/common/get-host-info.sub.js")
5 }
6
7 function fetchSameOrigin(url, shouldPass) {
8 promise_test(function(test) {
9 if (shouldPass)
10 return fetch(url , {"mode": "same-origin"}).then(function(resp) {
11 assert_equals(resp.status, 200, "HTTP status is 200");
12 assert_equals(resp.type, "basic", "response type is basic");
13 });
14 else
15 return promise_rejects(test, new TypeError, fetch(url, {mode: "same-origin "}));
16 }, "Fetch "+ url + " with same-origin mode");
17 }
18
19 var host_info = get_host_info();
20
21 fetchSameOrigin(RESOURCES_DIR + "top.txt", true);
22 fetchSameOrigin(host_info.HTTP_ORIGIN + "/fetch/api/resources/top.txt", true);
23 fetchSameOrigin(host_info.HTTPS_ORIGIN + "/fetch/api/resources/top.txt", false);
24 fetchSameOrigin(host_info.HTTP_REMOTE_ORIGIN + "/fetch/api/resources/top.txt", f alse);
25
26 var redirPath = dirname(location.pathname) + RESOURCES_DIR + "redirect.py?locati on=";
27
28 fetchSameOrigin(redirPath + RESOURCES_DIR + "top.txt", true);
29 fetchSameOrigin(redirPath + host_info.HTTP_ORIGIN + "/fetch/api/resources/top.tx t", true);
30 fetchSameOrigin(redirPath + host_info.HTTPS_ORIGIN + "/fetch/api/resources/top.t xt", false);
31 fetchSameOrigin(redirPath + host_info.HTTP_REMOTE_ORIGIN + "/fetch/api/resources /top.txt", false);
32
33 done();
34
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698