2 <script src=
"/js-test-resources/js-test.js"></script>
3 <script type=
"text/javascript">
4 window
.jsTestIsAsync
= true;
5 description('XMLHttpRequest.responseText should not throw even when not (loading or done).');
6 function test(readyState
) {
8 return new Promise(function(resolve
, reject
) {
9 xhr
= new XMLHttpRequest();
10 xhr
.onreadystatechange = function() {
12 if (this.readyState
=== readyState
) {
13 // We evaluate responseText because we want to make sure
14 // doing that doesn't throw.
15 var response
= xhr
.responseText
;
23 xhr
.open('GET', 'resources/1251.html');
24 if (readyState
!== 1) {
28 testPassed('readyState = ' + readyState
);
31 testFailed('readyState = ' + readyState
, + ', ' + e
);
35 var promise
= Promise
.resolve();
36 for (var readyState
= 1; readyState
<= 4; ++readyState
) {
37 promise
= promise
.then(test
.bind(undefined, readyState
));
39 promise
.then(finishJSTest
, function(e
) {