Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / response-legacystream.html
blob6c4bfc15fbcdbadd0f7e3ef19bf3ee8bb6d0b5ce
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.");
9 test.step(function()
11 var xhr = new XMLHttpRequest;
13 xhr.responseType = "legacystream";
14 assert_equals(xhr.responseType, "legacystream", "xhr.responseType");
16 assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState");
17 assert_equals(xhr.response, null, "xhr.response during UNSENT");
19 var seenStates = [];
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);
26 switch (xhr.readyState) {
27 case xhr.UNSENT:
28 assert_unreached('Unexpected readyState: UNSENT');
29 return;
31 case xhr.OPENED:
32 assert_equals(xhr.response, null, "xhr.response during OPENED");
33 return;
35 case xhr.HEADERS_RECEIVED:
36 assert_equals(xhr.response, null, "xhr.response during HEADERS_RECEIVED");
37 return;
39 case xhr.LOADING:
40 assert_not_equals(xhr.response, null, "xhr.response during LOADING");
41 return;
43 case xhr.DONE:
44 assert_equals(xhr.status, 200, "xhr.status");
46 // Check that we saw all states.
47 assert_array_equals(seenStates,
48 [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]);
50 test.done();
51 return;
53 default:
54 assert_unreached('Unexpected readyState: ' + xhr.readyState)
55 return;
57 });
59 xhr.open('GET', '../resources/test.ogv', true);
60 xhr.send();
61 });
62 </script>
63 </body>
64 </html>