Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-50ms-download-dispatch.html
blob83877c8f6127f1e5e1e706b30bbfb5e140ed3a02
1 <html>
2 <head>
3 <title> Test case for bug 18655 </title>
4 </head>
5 <body>
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>
11 <p id="console"></p>
13 <script type="text/javascript">
14 if (window.testRunner) {
15 testRunner.dumpAsText();
16 testRunner.waitUntilDone();
19 function log(message)
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)
29 var count = 0;
30 var sawReadyStateDONE = false;
31 function onProgress(e) {
32 ++count;
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);
42 ++testsCompleted;
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);
54 req.send(null);
57 try {
58 // Number of chunks to send, delay between chunks
59 var strictTests = [ 2, 80,
60 1, 1000,
61 2, 50 ];
62 function compareStrict(count, iteration)
64 return count == iteration;
67 var i = 0;
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,
76 6, 30 ];
77 function compareThrottled(count, iteration)
79 return count < iteration;
82 i = 0;
83 while(throttledTests.length) {
84 var iteration = throttledTests.shift();
85 var delay = throttledTests.shift();
86 test(iteration, delay, compareThrottled, "throttled test " + ++i);
88 } catch(e) {
89 log("FAILED: exception raised: " + e.message);
91 </script>
92 </body>
93 </html>