bdd: Add some tests for geolocation.

This commit is contained in:
Florian Bruhin 2016-01-14 07:01:58 +01:00
parent 252dc5bf1b
commit 1ddf817f4c
3 changed files with 78 additions and 6 deletions

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function on_success(position) {
console.log("geolocation permission granted");
}
function on_error(error) {
switch(error.code) {
case error.PERMISSION_DENIED:
console.log("geolocation permission denied");
break;
default:
console.log("[FAIL] geolocation error: " + error.message);
break;
}
}
function get_location() {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(on_success, on_error);
} else {
console.log("[FAIL] geolocation unavailable");
}
}
</script>
</head>
<body>
<input type="button" onclick="get_location()" value="Get position">
</body>
</html>

View File

@ -2,12 +2,12 @@
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function prompter() {
var reply = prompt("js prompt", "")
console.log("Prompt reply: " + reply)
}
</script>
<script type="text/javascript">
function prompter() {
var reply = prompt("js prompt", "")
console.log("Prompt reply: " + reply)
}
</script>
</head>
<body>
<input type="button" onclick="prompter()" value="Show prompt">

View File

@ -99,3 +99,41 @@ Feature: Prompts
And I run :prompt-no
Then "Error while loading *: SSL handshake failed" should be logged
And the page should contain the plaintext "Unable to load page"
# Geolocation
Scenario: Always rejecting geolocation
When I set content -> geolocation to false
And I open data/prompt/geolocation.html
And I click the button
Then the javascript message "geolocation permission denied" should be logged
Scenario: Always accepting geolocation
When I set content -> geolocation to true
And I open data/prompt/geolocation.html
And I click the button
Then the javascript message "geolocation permission denied" should not be logged
Scenario: geolocation with ask -> true
When I set content -> geolocation to ask
And I open data/prompt/geolocation.html
And I click the button
And I wait for a prompt
And I run :prompt-yes
Then the javascript message "geolocation permission denied" should not be logged
Scenario: geolocation with ask -> false
When I set content -> geolocation to ask
And I open data/prompt/geolocation.html
And I click the button
And I wait for a prompt
And I run :prompt-no
Then the javascript message "geolocation permission denied" should be logged
Scenario: geolocation with ask -> abort
When I set content -> geolocation to ask
And I open data/prompt/geolocation.html
And I click the button
And I wait for a prompt
And I run :leave-mode
Then the javascript message "geolocation permission denied" should be logged