Title: [220773] trunk/LayoutTests
Revision
220773
Author
jfbast...@apple.com
Date
2017-08-15 16:48:46 -0700 (Tue, 15 Aug 2017)

Log Message

LayoutTests: test that an XMLHttpRequest with Content-Encoding: gzip is properly decompressed
https://bugs.webkit.org/show_bug.cgi?id=175579

Also test that without Content-Encoding proper sniffing takes place, and gzip
decoding occurs. This test is disabled and tracked by #175597.

Reviewed by Daniel Bates.

* TestExpectations:
* http/tests/xmlhttprequest/gzip-content-type-expected.txt: Added.
* http/tests/xmlhttprequest/gzip-content-type-no-content-encoding-expected.txt: Added.
* http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html: Added.
* http/tests/xmlhttprequest/gzip-content-type.html: Added.
* http/tests/xmlhttprequest/resources/gzip-lorem-no-content-encoding.php: Added.
* http/tests/xmlhttprequest/resources/gzip-lorem.php: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (220772 => 220773)


--- trunk/LayoutTests/ChangeLog	2017-08-15 23:23:51 UTC (rev 220772)
+++ trunk/LayoutTests/ChangeLog	2017-08-15 23:48:46 UTC (rev 220773)
@@ -1,3 +1,21 @@
+2017-08-15  JF Bastien  <jfbast...@apple.com>
+
+        LayoutTests: test that an XMLHttpRequest with Content-Encoding: gzip is properly decompressed
+        https://bugs.webkit.org/show_bug.cgi?id=175579
+
+        Also test that without Content-Encoding proper sniffing takes place, and gzip
+        decoding occurs. This test is disabled and tracked by #175597.
+
+        Reviewed by Daniel Bates.
+
+        * TestExpectations:
+        * http/tests/xmlhttprequest/gzip-content-type-expected.txt: Added.
+        * http/tests/xmlhttprequest/gzip-content-type-no-content-encoding-expected.txt: Added.
+        * http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html: Added.
+        * http/tests/xmlhttprequest/gzip-content-type.html: Added.
+        * http/tests/xmlhttprequest/resources/gzip-lorem-no-content-encoding.php: Added.
+        * http/tests/xmlhttprequest/resources/gzip-lorem.php: Added.
+
 2017-08-15  Chris Dumez  <cdu...@apple.com>
 
         Re-sync DOM Web-Platform-Tests from upstream

Modified: trunk/LayoutTests/TestExpectations (220772 => 220773)


--- trunk/LayoutTests/TestExpectations	2017-08-15 23:23:51 UTC (rev 220772)
+++ trunk/LayoutTests/TestExpectations	2017-08-15 23:48:46 UTC (rev 220773)
@@ -1437,3 +1437,5 @@
 webkit.org/b/175288 imported/w3c/web-platform-tests/css/css-ui-3/outline-016.html [ ImageOnlyFailure ]
 webkit.org/b/175288 imported/w3c/web-platform-tests/css/css-ui-3/outline-019.html [ ImageOnlyFailure ]
 webkit.org/b/175290 imported/w3c/web-platform-tests/css/css-ui-3/text-overflow-005.html [ ImageOnlyFailure ]
+
+webkit.org/b/175597 http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html [ Failure ]

Added: trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-expected.txt (0 => 220773)


--- trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-expected.txt	2017-08-15 23:48:46 UTC (rev 220773)
@@ -0,0 +1,9 @@
+Test that an XMLHttpRequest with Content-Type: gzip is properly uncompressed.
+
+Content Type: application/octet-stream
+Content Encoding: gzip
+Content Length: 282
+RESPONSE 200: [object ArrayBuffer]
+LENGTH: 445
+CONTENT: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-no-content-encoding-expected.txt (0 => 220773)


--- trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-no-content-encoding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-no-content-encoding-expected.txt	2017-08-15 23:48:46 UTC (rev 220773)
@@ -0,0 +1,9 @@
+Test that an XMLHttpRequest with Content-Type: gzip is properly uncompressed.
+
+Content Type: application/octet-stream
+Content Encoding: null
+Content Length: 282
+RESPONSE 200: [object ArrayBuffer]
+LENGTH: 445
+CONTENT: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html (0 => 220773)


--- trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type-no-content-encoding.html	2017-08-15 23:48:46 UTC (rev 220773)
@@ -0,0 +1,52 @@
+<html>
+<body>
+<p>Test that an XMLHttpRequest with Content-Type: gzip is properly uncompressed.</p>
+<pre id="console"></pre>
+<script>
+const max = 2048;
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+const log = text => {
+    let console = document.getElementById('console');
+    console.appendChild(document.createTextNode(text + '\n'));
+};
+
+const xhr = new XMLHttpRequest();
+xhr.open('GET', 'resources/gzip-lorem-no-content-encoding.php');
+xhr.responseType = 'arraybuffer';
+xhr._onerror_ = e => log(`FAILED: ${xhr.status} ${xhr.statusText}`);
+xhr._onreadystatechange_ = () => {
+    switch (xhr.readyState) {
+    case xhr.HEADERS_RECEIVED: 
+        log(`Content Type: ${xhr.getResponseHeader('Content-Type')}`);
+        log(`Content Encoding: ${xhr.getResponseHeader('Content-Encoding')}`);
+        log(`Content Length: ${xhr.getResponseHeader('Content-Length')}`);
+        break;
+    case xhr.DONE:
+        log(`RESPONSE ${xhr.status}: ${xhr.response}`);
+        const array = new Uint8Array(xhr.response);
+        log(`LENGTH: ${array.length}`);
+        let content = '"';
+        let i = 0;
+        while (i < max && i < array.length) {
+            const c = array[i];
+            content += (0x20 <= c && c <= 0x7e) ? String.fromCodePoint(c) : `\\x${c.toString(16).padStart(2, '0')}`;
+            ++i;
+        }
+        content += '"';
+        log(`CONTENT: ${content}`);
+        if (array.length > i)
+            log('Output truncated to ${max} characters');
+        if (window.testRunner)
+            testRunner.notifyDone();
+        break;
+    }
+};
+xhr.send(null);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type.html (0 => 220773)


--- trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/gzip-content-type.html	2017-08-15 23:48:46 UTC (rev 220773)
@@ -0,0 +1,52 @@
+<html>
+<body>
+<p>Test that an XMLHttpRequest with Content-Type: gzip is properly uncompressed.</p>
+<pre id="console"></pre>
+<script>
+const max = 2048;
+
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+const log = text => {
+    let console = document.getElementById('console');
+    console.appendChild(document.createTextNode(text + '\n'));
+};
+
+const xhr = new XMLHttpRequest();
+xhr.open('GET', 'resources/gzip-lorem.php');
+xhr.responseType = 'arraybuffer';
+xhr._onerror_ = e => log(`FAILED: ${xhr.status} ${xhr.statusText}`);
+xhr._onreadystatechange_ = () => {
+    switch (xhr.readyState) {
+    case xhr.HEADERS_RECEIVED: 
+        log(`Content Type: ${xhr.getResponseHeader('Content-Type')}`);
+        log(`Content Encoding: ${xhr.getResponseHeader('Content-Encoding')}`);
+        log(`Content Length: ${xhr.getResponseHeader('Content-Length')}`);
+        break;
+    case xhr.DONE:
+        log(`RESPONSE ${xhr.status}: ${xhr.response}`);
+        const array = new Uint8Array(xhr.response);
+        log(`LENGTH: ${array.length}`);
+        let content = '"';
+        let i = 0;
+        while (i < max && i < array.length) {
+            const c = array[i];
+            content += (0x20 <= c && c <= 0x7e) ? String.fromCodePoint(c) : `\\x${c.toString(16).padStart(2, '0')}`;
+            ++i;
+        }
+        content += '"';
+        log(`CONTENT: ${content}`);
+        if (array.length > i)
+            log('Output truncated to ${max} characters');
+        if (window.testRunner)
+            testRunner.notifyDone();
+        break;
+    }
+};
+xhr.send(null);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/gzip-lorem-no-content-encoding.php (0 => 220773)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/gzip-lorem-no-content-encoding.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/gzip-lorem-no-content-encoding.php	2017-08-15 23:48:46 UTC (rev 220773)
@@ -0,0 +1,8 @@
+<?php
+$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
+$gzipText = gzencode($text, 6);
+
+header("Content-Type: application/octet-stream");
+
+echo $gzipText;
+?>

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/gzip-lorem.php (0 => 220773)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/gzip-lorem.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/gzip-lorem.php	2017-08-15 23:48:46 UTC (rev 220773)
@@ -0,0 +1,10 @@
+<?php
+$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
+$gzipText = gzencode($text, 6);
+
+header("Content-Encoding: gzip");
+header("Content-Type: application/octet-stream");
+header("Content-Length: " . strlen($gzipText));
+
+echo $gzipText;
+?>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to