summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-03-08 17:34:37 +0100
committerWojtek Kosior <koszko@koszko.org>2022-03-08 17:34:37 +0100
commit093ec2a52697afdda610dde1302a59183719ac0f (patch)
tree1216a20fed8a04b83bdd6ef42f6134c9bddd7a77
parent96efcc335bbd9f2ad098e694d6cff6c1c22b4ce8 (diff)
downloadbrowser-extension-093ec2a52697afdda610dde1302a59183719ac0f.tar.gz
browser-extension-093ec2a52697afdda610dde1302a59183719ac0f.zip
correct the Private Browsing mode notice on settings page
-rw-r--r--html/settings.html47
-rw-r--r--html/settings.js19
-rw-r--r--test/haketilo_test/unit/test_settings.py17
3 files changed, 37 insertions, 46 deletions
diff --git a/html/settings.html b/html/settings.html
index e33f112..548a39e 100644
--- a/html/settings.html
+++ b/html/settings.html
@@ -35,12 +35,12 @@
#LOADCSS html/base.css
#LOADCSS html/grid.css
<style>
- #loader, #indexeddb_error {
+ .full_page_msg {
margin: auto;
padding: 1em;
max-width: 800px;
}
- #indexeddb_error p {
+ .full_page_msg p {
margin-bottom: 1em;
}
@@ -123,10 +123,12 @@
#INCLUDE html/item_preview.html
#INCLUDE html/text_entry_list.html
#INCLUDE html/payload_create.html
- <div id="loader">
- Loading settings page...
+ <div id="loader" class="full_page_msg">
+ <p>
+ Loading settings page...
+ </p>
</div>
- <div id="indexeddb_error" class="hide">
+ <div id="indexeddb_error" class="hide full_page_msg">
<p>
Cannot display settings page.
</p>
@@ -135,30 +137,21 @@
database in which Haketilo stores all its configuration. Without it, the
settings page is non-operational.
<p>
+ </div>
#IF MOZILLA
- <div id="indexeddb_private_mode_explanation" class="hide">
- <p>
- This issue is the result of using Haketilo in Private Browsing mode.
- For privacy reasons your browser blocks access to IndexedDB in
- private windows and this unfortunately also affects Haketilo's
- settings page.
- </p>
- <p>
- You can sacrifice this single privacy feature and enable IndexedDB
- access in private windows by navigating to "about:config" in the URL
- bar, agreeing to accept the risk and setting the
- "dom.indexedDB.privateBrowsing.enabled" preference to "true". Those
- pages that have their scripts blocked will still be unable to access
- IndexedDB.
- </p>
- <p>
- Alternatively, you can open Haketilo's settings in a separate,
- non-private window. The configuration you make there will take
- effect on pages opened in Private Browsing mode as well.
- </p>
- </div>
-#ENDIF
+ <div id="private_mode_error" class="hide full_page_msg">
+ <p>
+ The settings page could not be displayed in a private window.
+ </p>
+ <p>
+ Due to bug <a href="https://hydrillabugs.koszko.org/issues/115">#115</a>
+ it is currently impossible to access Haketilo settings when in Private
+ Browsing mode. You can instead open this settings page in a non-private
+ window. Changes you make there shall affect websites browsed in Private
+ Mode as well.
+ </p>
</div>
+#ENDIF
<div id="main_view" class="hide">
<ul id="tab_heads">
<li id="blocking_head"> Blocking </li>
diff --git a/html/settings.js b/html/settings.js
index e258fcb..87c1095 100644
--- a/html/settings.js
+++ b/html/settings.js
@@ -134,24 +134,23 @@ function set_up_settings_view() {
set_up_repos_tab();
}
+async function init_settings_page() {
#IF MOZILLA
-async function show_indexeddb_error() {
const this_tab = await browser.tabs.getCurrent();
- if (this_tab.incognito)
- by_id("indexeddb_private_mode_explanation").classList.remove("hide");
-#ELSE
-function show_indexeddb_error() {
+
+ if (this_tab.incognito) {
+ by_id("private_mode_error").classList.remove("hide");
+ by_id("loader").remove();
+ return;
+ }
#ENDIF
- by_id("loader").remove();
- by_id("indexeddb_error").classList.remove("hide");
-}
-async function init_settings_page() {
try {
await haketilodb.get();
} catch(e) {
console.error("Haketilo:", e);
- show_indexeddb_error();
+ by_id("indexeddb_error").classList.remove("hide");
+ by_id("loader").remove();
return;
}
diff --git a/test/haketilo_test/unit/test_settings.py b/test/haketilo_test/unit/test_settings.py
index 92ec4b6..6f669cb 100644
--- a/test/haketilo_test/unit/test_settings.py
+++ b/test/haketilo_test/unit/test_settings.py
@@ -81,16 +81,19 @@ def test_settings_page_tabs(driver, execute_in_page):
})
@pytest.mark.usefixtures('webextension')
@pytest.mark.parametrize('incognito', [True, False])
-def test_settings_page_indexeddb_error(driver, execute_in_page, incognito):
+def test_settings_page_error(driver, execute_in_page, incognito):
"""
- Test if failure to access IndexedDB in settings page results in the
- appropriate message being shown.
+ Test whether being in Private Browsing mode and failure to access IndexedDB
+ in settings page result in the appropriate messages being shown.
"""
+ error_divs = 'indexeddb_error', 'private_mode_error'
+
execute_in_page(
'''{
/*
* Mock an unavailable IndexedDB. Calling onerror() without having set
- * "errorCode" on the request is the behavior observed under Mozilla.
+ * "errorCode" on the request is the behavior observed under Mozilla
+ * when IndexedDB is disabled.
*/
indexedDB.open = function() {
const dummy_open_request = {};
@@ -108,11 +111,7 @@ def test_settings_page_indexeddb_error(driver, execute_in_page, incognito):
incognito)
WebDriverWait(driver, 10)\
- .until(EC.visibility_of_element_located((By.ID, 'indexeddb_error')))
+ .until(EC.visibility_of_element_located((By.ID, error_divs[incognito])))
assert driver.find_elements_by_id('loader') == []
assert not driver.find_element_by_id('main_view').is_displayed()
-
- if incognito:
- assert driver.find_element_by_id('indexeddb_private_mode_explanation')\
- .is_displayed()