| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| Ms2ger | 91fef14 | 2014-11-01 09:24:37 | [diff] [blame] | 4 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[4]/dl[1]/dd[2]/p[3]"/> |
| 5 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-status-attribute" data-tested-assertations="following::ol[1]/li[3]"/> |
| 6 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetype-attribute" data-tested-assertations="following::ol[1]/li[4]"/> |
| 7 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-response-attribute" data-tested-assertations="following::a[contains(@href,'#blob-response-entity-body')]/.."/> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 8 | |
| 9 | <script src="/resources/testharness.js"></script> |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 10 | <script src="/resources/testharnessreport.js"></script> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 11 | <title>XMLHttpRequest: The send() method: Blob data</title> |
| 12 | </head> |
| 13 | |
| 14 | <body> |
| 15 | <div id="log"></div> |
| 16 | |
| 17 | <script type="text/javascript"> |
| 18 | var test = async_test(); |
| 19 | |
| 20 | test.step(function() |
| 21 | { |
| 22 | var xhr = new XMLHttpRequest(); |
| 23 | var xhr2 = new XMLHttpRequest(); |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 24 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 25 | var content = "Hello"; |
| 26 | var blob; |
| 27 | |
| 28 | xhr.onreadystatechange = function() |
| 29 | { |
| 30 | if (xhr.readyState == 4) |
| 31 | { |
| 32 | test.step(function() |
| 33 | { |
| 34 | blob = xhr.response; |
| 35 | assert_true(blob instanceof Blob, "Blob from XHR Response"); |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 36 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 37 | xhr2.open("POST", "./resources/content.py", true); |
| 38 | xhr2.send(blob); |
| 39 | }); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | xhr2.onreadystatechange = function() |
| 44 | { |
| 45 | if (xhr2.readyState == 4) |
| 46 | { |
| 47 | test.step(function() |
| 48 | { |
| 49 | assert_equals(xhr2.status, 200); |
| 50 | assert_equals(xhr2.response, content); |
| 51 | test.done(); |
| 52 | }); |
| 53 | } |
| 54 | }; |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 55 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 56 | xhr.open("GET", "./resources/content.py?content=" + content, true); |
| 57 | xhr.responseType = "blob"; |
| 58 | xhr.send(); |
| 59 | }); |
| 60 | </script> |
| 61 | </body> |
| 62 | </html> |