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.");
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");
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
) {
28 assert_unreached('Unexpected readyState: UNSENT');
32 assert_equals(xhr
.response
, null, "xhr.response during OPENED");
35 case xhr
.HEADERS_RECEIVED
:
36 assert_equals(xhr
.response
, null, "xhr.response during HEADERS_RECEIVED");
40 assert_not_equals(xhr
.response
, null, "xhr.response during LOADING");
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
]);
54 assert_unreached('Unexpected readyState: ' + xhr
.readyState
)
59 xhr
.open('GET', '../resources/test.ogv', true);