diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-06-05 11:46:48 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-06-05 11:46:48 -0500 |
commit | 458a5324618b8e58565d686fdea3363a31e11973 (patch) | |
tree | c65fbae75f28bb7067663b2d7b7066edde0c1855 | |
parent | 0a93ed26e85319fe217a706be52cdb9e4060120f (diff) | |
parent | 1612f723a89a44dd12d833ec7cc97f2473df02c6 (diff) | |
download | servo-458a5324618b8e58565d686fdea3363a31e11973.tar.gz servo-458a5324618b8e58565d686fdea3363a31e11973.zip |
Auto merge of #6292 - Wafflespeanut:timestamp, r=jdm
Changed the operator and updated the wpt-test for `hr-time`.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6292)
<!-- Reviewable:end -->
-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> |