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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.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/reentrant-error.js
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js
index e1a392936159e21c3f2565f1bb642cae545fa808..cfc8a64c147081e363ab9f24b856fd507c292f5c 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js
+++ b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js
@@ -2,46 +2,48 @@ description("Tests that reentrant calls to Geolocation methods from the error ca
var mockMessage = 'test';
-if (!window.testRunner || !window.internals)
- debug('This test can not run without testRunner or internals');
-
-internals.setGeolocationClientMock(document);
-internals.setGeolocationPermission(document, true);
-internals.setGeolocationPositionUnavailableError(document, mockMessage);
+if (!window.testRunner || !window.mojo)
+ debug('This test can not run without testRunner or mojo');
var error;
-var errorCallbackInvoked = false;
-navigator.geolocation.getCurrentPosition(function(p) {
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
-}, function(e) {
- if (errorCallbackInvoked) {
- testFailed('Error callback invoked unexpectedly');
- finishJSTest();
- }
- errorCallbackInvoked = true;
- error = e;
- shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
- shouldBe('error.message', 'mockMessage');
- debug('');
- continueTest();
-});
-
-function continueTest() {
- mockMessage += ' repeat';
-
- internals.setGeolocationPositionUnavailableError(document, mockMessage);
+geolocationServiceMock.then(mock => {
+ mock.setGeolocationPermission(true);
+ mock.setGeolocationPositionUnavailableError(mockMessage);
+ var errorCallbackInvoked = false;
navigator.geolocation.getCurrentPosition(function(p) {
testFailed('Success callback invoked unexpectedly');
finishJSTest();
}, function(e) {
+ if (errorCallbackInvoked) {
+ testFailed('Error callback invoked unexpectedly');
+ finishJSTest();
+ }
+ errorCallbackInvoked = true;
+
error = e;
shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
shouldBe('error.message', 'mockMessage');
- finishJSTest();
+ debug('');
+ continueTest();
});
-}
+
+ function continueTest() {
+ mockMessage += ' repeat';
+
+ mock.setGeolocationPositionUnavailableError(mockMessage);
+
+ navigator.geolocation.getCurrentPosition(function(p) {
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(e) {
+ error = e;
+ shouldBe('error.code', 'error.POSITION_UNAVAILABLE');
+ shouldBe('error.message', 'mockMessage');
+ finishJSTest();
+ });
+ }
+});
window.jsTestIsAsync = true;

Powered by Google App Engine
This is Rietveld 408576698