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

Unified Diff: LayoutTests/http/tests/xmlhttprequest/abort-after-send.html

Issue 66323004: XHR: compliant event sequencing on request errors and aborts. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Improve test code quality 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/xmlhttprequest/abort-after-send-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/xmlhttprequest/abort-after-send.html
diff --git a/LayoutTests/http/tests/xmlhttprequest/abort-after-send.html b/LayoutTests/http/tests/xmlhttprequest/abort-after-send.html
new file mode 100644
index 0000000000000000000000000000000000000000..fdc33464ebb22d2b93c7fdf801e2964c7aa2ab4e
--- /dev/null
+++ b/LayoutTests/http/tests/xmlhttprequest/abort-after-send.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html>
+<head>
+<title>XMLHttpRequest: abort() while sending data</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+</head>
+<body>
+Correct progress event sequencing on abort(), <a href="http://crbug.com/315488">bug 315488</a>.
+<script>
+// Based on http://w3c-test.org/web-platform-tests/master/XMLHttpRequest/abort-during-upload.htm
+
+var expected = [
+ 'upload', 'progress',
+ 'upload', 'abort',
+ 'upload', 'loadend',
+ 'load', 'progress',
+ 'load', 'abort',
+ 'load', 'loadend'];
+
+var result = [];
+function recordEvent(e) {
+ var kind = e.target instanceof XMLHttpRequest ? 'load' : 'upload';
+ result.push(kind, e.type);
+}
+
+var abortAfterSendLoadend = async_test("Progress event delivery on abort(), post-send() (async)");
+abortAfterSendLoadend.step(function() {
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "resources/delay.php?iteration=1&delay=1000");
+ xhr.onprogress = recordEvent;
+ xhr.onabort = recordEvent;
+ xhr.onloadend = abortAfterSendLoadend.step_func(function (e) {
+ recordEvent(e);
+ assert_equals(xhr.readyState, XMLHttpRequest.DONE);
+ assert_array_equals(result, expected);
+ // Runs after abort()'s transition of readyState to UNSENT.
+ setTimeout(abortAfterSendLoadend.step_func(function () {
+ assert_equals(xhr.readyState, XMLHttpRequest.UNSENT);
+ abortAfterSendLoadend.done();
+ }), 0);
+ });
+ xhr.upload.onprogress = recordEvent;
+ xhr.upload.onabort = recordEvent;
+ xhr.upload.onloadend = recordEvent;
+
+ xhr.send();
+ xhr.abort();
+});
+
+var resultSync = [];
+function recordEventSync(e) {
+ var kind = e.target instanceof XMLHttpRequest ? 'load' : 'upload';
+ resultSync.push(kind, e.type);
+}
+var abortAfterSendSync = async_test("Progress event delivery on abort(), post-send() (sync)");
+abortAfterSendSync.step(function() {
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", "resources/delay.php?iteration=1&delay=10");
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState > XMLHttpRequest.OPENED && xhr.readyState != XMLHttpRequest.DONE)
+ xhr.abort();
+ };
+ xhr.onprogress = recordEventSync;
+ xhr.onabort = recordEventSync;
+ xhr.onloadend = abortAfterSendSync.step_func(function (e) {
+ recordEventSync(e);
+ assert_equals(xhr.readyState, XMLHttpRequest.DONE);
+ assert_array_equals(resultSync, expected);
+ // Runs after abort()'s transition of readyState to UNSENT.
+ setTimeout(abortAfterSendSync.step_func(function () {
+ assert_equals(xhr.readyState, XMLHttpRequest.UNSENT);
+ abortAfterSendSync.done();
+ }), 0);
+ });
+ xhr.upload.onprogress = recordEventSync;
+ xhr.upload.onabort = recordEventSync;
+ xhr.upload.onloadend = recordEventSync;
+ xhr.send();
+});
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/http/tests/xmlhttprequest/abort-after-send-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698