Bug 1286743 - Correct WPTs and mark Firefox as passing them where appropriate. r=annevk
authorThomas Wisniewski <wisniewskit@gmail.com>
Mon, 18 Jul 2016 13:24:39 -0400
changeset 389956 b1b89c4a8e6ada4c031c7c11b4f15a36a2681a20
parent 389955 6ed62e6074afa9f70dd7921533d2f3b1f7c5e622
child 389957 f4320d509686d6ef91ad4f5fff485adbbad18933
push id23566
push usertkuo@mozilla.com
push dateWed, 20 Jul 2016 10:57:43 +0000
reviewersannevk
bugs1286743
milestone50.0a1
Bug 1286743 - Correct WPTs and mark Firefox as passing them where appropriate. r=annevk
testing/web-platform/meta/XMLHttpRequest/send-entity-body-get-head-async.htm.ini
testing/web-platform/meta/XMLHttpRequest/send-entity-body-get-head.htm.ini
testing/web-platform/meta/fetch/api/basic/request-headers-worker.html.ini
testing/web-platform/meta/fetch/api/basic/request-headers.html.ini
testing/web-platform/tests/XMLHttpRequest/send-entity-body-empty.htm
testing/web-platform/tests/XMLHttpRequest/send-entity-body-get-head-async.htm
testing/web-platform/tests/XMLHttpRequest/send-entity-body-get-head.htm
testing/web-platform/tests/XMLHttpRequest/send-entity-body-none.htm
testing/web-platform/tests/fetch/api/basic/request-headers.js
deleted file mode 100644
--- a/testing/web-platform/meta/XMLHttpRequest/send-entity-body-get-head-async.htm.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[send-entity-body-get-head-async.htm]
-  type: testharness
-  [XMLHttpRequest: send() - non-empty data argument and GET/HEAD - async, no upload events should fire (HEAD)]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/XMLHttpRequest/send-entity-body-get-head.htm.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[send-entity-body-get-head.htm]
-  type: testharness
-  [XMLHttpRequest: send() - non-empty data argument and GET/HEAD (HEAD)]
-    expected: FAIL
-
--- a/testing/web-platform/meta/fetch/api/basic/request-headers-worker.html.ini
+++ b/testing/web-platform/meta/fetch/api/basic/request-headers-worker.html.ini
@@ -1,8 +1,5 @@
 [request-headers-worker.html]
   type: testharness
-  [Fetch with HEAD]
-    expected: FAIL
-
   [Fetch with HEAD with body]
     expected: FAIL
 
--- a/testing/web-platform/meta/fetch/api/basic/request-headers.html.ini
+++ b/testing/web-platform/meta/fetch/api/basic/request-headers.html.ini
@@ -1,8 +1,5 @@
 [request-headers.html]
   type: testharness
-  [Fetch with HEAD]
-    expected: FAIL
-
   [Fetch with HEAD with body]
     expected: FAIL
 
--- a/testing/web-platform/tests/XMLHttpRequest/send-entity-body-empty.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-empty.htm
@@ -5,18 +5,22 @@
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[7]" />
     <link rel="help" href="https://xhr.spec.whatwg.org/#dom-XMLHttpRequest-send-a-string" data-tested-assertations="following::p[1] following::p[2] following::p[3]" />
   </head>
   <body>
     <div id="log"></div>
     <script>
-      test(function() {
+      function request(method) {
         var client = new XMLHttpRequest()
-        client.open("POST", "resources/content.py", false)
+        client.open(method, "resources/content.py", false)
         client.upload.onloadstart = function(){assert_unreached('this event should not fire for empty strings')}
         client.send("")
-        assert_equals(client.getResponseHeader("x-request-content-length"), "0")
-      })
+        var expectedLength = method == "HEAD" ? "NO" : "0";
+        assert_equals(client.getResponseHeader("x-request-content-length"), expectedLength)
+      }
+      test(function() { request("POST"); }, document.title + " (POST)");
+      test(function() { request("PUT"); }, document.title + " (PUT)");
+      test(function() { request("HEAD"); }, document.title + " (HEAD)");
     </script>
   </body>
 </html>
--- a/testing/web-platform/tests/XMLHttpRequest/send-entity-body-get-head-async.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-get-head-async.htm
@@ -18,23 +18,17 @@
         }
         var client = new XMLHttpRequest()
         client.open(method, "resources/content.py")
         client.upload.addEventListener('progress', logEvt)
         client.upload.addEventListener('loadend', logEvt)
         client.upload.addEventListener('loadstart', logEvt)
         client.addEventListener('loadend', function(){
           test.step(function(){
-            if (method === "HEAD") {
-              // Fetch 4.4.3 --- Set Content-Length to 0 if method is HEAD and
-              // request's body is null.
-              assert_equals(client.getResponseHeader("x-request-content-length"), "0")
-            } else {
-              assert_equals(client.getResponseHeader("x-request-content-length"), "NO")
-            }
+            assert_equals(client.getResponseHeader("x-request-content-length"), "NO")
             assert_equals(client.getResponseHeader("x-request-method"), method)
             assert_equals(client.responseText, "")
             assert_array_equals(events, [])
             test.done()
           })
         })
         client.send("TEST")
       }
