From 60c0b4fe97192617a753a9f39b89ecb166405de9 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 15 Mar 2022 11:31:28 +0100 Subject: 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. --- test/haketilo_test/unit/test_policy_enforcing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)); -- cgit v1.2.3