| Index: webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html
|
| ===================================================================
|
| --- webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html (revision 0)
|
| +++ webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html (revision 0)
|
| @@ -0,0 +1,67 @@
|
| +<html>
|
| +<body onload="test()">
|
| +<div id="result">
|
| +<p>
|
| +This tests that the chromium.Interval functionality works correctly.
|
| +</p>
|
| +</div>
|
| +<script>
|
| +if (window.layoutTestController) {
|
| + layoutTestController.dumpAsText();
|
| +}
|
| +
|
| +var resultDiv = document.getElementById("result");
|
| +
|
| +function check(name, passed) {
|
| + if (passed) {
|
| + resultDiv.innerHTML += "PASS - " + name + "<br>";
|
| + } else {
|
| + resultDiv.innerHTML += "FAIL - " + name + "<br>";
|
| + }
|
| +}
|
| +
|
| +// Spin loop for a short time
|
| +function pause(millisecs) {
|
| + var start = new Date();
|
| + while ((new Date() - start) < millisecs);
|
| +}
|
| +
|
| +
|
| +function test() {
|
| + var interval = new chromium.Interval();
|
| +
|
| + // Verify initialization.
|
| + check("initial zero", interval.microseconds() == 0);
|
| +
|
| + // Verify that starting the timer works.
|
| + interval.start();
|
| + pause(500);
|
| + check("start", interval.microseconds() >= 500000);
|
| +
|
| + // Verify that restarting the interval should reset the beginning time
|
| + interval.start();
|
| + pause(1);
|
| + check("restart", interval.microseconds() > 0 && interval.microseconds() < 500000);
|
| +
|
| + // Verify that calling stop() before start() has no effect.
|
| + var interval = new chromium.Interval();
|
| + interval.stop();
|
| + check("initial stop", interval.microseconds() == 0);
|
| +
|
| + // Verify a start/stop sequence.
|
| + interval.start();
|
| + pause(50);
|
| + interval.stop();
|
| + var ms = interval.microseconds();
|
| + check("stop", ms > 0 && ms < 1000000);
|
| +
|
| + // Verify that the timer is really stopped.
|
| + check("stopped", ms == interval.microseconds());
|
| +
|
| + // Verify that re-stopping the timer works.
|
| + interval.stop();
|
| + check("re-stopped", interval.microseconds() > ms);
|
| +}
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|