| ronkorving | 08ca59a | 2013-06-08 04:33:21 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>XMLHttpRequest: GZIP response was correctly inflated</title> |
| 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| Hallvord Reiar M. Steen | c136f2b | 2013-06-10 13:51:45 | [diff] [blame] | 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')]" /> |
| ronkorving | 08ca59a | 2013-06-08 04:33:21 | [diff] [blame] | 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() |
| ronkorving | 6a6eb21 | 2013-06-08 04:35:38 | [diff] [blame] | 16 | |
| James Graham | 234a672 | 2013-09-17 17:54:38 | [diff] [blame] | 17 | client.open("POST", "resources/gzip.py", false); |
| ronkorving | 08ca59a | 2013-06-08 04:33:21 | [diff] [blame] | 18 | |
| 19 | client.onreadystatechange = test.step_func(function () { |
| 20 | if (client.readyState === 4) { |
| 21 | var len = parseInt(client.getResponseHeader('content-length'), 10); |
| 22 | |
| ronkorving | 4d094d5 | 2013-06-08 05:00:43 | [diff] [blame] | 23 | assert_equals(client.getResponseHeader('content-encoding'), 'gzip'); |
| ronkorving | 08ca59a | 2013-06-08 04:33:21 | [diff] [blame] | 24 | assert_true(len < input.length); |
| 25 | assert_equals(client.responseText, input); |
| 26 | test.done(); |
| 27 | } |
| 28 | }); |
| 29 | |
| 30 | client.send(input); |
| 31 | }, document.title); |
| 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> |