From 98b2b67b8b9e28308dc858e7e81687eb48b75a58 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 23 Feb 2018 15:08:07 +0100 Subject: [PATCH] Add tests for per-URL JavaScript settings --- tests/end2end/data/javascript/enabled.html | 16 ++++++++++++++++ tests/end2end/data/javascript/localstorage.html | 2 ++ tests/end2end/features/javascript.feature | 16 ++++++++++++++++ tests/end2end/fixtures/webserver_sub.py | 1 + 4 files changed, 35 insertions(+) create mode 100644 tests/end2end/data/javascript/enabled.html diff --git a/tests/end2end/data/javascript/enabled.html b/tests/end2end/data/javascript/enabled.html new file mode 100644 index 000000000..a25f02566 --- /dev/null +++ b/tests/end2end/data/javascript/enabled.html @@ -0,0 +1,16 @@ + + + + + + +

JavaScript is disabled

+ + + diff --git a/tests/end2end/data/javascript/localstorage.html b/tests/end2end/data/javascript/localstorage.html index 28a11f24f..12c17bbc9 100644 --- a/tests/end2end/data/javascript/localstorage.html +++ b/tests/end2end/data/javascript/localstorage.html @@ -7,8 +7,10 @@ try { localStorage.qute_test = "foo"; elem.innerHTML = "working"; + console.log("local storage is working"); } catch (e) { elem.innerHTML = "not working"; + console.log("local storage is not working"); } } diff --git a/tests/end2end/features/javascript.feature b/tests/end2end/features/javascript.feature index c74811b4b..8428306cb 100644 --- a/tests/end2end/features/javascript.feature +++ b/tests/end2end/features/javascript.feature @@ -151,3 +151,19 @@ Feature: Javascript stuff And I run :greasemonkey-reload And I open data/hints/iframe.html Then the javascript message "Script is running on /data/hints/html/wrapped.html" should not be logged + + Scenario: Per-URL localstorage setting + When I set content.local_storage to false + And I run :set -u http://localhost:*/data2/* content.local_storage true + And I open data/javascript/localstorage.html + And I wait for "[*] local storage is not working" in the log + And I open data2/javascript/localstorage.html + Then the javascript message "local storage is working" should be logged + + Scenario: Per-URL JavaScript setting + When I set content.javascript.enabled to false + And I run :set -u http://localhost:*/data2/* content.javascript.enabled true + And I open data2/javascript/enabled.html + And I wait for "[*] JavaScript is enabled" in the log + And I open data/javascript/enabled.html + Then the page should contain the plaintext "JavaScript is disabled" diff --git a/tests/end2end/fixtures/webserver_sub.py b/tests/end2end/fixtures/webserver_sub.py index 4ec4619f7..75c080c34 100644 --- a/tests/end2end/fixtures/webserver_sub.py +++ b/tests/end2end/fixtures/webserver_sub.py @@ -48,6 +48,7 @@ def root(): @app.route('/data/') +@app.route('/data2/') # for per-URL settings def send_data(path): """Send a given data file to qutebrowser.