| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <meta charset="utf-8" /> | 4 <meta charset="utf-8" /> |
| 5 <title>window.performance.now exists</title> | 5 <title>window.performance.now exists</title> |
| 6 <link rel="author" title="W3C" href="http://www.w3.org/" /> | 6 <link rel="author" title="W3C" href="http://www.w3.org/" /> |
| 7 <link rel="help" href="http://www.w3.org/TR/hr-time/#sec-extenstions-performance
-interface"/> | 7 <link rel="help" href="http://www.w3.org/TR/hr-time/#sec-extenstions-performance
-interface"/> |
| 8 <script src="/w3c/resources/testharness.js"></script> | 8 <script src="../../../resources/testharness.js"></script> |
| 9 <script src="/w3c/resources/testharnessreport.js"></script> | 9 <script src="../../../resources/testharnessreport.js"></script> |
| 10 <link rel="stylesheet" href="/w3c/resources/testharness.css" /> | 10 <link rel="stylesheet" href="../../../resources/testharness.css" /> |
| 11 <script> | 11 <script> |
| 12 test(function() { | 12 test(function() { |
| 13 assert_equals(typeof window.performance, "object"); | 13 assert_equals(typeof window.performance, "object"); |
| 14 }, "window.performance is defined", {assert: "The window.performance attribute p
rovides a hosting area for performance related attributes."}); | 14 }, "window.performance is defined", {assert: "The window.performance attribute p
rovides a hosting area for performance related attributes."}); |
| 15 | 15 |
| 16 test(function() { | 16 test(function() { |
| 17 assert_not_equals(window.performance.now, undefined, 'window.performance.now i
s defined'); | 17 assert_not_equals(window.performance.now, undefined, 'window.performance.now i
s defined'); |
| 18 }, "High Resolution Time extension to the Performance interface", {assert: "wind
ow.performance.now exists"}); | 18 }, "High Resolution Time extension to the Performance interface", {assert: "wind
ow.performance.now exists"}); |
| 19 | 19 |
| 20 test(function() { | 20 test(function() { |
| 21 assert_equals(typeof window.performance.now, "function", "window.performance.n
ow is a function"); | 21 assert_equals(typeof window.performance.now, "function", "window.performance.n
ow is a function"); |
| 22 }, "window.performance.now() function", {assert: "window.performance.now is a fu
nction"}); | 22 }, "window.performance.now() function", {assert: "window.performance.now is a fu
nction"}); |
| 23 | 23 |
| 24 test(function() { | 24 test(function() { |
| 25 assert_equals(typeof window.performance.now(), "number", "window.performance.n
ow() returns a number"); | 25 assert_equals(typeof window.performance.now(), "number", "window.performance.n
ow() returns a number"); |
| 26 }, "window.performance.now() returns a number", {assert: "The now method MUST re
turn a DOMHighResTimeStamp"}); | 26 }, "window.performance.now() returns a number", {assert: "The now method MUST re
turn a DOMHighResTimeStamp"}); |
| 27 |
| 28 async_test(function() { |
| 29 // Check whether the performance.now() method is close to Date() within 30ms (
due to inaccuracies) |
| 30 var initial_hrt = performance.now(); |
| 31 var initial_date = Date.now(); |
| 32 setTimeout(this.step_func(function() { |
| 33 var final_hrt = performance.now(); |
| 34 var final_date = Date.now(); |
| 35 assert_approx_equals(final_hrt - initial_hrt, final_date - initial_date, 30,
'High resolution time value increased by approximately the same amount as time
from date object'); |
| 36 this.done(); |
| 37 }), 2000); |
| 38 }, 'High resolution time has approximately the right relative magnitude'); |
| 27 </script> | 39 </script> |
| 28 </head> | 40 </head> |
| 29 <body> | 41 <body> |
| 30 <h1>Description</h1> | 42 <h1>Description</h1> |
| 31 <p>This test validates that window.performance.now() exist and is a function.</p
> | 43 <p>This test validates that window.performance.now() exist and is a function.</p
> |
| 32 | 44 |
| 33 <div id="log"></div> | 45 <div id="log"></div> |
| 34 | 46 |
| 35 </body> | 47 </body> |
| 36 </html> | 48 </html> |
| OLD | NEW |