Title: [217901] trunk/LayoutTests
Revision
217901
Author
[email protected]
Date
2017-06-07 13:10:50 -0700 (Wed, 07 Jun 2017)

Log Message

Fetching Blob URLs with XHR gives null content-type and content-length
https://bugs.webkit.org/show_bug.cgi?id=137647
<rdar://problem/18215114>

Reviewed by Darin Adler.

Add a test to ensure that we do not regress the computed Content-Type and Content-Length
for a blob URL fetched using XHR.

* fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size-expected.txt: Added.
* fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217900 => 217901)


--- trunk/LayoutTests/ChangeLog	2017-06-07 19:59:59 UTC (rev 217900)
+++ trunk/LayoutTests/ChangeLog	2017-06-07 20:10:50 UTC (rev 217901)
@@ -1,3 +1,17 @@
+2017-06-07  Daniel Bates  <[email protected]>
+
+        Fetching Blob URLs with XHR gives null content-type and content-length
+        https://bugs.webkit.org/show_bug.cgi?id=137647
+        <rdar://problem/18215114>
+
+        Reviewed by Darin Adler.
+
+        Add a test to ensure that we do not regress the computed Content-Type and Content-Length
+        for a blob URL fetched using XHR.
+
+        * fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size-expected.txt: Added.
+        * fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size.html: Added.
+
 2017-06-07  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK+ and WPE gardening.

Added: trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size-expected.txt (0 => 217901)


--- trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size-expected.txt	2017-06-07 20:10:50 UTC (rev 217901)
@@ -0,0 +1,11 @@
+Tests that a blob URL fetched via XHR has appropriate Content-Type and Content-Length headers.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS xhr.getResponseHeader('Content-Type') is "image/jpeg"
+PASS xhr.getResponseHeader('Content-Length') is "764"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size.html (0 => 217901)


--- trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size.html	                        (rev 0)
+++ trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-blob-url-has-valid-response-type-and-size.html	2017-06-07 20:10:50 UTC (rev 217901)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+window.jsTestIsAsync = true;
+
+var xhr;
+var greenSquareBase64Encoded = [
+    "/9j/4AAQSkZJRgABAQEAYABgAAD/4QCARXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUA",
+    "AAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABgAAAAAQAA",
+    "AGAAAAABAAKgAgAEAAAAAQAAABCgAwAEAAAAAQAAABAAAAAA/9sAQwACAQECAQECAgECAgICAgMF",
+    "AwMDAwMGBAQDBQcGBwcHBgYGBwgLCQcICggGBgkNCQoLCwwMDAcJDQ4NDA4LDAwL/9sAQwECAgID",
+    "AgMFAwMFCwgGCAsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsL",
+    "CwsL/8AAEQgAEAAQAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//E",
+    "ALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJ",
+    "ChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeI",
+    "iYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq",
+    "8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQH",
+    "BQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJico",
+    "KSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZ",
+    "mqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/a",
+    "AAwDAQACEQMRAD8A90ooor+Kz/D8/9k="
+].join("");
+
+// Derived from <http://stackoverflow.com/questions/14967647/>
+function createBlobWithBase64EncodedData(base64EncodedData, mimeType)
+{
+    var decodedData = atob(base64EncodedData);
+    var length = decodedData.length;
+    var view = new Uint8Array(new ArrayBuffer(length));
+    for (var i = 0; i < length; ++i)
+        view[i] = decodedData.charCodeAt(i);
+    return new Blob([view.buffer], {type: mimeType});
+}
+
+function runTest()
+{
+    xhr = new XMLHttpRequest;
+    xhr.open("GET", URL.createObjectURL(createBlobWithBase64EncodedData(greenSquareBase64Encoded, "image/jpeg")));
+    xhr.responseType = "arraybuffer";
+    xhr._onload_ = function () {
+        shouldBeEqualToString("xhr.getResponseHeader('Content-Type')", "image/jpeg");
+        shouldBeEqualToString("xhr.getResponseHeader('Content-Length')", "764");
+        finishJSTest();
+    }
+    xhr._onerror_ = function () {
+        testFailed("Failed to fetch blob URL.");
+        finishJSTest();
+    }
+    xhr.send();
+}
+
+description("Tests that a blob URL fetched via XHR has appropriate Content-Type and Content-Length headers.");
+runTest();
+</script>
+</body>
+</html>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to