3 <title> Test case for bug
18655 </title>
6 <p> Test case for Bug
<a href=
"https://bugs.webkit.org/show_bug.cgi?id=18655">18655</a>: [XHR] onProgress event
7 needs to be dispatched according to what the specification states
</p>
8 <p> This test verify that we
"dispatch a progress event called progress about
9 every 50ms or for every byte received, whichever is least frequent".
</p>
10 <p> You should see a sequence of
5 PASSED.
</p>
13 <script type=
"text/javascript">
14 if (window
.testRunner
) {
15 testRunner
.dumpAsText();
16 testRunner
.waitUntilDone();
21 document
.getElementById("console").appendChild(document
.createTextNode(message
));
22 document
.getElementById("console").appendChild(document
.createElement("br"));
25 var testsCompleted
= 0;
27 function test(iteration
, delay
, compare
, testDescription
)
30 var sawReadyStateDONE
= false;
31 function onProgress(e
) {
33 if (sawReadyStateDONE
)
34 log("FAILED: saw 'progress' event after readystate 'DONE' event for " + testDescription
);
37 function onReadyState(e
) {
38 if (this.readyState
== 4) {
39 sawReadyStateDONE
= true;
40 var passed
= compare(count
, iteration
);
41 log(passed
? "PASSED" : "FAILED (count was " + count
+ ") for " + testDescription
);
43 if (testsCompleted
== 5) {
44 if (window
.testRunner
)
45 testRunner
.notifyDone();
50 var req
= new XMLHttpRequest();
51 req
.onprogress
= onProgress
;
52 req
.onreadystatechange
= onReadyState
;
53 req
.open("GET", "resources/download-with-delay.php?iteration=" + iteration
+ "&delay=" + delay
, true);
58 // Number of chunks to send, delay between chunks
59 var strictTests
= [ 2, 80,
62 function compareStrict(count
, iteration
)
64 return count
== iteration
;
68 while (strictTests
.length
) {
69 var iteration
= strictTests
.shift();
70 var delay
= strictTests
.shift();
71 test(iteration
, delay
, compareStrict
, "strict test " + ++i
);
74 // Number of chunks to send, delay between chunks
75 var throttledTests
= [ 5, 20,
77 function compareThrottled(count
, iteration
)
79 return count
< iteration
;
83 while(throttledTests
.length
) {
84 var iteration
= throttledTests
.shift();
85 var delay
= throttledTests
.shift();
86 test(iteration
, delay
, compareThrottled
, "throttled test " + ++i
);
89 log("FAILED: exception raised: " + e
.message
);