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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/upload-progress-events-handlers-must-be-set-before-send.html

Issue 2427553002: Fix XHR's logic to determine whether or not to dispatch upload progress events
Patch Set: a Created 4 years, 2 months 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
OLDNEW
(Empty)
1 <!doctype html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <script type="text/javascript">
5 async_test(test => {
6 const xhr = new XMLHttpRequest();
7 xhr.open("POST", "resources/post-echo.php", true);
8 xhr.send('hello');
9
10 const upload = xhr.upload;
11 upload.onloadstart = test.step_func(() => {
12 assert_unreached('Unexpected upload.onloadstart call');
13 });
14 upload.onprogress = test.step_func(() => {
15 assert_unreached('Unexpected upload.onprogress call');
16 });
17 upload.onload = test.step_func(() => {
18 assert_unreached('Unexpected upload.onload call');
19 });
20 upload.onloadend = test.step_func(() => {
21 assert_unreached('Unexpected upload.onloadend call');
22 });
23
24 xhr.onload = test.step_func(() => {
25 test.done();
26 });
27 }, 'Upload progress events should not be dispatched if the handlers are set afte r send().');
28
29 async_test(test => {
30 const xhr = new XMLHttpRequest();
31 xhr.open("POST", "resources/post-echo.php", true);
32
33 const upload = xhr.upload;
34
35 xhr.send('hello');
36
37 upload.onloadstart = test.step_func(() => {
38 assert_unreached('Unexpected upload.onloadstart call');
39 });
40 upload.onprogress = test.step_func(() => {
41 assert_unreached('Unexpected upload.onprogress call');
42 });
43 upload.onload = test.step_func(() => {
44 assert_unreached('Unexpected upload.onload call');
45 });
46 upload.onloadend = test.step_func(() => {
47 assert_unreached('Unexpected upload.onloadend call');
48 });
49
50 xhr.onload = test.step_func(() => {
51 test.done();
52 });
53 }, 'Upload progress events should not be dispatched even if the upload atrribute is touched before send().');
54
55 async_test(test => {
56 const xhr = new XMLHttpRequest();
57 xhr.open("POST", "resources/post-echo.php", true);
58
59 const upload = xhr.upload;
60 let onloadstartCalled;
61 upload.onloadstart = test.step_func(() => {
62 onloadstartCalled = true;
63 });
64
65 xhr.send('hello');
66
67 let onprogressCalled;
68 upload.onprogress = test.step_func(() => {
69 onprogressCalled = true;
70 });
71 let onloadCalled;
72 upload.onload = test.step_func(() => {
73 onloadCalled = true;
74 });
75 let onloadendCalled;
76 upload.onloadend = test.step_func(() => {
77 onloadendCalled = true;
78 });
79
80 xhr.onload = test.step_func(() => {
81 assert_true(onloadstartCalled, 'upload.onloadstart is called');
82 assert_true(onprogressCalled, 'upload.onprogress is called');
83 assert_true(onloadCalled, 'upload.onload is called');
84 assert_true(onloadendCalled, 'upload.onloadend is called');
85
86 test.done();
87 });
88 }, 'All upload progress events should be dispatched if at least one handler is s et to the upload atrribute before send().');
89 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698