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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-allowed-for-multiple-requests.js

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/script-tests/delayed-permission-allowed-for-multiple-requests.js
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-allowed-for-multiple-requests.js b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-allowed-for-multiple-requests.js
index e19e79c11b8e5206d5c09120922ad25a4a0231ee..a37a6e8165112a3e579a48696edcd0d23e2dc1a7 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-allowed-for-multiple-requests.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-allowed-for-multiple-requests.js
@@ -1,54 +1,55 @@
description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is allowed.");
-if (!window.testRunner || !window.internals)
- debug('This test can not run without testRunner or internals');
+if (!window.testRunner || !window.mojo)
+ debug('This test can not run without testRunner or mojo');
-internals.setGeolocationClientMock(document);
-internals.setGeolocationPosition(document, 51.478, -0.166, 100);
+geolocationServiceMock.then(mock => {
+ mock.setGeolocationPosition(51.478, -0.166, 100);
-var permissionSet = false;
+ var permissionSet = false;
-function allowPermission() {
- permissionSet = true;
- internals.setGeolocationPermission(document, true);
-}
+ function allowPermission() {
+ permissionSet = true;
+ mock.setGeolocationPermission(true);
+ }
-var watchCallbackInvoked = false;
-var oneShotCallbackInvoked = false;
+ var watchCallbackInvoked = false;
+ var oneShotCallbackInvoked = false;
+
+ navigator.geolocation.watchPosition(function() {
+ if (permissionSet) {
+ testPassed('Success callback invoked');
+ watchCallbackInvoked = true;
+ maybeFinishTest();
+ return;
+ }
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(err) {
+ testFailed('Error callback invoked unexpectedly');
+ finishJSTest();
+ });
+
+ navigator.geolocation.getCurrentPosition(function() {
+ if (permissionSet) {
+ testPassed('Success callback invoked');
+ oneShotCallbackInvoked = true;
+ maybeFinishTest();
+ return;
+ }
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(err) {
+ testFailed('Error callback invoked unexpectedly');
+ finishJSTest();
+ });
-navigator.geolocation.watchPosition(function() {
- if (permissionSet) {
- testPassed('Success callback invoked');
- watchCallbackInvoked = true;
- maybeFinishTest();
- return;
- }
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
-}, function(err) {
- testFailed('Error callback invoked unexpectedly');
- finishJSTest();
-});
+ window.setTimeout(allowPermission, 100);
-navigator.geolocation.getCurrentPosition(function() {
- if (permissionSet) {
- testPassed('Success callback invoked');
- oneShotCallbackInvoked = true;
- maybeFinishTest();
- return;
+ function maybeFinishTest() {
+ if (watchCallbackInvoked && oneShotCallbackInvoked)
+ finishJSTest();
}
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
-}, function(err) {
- testFailed('Error callback invoked unexpectedly');
- finishJSTest();
});
-window.setTimeout(allowPermission, 100);
-
-function maybeFinishTest() {
- if (watchCallbackInvoked && oneShotCallbackInvoked)
- finishJSTest();
-}
-
window.jsTestIsAsync = true;

Powered by Google App Engine
This is Rietveld 408576698