diff options
author | Wafflespeanut <wafflespeanut@gmail.com> | 2015-06-05 21:57:19 +0530 |
---|---|---|
committer | Wafflespeanut <wafflespeanut@gmail.com> | 2015-06-05 21:57:19 +0530 |
commit | 1612f723a89a44dd12d833ec7cc97f2473df02c6 (patch) | |
tree | 600c8a4cb3aaa1e69ebf31f4a7914d41efe37c20 | |
parent | ad5846f2e14ac15aca9f561975ae9476d0f13244 (diff) | |
download | servo-1612f723a89a44dd12d833ec7cc97f2473df02c6.tar.gz servo-1612f723a89a44dd12d833ec7cc97f2473df02c6.zip |
Timestamp fix for issue #5690
-rw-r--r-- | components/script/dom/performance.rs | 2 | ||||
-rw-r--r-- | tests/wpt/include.ini | 2 | ||||
-rw-r--r-- | tests/wpt/metadata/hr-time/test_cross_frame_start.html.ini | 8 | ||||
-rw-r--r-- | tests/wpt/web-platform-tests/hr-time/basic.html | 12 |
4 files changed, 23 insertions, 1 deletions
diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index d9dd8472d74..dcb5dd290e9 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -51,7 +51,7 @@ impl<'a> PerformanceMethods for JSRef<'a, Performance> { // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html#dom-performance-now fn Now(self) -> DOMHighResTimeStamp { let navStart = self.timing.root().r().NavigationStartPrecise(); - let now = (time::precise_time_ns() as f64 - navStart) * 1000000 as f64; + let now = (time::precise_time_ns() as f64 - navStart) / 1000000 as f64; Finite::wrap(now) } } diff --git a/tests/wpt/include.ini b/tests/wpt/include.ini index 505beee1521..8171cccc885 100644 --- a/tests/wpt/include.ini +++ b/tests/wpt/include.ini @@ -103,3 +103,5 @@ skip: true skip: false [_mozilla] skip: false +[hr-time] + skip: false diff --git a/tests/wpt/metadata/hr-time/test_cross_frame_start.html.ini b/tests/wpt/metadata/hr-time/test_cross_frame_start.html.ini new file mode 100644 index 00000000000..78f8aef8a7d --- /dev/null +++ b/tests/wpt/metadata/hr-time/test_cross_frame_start.html.ini @@ -0,0 +1,8 @@ +[test_cross_frame_start.html] + type: testharness + [Child created at least 1 second after parent] + expected: FAIL + + [Child and parent time bases are correct] + expected: FAIL + diff --git a/tests/wpt/web-platform-tests/hr-time/basic.html b/tests/wpt/web-platform-tests/hr-time/basic.html index 959657e8281..aabdc55a706 100644 --- a/tests/wpt/web-platform-tests/hr-time/basic.html +++ b/tests/wpt/web-platform-tests/hr-time/basic.html @@ -24,6 +24,18 @@ test(function() { test(function() { assert_equals(typeof window.performance.now(), "number", "window.performance.now() returns a number"); }, "window.performance.now() returns a number", {assert: "The now method MUST return a DOMHighResTimeStamp"}); + +async_test(function() { + // Check whether the performance.now() method is close to Date() within 30ms (due to inaccuracies) + var initial_hrt = performance.now(); + var initial_date = Date.now(); + setTimeout(this.step_func(function() { + var final_hrt = performance.now(); + var final_date = Date.now(); + 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'); + this.done(); + }), 2000); +}, 'High resolution time has approximately the right relative magnitude'); </script> </head> <body> |