Commit b0aed69d authored by Jungshik Shin's avatar Jungshik Shin Committed by Commit Bot

Fix geolocation mock to calculate the correct epoch delta

When calculating the delta between Windows Epoch and Unix Epoch in
geolocation mock, Date constructor (that interpretes
parameters in terms of *local* time) was used for the Windows
epoch (1601-01-01) and Unix epoch (1970-01-01) assuming that the
timezone offset didn't change between 1601 and 1970. That assumption
does not hold any more when ICU is used to take into account
the historical timezone offset changes. As a result,
geolocation-api/timestamp.html test failed when the fix for v8:3547
was landed. (https://chromium-review.googlesource.com/c/v8/v8/+/572148 ).

This CL uses Date.UTC() to avoid the issue and is a pre-requisite
to relanding the above v8 CL.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Bug: v8:3547, chromium:417640, v8:5714
Test: layout test: geolocation-api/*
Change-Id: Iaf718c2818fa9a5f5c64136a38579a1fcafe7805
Reviewed-on: https://chromium-review.googlesource.com/994343Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548095}
parent 015681f1
...@@ -92,10 +92,10 @@ class GeolocationMock { ...@@ -92,10 +92,10 @@ class GeolocationMock {
// device.mojom.Geoposition represents the value of microseconds since the // device.mojom.Geoposition represents the value of microseconds since the
// Windows FILETIME epoch (1601-01-01 00:00:00 UTC). So add the delta when // Windows FILETIME epoch (1601-01-01 00:00:00 UTC). So add the delta when
// sets the |internalValue|. See more info in //base/time/time.h. // sets the |internalValue|. See more info in //base/time/time.h.
const windowsEpoch = new Date(1601,1,1,0,0,0,0); const windowsEpoch = Date.UTC(1601,0,1,0,0,0,0);
const unixEpoch = new Date(1970,1,1,0,0,0,0); const unixEpoch = Date.UTC(1970,0,1,0,0,0,0);
// |epochDeltaInMs| equals to base::Time::kTimeTToMicrosecondsOffset. // |epochDeltaInMs| equals to base::Time::kTimeTToMicrosecondsOffset.
const epochDeltaInMs = unixEpoch.getTime() - windowsEpoch.getTime(); const epochDeltaInMs = unixEpoch - windowsEpoch;
this.geoposition_.timestamp.internalValue = this.geoposition_.timestamp.internalValue =
(new Date().getTime() + epochDeltaInMs) * 1000; (new Date().getTime() + epochDeltaInMs) * 1000;
......
...@@ -37,6 +37,10 @@ function checkPosition(p) { ...@@ -37,6 +37,10 @@ function checkPosition(p) {
debug(" t = " + t); debug(" t = " + t);
} }
shouldBeTrue('t <= then + 1'); // Avoid rounding errors shouldBeTrue('t <= then + 1'); // Avoid rounding errors
if (t > then + 1) {
debug(" t = " + t);
debug(" then + 1 = " + (then + 1));
}
finishJSTest(); finishJSTest();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment