summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js
diff options
context:
space:
mode:
authorRussell Brenner <russellbrenner@google.com>2010-11-18 17:33:13 -0800
committerRussell Brenner <russellbrenner@google.com>2010-12-02 13:47:21 -0800
commit6b70adc33054f8aee8c54d0f460458a9df11b8a5 (patch)
tree103a13998c33944d6ab3b8318c509a037e639460 /LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js
parentbdf4ebc8e70b2d221b6ee7a65660918ecb1d33aa (diff)
downloadexternal_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.zip
external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.tar.gz
external_webkit-6b70adc33054f8aee8c54d0f460458a9df11b8a5.tar.bz2
Merge WebKit at r72274: Initial merge by git.
Change-Id: Ie51f0b4a16da82942bd516dce59cfb79ebbe25fb
Diffstat (limited to 'LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js')
-rw-r--r--LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js b/LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js
new file mode 100644
index 0000000..b51ca43
--- /dev/null
+++ b/LayoutTests/fast/dom/Geolocation/script-tests/timestamp.js
@@ -0,0 +1,34 @@
+description("Tests that Geoposition timestamps are well-formed (non-zero and in the same units as Date.getTime).");
+
+var mockLatitude = 51.478;
+var mockLongitude = -0.166;
+var mockAccuracy = 100.0;
+
+if (window.layoutTestController) {
+ layoutTestController.setGeolocationPermission(true);
+ layoutTestController.setMockGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy);
+}
+
+var now = new Date().getTime();
+shouldBeTrue('now != 0');
+var t = null;
+var then = null;
+
+function checkPosition(p) {
+ t = p.timestamp;
+ var d = new Date();
+ then = d.getTime();
+ shouldBeTrue('t != 0');
+ shouldBeTrue('then != 0');
+ shouldBeTrue('now - 1 <= t'); // Avoid rounding errors
+ if (now - 1 > t) {
+ debug(" now - 1 = " + (now-1));
+ debug(" t = " + t);
+ }
+ shouldBeTrue('t <= then + 1'); // Avoid rounding errors
+ finishJSTest();
+}
+
+navigator.geolocation.getCurrentPosition(checkPosition);
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;