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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-stops-watches.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/permission-denied-stops-watches.js
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-stops-watches.js b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-stops-watches.js
index d4c44a347c927bde7ac5389f88d76cc8c78b79e2..8e2feb7233f61b289a90abed478d657c52423851 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-stops-watches.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/permission-denied-stops-watches.js
@@ -1,36 +1,37 @@
description("Tests that when Geolocation permission is denied, watches are stopped, as well as one-shots.");
-if (!window.testRunner || !window.internals)
- debug('This test can not run without testRunner or internals');
-
-internals.setGeolocationClientMock(document);
-
-// Configure the mock Geolocation service to report a position to cause permission
-// to be requested, then deny it.
-internals.setGeolocationPermission(document, false);
-internals.setGeolocationPosition(document, 51.478, -0.166, 100.0);
+if (!window.testRunner || !window.mojo)
+ debug('This test can not run without testRunner or mojo');
var error;
-var errorCallbackInvoked = false;
-navigator.geolocation.watchPosition(function(p) {
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
-}, function(e) {
- if (errorCallbackInvoked) {
- testFailed('Error callback invoked unexpectedly : ' + error.message);
- finishJSTest();
- }
- errorCallbackInvoked = true;
- error = e;
- shouldBe('error.code', 'error.PERMISSION_DENIED');
- shouldBe('error.message', '"User denied Geolocation"');
+geolocationServiceMock.then(mock => {
- // Update the mock Geolocation service to report a new position, then
- // yield to allow a chance for the success callback to be invoked.
- internals.setGeolocationPosition(document, 55.478, -0.166, 100);
- window.setTimeout(finishJSTest, 0);
-});
+ // Configure the mock Geolocation service to report a position to cause permission
+ // to be requested, then deny it.
+ mock.setGeolocationPermission(false);
+ mock.setGeolocationPosition(51.478, -0.166, 100.0);
+ var errorCallbackInvoked = false;
+ navigator.geolocation.watchPosition(function(p) {
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(e) {
+ if (errorCallbackInvoked) {
+ testFailed('Error callback invoked unexpectedly : ' + error.message);
+ finishJSTest();
+ }
+ errorCallbackInvoked = true;
+
+ error = e;
+ shouldBe('error.code', 'error.PERMISSION_DENIED');
+ shouldBe('error.message', '"User denied Geolocation"');
+
+ // Update the mock Geolocation service to report a new position, then
+ // yield to allow a chance for the success callback to be invoked.
+ mock.setGeolocationPosition(55.478, -0.166, 100);
+ window.setTimeout(finishJSTest, 0);
+ });
+});
window.jsTestIsAsync = true;

Powered by Google App Engine
This is Rietveld 408576698