add ability to stop a navigation in monkey frontend

This commit is contained in:
Vincent Sanders 2019-06-06 15:44:52 +01:00
parent 4be18fcf47
commit eeeca4b712
2 changed files with 31 additions and 1 deletions

View File

@ -112,6 +112,11 @@ Commands
Cause the given browser window to visit the given URL.
Optionally you can give a referrer URL to also use (simulating
a click in the browser on a link).
Minimally you can expect throbber stop response.
* `WINDOW STOP` _%id%_
Cause a browser window to stop any in progress navigatoipn.
Minimally you can expect throbber, url etc responses.
* `WINDOW REDRAW` _%id%_ [_%num% %num% %num% %num%_]
@ -125,7 +130,7 @@ Commands
Minimally you can expect redraw start/stop messages and you
can likely expect some number of `PLOT` results.
* `WINDOW RELOAD` _%id%_
* `WINDOW RELOAD` _%id%_ [all]
Cause a browser window to reload its current content.
Expect responses similar to a GO command.

View File

@ -494,6 +494,28 @@ monkey_window_handle_go(int argc, char **argv)
}
}
/**
* handle WINDOW STOP command
*/
static void
monkey_window_handle_stop(int argc, char **argv)
{
struct gui_window *gw;
if (argc != 3) {
moutf(MOUT_ERROR, "WINDOW STOP ARGS BAD\n");
return;
}
gw = monkey_find_window_by_num(atoi(argv[2]));
if (gw == NULL) {
moutf(MOUT_ERROR, "WINDOW NUM BAD");
} else {
browser_window_stop(gw->bw);
}
}
static void
monkey_window_handle_redraw(int argc, char **argv)
{
@ -541,6 +563,7 @@ monkey_window_handle_reload(int argc, char **argv)
struct gui_window *gw;
if (argc != 3 && argc != 4) {
moutf(MOUT_ERROR, "WINDOW RELOAD ARGS BAD\n");
return;
}
gw = monkey_find_window_by_num(atoi(argv[2]));
@ -598,6 +621,8 @@ monkey_window_handle_command(int argc, char **argv)
monkey_window_handle_destroy(argc, argv);
} else if (strcmp(argv[1], "GO") == 0) {
monkey_window_handle_go(argc, argv);
} else if (strcmp(argv[1], "STOP") == 0) {
monkey_window_handle_stop(argc, argv);
} else if (strcmp(argv[1], "REDRAW") == 0) {
monkey_window_handle_redraw(argc, argv);
} else if (strcmp(argv[1], "RELOAD") == 0) {