diff options
Diffstat (limited to 'LayoutTests/fast/dom/Geolocation')
53 files changed, 1211 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/Geolocation/argument-types-expected.txt b/LayoutTests/fast/dom/Geolocation/argument-types-expected.txt new file mode 100644 index 0000000..0c80a85 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/argument-types-expected.txt @@ -0,0 +1,82 @@ +Tests the acceptable types for arguments to Geolocation methods. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS navigator.geolocation.getCurrentPosition() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition({}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(Math.abs) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition("string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, null) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, "string") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, null) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, objectThrowingException) threw exception Error: enableHighAccuracy getter exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, emptyFunction) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string") did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:null}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:{}}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:objectThrowingException}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:emptyFunction}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:null}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:{}}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:objectThrowingException}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:emptyFunction}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:null}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:{}}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:objectThrowingException}) threw exception Error: valueOf threw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:emptyFunction}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:null}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:{}}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:objectThrowingException}) threw exception Error: valueOf threw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:emptyFunction}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity}) did not throw exception. +PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"}) did not throw exception. +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/argument-types.html b/LayoutTests/fast/dom/Geolocation/argument-types.html new file mode 100644 index 0000000..f6b0ad4 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/argument-types.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/argument-types.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/callback-exception-expected.txt b/LayoutTests/fast/dom/Geolocation/callback-exception-expected.txt new file mode 100644 index 0000000..ca77390 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/callback-exception-expected.txt @@ -0,0 +1,13 @@ +CONSOLE MESSAGE: line 22: Error: Exception in success callback +Tests that when an exception is thrown in the success callback, the error callback is not invoked. Note that this test throws an exception which is not caught. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/callback-exception.html b/LayoutTests/fast/dom/Geolocation/callback-exception.html new file mode 100644 index 0000000..e5f9a7c --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/callback-exception.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/callback-exception.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/enabled-expected.txt b/LayoutTests/fast/dom/Geolocation/enabled-expected.txt new file mode 100644 index 0000000..c197c5a --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/enabled-expected.txt @@ -0,0 +1,13 @@ +Tests that the navigator.geolocation object is present. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS typeof navigator.geolocation == 'object' is true +PASS hasGeolocationProperty() is true +PASS 'geolocation' in navigator is true +PASS navigator.hasOwnProperty('geolocation') is true +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/enabled.html b/LayoutTests/fast/dom/Geolocation/enabled.html new file mode 100644 index 0000000..bd6381a --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/enabled.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/enabled.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/error-expected.txt b/LayoutTests/fast/dom/Geolocation/error-expected.txt new file mode 100644 index 0000000..ea5d7d8 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/error-expected.txt @@ -0,0 +1,15 @@ +Tests Geolocation error callback using the mock service. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is mockCode +PASS error.message is mockMessage +PASS error.UNKNOWN_ERROR is undefined +PASS error.PERMISSION_DENIED is 1 +PASS error.POSITION_UNAVAILABLE is 2 +PASS error.TIMEOUT is 3 + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/error.html b/LayoutTests/fast/dom/Geolocation/error.html new file mode 100644 index 0000000..19718c7 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/error.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/error.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-already-clear-watch-expected.txt b/LayoutTests/fast/dom/Geolocation/permission-denied-already-clear-watch-expected.txt new file mode 100644 index 0000000..63195b2 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-already-clear-watch-expected.txt @@ -0,0 +1,14 @@ +Tests that when Geolocation permission has been denied prior to a call to watchPosition, and the watch is cleared in the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-already-clear-watch.html b/LayoutTests/fast/dom/Geolocation/permission-denied-already-clear-watch.html new file mode 100644 index 0000000..2db2637 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-already-clear-watch.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/permission-denied-already-clear-watch.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-already-error-expected.txt b/LayoutTests/fast/dom/Geolocation/permission-denied-already-error-expected.txt new file mode 100644 index 0000000..e013242 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-already-error-expected.txt @@ -0,0 +1,14 @@ +Tests that when Geolocation permission has been denied prior to a call to a Geolocation method, the error callback is invoked with code PERMISSION_DENIED, when the Geolocation service encounters an error. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-already-error.html b/LayoutTests/fast/dom/Geolocation/permission-denied-already-error.html new file mode 100644 index 0000000..dc166c9 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-already-error.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/permission-denied-already-error.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-already-success-expected.txt b/LayoutTests/fast/dom/Geolocation/permission-denied-already-success-expected.txt new file mode 100644 index 0000000..f617a5f --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-already-success-expected.txt @@ -0,0 +1,14 @@ +Tests that when Geolocation permission has been denied prior to a call to a Geolocation method, the error callback is invoked with code PERMISSION_DENIED, when the Geolocation service has a good position. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-already-success.html b/LayoutTests/fast/dom/Geolocation/permission-denied-already-success.html new file mode 100644 index 0000000..4b086a7 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-already-success.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/permission-denied-already-success.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-expected.txt b/LayoutTests/fast/dom/Geolocation/permission-denied-expected.txt new file mode 100644 index 0000000..680aa63 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-expected.txt @@ -0,0 +1,11 @@ +Tests Geolocation when permission is denied, using the mock service. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-stops-watches-expected.txt b/LayoutTests/fast/dom/Geolocation/permission-denied-stops-watches-expected.txt new file mode 100644 index 0000000..d8f50ca --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-stops-watches-expected.txt @@ -0,0 +1,11 @@ +Tests that when Geolocation permission is denied, watches are stopped, as well as one-shots. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.PERMISSION_DENIED +PASS error.message is "User denied Geolocation" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied-stops-watches.html b/LayoutTests/fast/dom/Geolocation/permission-denied-stops-watches.html new file mode 100644 index 0000000..92f3a48 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied-stops-watches.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/permission-denied-stops-watches.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/permission-denied.html b/LayoutTests/fast/dom/Geolocation/permission-denied.html new file mode 100644 index 0000000..6012079 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/permission-denied.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/permission-denied.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/position-string-expected.txt b/LayoutTests/fast/dom/Geolocation/position-string-expected.txt new file mode 100644 index 0000000..b042998 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/position-string-expected.txt @@ -0,0 +1,14 @@ +Tests formatting of position.toString(). + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy +PASS position.toString() is "[object Geoposition]" +PASS position.coords.toString() is "[object Coordinates]" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/position-string.html b/LayoutTests/fast/dom/Geolocation/position-string.html new file mode 100644 index 0000000..e75a4f5 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/position-string.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/position-string.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/reentrant-error-expected.txt b/LayoutTests/fast/dom/Geolocation/reentrant-error-expected.txt new file mode 100644 index 0000000..7420919 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/reentrant-error-expected.txt @@ -0,0 +1,14 @@ +Tests that reentrant calls to Geolocation methods from the error callback are OK. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is mockCode +PASS error.message is mockMessage + +PASS error.code is mockCode +PASS error.message is mockMessage + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/reentrant-error.html b/LayoutTests/fast/dom/Geolocation/reentrant-error.html new file mode 100644 index 0000000..f3300af --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/reentrant-error.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/reentrant-error.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/reentrant-success-expected.txt b/LayoutTests/fast/dom/Geolocation/reentrant-success-expected.txt new file mode 100644 index 0000000..ad63fa3 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/reentrant-success-expected.txt @@ -0,0 +1,16 @@ +Tests that reentrant calls to Geolocation methods from the success callback are OK. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/reentrant-success.html b/LayoutTests/fast/dom/Geolocation/reentrant-success.html new file mode 100644 index 0000000..f09cf28 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/reentrant-success.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/reentrant-success.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/resources/TEMPLATE.html b/LayoutTests/fast/dom/Geolocation/resources/TEMPLATE.html new file mode 100644 index 0000000..fcb8be1 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/TEMPLATE.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="YOUR_JS_FILE_HERE"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/resources/argument-types.js b/LayoutTests/fast/dom/Geolocation/resources/argument-types.js new file mode 100644 index 0000000..956e3d6 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/argument-types.js @@ -0,0 +1,119 @@ +description("Tests the acceptable types for arguments to Geolocation methods."); + +function shouldNotThrow(expression) +{ + try { + eval(expression); + testPassed(expression + " did not throw exception."); + } catch(e) { + testFailed(expression + " should not throw exception. Threw exception " + e); + } +} + +function test(expression, expressionShouldThrow, expectedException) { + if (expressionShouldThrow) { + if (expectedException) + shouldThrow(expression, '(function() { return "' + expectedException + '"; })();'); + else + shouldThrow(expression, '(function() { return "Error: TYPE_MISMATCH_ERR: DOM Exception 17"; })();'); + } else { + shouldNotThrow(expression); + } +} + +var emptyFunction = function() {}; + +function ObjectThrowingException() {}; +ObjectThrowingException.prototype.valueOf = function() { + throw new Error('valueOf threw exception'); +} +ObjectThrowingException.prototype.__defineGetter__("enableHighAccuracy", function() { + throw new Error('enableHighAccuracy getter exception'); +}); +var objectThrowingException = new ObjectThrowingException(); + + +test('navigator.geolocation.getCurrentPosition()', true); + +test('navigator.geolocation.getCurrentPosition(undefined)', true); +test('navigator.geolocation.getCurrentPosition(null)', true); +test('navigator.geolocation.getCurrentPosition({})', true); +test('navigator.geolocation.getCurrentPosition(objectThrowingException)', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction)', false); +test('navigator.geolocation.getCurrentPosition(Math.abs)', false); +test('navigator.geolocation.getCurrentPosition(true)', true); +test('navigator.geolocation.getCurrentPosition(42)', true); +test('navigator.geolocation.getCurrentPosition(Infinity)', true); +test('navigator.geolocation.getCurrentPosition(-Infinity)', true); +test('navigator.geolocation.getCurrentPosition("string")', true); + +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, {})', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException)', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction, emptyFunction)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, Math.abs)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, true)', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction, 42)', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction, Infinity)', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction, -Infinity)', true); +test('navigator.geolocation.getCurrentPosition(emptyFunction, "string")', true); + +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, undefined)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, null)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, objectThrowingException)', true, 'Error: enableHighAccuracy getter exception'); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, emptyFunction)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, true)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, 42)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, Infinity)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, -Infinity)', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, "string")', false); + +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:undefined})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:null})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:{}})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:objectThrowingException})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:emptyFunction})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:true})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:42})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:-Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {dummyProperty:"string"})', false); + +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:undefined})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:null})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:{}})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:objectThrowingException})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:emptyFunction})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:true})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:42})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:-Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {enableHighAccuracy:"string"})', false); + +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:undefined})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:null})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:{}})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:objectThrowingException})', true, 'Error: valueOf threw exception'); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:emptyFunction})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:true})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:42})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:-Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {maximumAge:"string"})', false); + +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:undefined})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:null})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:{}})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:objectThrowingException})', true, 'Error: valueOf threw exception'); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:emptyFunction})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:true})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:42})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:-Infinity})', false); +test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined, {timeout:"string"})', false); + +var isAsynchronous = false; +var successfullyParsed = true; + diff --git a/LayoutTests/fast/dom/Geolocation/resources/callback-exception.js b/LayoutTests/fast/dom/Geolocation/resources/callback-exception.js new file mode 100644 index 0000000..d5cd682 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/callback-exception.js @@ -0,0 +1,36 @@ +description("Tests that when an exception is thrown in the success callback, the error callback is not invoked. Note that this test throws an exception which is not caught."); + +var mockLatitude = 51.478; +var mockLongitude = -0.166; +var mockAccuracy = 100; + +window.layoutTestController.setGeolocationPermission(true); +window.layoutTestController.setMockGeolocationPosition(mockLatitude, + mockLongitude, + mockAccuracy); + +var position; +navigator.geolocation.getCurrentPosition(function(p) { + position = p + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + + // Yield to allow for the error callback to be invoked. The timer + // must be started before the exception is thrown. + window.setTimeout(completeTest, 0); + throw new Error('Exception in success callback'); +}, function(e) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}); + +function completeTest() +{ + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/enabled.js b/LayoutTests/fast/dom/Geolocation/resources/enabled.js new file mode 100644 index 0000000..4e99984 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/enabled.js @@ -0,0 +1,18 @@ +description("Tests that the navigator.geolocation object is present."); + +function hasGeolocationProperty() +{ + for (var property in navigator) { + if (property == "geolocation") + return true; + } + return false; +} + +shouldBeTrue("typeof navigator.geolocation == 'object'"); +shouldBeTrue("hasGeolocationProperty()"); +shouldBeTrue("'geolocation' in navigator"); +shouldBeTrue("navigator.hasOwnProperty('geolocation')"); + +var isAsynchronous = false; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/error.js b/LayoutTests/fast/dom/Geolocation/resources/error.js new file mode 100644 index 0000000..c76570b --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/error.js @@ -0,0 +1,27 @@ +description("Tests Geolocation error callback using the mock service."); + +var mockCode = 0; +var mockMessage = "debug"; + +window.layoutTestController.setMockGeolocationError(mockCode, mockMessage); + +var error; +navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'mockCode'); + shouldBe('error.message', 'mockMessage'); + shouldBe('error.UNKNOWN_ERROR', 'undefined'); + shouldBe('error.PERMISSION_DENIED', '1'); + shouldBe('error.POSITION_UNAVAILABLE', '2'); + shouldBe('error.TIMEOUT', '3'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/js-test-post.js b/LayoutTests/fast/dom/Geolocation/resources/js-test-post.js new file mode 100644 index 0000000..558f149 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/js-test-post.js @@ -0,0 +1,4 @@ +shouldBeTrue("successfullyParsed"); +if (!isAsynchronous) { + debug('<br /><span class="pass">TEST COMPLETE</span>'); +} diff --git a/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-clear-watch.js b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-clear-watch.js new file mode 100644 index 0000000..1e980a5 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-clear-watch.js @@ -0,0 +1,42 @@ +description("Tests that when Geolocation permission has been denied prior to a call to watchPosition, and the watch is cleared in the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111."); + +// Prime the Geolocation instance by denying permission. +window.layoutTestController.setGeolocationPermission(false); +window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); + +var error; +navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + debug(''); + continueTest(); +}); + +function continueTest() +{ + // Make another request, with permission already denied. + var watchId = navigator.geolocation.watchPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + }, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + navigator.geolocation.clearWatch(watchId); + window.setTimeout(completeTest, 0); + }); +} + +function completeTest() +{ + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-error.js b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-error.js new file mode 100644 index 0000000..77c8259 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-error.js @@ -0,0 +1,38 @@ +description("Tests that when Geolocation permission has been denied prior to a call to a Geolocation method, the error callback is invoked with code PERMISSION_DENIED, when the Geolocation service encounters an error."); + +// Prime the Geolocation instance by denying permission. +window.layoutTestController.setGeolocationPermission(false); +window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); + +var error; +navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + debug(''); + continueTest(); +}); + +function continueTest() +{ + // Make another request, with permission already denied. + window.layoutTestController.setMockGeolocationError(0, 'test'); + + navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + }, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); + }); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-success.js b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-success.js new file mode 100644 index 0000000..966c64d --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-already-success.js @@ -0,0 +1,36 @@ +description("Tests that when Geolocation permission has been denied prior to a call to a Geolocation method, the error callback is invoked with code PERMISSION_DENIED, when the Geolocation service has a good position."); + +// Prime the Geolocation instance by denying permission. +window.layoutTestController.setGeolocationPermission(false); +window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); + +var error; +navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + debug(''); + continueTest(); +}); + +function continueTest() +{ + // Make another request, with permission already denied. + navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + }, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); + }); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/permission-denied-stops-watches.js b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-stops-watches.js new file mode 100644 index 0000000..89e5004 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/permission-denied-stops-watches.js @@ -0,0 +1,38 @@ +description("Tests that when Geolocation permission is denied, watches are stopped, as well as one-shots."); + +// Configure the mock Geolocation service to report a position to cause permission +// to be requested, then deny it. +window.layoutTestController.setGeolocationPermission(false); +window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0); + +var error; +var errorCallbackInvoked = false; +navigator.geolocation.watchPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + if (errorCallbackInvoked) { + testFailed('Error callback invoked unexpectedly : ' + error.message); + window.layoutTestController.notifyDone(); + } + 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. + window.layoutTestController.setMockGeolocationPosition(55.478, -0.166, 100); + window.setTimeout(completeTest, 0); +}); + +function completeTest() +{ + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/permission-denied.js b/LayoutTests/fast/dom/Geolocation/resources/permission-denied.js new file mode 100644 index 0000000..1915469 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/permission-denied.js @@ -0,0 +1,20 @@ +description("Tests Geolocation when permission is denied, using the mock service."); + +window.layoutTestController.setGeolocationPermission(false); +window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); + +var error; +navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'error.PERMISSION_DENIED'); + shouldBe('error.message', '"User denied Geolocation"'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/position-string.js b/LayoutTests/fast/dom/Geolocation/resources/position-string.js new file mode 100644 index 0000000..6365fca --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/position-string.js @@ -0,0 +1,30 @@ +description("Tests formatting of position.toString()."); + +var mockLatitude = 51.478; +var mockLongitude = -0.166; +var mockAccuracy = 100.0; + +window.layoutTestController.setGeolocationPermission(true); +window.layoutTestController.setMockGeolocationPosition(mockLatitude, + mockLongitude, + mockAccuracy); + +var position; +navigator.geolocation.getCurrentPosition(function(p) { + // shouldBe can't use local variables yet. + position = p + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + shouldBe('position.toString()', '"[object Geoposition]"'); + shouldBe('position.coords.toString()', '"[object Coordinates]"'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}, function(e) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/reentrant-error.js b/LayoutTests/fast/dom/Geolocation/resources/reentrant-error.js new file mode 100644 index 0000000..32858bf --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/reentrant-error.js @@ -0,0 +1,47 @@ +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'); + window.layoutTestController.notifyDone(); +}, function(e) { + if (errorCallbackInvoked) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + } + 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'); + window.layoutTestController.notifyDone(); + }, function(e) { + error = e; + shouldBe('error.code', 'mockCode'); + shouldBe('error.message', 'mockMessage'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); + }); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/reentrant-success.js b/LayoutTests/fast/dom/Geolocation/resources/reentrant-success.js new file mode 100644 index 0000000..12dfe39 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/reentrant-success.js @@ -0,0 +1,52 @@ +description("Tests that reentrant calls to Geolocation methods from the success callback are OK."); + +var mockLatitude = 51.478; +var mockLongitude = -0.166; +var mockAccuracy = 100.0; + +window.layoutTestController.setGeolocationPermission(true); +window.layoutTestController.setMockGeolocationPosition(mockLatitude, + mockLongitude, + mockAccuracy); + +var position; +var successCallbackInvoked = false; +navigator.geolocation.getCurrentPosition(function(p) { + if (successCallbackInvoked) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + } + successCallbackInvoked = true; + + position = p; + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + debug(''); + continueTest(); +}, function(e) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}); + +function continueTest() { + window.layoutTestController.setMockGeolocationPosition(++mockLatitude, + ++mockLongitude, + ++mockAccuracy); + + navigator.geolocation.getCurrentPosition(function(p) { + position = p; + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); + }, function(e) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + }); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/success.js b/LayoutTests/fast/dom/Geolocation/resources/success.js new file mode 100644 index 0000000..c5f566f --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/success.js @@ -0,0 +1,27 @@ +description("Tests Geolocation success callback using the mock service."); + +var mockLatitude = 51.478; +var mockLongitude = -0.166; +var mockAccuracy = 100; + +window.layoutTestController.setGeolocationPermission(true); +window.layoutTestController.setMockGeolocationPosition(mockLatitude, + mockLongitude, + mockAccuracy); + +var position; +navigator.geolocation.getCurrentPosition(function(p) { + position = p + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}, function(e) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/timeout-clear-watch.js b/LayoutTests/fast/dom/Geolocation/resources/timeout-clear-watch.js new file mode 100644 index 0000000..e9d247a --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/timeout-clear-watch.js @@ -0,0 +1,27 @@ +description("Tests that when a watch times out and is cleared from the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111."); + +window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0); + +var error; +var watchId = navigator.geolocation.watchPosition(function() { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'error.TIMEOUT'); + shouldBe('error.message', '"Timeout expired"'); + navigator.geolocation.clearWatch(watchId); + window.setTimeout(completeTest, 0); +}, { + timeout: 0 +}); + +function completeTest() +{ + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +} +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/timeout-zero.js b/LayoutTests/fast/dom/Geolocation/resources/timeout-zero.js new file mode 100644 index 0000000..8a930d9 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/timeout-zero.js @@ -0,0 +1,21 @@ +description("Tests that when timeout is zero (and maximumAge is too), the error callback is called immediately with code TIMEOUT."); + +layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100.0); + +var error; +navigator.geolocation.getCurrentPosition(function(p) { + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, function(e) { + error = e + shouldBe('error.code', 'error.TIMEOUT'); + shouldBe('error.message', '"Timeout expired"'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}, { + timeout: 0 +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/timeout.js b/LayoutTests/fast/dom/Geolocation/resources/timeout.js new file mode 100644 index 0000000..d4fa1a7 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/timeout.js @@ -0,0 +1,29 @@ +description("Tests that when timeout is non-zero, the success callback is called as expected."); + +var mockLatitude = 51.478; +var mockLongitude = -0.166; +var mockAccuracy = 100.0; + +window.layoutTestController.setGeolocationPermission(true); +window.layoutTestController.setMockGeolocationPosition(mockLatitude, + mockLongitude, + mockAccuracy); + +var position; +navigator.geolocation.getCurrentPosition(function(p) { + position = p; + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); +}, function(e) { + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); +}, { + timeout: 1000 +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/resources/watch.js b/LayoutTests/fast/dom/Geolocation/resources/watch.js new file mode 100644 index 0000000..dbf4272 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/resources/watch.js @@ -0,0 +1,65 @@ +description("Tests that watchPosition correctly reports position updates and errors from the Geolocation service."); + +var mockLatitude = 51.478; +var mockLongitude = -0.166; +var mockAccuracy = 100.0; + +var mockCode = 1; +var mockMessage = 'test'; + +var position; +var error; + +function checkPosition(p) { + position = p; + shouldBe('position.coords.latitude', 'mockLatitude'); + shouldBe('position.coords.longitude', 'mockLongitude'); + shouldBe('position.coords.accuracy', 'mockAccuracy'); + debug(''); +} + +function checkError(e) { + error = e; + shouldBe('error.code', 'mockCode'); + shouldBe('error.message', 'mockMessage'); + debug(''); +} + +window.layoutTestController.setGeolocationPermission(true); +window.layoutTestController.setMockGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); + +var state = 0; +navigator.geolocation.watchPosition(function(p) { + switch (state++) { + case 0: + checkPosition(p); + window.layoutTestController.setMockGeolocationPosition(++mockLatitude, ++mockLongitude, ++mockAccuracy); + break; + case 1: + checkPosition(p); + window.layoutTestController.setMockGeolocationError(mockCode, mockMessage); + break; + case 3: + checkPosition(p); + debug('<br /><span class="pass">TEST COMPLETE</span>'); + window.layoutTestController.notifyDone(); + break; + default: + testFailed('Success callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + } +}, function(e) { + switch (state++) { + case 2: + checkError(e); + window.layoutTestController.setMockGeolocationPosition(++mockLatitude, ++mockLongitude, ++mockAccuracy); + break; + default: + testFailed('Error callback invoked unexpectedly'); + window.layoutTestController.notifyDone(); + } +}); +window.layoutTestController.waitUntilDone(); + +var isAsynchronous = true; +var successfullyParsed = true; diff --git a/LayoutTests/fast/dom/Geolocation/success-expected.txt b/LayoutTests/fast/dom/Geolocation/success-expected.txt new file mode 100644 index 0000000..a063801 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/success-expected.txt @@ -0,0 +1,12 @@ +Tests Geolocation success callback using the mock service. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/success.html b/LayoutTests/fast/dom/Geolocation/success.html new file mode 100644 index 0000000..ecd7a25 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/success.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/success.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/timeout-clear-watch-expected.txt b/LayoutTests/fast/dom/Geolocation/timeout-clear-watch-expected.txt new file mode 100644 index 0000000..e97fccd --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/timeout-clear-watch-expected.txt @@ -0,0 +1,11 @@ +Tests that when a watch times out and is cleared from the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.TIMEOUT +PASS error.message is "Timeout expired" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/timeout-clear-watch.html b/LayoutTests/fast/dom/Geolocation/timeout-clear-watch.html new file mode 100644 index 0000000..45c7735 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/timeout-clear-watch.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/timeout-clear-watch.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/timeout-expected.txt b/LayoutTests/fast/dom/Geolocation/timeout-expected.txt new file mode 100644 index 0000000..c673cd2 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/timeout-expected.txt @@ -0,0 +1,12 @@ +Tests that when timeout is non-zero, the success callback is called as expected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/timeout-zero-expected.txt b/LayoutTests/fast/dom/Geolocation/timeout-zero-expected.txt new file mode 100644 index 0000000..f083301 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/timeout-zero-expected.txt @@ -0,0 +1,11 @@ +Tests that when timeout is zero (and maximumAge is too), the error callback is called immediately with code TIMEOUT. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS error.code is error.TIMEOUT +PASS error.message is "Timeout expired" + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/timeout-zero.html b/LayoutTests/fast/dom/Geolocation/timeout-zero.html new file mode 100644 index 0000000..955398e --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/timeout-zero.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/timeout-zero.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/timeout.html b/LayoutTests/fast/dom/Geolocation/timeout.html new file mode 100644 index 0000000..f8eaafe --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/timeout.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/timeout.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/Geolocation/watch-expected.txt b/LayoutTests/fast/dom/Geolocation/watch-expected.txt new file mode 100644 index 0000000..0f923dc --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/watch-expected.txt @@ -0,0 +1,24 @@ +Tests that watchPosition correctly reports position updates and errors from the Geolocation service. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS successfullyParsed is true +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + +PASS error.code is mockCode +PASS error.message is mockMessage + +PASS position.coords.latitude is mockLatitude +PASS position.coords.longitude is mockLongitude +PASS position.coords.accuracy is mockAccuracy + + +TEST COMPLETE + diff --git a/LayoutTests/fast/dom/Geolocation/watch.html b/LayoutTests/fast/dom/Geolocation/watch.html new file mode 100644 index 0000000..6568883 --- /dev/null +++ b/LayoutTests/fast/dom/Geolocation/watch.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/watch.js"></script> +<script src="resources/js-test-post.js"></script> +</body> +</html> |