summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js')
-rw-r--r--LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js b/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js
new file mode 100644
index 0000000..e3361de
--- /dev/null
+++ b/LayoutTests/fast/dom/Geolocation/script-tests/reentrant-error.js
@@ -0,0 +1,46 @@
+description("Tests that reentrant calls to Geolocation methods from the error callback are OK.");
+
+var mockCode = 0;
+var mockMessage = 'test';
+
+window.layoutTestController.setMockGeolocationError(mockCode, mockMessage);
+
+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', 'mockCode');
+ shouldBe('error.message', 'mockMessage');
+ debug('');
+ continueTest();
+});
+
+function continueTest() {
+ mockCode += 1;
+ mockMessage += ' repeat';
+
+ window.layoutTestController.setMockGeolocationError(mockCode, mockMessage);
+
+ navigator.geolocation.getCurrentPosition(function(p) {
+ testFailed('Success callback invoked unexpectedly');
+ finishJSTest();
+ }, function(e) {
+ error = e;
+ shouldBe('error.code', 'mockCode');
+ shouldBe('error.message', 'mockMessage');
+ finishJSTest();
+ });
+}
+window.layoutTestController.waitUntilDone();
+
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;