From 4c6a2323d90e9321ec2b78e226167b3013ea69ab Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Sat, 29 Jan 2022 00:03:51 +0100 Subject: make Haketilo buildable again (for Mozilla) How cool it is to throw away 5755 lines of code... --- test/unit/test_patterns_query_manager.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'test/unit/test_patterns_query_manager.py') diff --git a/test/unit/test_patterns_query_manager.py b/test/unit/test_patterns_query_manager.py index c6ebb81..5daf3a0 100644 --- a/test/unit/test_patterns_query_manager.py +++ b/test/unit/test_patterns_query_manager.py @@ -150,14 +150,14 @@ def test_pqm_tree_building(driver, execute_in_page): all([m['identifier'] in last_script for m in sample_mappings])) execute_in_page( - ''' + '''{ const new_setting_val = {name: "default_allow", value: false}; settingchange({key: "default_allow", new_val: new_setting_val}); for (const mapping of arguments[0]) mappingchange({key: mapping.identifier, new_val: mapping}); for (const blocking of arguments[1]) blockingchange({key: blocking.pattern, new_val: blocking}); - ''', + }''', sample_mappings[2:], sample_blocking[2:]) WebDriverWait(driver, 10).until(condition_all_added) @@ -201,6 +201,19 @@ def test_pqm_tree_building(driver, execute_in_page): WebDriverWait(driver, 10).until(condition_all_removed) + def condition_default_allowed_again(driver): + content_script = execute_in_page('returnval(last_script);') + cs_values = get_content_script_values(driver, content_script) + return cs_values['haketilo_default_allow'] == True + + execute_in_page( + '''{ + const new_setting_val = {name: "default_allow", value: true}; + settingchange({key: "default_allow", new_val: new_setting_val}); + }''') + + WebDriverWait(driver, 10).until(condition_default_allowed_again) + content_js = ''' let already_run = false; this.haketilo_content_script_main = function() { @@ -229,8 +242,8 @@ def test_pqm_script_injection(driver, execute_in_page): # Let's open a normal page in a second window. Window 0 will be used to make # changed to IndexedDB and window 1 to test the working of content scripts. driver.execute_script('window.open("about:blank", "_blank");') + WebDriverWait(driver, 10).until(lambda d: len(d.window_handles) == 2) windows = [*driver.window_handles] - assert len(windows) == 2 def run_content_script(): driver.switch_to.window(windows[1]) -- cgit v1.2.3