| <html> |
| |
| <head> |
| <script type="text/javascript" src="../../resources/js-test-pre.js"></script> |
| <script> |
| window.jsTestIsAsync = true; |
| |
| description("Runs 3 separate 1 second <script> blocks with a setTimeout schedule before each. The execution time of the setTimeout is when the HTML yielded to the event loop. The yields also represent painting opportunities. We want the parser to yield every 0.5 seconds once it has seen a script."); |
| |
| var startTime = new Date().getTime(); |
| var tolerance = 300; // 300 ms |
| |
| function expectElapsedTime(expectedTime) { |
| shouldBeCloseTo("new Date().getTime() - startTime", expectedTime, tolerance); |
| } |
| |
| function sleep(ms) { |
| var endTime = (new Date().getTime()) + ms; |
| while ((new Date().getTime()) < endTime); |
| } |
| </script> |
| </head> |
| |
| <body> |
| <p></p> |
| |
| <script> |
| setTimeout(function() { expectElapsedTime(1000) }, 0); |
| </script> |
| <script> |
| sleep(1000); |
| </script> |
| <script> |
| setTimeout(function() { expectElapsedTime(2000) }, 0); |
| </script> |
| <script> |
| sleep(1000); |
| </script> |
| <script> |
| setTimeout(function() { |
| expectElapsedTime(3000); |
| |
| finishJSTest(); |
| }, 0); |
| </script> |
| <script> |
| sleep(1000); |
| </script> |
| <script type="text/javascript" src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |
| |