Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / response-legacystream.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script type="text/javascript">
7 var test = async_test("Test response of XMLHttpRequest with responseType set to 'legacystream' for various readyState.");
8
9 test.step(function()
10 {
11     var xhr = new XMLHttpRequest;
12
13     xhr.responseType = "legacystream";
14     assert_equals(xhr.responseType, "legacystream", "xhr.responseType");
15
16     assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState");
17     assert_equals(xhr.response, null, "xhr.response during UNSENT");
18
19     var seenStates = [];
20
21     xhr.onreadystatechange = test.step_func(function() {
22         // onreadystatechange can be invoked multiple times in LOADING state.
23         if (seenStates.length == 0 || xhr.readyState != seenStates[seenStates.length - 1])
24             seenStates.push(xhr.readyState);
25
26         switch (xhr.readyState) {
27         case xhr.UNSENT:
28             assert_unreached('Unexpected readyState: UNSENT');
29             return;
30
31         case xhr.OPENED:
32             assert_equals(xhr.response, null, "xhr.response during OPENED");
33             return;
34
35         case xhr.HEADERS_RECEIVED:
36             assert_equals(xhr.response, null, "xhr.response during HEADERS_RECEIVED");
37             return;
38
39         case xhr.LOADING:
40             assert_not_equals(xhr.response, null, "xhr.response during LOADING");
41             return;
42
43         case xhr.DONE:
44             assert_equals(xhr.status, 200, "xhr.status");
45
46             // Check that we saw all states.
47             assert_array_equals(seenStates,
48                                 [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]);
49
50             test.done();
51             return;
52
53         default:
54             assert_unreached('Unexpected readyState: ' + xhr.readyState)
55             return;
56         }
57     });
58
59     xhr.open('GET', '../resources/test.ogv', true);
60     xhr.send();
61 });
62 </script>
63 </body>
64 </html>