4 <script src=
"../resources/testharness.js"></script>
5 <script src=
"../resources/testharnessreport.js"></script>
8 <p> Verify that a timeout ProgressEvent is dispatched and have the expected values.
</p>
10 <script type=
"text/javascript">
12 function verifyProgressEvent(context
, e
)
14 assert_true(e
.loaded
>= 0, "Non-zero 'loaded' value for '" + context
+ "' event.");
15 assert_true(!e
.lengthComputable
|| e
.total
> 0, "Non-zero 'total' value for '" + context
+ "' event.");
18 function logProgressEvent(e
) {
19 results
+= " " + e
.type
;
22 function unexpectedProgressEvent(e
) {
23 assert_unreached("Unexpected request error");
26 function timeoutHandler(e
)
28 assert_true(e
instanceof ProgressEvent
);
29 verifyProgressEvent("ontimeout", e
);
30 testOnTimeoutEvent
.done();
33 var testOnTimeoutEvent
= async_test("Check that 'timeout' events are delivered and have expected values.");
34 testOnTimeoutEvent
.step(function () {
35 var xhr
= new XMLHttpRequest();
36 xhr
.ontimeout
= testOnTimeoutEvent
.step_func(timeoutHandler
);
37 xhr
.onabort
= testOnTimeoutEvent
.step_func(unexpectedProgressEvent
);
38 xhr
.onerror
= testOnTimeoutEvent
.step_func(unexpectedProgressEvent
);
39 xhr
.onload
= testOnTimeoutEvent
.step_func(unexpectedProgressEvent
);
41 xhr
.open("GET", "/resources/load-and-stall.php?name=../resources/test.mp4&stallAt=100&stallFor=10000&mimeType=video/mp4", true);