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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>XMLHttpRequest: abort() while sending data</title>
5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 Correct progress event sequencing on abort(), <a href="http://crbug.com/315488"> bug 315488</a>.
10 <script>
11 // Based on http://w3c-test.org/web-platform-tests/master/XMLHttpRequest/abort-d uring-upload.htm
12
13 var expected = [
14 'upload', 'progress',
15 'upload', 'abort',
16 'upload', 'loadend',
17 'load', 'progress',
18 'load', 'abort',
19 'load', 'loadend'];
20
21 var result = [];
22 function recordEvent(e) {
23 var kind = e.target instanceof XMLHttpRequest ? 'load' : 'upload';
24 result.push(kind, e.type);
25 }
26
27 var abortAfterSendLoadend = async_test("Progress event delivery on abort(), post -send() (async)");
28 abortAfterSendLoadend.step(function() {
29 var xhr = new XMLHttpRequest();
30 xhr.open("POST", "resources/delay.php?iteration=1&delay=1000");
31 xhr.onprogress = recordEvent;
32 xhr.onabort = recordEvent;
33 xhr.onloadend = abortAfterSendLoadend.step_func(function (e) {
34 recordEvent(e);
35 assert_equals(xhr.readyState, XMLHttpRequest.DONE);
36 assert_array_equals(result, expected);
37 // Runs after abort()'s transition of readyState to UNSENT.
38 setTimeout(abortAfterSendLoadend.step_func(function () {
39 assert_equals(xhr.readyState, XMLHttpRequest.UNSENT);
40 abortAfterSendLoadend.done();
41 }), 0);
42 });
43 xhr.upload.onprogress = recordEvent;
44 xhr.upload.onabort = recordEvent;
45 xhr.upload.onloadend = recordEvent;
46
47 xhr.send();
48 xhr.abort();
49 });
50
51 var resultSync = [];
52 function recordEventSync(e) {
53 var kind = e.target instanceof XMLHttpRequest ? 'load' : 'upload';
54 resultSync.push(kind, e.type);
55 }
56 var abortAfterSendSync = async_test("Progress event delivery on abort(), post-se nd() (sync)");
57 abortAfterSendSync.step(function() {
58 var xhr = new XMLHttpRequest();
59 xhr.open("POST", "resources/delay.php?iteration=1&delay=10");
60 xhr.onreadystatechange = function () {
61 if (xhr.readyState > XMLHttpRequest.OPENED && xhr.readyState != XMLHttpR equest.DONE)
62 xhr.abort();
63 };
64 xhr.onprogress = recordEventSync;
65 xhr.onabort = recordEventSync;
66 xhr.onloadend = abortAfterSendSync.step_func(function (e) {
67 recordEventSync(e);
68 assert_equals(xhr.readyState, XMLHttpRequest.DONE);
69 assert_array_equals(resultSync, expected);
70 // Runs after abort()'s transition of readyState to UNSENT.
71 setTimeout(abortAfterSendSync.step_func(function () {
72 assert_equals(xhr.readyState, XMLHttpRequest.UNSENT);
73 abortAfterSendSync.done();
74 }), 0);
75 });
76 xhr.upload.onprogress = recordEventSync;
77 xhr.upload.onabort = recordEventSync;
78 xhr.upload.onloadend = recordEventSync;
79 xhr.send();
80 });
81 </script>
82 </body>
83 </html>
OLDNEW
« 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