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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-multiple-origins.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-multiple-origins.js b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-multiple-origins.js
new file mode 100644
index 0000000000000000000000000000000000000000..e4cf7245dcfa866ca9065aea4ae68b0f7c15e94c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-multiple-origins.js
@@ -0,0 +1,32 @@
+if (this.document === undefined) {
+ importScripts("/resources/testharness.js");
+ importScripts("../resources/utils.js");
+}
+
+function corsMultipleOrigins(desc, originList, shouldPass) {
+ var urlParameters = "?origin=" + encodeURIComponent(originList.join(", "));
+ var url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "preflight.py";
+
+ if (shouldPass) {
+ promise_test(function(test) {
+ return fetch(url + urlParameters).then(function(resp) {
+ assert_equals(resp.status, 200, "Response's status is 200");
+ });
+ }, desc);
+ } else {
+ promise_test(function(test) {
+ return promise_rejects(test, new TypeError(), fetch(url + urlParameters));
+ }, desc);
+ }
+}
+/* Actual origin */
+var origin = "http://{{host}}:{{ports[http][0]}}";
+
+corsMultipleOrigins("3 origins allowed, match the 3rd (" + origin + ")", ["\"\"", "http://example.com", origin], true);
+corsMultipleOrigins("3 origins allowed, match the 3rd (\"*\")", ["\"\"", "http://example.com", "*"], true);
+corsMultipleOrigins("3 origins allowed, match twice (" + origin + ")", ["\"\"", origin, origin], true);
+corsMultipleOrigins("3 origins allowed, match twice (\"*\")", ["*", "http://example.com", "*"], true);
+corsMultipleOrigins("3 origins allowed, match twice (\"*\" and " + origin + ")", ["*", "http://example.com", origin], true);
+corsMultipleOrigins("3 origins allowed, no match", ["", "http://example.com", "https://example2.com"], false);
+
+done();

Powered by Google App Engine
This is Rietveld 408576698