Revision 093ec2a5
Added by koszko over 1 year ago
| html/settings.html | ||
|---|---|---|
| 35 | 35 |
#LOADCSS html/base.css |
| 36 | 36 |
#LOADCSS html/grid.css |
| 37 | 37 |
<style> |
| 38 |
#loader, #indexeddb_error {
|
|
| 38 |
.full_page_msg {
|
|
| 39 | 39 |
margin: auto; |
| 40 | 40 |
padding: 1em; |
| 41 | 41 |
max-width: 800px; |
| 42 | 42 |
} |
| 43 |
#indexeddb_error p {
|
|
| 43 |
.full_page_msg p {
|
|
| 44 | 44 |
margin-bottom: 1em; |
| 45 | 45 |
} |
| 46 | 46 |
|
| ... | ... | |
| 123 | 123 |
#INCLUDE html/item_preview.html |
| 124 | 124 |
#INCLUDE html/text_entry_list.html |
| 125 | 125 |
#INCLUDE html/payload_create.html |
| 126 |
<div id="loader"> |
|
| 127 |
Loading settings page... |
|
| 126 |
<div id="loader" class="full_page_msg"> |
|
| 127 |
<p> |
|
| 128 |
Loading settings page... |
|
| 129 |
</p> |
|
| 128 | 130 |
</div> |
| 129 |
<div id="indexeddb_error" class="hide"> |
|
| 131 |
<div id="indexeddb_error" class="hide full_page_msg">
|
|
| 130 | 132 |
<p> |
| 131 | 133 |
Cannot display settings page. |
| 132 | 134 |
</p> |
| ... | ... | |
| 135 | 137 |
database in which Haketilo stores all its configuration. Without it, the |
| 136 | 138 |
settings page is non-operational. |
| 137 | 139 |
<p> |
| 140 |
</div> |
|
| 138 | 141 |
#IF MOZILLA |
| 139 |
<div id="indexeddb_private_mode_explanation" class="hide"> |
|
| 140 |
<p> |
|
| 141 |
This issue is the result of using Haketilo in Private Browsing mode. |
|
| 142 |
For privacy reasons your browser blocks access to IndexedDB in |
|
| 143 |
private windows and this unfortunately also affects Haketilo's |
|
| 144 |
settings page. |
|
| 145 |
</p> |
|
| 146 |
<p> |
|
| 147 |
You can sacrifice this single privacy feature and enable IndexedDB |
|
| 148 |
access in private windows by navigating to "about:config" in the URL |
|
| 149 |
bar, agreeing to accept the risk and setting the |
|
| 150 |
"dom.indexedDB.privateBrowsing.enabled" preference to "true". Those |
|
| 151 |
pages that have their scripts blocked will still be unable to access |
|
| 152 |
IndexedDB. |
|
| 153 |
</p> |
|
| 154 |
<p> |
|
| 155 |
Alternatively, you can open Haketilo's settings in a separate, |
|
| 156 |
non-private window. The configuration you make there will take |
|
| 157 |
effect on pages opened in Private Browsing mode as well. |
|
| 158 |
</p> |
|
| 159 |
</div> |
|
| 160 |
#ENDIF |
|
| 142 |
<div id="private_mode_error" class="hide full_page_msg"> |
|
| 143 |
<p> |
|
| 144 |
The settings page could not be displayed in a private window. |
|
| 145 |
</p> |
|
| 146 |
<p> |
|
| 147 |
Due to bug <a href="https://hydrillabugs.koszko.org/issues/115">#115</a> |
|
| 148 |
it is currently impossible to access Haketilo settings when in Private |
|
| 149 |
Browsing mode. You can instead open this settings page in a non-private |
|
| 150 |
window. Changes you make there shall affect websites browsed in Private |
|
| 151 |
Mode as well. |
|
| 152 |
</p> |
|
| 161 | 153 |
</div> |
| 154 |
#ENDIF |
|
| 162 | 155 |
<div id="main_view" class="hide"> |
| 163 | 156 |
<ul id="tab_heads"> |
| 164 | 157 |
<li id="blocking_head"> Blocking </li> |
| html/settings.js | ||
|---|---|---|
| 134 | 134 |
set_up_repos_tab(); |
| 135 | 135 |
} |
| 136 | 136 |
|
| 137 |
async function init_settings_page() {
|
|
| 137 | 138 |
#IF MOZILLA |
| 138 |
async function show_indexeddb_error() {
|
|
| 139 | 139 |
const this_tab = await browser.tabs.getCurrent(); |
| 140 |
if (this_tab.incognito) |
|
| 141 |
by_id("indexeddb_private_mode_explanation").classList.remove("hide");
|
|
| 142 |
#ELSE |
|
| 143 |
function show_indexeddb_error() {
|
|
| 140 |
|
|
| 141 |
if (this_tab.incognito) {
|
|
| 142 |
by_id("private_mode_error").classList.remove("hide");
|
|
| 143 |
by_id("loader").remove();
|
|
| 144 |
return; |
|
| 145 |
} |
|
| 144 | 146 |
#ENDIF |
| 145 |
by_id("loader").remove();
|
|
| 146 |
by_id("indexeddb_error").classList.remove("hide");
|
|
| 147 |
} |
|
| 148 | 147 |
|
| 149 |
async function init_settings_page() {
|
|
| 150 | 148 |
try {
|
| 151 | 149 |
await haketilodb.get(); |
| 152 | 150 |
} catch(e) {
|
| 153 | 151 |
console.error("Haketilo:", e);
|
| 154 |
show_indexeddb_error(); |
|
| 152 |
by_id("indexeddb_error").classList.remove("hide");
|
|
| 153 |
by_id("loader").remove();
|
|
| 155 | 154 |
return; |
| 156 | 155 |
} |
| 157 | 156 |
|
| test/haketilo_test/unit/test_settings.py | ||
|---|---|---|
| 81 | 81 |
}) |
| 82 | 82 |
@pytest.mark.usefixtures('webextension')
|
| 83 | 83 |
@pytest.mark.parametrize('incognito', [True, False])
|
| 84 |
def test_settings_page_indexeddb_error(driver, execute_in_page, incognito):
|
|
| 84 |
def test_settings_page_error(driver, execute_in_page, incognito): |
|
| 85 | 85 |
""" |
| 86 |
Test if failure to access IndexedDB in settings page results in the
|
|
| 87 |
appropriate message being shown.
|
|
| 86 |
Test whether being in Private Browsing mode and failure to access IndexedDB
|
|
| 87 |
in settings page result in the appropriate messages being shown.
|
|
| 88 | 88 |
""" |
| 89 |
error_divs = 'indexeddb_error', 'private_mode_error' |
|
| 90 |
|
|
| 89 | 91 |
execute_in_page( |
| 90 | 92 |
'''{
|
| 91 | 93 |
/* |
| 92 | 94 |
* Mock an unavailable IndexedDB. Calling onerror() without having set |
| 93 |
* "errorCode" on the request is the behavior observed under Mozilla. |
|
| 95 |
* "errorCode" on the request is the behavior observed under Mozilla |
|
| 96 |
* when IndexedDB is disabled. |
|
| 94 | 97 |
*/ |
| 95 | 98 |
indexedDB.open = function() {
|
| 96 | 99 |
const dummy_open_request = {};
|
| ... | ... | |
| 108 | 111 |
incognito) |
| 109 | 112 |
|
| 110 | 113 |
WebDriverWait(driver, 10)\ |
| 111 |
.until(EC.visibility_of_element_located((By.ID, 'indexeddb_error')))
|
|
| 114 |
.until(EC.visibility_of_element_located((By.ID, error_divs[incognito])))
|
|
| 112 | 115 |
|
| 113 | 116 |
assert driver.find_elements_by_id('loader') == []
|
| 114 | 117 |
assert not driver.find_element_by_id('main_view').is_displayed()
|
| 115 |
|
|
| 116 |
if incognito: |
|
| 117 |
assert driver.find_element_by_id('indexeddb_private_mode_explanation')\
|
|
| 118 |
.is_displayed() |
|
Also available in: Unified diff
correct the Private Browsing mode notice on settings page