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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-multiple-origins.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 }
5
6 function corsMultipleOrigins(desc, originList, shouldPass) {
7 var urlParameters = "?origin=" + encodeURIComponent(originList.join(", "));
8 var url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
9
10 if (shouldPass) {
11 promise_test(function(test) {
12 return fetch(url + urlParameters).then(function(resp) {
13 assert_equals(resp.status, 200, "Response's status is 200");
14 });
15 }, desc);
16 } else {
17 promise_test(function(test) {
18 return promise_rejects(test, new TypeError(), fetch(url + urlParameters));
19 }, desc);
20 }
21 }
22 /* Actual origin */
23 var origin = "http://{{host}}:{{ports[http][0]}}";
24
25 corsMultipleOrigins("3 origins allowed, match the 3rd (" + origin + ")", ["\"\"" , "http://example.com", origin], true);
26 corsMultipleOrigins("3 origins allowed, match the 3rd (\"*\")", ["\"\"", "http:/ /example.com", "*"], true);
27 corsMultipleOrigins("3 origins allowed, match twice (" + origin + ")", ["\"\"", origin, origin], true);
28 corsMultipleOrigins("3 origins allowed, match twice (\"*\")", ["*", "http://exam ple.com", "*"], true);
29 corsMultipleOrigins("3 origins allowed, match twice (\"*\" and " + origin + ")", ["*", "http://example.com", origin], true);
30 corsMultipleOrigins("3 origins allowed, no match", ["", "http://example.com", "h ttps://example2.com"], false);
31
32 done();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698