diff options
author | Florian Bruhin <me@the-compiler.org> | 2019-07-10 16:49:31 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2019-07-10 16:49:31 +0200 |
commit | 7c3d45f3b371266943e18c8581718ec04d0b7cfb (patch) | |
tree | 908d846a90ea971862f1baf9cb9be1180acb7b46 | |
parent | 61d2d5e7843b455c14e8018a5c5b4c03b4b08517 (diff) | |
download | qutebrowser-7c3d45f3b371266943e18c8581718ec04d0b7cfb.tar.gz qutebrowser-7c3d45f3b371266943e18c8581718ec04d0b7cfb.zip |
Add tests for :prompt-accept --save
-rw-r--r-- | tests/end2end/features/conftest.py | 7 | ||||
-rw-r--r-- | tests/end2end/features/prompts.feature | 31 | ||||
-rw-r--r-- | tests/end2end/fixtures/quteprocess.py | 15 |
3 files changed, 50 insertions, 3 deletions
diff --git a/tests/end2end/features/conftest.py b/tests/end2end/features/conftest.py index 95e9f8022..e0fc32307 100644 --- a/tests/end2end/features/conftest.py +++ b/tests/end2end/features/conftest.py @@ -676,3 +676,10 @@ def check_not_scrolled(request, quteproc): def check_option(quteproc, option, value): actual_value = quteproc.get_setting(option) assert actual_value == value + + +@bdd.then(bdd.parsers.parse("the per-domain option {option} should be set to {value} for {pattern}")) +def check_option_per_domain(quteproc, option, value, pattern, server): + pattern = pattern.replace('(port)', str(server.port)) + actual_value = quteproc.get_setting(option, pattern=pattern) + assert actual_value == value diff --git a/tests/end2end/features/prompts.feature b/tests/end2end/features/prompts.feature index 008b5b906..c3e72c61e 100644 --- a/tests/end2end/features/prompts.feature +++ b/tests/end2end/features/prompts.feature @@ -227,6 +227,15 @@ Feature: Prompts And I run :prompt-accept no Then the javascript message "geolocation permission denied" should be logged + Scenario: geolocation with ask -> false and save + When I set content.geolocation to ask + And I open data/prompt/geolocation.html in a new tab + And I run :click-element id button + And I wait for a prompt + And I run :prompt-accept --save no + Then the javascript message "geolocation permission denied" should be logged + And the per-domain option content.geolocation should be set to false for http://localhost:(port)/ + Scenario: geolocation with ask -> abort When I set content.geolocation to ask And I open data/prompt/geolocation.html in a new tab @@ -264,6 +273,17 @@ Feature: Prompts Then the javascript message "notification permission denied" should be logged @qtwebengine_notifications + Scenario: notifications with ask -> false and save + Given I have a fresh instance + When I set content.notifications to ask + And I open data/prompt/notifications.html in a new tab + And I run :click-element id button + And I wait for a prompt + And I run :prompt-accept --save no + Then the javascript message "notification permission denied" should be logged + And the per-domain option content.notifications should be set to false for http://localhost:(port)/ + + @qtwebengine_notifications Scenario: notifications with ask -> true Given I have a fresh instance When I set content.notifications to ask @@ -273,6 +293,17 @@ Feature: Prompts And I run :prompt-accept yes Then the javascript message "notification permission granted" should be logged + @qtwebengine_notifications + Scenario: notifications with ask -> true and save + Given I have a fresh instance + When I set content.notifications to ask + And I open data/prompt/notifications.html in a new tab + And I run :click-element id button + And I wait for a prompt + And I run :prompt-accept --save yes + Then the javascript message "notification permission granted" should be logged + And the per-domain option content.notifications should be set to true for http://localhost:(port)/ + # This actually gives us a denied rather than an aborted @xfail_norun Scenario: notifications with ask -> abort diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index 9cad17096..c6c6bbcb9 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -681,12 +681,21 @@ class QuteProc(testprocess.Process): return self.wait_for(category='commands', module='command', function='run', message='command called: *') - def get_setting(self, opt): + def get_setting(self, opt, pattern=None): """Get the value of a qutebrowser setting.""" - self.send_cmd(':set {}?'.format(opt)) + if pattern is None: + cmd = ':set {}?'.format(opt) + else: + cmd = ':set -u {} {}?'.format(pattern, opt) + + self.send_cmd(cmd) msg = self.wait_for(loglevel=logging.INFO, category='message', message='{} = *'.format(opt)) - return msg.message.split(' = ')[1] + + if pattern is None: + return msg.message.split(' = ')[1] + else: + return msg.message.split(' = ')[1].split(' for ')[0] def set_setting(self, option, value): # \ and " in a value should be treated literally, so escape them |