Bug 1507586 [wpt PR 14079] - Fetch: test no-cors Headers API better, a=testonly
☠☠ backed out by 46ad93280b06 ☠ ☠
authorAnne van Kesteren <annevk@annevk.nl>
Mon, 19 Nov 2018 18:46:10 +0000
changeset 503742 ab97e60ed77733bc1c112b86ab29916173f7ae02
parent 503741 d4129dccff17ea22573a8b3dc486cffcf43b89bf
child 503743 f73f874848390bfe55e387771beda2ccec982460
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
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");
   });
 }