--- a/testing/web-platform/tests/XMLHttpRequest/send-entity-body-get-head.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-get-head.htm
@@ -18,23 +18,17 @@
           }
           var client = new XMLHttpRequest()
           client.open(method, "resources/content.py", false)
           client.send("TEST")
           client.upload.addEventListener('progress', logEvt)
           client.upload.addEventListener('loadend', logEvt)
           client.upload.addEventListener('loadstart', logEvt)
 
-          if (method === "HEAD") {
-            // Fetch 4.4.3 --- Set Content-Length to 0 if method is HEAD and
-            // request's body is null.
-            assert_equals(client.getResponseHeader("x-request-content-length"), "0")
-          } else {
-            assert_equals(client.getResponseHeader("x-request-content-length"), "NO")
-          }
+          assert_equals(client.getResponseHeader("x-request-content-length"), "NO")
           assert_equals(client.getResponseHeader("x-request-method"), method)
           assert_equals(client.responseText, "")
           assert_array_equals(events, [])
         }, document.title + " (" + method + ")")
       }
       request("GET")
       request("HEAD")
     </script>
--- a/testing/web-platform/tests/XMLHttpRequest/send-entity-body-none.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-none.htm
@@ -4,29 +4,37 @@
     <title>XMLHttpRequest: send(null) - no entity body</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
     <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[7]" />
   </head>
   <body>
     <div id="log"></div>
     <script>
-      test(function() {
+      function noContentTypeTest(method) {
         var client = new XMLHttpRequest()
-        client.open("POST", "resources/content.py", false)
+        client.open(method, "resources/content.py", false)
         client.upload.onloadstart = function(){assert_unreached('this event should not fire for null')}
         client.send(null)
-        assert_equals(client.getResponseHeader("x-request-content-length"), "0")
+        var expectedLength = method == "HEAD" ? "NO" : "0";
+        assert_equals(client.getResponseHeader("x-request-content-length"), expectedLength)
         assert_equals(client.getResponseHeader("x-request-content-type"), "NO")
-      }, "No content type")
+      }
+      test(function() { noContentTypeTest("POST"); }, "No content type (POST)");
+      test(function() { noContentTypeTest("PUT"); }, "No content type (PUT)");
+      test(function() { noContentTypeTest("HEAD"); }, "No content type (HEAD)");
 
-      test(function() {
+      function explicitContentTypeTest(method) {
         var client = new XMLHttpRequest()
-        client.open("POST", "resources/content.py", false)
+        client.open(method, "resources/content.py", false)
         var content_type = 'application/x-foo'
         client.setRequestHeader('Content-Type', content_type)
         client.send(null)
-        assert_equals(client.getResponseHeader("x-request-content-length"), "0")
+        var expectedLength = method == "HEAD" ? "NO" : "0";
+        assert_equals(client.getResponseHeader("x-request-content-length"), expectedLength)
         assert_equals(client.getResponseHeader("x-request-content-type"), content_type)
-      }, "Explicit content type")
+      }
+      test(function() { explicitContentTypeTest("POST"); }, "Explicit content type (POST)");
+      test(function() { explicitContentTypeTest("PUT"); }, "Explicit content type (PUT)");
+      test(function() { explicitContentTypeTest("HEAD"); }, "Explicit content type (HEAD)");
     </script>
   </body>
 </html>
--- a/testing/web-platform/tests/fetch/api/basic/request-headers.js
+++ b/testing/web-platform/tests/fetch/api/basic/request-headers.js
@@ -18,17 +18,17 @@ function requestHeaders(desc, url, metho
       assert_false(resp.headers.has("accept-charset"), "Request has header accept-charset");
     });
   }, desc);
 }
 
 var url = RESOURCES_DIR + "inspect-headers.py"
 
 requestHeaders("Fetch with GET", url, "GET", null, location.origin, null);
-requestHeaders("Fetch with HEAD", url, "HEAD", null, location.origin, "0");
+requestHeaders("Fetch with HEAD", url, "HEAD", null, location.origin, null);
 requestHeaders("Fetch with HEAD with body", url, "HEAD", "Request's body", location.origin, "14");
 requestHeaders("Fetch with PUT without body", url, "POST", null, location.origin, "0");
 requestHeaders("Fetch with PUT with body", url, "PUT", "Request's body", location.origin, "14");
 requestHeaders("Fetch with POST without body", url, "POST", null, location.origin, "0");
 requestHeaders("Fetch with POST with body", url, "POST", "Request's body", location.origin, "14");
 requestHeaders("Fetch with Chicken", url, "Chicken", null, location.origin, null);
 requestHeaders("Fetch with Chicken with body", url, "Chicken", "Request's body", location.origin, "14");