Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html

Issue 1948033003: Convert most geolocation layout tests to use a JS mock implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-disconnect
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html
index cfda7af88308af74ce04e88c75f56e7baa1f2212..073a3748d798134038af5afd9d917b65876a0a98 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/coordinates-interface-attributes.html
@@ -2,20 +2,19 @@
<html>
<head>
<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/mojo-helpers.js"></script>
+<script src="resources/geolocation-mock.js"></script>
</head>
<body>
<script>
description("Test the attribute handling of the Coordinates interface");
window.jsTestIsAsync = true;
-if (!window.testRunner || !window.internals)
- debug('This test can not run without testRunner or internals');
-
-internals.setGeolocationClientMock(document);
-internals.setGeolocationPermission(document, true);
+if (!window.testRunner || !window.mojo)
+ debug('This test can not run without testRunner or mojo');
// Format: [Input], [Expected]
-// Input: latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed.
+// Input: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed.
// Expected: latitude, longitude, accuracy, altitude, altitudeAccuracy, heading, speed.
var testSet = [
[[1, 2, 3], [1, 2, 3, null, null, null, null]],
@@ -28,40 +27,44 @@ var testSet = [
var currentTestIndex = -1;
var globalCoordinates = null;
-function runNextTest()
-{
- ++currentTestIndex;
- internals.setGeolocationPosition.apply(internals, [document].concat(testSet[currentTestIndex][0]));
-}
+geolocationServiceMock.then(mock => {
+ mock.setGeolocationPermission(true);
+
+ function runNextTest()
+ {
+ ++currentTestIndex;
+ mock.setGeolocationPosition(...testSet[currentTestIndex][0]);
+ }
-function verifyResults()
-{
- shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]');
- shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]');
- shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]');
- shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]');
- shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex][1][4]');
- shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]');
- shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]');
- debug('');
-}
+ function verifyResults()
+ {
+ shouldBe('globalCoordinates.latitude', 'testSet[currentTestIndex][1][0]');
+ shouldBe('globalCoordinates.longitude', 'testSet[currentTestIndex][1][1]');
+ shouldBe('globalCoordinates.accuracy', 'testSet[currentTestIndex][1][2]');
+ shouldBe('globalCoordinates.altitude', 'testSet[currentTestIndex][1][3]');
+ shouldBe('globalCoordinates.altitudeAccuracy', 'testSet[currentTestIndex][1][4]');
+ shouldBe('globalCoordinates.heading', 'testSet[currentTestIndex][1][5]');
+ shouldBe('globalCoordinates.speed', 'testSet[currentTestIndex][1][6]');
+ debug('');
+ }
-var watchId = navigator.geolocation.watchPosition(function(position) {
- globalCoordinates = position.coords;
- verifyResults();
+ var watchId = navigator.geolocation.watchPosition(function(position) {
+ globalCoordinates = position.coords;
+ verifyResults();
- if (currentTestIndex + 1 === testSet.length) {
+ if (currentTestIndex + 1 === testSet.length) {
+ finishJSTest();
+ return;
+ }
+ runNextTest();
+ }, function(e) {
+ debug("Error!: the error callback was called.");
finishJSTest();
- return;
- }
+ });
+
runNextTest();
-}, function(e) {
- debug("Error!: the error callback was called.");
- finishJSTest();
});
-runNextTest();
-
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698