Andrew Top | 61a8495 | 2019-04-30 15:07:33 -0700 | [diff] [blame^] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>XMLHttpRequest: content-encoding:deflate response was correctly inflated</title> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <link rel="help" href="https://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="following::p[contains(text(),'content-encodings')]" /> |
| 8 | </head> |
| 9 | <body> |
| 10 | <div id="log"></div> |
| 11 | <script> |
| 12 | function request(input) { |
| 13 | var test = async_test(); |
| 14 | test.step(function() { |
| 15 | var client = new XMLHttpRequest() |
| 16 | |
| 17 | client.open("POST", "resources/zlib.py", false); |
| 18 | |
| 19 | client.onreadystatechange = test.step_func(function () { |
| 20 | if (client.readyState === 4) { |
| 21 | var len = parseInt(client.getResponseHeader('content-length'), 10); |
| 22 | |
| 23 | assert_equals(client.getResponseHeader('content-encoding'), 'deflate'); |
| 24 | assert_true(len < input.length); |
| 25 | assert_equals(client.responseText, input); |
| 26 | test.done(); |
| 27 | } |
| 28 | }); |
| 29 | |
| 30 | client.send(input); |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | var wellCompressableData = ''; |
| 35 | for (var i = 0; i < 500; i++) { |
| 36 | wellCompressableData += 'foofoofoofoofoofoofoo'; |
| 37 | } |
| 38 | |
| 39 | request(wellCompressableData); |
| 40 | </script> |
| 41 | </body> |
| 42 | </html> |