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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-denied-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-denied-for-multiple-requests.js
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-denied-for-multiple-requests.js b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-denied-for-multiple-requests.js
index a2b0cbde54af831ee25d8aabb4da58ce15477ab7..63ec68946a08a3057e558c88828bc3424be8a23b 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-denied-for-multiple-requests.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/delayed-permission-denied-for-multiple-requests.js
@@ -1,58 +1,60 @@
description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is denied.");
-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);
-
-var permissionSet = false;
+var error;
-function denyPermission() {
- permissionSet = true;
- internals.setGeolocationPermission(document, false);
-}
+geolocationServiceMock.then(mock => {
+ mock.setGeolocationPosition(51.478, -0.166, 100);
-var watchCallbackInvoked = false;
-var oneShotCallbackInvoked = false;
-var error;
+ var permissionSet = false;
-navigator.geolocation.watchPosition(function() {
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
-}, function(e) {
- if (permissionSet) {
- error = e;
- shouldBe('error.code', 'error.PERMISSION_DENIED');
- shouldBe('error.message', '"User denied Geolocation"');
- watchCallbackInvoked = true;
- maybeFinishTest();
- return;
+ function denyPermission() {
+ permissionSet = true;
+ mock.setGeolocationPermission(false);
}
- testFailed('Error callback invoked unexpectedly');
- finishJSTest();
-});
-navigator.geolocation.getCurrentPosition(function() {
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
-}, function(e) {
- if (permissionSet) {
- error = e;
- shouldBe('error.code', 'error.PERMISSION_DENIED');
- shouldBe('error.message', '"User denied Geolocation"');
- oneShotCallbackInvoked = true;
- maybeFinishTest();
- return;
- }
- testFailed('Error callback invoked unexpectedly');
- finishJSTest();
-});
-window.setTimeout(denyPermission, 100);
+ var watchCallbackInvoked = false;
+ var oneShotCallbackInvoked = false;
-function maybeFinishTest() {
- if (watchCallbackInvoked && oneShotCallbackInvoked)
+ navigator.geolocation.watchPosition(function() {
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(e) {
+ if (permissionSet) {
+ error = e;
+ shouldBe('error.code', 'error.PERMISSION_DENIED');
+ shouldBe('error.message', '"User denied Geolocation"');
+ watchCallbackInvoked = true;
+ maybeFinishTest();
+ return;
+ }
+ testFailed('Error callback invoked unexpectedly');
finishJSTest();
-}
+ });
+
+ navigator.geolocation.getCurrentPosition(function() {
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(e) {
+ if (permissionSet) {
+ error = e;
+ shouldBe('error.code', 'error.PERMISSION_DENIED');
+ shouldBe('error.message', '"User denied Geolocation"');
+ oneShotCallbackInvoked = true;
+ maybeFinishTest();
+ return;
+ }
+ testFailed('Error callback invoked unexpectedly');
+ finishJSTest();
+ });
+ window.setTimeout(denyPermission, 100);
+
+ function maybeFinishTest() {
+ if (watchCallbackInvoked && oneShotCallbackInvoked)
+ finishJSTest();
+ }
+});
window.jsTestIsAsync = true;

Powered by Google App Engine
This is Rietveld 408576698