Bug 1504103 [wpt PR 13849] - Fetch: Access-Control-Expose-Headers parsing, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Thu, 15 Nov 2018 10:14:51 +0000
changeset 503414 b12ab8efbefe006789483f40036d4b1fe8eab05f
parent 503413 623c8426e847a513088ec0c9908488774b58f7ba
child 503415 d16af01833d24047cb3853e1e0d7214111c9a572
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1504103, 13849
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1504103 [wpt PR 13849] - Fetch: Access-Control-Expose-Headers parsing, a=testonly Automatic update from web-platform-testsFetch: Access-Control-Expose-Headers parsing See https://github.com/whatwg/fetch/issues/814 for context. -- wpt-commits: 645c0e8a5c028a613e7ad1732834100dbe946fc7 wpt-pr: 13849
testing/web-platform/tests/cors/access-control-expose-headers-parsing.window.js
testing/web-platform/tests/cors/resources/access-control-expose-headers-parsing-2.asis
testing/web-platform/tests/cors/resources/access-control-expose-headers-parsing.asis
testing/web-platform/tests/cors/resources/access-control-expose-headers.json
testing/web-platform/tests/cors/resources/expose-headers.py
--- a/testing/web-platform/tests/cors/access-control-expose-headers-parsing.window.js
+++ b/testing/web-platform/tests/cors/access-control-expose-headers-parsing.window.js
@@ -1,13 +1,15 @@
-function exposeTest(resource, desc) {
-  const url = new URL("resources/" + resource, location.href).href.replace("://", "://élève.");
+promise_test(() => fetch("resources/access-control-expose-headers.json").then(res => res.json()).then(runTests), "Loading JSON…");
 
-  promise_test(() => {
-    return fetch(url).then(res => {
-      assert_equals(res.headers.get("content-language"), "sure")
-      assert_equals(res.headers.get("x-custom"), null);
-    })
-  }, "Access-Control-Expose-Headers parsing: " + desc);
+function runTests(allTestData) {
+  allTestData.forEach(testData => {
+    const encodedInput = encodeURIComponent(testData.input);
+    promise_test(() => {
+      const relativeURL = "resources/expose-headers.py?expose=" + encodedInput,
+            url = new URL(relativeURL, location.href).href.replace("://", "://élève.");
+      return fetch(url).then(res => {
+        assert_equals(res.headers.get("content-language"), "mkay");
+        assert_equals(res.headers.get("bb-8"), (testData.exposed ? "hey" : null));
+      });
+    }, "Parsing: " + encodedInput);
+  })
 }
-
-exposeTest("access-control-expose-headers-parsing.asis", "#1");
-exposeTest("access-control-expose-headers-parsing-2.asis", "#2")
deleted file mode 100644
--- a/testing/web-platform/tests/cors/resources/access-control-expose-headers-parsing-2.asis
+++ /dev/null
@@ -1,8 +0,0 @@
-HTTP/1.1 200 OK
-Access-Control-Allow-Origin: *
-Access-Control-Expose-Headers: not valid
-Access-Control-Expose-Headers: x-custom
-X-Custom: test
-Content-Language: sure
-
-TEST
deleted file mode 100644
--- a/testing/web-platform/tests/cors/resources/access-control-expose-headers-parsing.asis
+++ /dev/null
@@ -1,7 +0,0 @@
-HTTP/1.1 200 OK
-Access-Control-Allow-Origin: *
-Access-Control-Expose-Headers: not valid, x-custom
-X-Custom: test
-Content-Language: sure
-
-TEST
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/cors/resources/access-control-expose-headers.json
@@ -0,0 +1,62 @@
+[
+  {
+    "input": "access-control-expose-headers: BB-8",
+    "exposed": true
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8,,@#$#%%&^&^*()()11!",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8, no no",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: @#$#%%&^&^*()()11!,bb-8",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8\r\nAccess-Control-Expose-Headers: no",
+    "exposed": true
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8\r\nAccess-Control-Expose-Headers: no no",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: no\r\nAccess-Control-Expose-Headers: bb-8",
+    "exposed": true
+  },
+  {
+    "input": "Access-Control-Expose-Headers:\r\nAccess-Control-Expose-Headers: bb-8",
+    "exposed": true
+  },
+  {
+    "input": "Access-Control-Expose-Headers: ,bb-8",
+    "exposed": true
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8\u000C",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8\u000B",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: bb-8\u000B,bb-8",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: 'bb-8'",
+    "exposed": false
+  },
+  {
+    "input": "Access-Control-Expose-Headers: 'bb-8',bb-8",
+    "exposed": true
+  },
+  {
+    "input": "Access-Control-Expose-Headers: \"bb-8\",bb-8",
+    "exposed": false
+  }
+]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/cors/resources/expose-headers.py
@@ -0,0 +1,10 @@
+def main(request, response):
+    response.add_required_headers = False
+    output =  "HTTP/1.1 221 ALL YOUR BASE BELONG TO H1\r\n"
+    output += "Access-Control-Allow-Origin: *\r\n"
+    output += "BB-8: hey\r\n"
+    output += "Content-Language: mkay\r\n"
+    output += request.GET.first("expose") + "\r\n"
+    output += "\r\n"
+    response.writer.write(output)
+    response.close_connection = True