Revision 4c6a2323
Added by koszko over 1 year ago
| test/unit/test_patterns_query_manager.py | ||
|---|---|---|
| 150 | 150 |
all([m['identifier'] in last_script for m in sample_mappings])) |
| 151 | 151 |
|
| 152 | 152 |
execute_in_page( |
| 153 |
''' |
|
| 153 |
'''{
|
|
| 154 | 154 |
const new_setting_val = {name: "default_allow", value: false};
|
| 155 | 155 |
settingchange({key: "default_allow", new_val: new_setting_val});
|
| 156 | 156 |
for (const mapping of arguments[0]) |
| 157 | 157 |
mappingchange({key: mapping.identifier, new_val: mapping});
|
| 158 | 158 |
for (const blocking of arguments[1]) |
| 159 | 159 |
blockingchange({key: blocking.pattern, new_val: blocking});
|
| 160 |
''', |
|
| 160 |
}''',
|
|
| 161 | 161 |
sample_mappings[2:], sample_blocking[2:]) |
| 162 | 162 |
WebDriverWait(driver, 10).until(condition_all_added) |
| 163 | 163 |
|
| ... | ... | |
| 201 | 201 |
|
| 202 | 202 |
WebDriverWait(driver, 10).until(condition_all_removed) |
| 203 | 203 |
|
| 204 |
def condition_default_allowed_again(driver): |
|
| 205 |
content_script = execute_in_page('returnval(last_script);')
|
|
| 206 |
cs_values = get_content_script_values(driver, content_script) |
|
| 207 |
return cs_values['haketilo_default_allow'] == True |
|
| 208 |
|
|
| 209 |
execute_in_page( |
|
| 210 |
'''{
|
|
| 211 |
const new_setting_val = {name: "default_allow", value: true};
|
|
| 212 |
settingchange({key: "default_allow", new_val: new_setting_val});
|
|
| 213 |
}''') |
|
| 214 |
|
|
| 215 |
WebDriverWait(driver, 10).until(condition_default_allowed_again) |
|
| 216 |
|
|
| 204 | 217 |
content_js = ''' |
| 205 | 218 |
let already_run = false; |
| 206 | 219 |
this.haketilo_content_script_main = function() {
|
| ... | ... | |
| 229 | 242 |
# Let's open a normal page in a second window. Window 0 will be used to make |
| 230 | 243 |
# changed to IndexedDB and window 1 to test the working of content scripts. |
| 231 | 244 |
driver.execute_script('window.open("about:blank", "_blank");')
|
| 245 |
WebDriverWait(driver, 10).until(lambda d: len(d.window_handles) == 2) |
|
| 232 | 246 |
windows = [*driver.window_handles] |
| 233 |
assert len(windows) == 2 |
|
| 234 | 247 |
|
| 235 | 248 |
def run_content_script(): |
| 236 | 249 |
driver.switch_to.window(windows[1]) |
Also available in: Unified diff
make Haketilo buildable again (for Mozilla)
How cool it is to throw away 5755 lines of code...