Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: LayoutTests/http/tests/xmlhttprequest/response-stream.html

Issue 18883002: Add Streams API support to XMLHttpRequest (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: kinuko's comment Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../resources/testharness.js"></script> 4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script> 5 <script src="../resources/testharnessreport.js"></script>
6 <script type="text/javascript"> 6 <script type="text/javascript">
7 var test = async_test("Test response of XMLHttpRequest with responseType set to 'json' for various readyState."); 7 var test = async_test("Test response of XMLHttpRequest with responseType set to 'stream' for various readyState.");
8 8
9 test.step(function() 9 test.step(function()
10 { 10 {
11 var xhr = new XMLHttpRequest; 11 var xhr = new XMLHttpRequest;
12 12
13 xhr.responseType = "json"; 13 xhr.responseType = "stream";
14 assert_equals(xhr.responseType, "json", "xhr.responseType"); 14 assert_equals(xhr.responseType, "stream", "xhr.responseType");
15 15
16 assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState"); 16 assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState");
17 assert_equals(xhr.response, null, "xhr.response"); 17 assert_equals(xhr.response, null, "xhr.response during UNSENT");
18 18
19 var seenStates = []; 19 var seenStates = [];
20 20
21 xhr.onreadystatechange = test.step_func(function() { 21 xhr.onreadystatechange = test.step_func(function() {
22 seenStates.push(xhr.readyState); 22 // onreadystatechange can be invoked multiple times in LOADING state.
23 if (seenStates.length == 0 || xhr.readyState != seenStates[seenStates.le ngth - 1])
24 seenStates.push(xhr.readyState);
23 25
24 switch (xhr.readyState) { 26 switch (xhr.readyState) {
25 case xhr.UNSENT: 27 case xhr.UNSENT:
26 assert_unreached('Unexpected readyState: UNSENT'); 28 assert_unreached('Unexpected readyState: UNSENT');
27 return; 29 return;
28 30
29 case xhr.OPENED: 31 case xhr.OPENED:
30 assert_equals(xhr.response, null, "xhr.response"); 32 assert_equals(xhr.response, null, "xhr.response during OPENED");
31 return; 33 return;
32 34
33 case xhr.HEADERS_RECEIVED: 35 case xhr.HEADERS_RECEIVED:
34 assert_equals(xhr.response, null, "xhr.response"); 36 assert_equals(xhr.response, null, "xhr.response during HEADERS_RECEI VED");
35 return; 37 return;
36 38
37 case xhr.LOADING: 39 case xhr.LOADING:
38 assert_equals(xhr.response, null, "xhr.response"); 40 assert_not_equals(xhr.response, null, "xhr.response during LOADING") ;
39 return; 41 return;
40 42
41 case xhr.DONE: 43 case xhr.DONE:
42 assert_equals(xhr.status, 200, "xhr.status"); 44 assert_equals(xhr.status, 200, "xhr.status");
43 assert_equals(JSON.stringify(xhr.response),
44 '["a","b",2,{"3":3}]',
45 "Stringify result of xhr.response");
46 45
47 // Check that we saw all states. 46 // Check that we saw all states.
48 assert_array_equals(seenStates, 47 assert_array_equals(seenStates,
49 [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]); 48 [xhr.OPENED, xhr.HEADERS_RECEIVED, xhr.LOADING, xhr.DONE]);
50 49
51 test.done(); 50 test.done();
52 return; 51 return;
53 52
54 default: 53 default:
55 assert_unreached('Unexpected readyState: ' + xhr.readyState) 54 assert_unreached('Unexpected readyState: ' + xhr.readyState)
56 return; 55 return;
57 } 56 }
58 }); 57 });
59 58
60 xhr.open('GET', 'resources/test.json', true); 59 xhr.open('GET', '../resources/test.ogv', true);
61 xhr.send(); 60 xhr.send();
62 }); 61 });
63 </script> 62 </script>
64 </body> 63 </body>
65 </html> 64 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698