summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html/popup.js6
-rw-r--r--html/repo_query.html11
-rw-r--r--html/repo_query.js22
-rw-r--r--test/haketilo_test/unit/test_repo_query.py16
4 files changed, 42 insertions, 13 deletions
diff --git a/html/popup.js b/html/popup.js
index 5a5db6c..52df3ae 100644
--- a/html/popup.js
+++ b/html/popup.js
@@ -132,8 +132,8 @@ function repo_query_showing(show) {
by_id(`${id}_container`).classList[["add", "remove"][show ^ i]]("hide");
}
-function prepare_repo_query_view(tab_id, page_info) {
- const repo_query_view = new RepoQueryView(tab_id,
+function prepare_repo_query_view(tab, page_info) {
+ const repo_query_view = new RepoQueryView(tab,
() => repo_query_showing(true),
() => repo_query_showing(false));
by_id("repo_query_container").prepend(repo_query_view.main_div);
@@ -163,7 +163,7 @@ async function main() {
if (page_info) {
show_page_info(page_info);
if (!page_info.privileged)
- prepare_repo_query_view(tab_id, page_info);
+ prepare_repo_query_view(tab, page_info);
} else {
by_id("loading_info").innerText =
"Page info not avaialable. Try reloading the page.";
diff --git a/html/repo_query.html b/html/repo_query.html
index 67158cc..8692c3b 100644
--- a/html/repo_query.html
+++ b/html/repo_query.html
@@ -105,9 +105,16 @@
}
</style>
<template>
- <div id="repo_query" data-template="main_div" class="repo_query_main_div">
+ <span id="repo_query_private_mode_error", data-template="main_span">
+ Due to bug <a href="https://hydrillabugs.koszko.org/issues/115">#115</a> it
+ is currently impossible to install scripts through the popup when in Private
+ Browsing mode. You can instead perform the installation after navigating to
+ the website in a non-private window. Scripts you install there shall affect
+ websites browsed in Private Mode as well.
+ </span>
+ <div id="repo_query" data-template="main_div">
<div data-template="repos_list_container">
- <div class="repo_query_top_text">
+ <div class="repo_query_top_text", data-template="top_text">
Browsing custom resources for:
<span data-template="url_span" class="repo_queried_url"></span>
</div>
diff --git a/html/repo_query.js b/html/repo_query.js
index 7cfd6fe..601a0aa 100644
--- a/html/repo_query.js
+++ b/html/repo_query.js
@@ -160,11 +160,20 @@ function RepoEntry(query_view, repo_url) {
const container_ids = ["repos_list_container", "install_view_container"];
-function RepoQueryView(tab_id, on_view_show, on_view_hide) {
+function RepoQueryView(tab, on_view_show, on_view_hide) {
Showable.call(this, on_view_show, on_view_hide);
Object.assign(this, clone_template("repo_query"));
- this.tab_id = tab_id;
+ this.tab_id = tab.id;
+#IF MOZILLA
+ this.incognito = tab.incognito;
+ if (this.incognito) {
+ [...this.top_text.childNodes].forEach(n => n.remove());
+ this.top_text.append(
+ clone_template("repo_query_private_mode_error").main_span
+ );
+ }
+#ENDIF
const show_container = name => {
for (const cid of container_ids) {
@@ -175,7 +184,7 @@ function RepoQueryView(tab_id, on_view_show, on_view_hide) {
}
this.install_view = new InstallView(
- tab_id,
+ this.tab_id,
() => show_container("install_view_container"),
() => show_container("repos_list_container")
);
@@ -186,6 +195,13 @@ function RepoQueryView(tab_id, on_view_show, on_view_hide) {
if (!show_super())
return;
+#IF MOZILLA
+ if (this.incognito) {
+ this.repo_entries = [];
+ return;
+ }
+#ENDIF
+
this.url = url;
this.url_span.innerText = url;
diff --git a/test/haketilo_test/unit/test_repo_query.py b/test/haketilo_test/unit/test_repo_query.py
index 177d415..f6cae93 100644
--- a/test/haketilo_test/unit/test_repo_query.py
+++ b/test/haketilo_test/unit/test_repo_query.py
@@ -28,7 +28,7 @@ repo_urls = [f'https://hydril.la/{s}' for s in ('', '1/', '2/', '3/', '4/')]
queried_url = 'https://example_a.com/something'
-def setup_view(execute_in_page, repo_urls):
+def setup_view(execute_in_page, repo_urls, tab={'id': 0}):
mock_cacher(execute_in_page)
execute_in_page(load_script('html/repo_query.js'))
@@ -37,7 +37,7 @@ def setup_view(execute_in_page, repo_urls):
const repo_proms = arguments[0].map(url => haketilodb.set_repo(url));
const cb_calls = [];
- const view = new RepoQueryView(0,
+ const view = new RepoQueryView(arguments[1],
() => cb_calls.push("show"),
() => cb_calls.push("hide"));
document.body.append(view.main_div);
@@ -45,7 +45,7 @@ def setup_view(execute_in_page, repo_urls):
returnval(Promise.all(repo_proms));
''',
- repo_urls)
+ repo_urls, tab)
repo_query_ext_data = {
'background_script': broker_js,
@@ -133,6 +133,7 @@ def test_repo_query_normal_usage(driver, execute_in_page):
@pytest.mark.parametrize('message', [
'browsing_for',
'no_repos',
+ 'private_mode',
'failure_to_communicate',
'HTTP_code',
'invalid_JSON',
@@ -174,8 +175,13 @@ def test_repo_query_messages(driver, execute_in_page, message):
show_and_wait_for_repo_entry()
elem = execute_in_page('returnval(view.repos_list);')
- done = has_msg('You have no repositories configured :(', elem)
- WebDriverWait(driver, 10).until(done)
+ assert has_msg('You have no repositories configured :(', elem)(0)
+ elif message == 'private_mode':
+ setup_view(execute_in_page, repo_urls, tab={'id': 0, 'incognito': True})
+ show_and_wait_for_repo_entry()
+
+ elem = execute_in_page('returnval(view.top_text);')
+ assert has_msg('when in Private Browsing mode', elem)(0)
elif message == 'failure_to_communicate':
setup_view(execute_in_page, repo_urls)
execute_in_page(