Title: [220494] trunk/LayoutTests
Revision
220494
Author
cdu...@apple.com
Date
2017-08-09 16:01:05 -0700 (Wed, 09 Aug 2017)

Log Message

Import beacon/headers/header-content-type.html from upstream WPT
https://bugs.webkit.org/show_bug.cgi?id=175395

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

* web-platform-tests/beacon/headers/header-content-type-expected.txt:
* web-platform-tests/beacon/headers/header-content-type.html:

LayoutTests:

Drop local test that has been upstreamed to WPT.

* http/wpt/beacon/headers/header-content-type-same-origin-expected.txt: Removed.
* http/wpt/beacon/headers/header-content-type-same-origin.html: Removed.

Modified Paths

Removed Paths

  • trunk/LayoutTests/http/wpt/beacon/headers/

Diff

Modified: trunk/LayoutTests/ChangeLog (220493 => 220494)


--- trunk/LayoutTests/ChangeLog	2017-08-09 22:59:32 UTC (rev 220493)
+++ trunk/LayoutTests/ChangeLog	2017-08-09 23:01:05 UTC (rev 220494)
@@ -1,3 +1,15 @@
+2017-08-09  Chris Dumez  <cdu...@apple.com>
+
+        Import beacon/headers/header-content-type.html from upstream WPT
+        https://bugs.webkit.org/show_bug.cgi?id=175395
+
+        Reviewed by Sam Weinig.
+
+        Drop local test that has been upstreamed to WPT.
+
+        * http/wpt/beacon/headers/header-content-type-same-origin-expected.txt: Removed.
+        * http/wpt/beacon/headers/header-content-type-same-origin.html: Removed.
+
 2017-08-09  Nan Wang  <n_w...@apple.com>
 
         LayoutTest accessibility/presentation-role-iframe.html is a flaky failure

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (220493 => 220494)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-08-09 22:59:32 UTC (rev 220493)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-08-09 23:01:05 UTC (rev 220494)
@@ -1,3 +1,13 @@
+2017-08-09  Chris Dumez  <cdu...@apple.com>
+
+        Import beacon/headers/header-content-type.html from upstream WPT
+        https://bugs.webkit.org/show_bug.cgi?id=175395
+
+        Reviewed by Sam Weinig.
+
+        * web-platform-tests/beacon/headers/header-content-type-expected.txt:
+        * web-platform-tests/beacon/headers/header-content-type.html:
+
 2017-08-09  Daniel Bates  <daba...@apple.com>
 
         Import CSS-UI-3 Web Platform Tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt (220493 => 220494)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt	2017-08-09 22:59:32 UTC (rev 220493)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type-expected.txt	2017-08-09 23:01:05 UTC (rev 220494)
@@ -1,5 +1,8 @@
 
 PASS Test content-type header for a body string 
-PASS Test content-type header for a body ArrayBuffer 
+FAIL Test content-type header for a body ArrayBufferView assert_equals: Correct Content-Type header result expected "" but got "application/x-www-form-urlencoded"
+FAIL Test content-type header for a body ArrayBuffer assert_equals: Correct Content-Type header result expected "" but got "application/x-www-form-urlencoded"
+PASS Test content-type header for a body Blob 
 PASS Test content-type header for a body FormData 
+PASS Test content-type header for a body URLSearchParams 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html (220493 => 220494)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html	2017-08-09 22:59:32 UTC (rev 220493)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/beacon/headers/header-content-type.html	2017-08-09 23:01:05 UTC (rev 220494)
@@ -27,7 +27,7 @@
 }
 
 function testContentTypeHeader(what, contentType, title) {
-  var testBase = get_host_info().HTTP_REMOTE_ORIGIN + RESOURCES_DIR;
+  var testBase = RESOURCES_DIR;
   var id = self.token();
   var testUrl = testBase + "content-type.py?cmd=put&id=" + id;
 
@@ -34,22 +34,41 @@
   promise_test(function(test) {
     assert_true(navigator.sendBeacon(testUrl, what), "SendBeacon Succeeded");
     return pollResult(test, id) .then(result => {
-      assert_true(result.startsWith(contentType), "Correct referrer header result");
+      if (contentType == "multipart/form-data") {
+        assert_true(result.startsWith(contentType), "Correct Content-Type header result");
+      } else {
+        assert_equals(result, contentType, "Correct Content-Type header result");
+      }
     });
   }, "Test content-type header for a body " + title);
 }
 
+function stringToArrayBufferView(input) {
+  var buffer = new ArrayBuffer(input.length * 2);
+  var view = new Uint16Array(buffer);
+
+  // dumbly copy over the bytes
+  for (var i = 0, len = input.length; i < len; i++) {
+    view[i] = input.charCodeAt(i);
+  }
+  return view;
+}
+
 function stringToArrayBuffer(input) {
   var buffer = new ArrayBuffer(input.length * 2);
-  var array = new Uint16Array(buffer);
+  var view = new Uint16Array(buffer);
 
   // dumbly copy over the bytes
   for (var i = 0, len = input.length; i < len; i++) {
-    array[i] = input.charCodeAt(i);
+    view[i] = input.charCodeAt(i);
   }
-  return array;
+  return buffer;
 }
 
+function stringToBlob(input) {
+  return new Blob([input], {type: "text/plain"});
+}
+
 function stringToFormData(input) {
   var formdata = new FormData();
   formdata.append(input, new Blob(['hi']));
@@ -56,9 +75,17 @@
   return formdata;
 }
 
+function stringToURLSearchParams(input)
+{
+  return new URLSearchParams(input);
+}
+
 testContentTypeHeader("hi!", "text/plain;charset=UTF-8", "string");
+testContentTypeHeader(stringToArrayBufferView("123"), "", "ArrayBufferView");
 testContentTypeHeader(stringToArrayBuffer("123"), "", "ArrayBuffer");
+testContentTypeHeader(stringToBlob("123"), "text/plain", "Blob");
 testContentTypeHeader(stringToFormData("qwerty"), "multipart/form-data", "FormData");
+testContentTypeHeader(stringToURLSearchParams("key1=value1&key2=value2"), "application/x-www-form-urlencoded;charset=UTF-8", "URLSearchParams");
     </script>
   </body>
 </html>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to