aboutsummaryrefslogtreecommitdiff
path: root/content/page_actions.js
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2021-08-27 10:01:32 +0200
committerWojtek Kosior <koszko@koszko.org>2021-08-27 10:01:32 +0200
commit538376341e9a50ebd350897fe26f43c433f0ee06 (patch)
treefecea23bd499131f822d25e66b8b36819e6bb365 /content/page_actions.js
parent3303d7d70d4b9749c39ca87085d17495beab6030 (diff)
downloadbrowser-extension-538376341e9a50ebd350897fe26f43c433f0ee06.tar.gz
browser-extension-538376341e9a50ebd350897fe26f43c433f0ee06.zip
enable whitelisting of `file://' protocol\n\nThis commit additionally also changes the semantics of triple asterisk wildcard in URL path.
Diffstat (limited to 'content/page_actions.js')
-rw-r--r--content/page_actions.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/content/page_actions.js b/content/page_actions.js
index aff56b8..6a6b3a0 100644
--- a/content/page_actions.js
+++ b/content/page_actions.js
@@ -14,10 +14,13 @@
* IMPORTS_END
*/
-var port;
-var loaded = false;
-var scripts_awaiting = [];
-var nonce;
+let policy_received_callback;
+/* Snapshot url early because document.URL can be changed by other code. */
+let url;
+let port;
+let loaded = false;
+let scripts_awaiting = [];
+let nonce;
function handle_message(message)
{
@@ -31,8 +34,10 @@ function handle_message(message)
scripts_awaiting.push(script_text);
}
}
- if (action === "settings")
+ if (action === "settings") {
report_settings(data);
+ policy_received_callback({url, allow: !!data[1] && data[1].allow});
+ }
}
function document_loaded(event)
@@ -56,11 +61,14 @@ function add_script(script_text)
report_script(script_text);
}
-function handle_page_actions(script_nonce) {
+function handle_page_actions(script_nonce, policy_received_cb) {
+ policy_received_callback = policy_received_cb;
+ url = document.URL;
+
document.addEventListener("DOMContentLoaded", document_loaded);
port = browser.runtime.connect({name : CONNECTION_TYPE.PAGE_ACTIONS});
port.onMessage.addListener(handle_message);
- port.postMessage({url: document.URL});
+ port.postMessage({url});
nonce = script_nonce;
}