diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-03-05 15:54:53 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-03-05 15:54:53 +0100 |
commit | 96efcc335bbd9f2ad098e694d6cff6c1c22b4ce8 (patch) | |
tree | cf8120ca6658c04c62e63dc66a8a5b39dbec4c2d /test/haketilo_test/unit/utils.py | |
parent | 709238294ea83525e62476ce59d734c57c11fd3f (diff) | |
download | browser-extension-96efcc335bbd9f2ad098e694d6cff6c1c22b4ce8.tar.gz browser-extension-96efcc335bbd9f2ad098e694d6cff6c1c22b4ce8.zip |
improve script blocking in non-HTML documents (XML)
Diffstat (limited to 'test/haketilo_test/unit/utils.py')
-rw-r--r-- | test/haketilo_test/unit/utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/test/haketilo_test/unit/utils.py b/test/haketilo_test/unit/utils.py index b27a209..7ddf92a 100644 --- a/test/haketilo_test/unit/utils.py +++ b/test/haketilo_test/unit/utils.py @@ -228,11 +228,12 @@ def are_scripts_allowed(driver, nonce=None): return driver.execute_script( ''' document.haketilo_scripts_allowed = false; - const script = document.createElement("script"); + const html_ns = "http://www.w3.org/1999/xhtml"; + const script = document.createElementNS(html_ns, "script"); script.innerHTML = "document.haketilo_scripts_allowed = true;"; if (arguments[0]) script.setAttribute("nonce", arguments[0]); - document.head.append(script); + (document.head || document.documentElement).append(script); return document.haketilo_scripts_allowed; ''', nonce) |