From 96efcc335bbd9f2ad098e694d6cff6c1c22b4ce8 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Sat, 5 Mar 2022 15:54:53 +0100 Subject: improve script blocking in non-HTML documents (XML) --- .../data/pages/scripts_to_block_1.html | 33 ++++++---- .../data/pages/scripts_to_block_2.xml | 71 ++++++++++++++++++++++ test/haketilo_test/unit/test_policy_enforcing.py | 66 ++++++++++++++++++-- test/haketilo_test/unit/utils.py | 5 +- test/haketilo_test/world_wide_library.py | 2 + 5 files changed, 158 insertions(+), 19 deletions(-) create mode 100644 test/haketilo_test/data/pages/scripts_to_block_2.xml (limited to 'test') diff --git a/test/haketilo_test/data/pages/scripts_to_block_1.html b/test/haketilo_test/data/pages/scripts_to_block_1.html index e7793ee..67bff5e 100644 --- a/test/haketilo_test/data/pages/scripts_to_block_1.html +++ b/test/haketilo_test/data/pages/scripts_to_block_1.html @@ -29,18 +29,25 @@ - - - Click Meee! - - - - + +
+ + + Click Meee! + + + + +
diff --git a/test/haketilo_test/data/pages/scripts_to_block_2.xml b/test/haketilo_test/data/pages/scripts_to_block_2.xml new file mode 100644 index 0000000..6433a1d --- /dev/null +++ b/test/haketilo_test/data/pages/scripts_to_block_2.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + window.__run = [...(window.__run || []), 'grape']; + + + + + window.__run = [...(window.__run || []), 'raspberry']; + + + + + + + + + + + + + + + + + + + + diff --git a/test/haketilo_test/unit/test_policy_enforcing.py b/test/haketilo_test/unit/test_policy_enforcing.py index c5dd20e..98b5044 100644 --- a/test/haketilo_test/unit/test_policy_enforcing.py +++ b/test/haketilo_test/unit/test_policy_enforcing.py @@ -73,12 +73,15 @@ def get(driver, page, what_to_do): @pytest.mark.parametrize('csp_off_setting', [{}, {'csp_off': True}]) def test_policy_enforcing_html(driver, execute_in_page, csp_off_setting): """ - A test case of sanitizing