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

Side by Side Diff: content/test/data/loader/async_resource_handler.html

Issue 1318393003: Updated UploadProgress tests under ThreadSanitizer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: portable size_t formatting Created 5 years, 3 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
« no previous file with comments | « content/browser/loader/async_resource_handler_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 var ranProgressHandler = false; 4 var ranProgressHandler = false;
5 var completedUpload = false; 5 var completedUpload = false;
6 6
7 var asyncXHR; 7 var asyncXHR;
8 var lastSeenProgress = 0; 8 var lastSeenProgress = 0;
9 // Build a long string, fast. 9 var data;
10 // data.length = 2 * 3^15 = 28697814
11
12 var data = 'yo';
13 var iterations = 15;
14 for (var i = 0; i < iterations; i++) {
15 data = data + data + data;
16 }
17 10
18 function sendResults(failures) { 11 function sendResults(failures) {
19 var resultString = failures.length ? failures.join('\n') : "success"; 12 var resultString = failures.length ? failures.join('\n') : "success";
20 window.domAutomationController.send(resultString); 13 window.domAutomationController.send(resultString);
21 } 14 }
22 15
23 function progressListener(e) { 16 function progressListener(e) {
24 var progress = e.loaded; 17 var progress = e.loaded;
25 var failureList = []; 18 var failureList = [];
26 19
(...skipping 29 matching lines...) Expand all
56 failureList.push( 49 failureList.push(
57 'Receieved responseText: \'' + this.responseText +'\'. Expected: \'hello \'.'); 50 'Receieved responseText: \'' + this.responseText +'\'. Expected: \'hello \'.');
58 } 51 }
59 sendResults(failureList); 52 sendResults(failureList);
60 } 53 }
61 54
62 function onError(e) { 55 function onError(e) {
63 sendResults(['Received an XHR error event.']); 56 sendResults(['Received an XHR error event.']);
64 } 57 }
65 58
66 function WaitForAsyncXHR(url) { 59 function WaitForAsyncXHR(url, payloadSize) {
60 // Build a long string, fast.
61 // Note: payloadSize will be of the form 2*3^x.
62 data = 'yo';
63 while(data.length !== payloadSize) {
64 data = data + data + data;
65 }
67 asyncXHR = new XMLHttpRequest(); 66 asyncXHR = new XMLHttpRequest();
68 asyncXHR.addEventListener('load', onFinished); 67 asyncXHR.addEventListener('load', onFinished);
69 asyncXHR.addEventListener('error', onError); 68 asyncXHR.addEventListener('error', onError);
70 69
71 asyncXHR.upload.addEventListener('progress', progressListener); 70 asyncXHR.upload.addEventListener('progress', progressListener);
72 asyncXHR.upload.addEventListener('load', completedUpload); 71 asyncXHR.upload.addEventListener('load', completedUpload);
73 72
74 asyncXHR.open('POST', url, true); 73 asyncXHR.open('POST', url, true);
75 74
76 asyncXHR.setRequestHeader('Content-Type', 'text/plain'); 75 asyncXHR.setRequestHeader('Content-Type', 'text/plain');
77 asyncXHR.send(data); 76 asyncXHR.send(data);
78 } 77 }
79 </script> 78 </script>
80 </head> 79 </head>
81 <body> 80 <body>
82 This page sends an asynchronous XMLHttpRequest on calling WaitForAsyncXHR(url). 81 This page sends an asynchronous XMLHttpRequest on calling WaitForAsyncXHR(url).
83 </body> 82 </body>
84 </html> 83 </html>
OLDNEW
« no previous file with comments | « content/browser/loader/async_resource_handler_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698