blob: 5285fc180cc979e33c567f537e8575abf285db50 [file] [log] [blame]
Philip Jägenstedtc053f402014-01-22 17:02:181<!DOCTYPE html>
2<html>
3<head>
Ms2ger91fef142014-11-01 09:24:374 <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ägenstedtc053f402014-01-22 17:02:188
9 <script src="/resources/testharness.js"></script>
James Grahama3d9d8e2014-06-09 13:06:4810 <script src="/resources/testharnessreport.js"></script>
Philip Jägenstedtc053f402014-01-22 17:02:1811 <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 Grahama3d9d8e2014-06-09 13:06:4824
Philip Jägenstedtc053f402014-01-22 17:02:1825 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 Grahama3d9d8e2014-06-09 13:06:4836
Philip Jägenstedtc053f402014-01-22 17:02:1837 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 Grahama3d9d8e2014-06-09 13:06:4855
Philip Jägenstedtc053f402014-01-22 17:02:1856 xhr.open("GET", "./resources/content.py?content=" + content, true);
57 xhr.responseType = "blob";
58 xhr.send();
59 });
60 </script>
61</body>
62</html>