Bug 1507586 [wpt PR 14079] - Fetch: test no-cors Headers API better, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Mon, 19 Nov 2018 18:46:10 +0000
changeset 506777 c19205f65af76eca2160873f3438561d1888ac4a
parent 506776 15de90ba7ca81e1b83c8b0f62b37c4ab5a5c68ca
child 506778 359ee839f1a358175a0d4d537476d32a7f4a39a4
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1507586, 14079
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 1507586 [wpt PR 14079] - Fetch: test no-cors Headers API better, a=testonly Automatic update from web-platform-testsFetch: test no-cors Headers API better For https://github.com/whatwg/fetch/pull/833. -- wpt-commits: ccb1c202a4ad83d88fe9bc133e2816b86e4bcfd2 wpt-pr: 14079
testing/web-platform/tests/fetch/api/headers/headers-no-cors.window.js
--- a/testing/web-platform/tests/fetch/api/headers/headers-no-cors.window.js
+++ b/testing/web-platform/tests/fetch/api/headers/headers-no-cors.window.js
@@ -1,19 +1,48 @@
 promise_test(() => fetch("../cors/resources/not-cors-safelisted.json").then(res => res.json().then(runTests)), "Loading data…");
 
+const longValue = "s".repeat(127);
+
+[
+  {
+    "headers": ["accept", "accept-language", "content-language"],
+    "values": [longValue, "", longValue]
+  },
+  {
+    "headers": ["content-type"],
+    "values": ["text/plain;" + "s".repeat(116), "text/plain"]
+  }
+].forEach(testItem => {
+  testItem.headers.forEach(header => {
+    test(() => {
+      const noCorsHeaders = new Request("about:blank", { mode: "no-cors" }).headers;
+      testItem.values.forEach((value) => {
+        noCorsHeaders.append(header, value);
+        assert_equals(noCorsHeaders.get(header), testItem.values[0]);
+      });
+      noCorsHeaders.set(header, values.join(", "));
+      assert_equals(noCorsHeaders.get(header), testItem.values[0]);
+      noCorsHeaders.delete(header);
+      assert_false(noCorsHeaders.has(header));
+    }, "\"no-cors\" Headers object cannot have " + header + " set to " + testItem.values.join(", "));
+  });
+});
+
 function runTests(testArray) {
   testArray = testArray.concat([
     ["dpr", "2"],
     ["downlink", "1"], // https://wicg.github.io/netinfo/
     ["save-data", "on"],
     ["viewport-width", "100"],
     ["width", "100"]
   ]);
   testArray.forEach(testItem => {
     const [headerName, headerValue] = testItem;
     test(() => {
       const noCorsHeaders = new Request("about:blank", { mode: "no-cors" }).headers;
       noCorsHeaders.append(headerName, headerValue);
       assert_false(noCorsHeaders.has(headerName));
+      noCorsHeaders.set(headerName, headerValue);
+      assert_false(noCorsHeaders.has(headerName));
     }, "\"no-cors\" Headers object cannot have " + headerName + "/" + headerValue + " as header");
   });
 }