Add js-exec to monkey_driver, add a test, etc.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2019-05-06 19:20:15 +01:00
parent a43b83de03
commit 1736bdcfee
3 changed files with 25 additions and 2 deletions

View File

@ -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

View File

@ -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,
}

View File

@ -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: