From 046194ad6fd1ea2e3d3b59982a9d57f6531260fd Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 12 Jan 2016 07:34:09 +0100 Subject: [PATCH] bdd: Add first tests for JS prompt/confirm/alert. --- tests/integration/data/prompt/jsalert.html | 15 +++++ tests/integration/data/prompt/jsconfirm.html | 15 +++++ tests/integration/data/prompt/jsprompt.html | 15 +++++ tests/integration/features/prompt.feature | 61 ++++++++++++++++++++ tests/integration/features/test_prompt.py | 29 ++++++++++ 5 files changed, 135 insertions(+) create mode 100644 tests/integration/data/prompt/jsalert.html create mode 100644 tests/integration/data/prompt/jsconfirm.html create mode 100644 tests/integration/data/prompt/jsprompt.html create mode 100644 tests/integration/features/prompt.feature create mode 100644 tests/integration/features/test_prompt.py diff --git a/tests/integration/data/prompt/jsalert.html b/tests/integration/data/prompt/jsalert.html new file mode 100644 index 000000000..d4af29850 --- /dev/null +++ b/tests/integration/data/prompt/jsalert.html @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/tests/integration/data/prompt/jsconfirm.html b/tests/integration/data/prompt/jsconfirm.html new file mode 100644 index 000000000..292b5e2c8 --- /dev/null +++ b/tests/integration/data/prompt/jsconfirm.html @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/tests/integration/data/prompt/jsprompt.html b/tests/integration/data/prompt/jsprompt.html new file mode 100644 index 000000000..bdded2664 --- /dev/null +++ b/tests/integration/data/prompt/jsprompt.html @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/tests/integration/features/prompt.feature b/tests/integration/features/prompt.feature new file mode 100644 index 000000000..e946f0b4a --- /dev/null +++ b/tests/integration/features/prompt.feature @@ -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 diff --git a/tests/integration/features/test_prompt.py b/tests/integration/features/test_prompt.py new file mode 100644 index 000000000..7af07cba8 --- /dev/null +++ b/tests/integration/features/test_prompt.py @@ -0,0 +1,29 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2016 Florian Bruhin (The Compiler) +# +# 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 . + +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)')