bdd: Add first tests for JS prompt/confirm/alert.
This commit is contained in:
parent
71b74329a3
commit
046194ad6f
15
tests/integration/data/prompt/jsalert.html
Normal file
15
tests/integration/data/prompt/jsalert.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript">
|
||||
function do_alert() {
|
||||
alert("js alert");
|
||||
console.log("Alert done");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="button" onclick="do_alert()" value="Show alert">
|
||||
</body>
|
||||
</html>
|
15
tests/integration/data/prompt/jsconfirm.html
Normal file
15
tests/integration/data/prompt/jsconfirm.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript">
|
||||
function prompter() {
|
||||
var reply = confirm("js confirm", "")
|
||||
console.log("confirm reply: " + reply)
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="button" onclick="prompter()" value="Show prompt">
|
||||
</body>
|
||||
</html>
|
15
tests/integration/data/prompt/jsprompt.html
Normal file
15
tests/integration/data/prompt/jsprompt.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<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">
|
||||
</body>
|
||||
</html>
|
61
tests/integration/features/prompt.feature
Normal file
61
tests/integration/features/prompt.feature
Normal file
@ -0,0 +1,61 @@
|
||||
Feature: Prompts
|
||||
Various prompts (javascript, SSL errors, authentification, etc.)
|
||||
|
||||
Background:
|
||||
Given I set general -> log-javascript-console to debug
|
||||
|
||||
# Javascript
|
||||
|
||||
Scenario: Javascript prompt
|
||||
When I open data/prompt/jsprompt.html
|
||||
And I click the button
|
||||
And I press the keys "prompt test"
|
||||
And I run :prompt-accept
|
||||
Then the javascript message "Prompt reply: prompt test" should be logged
|
||||
|
||||
Scenario: Rejected javascript prompt
|
||||
When I open data/prompt/jsprompt.html
|
||||
And I click the button
|
||||
And I press the keys "prompt test"
|
||||
And I run :leave-mode
|
||||
Then the javascript message "Prompt reply: null" should be logged
|
||||
|
||||
Scenario: Using content -> ignore-javascript-prompt
|
||||
When I set content -> ignore-javascript-prompt to true
|
||||
And I open data/prompt/jsprompt.html
|
||||
# Can't use "I click the button" as it waits for a key mode change
|
||||
And I run :hint
|
||||
And I run :follow-hint a
|
||||
Then the javascript message "Prompt reply: null" should be logged
|
||||
|
||||
Scenario: Javascript alert
|
||||
When I open data/prompt/jsalert.html
|
||||
And I click the button
|
||||
And I run :prompt-accept
|
||||
Then the javascript message "Alert done" should be logged
|
||||
|
||||
Scenario: Using content -> ignore-javascript-alert
|
||||
When I set content -> ignore-javascript-alert to true
|
||||
And I open data/prompt/jsalert.html
|
||||
# Can't use "I click the button" as it waits for a key mode change
|
||||
And I run :hint
|
||||
And I run :follow-hint a
|
||||
Then the javascript message "Alert done" should be logged
|
||||
|
||||
Scenario: Javascript confirm - yes
|
||||
When I open data/prompt/jsconfirm.html
|
||||
And I click the button
|
||||
And I run :prompt-yes
|
||||
Then the javascript message "confirm reply: true" should be logged
|
||||
|
||||
Scenario: Javascript confirm - no
|
||||
When I open data/prompt/jsconfirm.html
|
||||
And I click the button
|
||||
And I run :prompt-no
|
||||
Then the javascript message "confirm reply: false" should be logged
|
||||
|
||||
Scenario: Javascript confirm - aborted
|
||||
When I open data/prompt/jsconfirm.html
|
||||
And I click the button
|
||||
And I run :leave-mode
|
||||
Then the javascript message "confirm reply: false" should be logged
|
29
tests/integration/features/test_prompt.py
Normal file
29
tests/integration/features/test_prompt.py
Normal file
@ -0,0 +1,29 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest_bdd as bdd
|
||||
bdd.scenarios('prompt.feature')
|
||||
|
||||
|
||||
@bdd.when("I click the button")
|
||||
def click_button(quteproc):
|
||||
quteproc.send_cmd(':hint')
|
||||
quteproc.send_cmd(':follow-hint a')
|
||||
quteproc.wait_for(message='Entering mode KeyMode.* (reason: question '
|
||||
'asked)')
|
Loading…
Reference in New Issue
Block a user