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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-expose-star.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-expose-star.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-expose-star.js b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-expose-star.js
new file mode 100644
index 0000000000000000000000000000000000000000..90a9351d1e8623805369d343e0d2fa73b8566f03
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/fetch/api/cors/cors-expose-star.js
@@ -0,0 +1,31 @@
+if (this.document === undefined) {
+ importScripts("/resources/testharness.js");
+ importScripts("../resources/utils.js");
+}
+
+const url = "http://{{host}}:{{ports[http][1]}}" + dirname(location.pathname) + RESOURCES_DIR + "top.txt",
+ sharedHeaders = "?pipe=header(Access-Control-Expose-Headers,*)|header(Test,X)|header(Set-Cookie,X)|"
+
+promise_test(() => {
+ const headers = "header(Access-Control-Allow-Origin,*)"
+ return fetch(url + sharedHeaders + headers).then(resp => {
+ assert_equals(resp.status, 200)
+ assert_equals(resp.type , "cors")
+ assert_equals(resp.headers.get("test"), "X")
+ assert_equals(resp.headers.get("set-cookie"), null)
+ })
+}, "Basic Access-Control-Expose-Headers: * support")
+
+promise_test(() => {
+ const origin = location.origin, // assuming an ASCII origin
+ headers = "header(Access-Control-Allow-Origin," + origin + ")|header(Access-Control-Allow-Credentials,true)"
+ return fetch(url + sharedHeaders + headers, { credentials:"include" }).then(resp => {
+ assert_equals(resp.status, 200)
+ assert_equals(resp.type , "cors")
+ assert_equals(resp.headers.get("content-type"), "text/plain") // safelisted
+ assert_equals(resp.headers.get("test"), null)
+ assert_equals(resp.headers.get("set-cookie"), null)
+ })
+}, "Cannot use * for credentialed fetches")
+
+done();

Powered by Google App Engine
This is Rietveld 408576698