mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
Add js-exec to monkey_driver, add a test, etc.
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
a43b83de03
commit
1736bdcfee
@ -10,7 +10,14 @@ steps:
|
||||
window: win1
|
||||
- action: navigate
|
||||
window: win1
|
||||
url: file:///home/dsilvers/dev-netsurf/workspace/netsurf/test/js/inserted-script.html
|
||||
url: about:blank
|
||||
- action: block
|
||||
conditions:
|
||||
- window: win1
|
||||
status: complete
|
||||
- action: js-exec
|
||||
window: win1
|
||||
cmd: location.assign("file:///home/dsilvers/dev-netsurf/workspace/netsurf/test/js/inserted-script.html")
|
||||
- action: block
|
||||
conditions:
|
||||
- window: win1
|
||||
|
@ -315,6 +315,18 @@ def run_test_step_action_wait_log(ctx, step):
|
||||
win.wait_for_log(source=source, foldable=foldable, level=level, substr=substr)
|
||||
|
||||
|
||||
def run_test_step_action_js_exec(ctx, step):
|
||||
print(get_indent(ctx) + "Action: " + step["action"])
|
||||
assert_browser(ctx)
|
||||
browser = ctx['browser']
|
||||
tag = step['window']
|
||||
cmd = step['cmd']
|
||||
print(get_indent(ctx) + " " + tag + " Run " + cmd)
|
||||
win = ctx['windows'].get(tag)
|
||||
assert(win is not None)
|
||||
win.js_exec(cmd)
|
||||
|
||||
|
||||
def run_test_step_action_quit(ctx, step):
|
||||
print(get_indent(ctx) + "Action: " + step["action"])
|
||||
assert_browser(ctx)
|
||||
@ -338,6 +350,7 @@ step_handlers = {
|
||||
"remove-auth": run_test_step_action_remove_auth,
|
||||
"clear-log": run_test_step_action_clear_log,
|
||||
"wait-log": run_test_step_action_wait_log,
|
||||
"js-exec": run_test_step_action_js_exec,
|
||||
"quit": run_test_step_action_quit,
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,10 @@ class BrowserWindow:
|
||||
|
||||
def reload(self):
|
||||
self.browser.farmer.tell_monkey("WINDOW RELOAD %s" % self.winid)
|
||||
|
||||
|
||||
def js_exec(self, src):
|
||||
self.browser.farmer.tell_monkey("WINDOW EXEC WIN %s %s" % (self.winid, src))
|
||||
|
||||
def handle(self, action, *args):
|
||||
handler = getattr(self, "handle_window_" + action, None)
|
||||
if handler is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user