diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-15 11:31:28 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-24 20:43:51 +0100 |
commit | 60c0b4fe97192617a753a9f39b89ecb166405de9 (patch) | |
tree | 23e2e278d1d83d87822e7bf5e93f9b5a5915a6ad | |
parent | 749f1c85670798999be5958580877277ce16aff0 (diff) | |
download | browser-extension-60c0b4fe97192617a753a9f39b89ecb166405de9.tar.gz browser-extension-60c0b4fe97192617a753a9f39b89ecb166405de9.zip |
delay loading of js code in test_policy_enforcing.py
We don't want JS loading to happen upon python module load. We want to do it lazily. Here it was being done eagerly due to some previous overlooking.
-rw-r--r-- | test/haketilo_test/unit/test_policy_enforcing.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/haketilo_test/unit/test_policy_enforcing.py b/test/haketilo_test/unit/test_policy_enforcing.py index bbc3eb9..90a6ed9 100644 --- a/test/haketilo_test/unit/test_policy_enforcing.py +++ b/test/haketilo_test/unit/test_policy_enforcing.py @@ -39,7 +39,11 @@ payload_policy = { 'csp': f"prefetch-src 'none'; script-src-attr 'none'; script-src 'nonce-{nonce}'; script-src-elem 'nonce-{nonce}';" } -content_script = load_script('content/policy_enforcing.js') + ''';{ +def content_script(): + return load_script('content/policy_enforcing.js') + \ + content_script_appended_code + +content_script_appended_code = ''';{ const smuggled_what_to_do = /^[^#]*#?(.*)$/.exec(document.URL)[1]; const what_to_do = smuggled_what_to_do === "" ? {policy: {allow: true}} : JSON.parse(decodeURIComponent(smuggled_what_to_do)); |