Timestamp fix for issue #5690

This commit is contained in:
Wafflespeanut 2015-06-05 21:57:19 +05:30
parent ad5846f2e1
commit 1612f723a8
4 changed files with 23 additions and 1 deletions

View file

@ -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)
}
}

View file

@ -103,3 +103,5 @@ skip: true
skip: false
[_mozilla]
skip: false
[hr-time]
skip: false

View file

@ -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

View file

@ -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>