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

Unified Diff: LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html

Issue 79953004: Improve fidelity of XHR progress events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test stable Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html
diff --git a/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html b/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..23d1e0474ac3999b5604fc2af961b31f098d1761
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<head>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+</head>
+<body>
+<p> Verify that a timeout ProgressEvent is dispatched and have the expected values.</p>
+<div id="log"></div>
+<script type="text/javascript">
+
+function verifyProgressEvent(context, e)
+{
+ assert_true(e.loaded >= 0, "Non-zero 'loaded' value for '" + context + "' event.");
+ assert_true(!e.lengthComputable || e.total > 0, "Non-zero 'total' value for '" + context + "' event.");
+}
+
+function logProgressEvent(e) {
+ results += " " + e.type;
+}
+
+function unexpectedProgressEvent(e) {
+ assert_unreached("Unexpected request error");
+}
+
+function timeoutHandler(e)
+{
+ assert_true(e instanceof ProgressEvent);
+ verifyProgressEvent("ontimeout", e);
+ testOnTimeoutEvent.done();
+}
+
+var testOnTimeoutEvent = async_test("Check that 'timeout' events are delivered and have expected values.");
+testOnTimeoutEvent.step(function () {
+ var xhr = new XMLHttpRequest();
+ xhr.ontimeout = testOnTimeoutEvent.step_func(timeoutHandler);
+ xhr.onabort = testOnTimeoutEvent.step_func(unexpectedProgressEvent);
+ xhr.onerror = testOnTimeoutEvent.step_func(unexpectedProgressEvent);
+ xhr.onload = testOnTimeoutEvent.step_func(unexpectedProgressEvent);
+ xhr.timeout = 30;
+ xhr.open("GET", "/resources/load-and-stall.php?name=../resources/test.mp4&stallAt=100&stallFor=10000&mimeType=video/mp4", true);
+ xhr.send();
+});
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698