Project

General

Profile

« Previous | Next » 

Revision 60c0b4fe

Added by koszko over 1 year ago

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.

View differences:

test/haketilo_test/unit/test_policy_enforcing.py
39 39
    'csp': f"prefetch-src 'none'; script-src-attr 'none'; script-src 'nonce-{nonce}'; script-src-elem 'nonce-{nonce}';"
40 40
}
41 41

  
42
content_script = load_script('content/policy_enforcing.js') + ''';{
42
def content_script():
43
    return load_script('content/policy_enforcing.js') + \
44
        content_script_appended_code
45

  
46
content_script_appended_code = ''';{
43 47
const smuggled_what_to_do = /^[^#]*#?(.*)$/.exec(document.URL)[1];
44 48
const what_to_do = smuggled_what_to_do === "" ? {policy: {allow: true}} :
45 49
                   JSON.parse(decodeURIComponent(smuggled_what_to_do));

Also available in: Unified diff