mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
50e99a3e9c
--HG-- extra : rebase_source : 0d5696d909848a907fa02d390189e62366797725
37 lines
1.4 KiB
HTML
37 lines
1.4 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test for High Resolution Timer</title>
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<script>
|
|
ok(window.performance, "Performance object should exist.");
|
|
ok(typeof window.performance.now == 'function', "Performance object should have a 'now' method.");
|
|
var n = window.performance.now(), d = Date.now();
|
|
ok(n >= 0, "The value of now() should be equal to or greater than 0.");
|
|
ok(window.performance.now() >= n, "The value of now() should monotonically increase.");
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
var checks = 0;
|
|
function checkAfterTimeout() {
|
|
checks++;
|
|
var d2 = Date.now();
|
|
// Timeouts aren't extremely reliable and especially on Windows we are prone to fallback to
|
|
// millisecond timers, in which case this test might occasionally fail. This is a workaround:
|
|
if (navigator.platform.indexOf("Win") == 0 &&
|
|
window.performance.now() == n && d == d2 &&
|
|
checks < 5) {
|
|
setTimeout(checkAfterTimeout, 20);
|
|
return;
|
|
}
|
|
ok(window.performance.now() > n, "After a timeout, the value of now() should be strictly greater than before.");
|
|
SimpleTest.finish();
|
|
};
|
|
setTimeout(checkAfterTimeout, 20);
|
|
</script>
|
|
</body>
|
|
</html>
|