diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 02:37:29 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 02:37:29 +0000 |
commit | c5a14d3864b3d648ebde099cd959cbba9203627f (patch) | |
tree | 602a4d54017c3f3a7559a58ede838f126466002a /webkit/data/layout_tests | |
parent | 4a4f066c6eea2638f5ff24bfee54b9e68e7ba174 (diff) | |
download | chromium_src-c5a14d3864b3d648ebde099cd959cbba9203627f.zip chromium_src-c5a14d3864b3d648ebde099cd959cbba9203627f.tar.gz chromium_src-c5a14d3864b3d648ebde099cd959cbba9203627f.tar.bz2 |
Changes to the interval timer:
- move into the window.chromium namespace.
- hide the native HiResTime() function.
- fixup the stop() mechanics.
- Added a layout test.
Review URL: http://codereview.chromium.org/28201
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/data/layout_tests')
-rw-r--r-- | webkit/data/layout_tests/chrome/fast/dom/extensions/interval-expected.txt | 9 | ||||
-rw-r--r-- | webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html | 67 |
2 files changed, 76 insertions, 0 deletions
diff --git a/webkit/data/layout_tests/chrome/fast/dom/extensions/interval-expected.txt b/webkit/data/layout_tests/chrome/fast/dom/extensions/interval-expected.txt new file mode 100644 index 0000000..f69fc7f --- /dev/null +++ b/webkit/data/layout_tests/chrome/fast/dom/extensions/interval-expected.txt @@ -0,0 +1,9 @@ +This tests that the chromium.Interval functionality works correctly. + +PASS - initial zero +PASS - start +PASS - restart +PASS - initial stop +PASS - stop +PASS - stopped +PASS - re-stopped diff --git a/webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html b/webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html new file mode 100644 index 0000000..1ff02bc --- /dev/null +++ b/webkit/data/layout_tests/chrome/fast/dom/extensions/interval.html @@ -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> |