diff --git a/src/ecmascript/ecmascript.c b/src/ecmascript/ecmascript.c index d1083c26f..cee6c85e9 100644 --- a/src/ecmascript/ecmascript.c +++ b/src/ecmascript/ecmascript.c @@ -34,6 +34,7 @@ #include "ecmascript/timer.h" #include "intl/libintl.h" #include "main/module.h" +#include "main/main.h" #include "main/select.h" #include "main/timer.h" #include "osdep/osdep.h" @@ -275,7 +276,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text) #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "%s:%s %s %d\n", __FILE__, __FUNCTION__, text, interpreter->changed); #endif - if (interpreter->changed && !get_cmd_opt_bool("test")) { + if (interpreter->changed && !program.testjs) { struct document_view *doc_view = interpreter->vs->doc_view; struct document *document = doc_view->document; struct session *ses = doc_view->session; @@ -643,7 +644,7 @@ init_ecmascript_module(struct module *module) if (xdg_config_home) { /* ecmascript console log */ console_log_filename = straconcat(xdg_config_home, "/console.log", NULL); - console_error_filename = get_cmd_opt_bool("test") ? stracpy("/dev/stderr") : straconcat(xdg_config_home, "/console.err", NULL); + console_error_filename = program.testjs ? stracpy("/dev/stderr") : straconcat(xdg_config_home, "/console.err", NULL); /* ecmascript local storage db location */ #ifdef CONFIG_OS_DOS local_storage_filename = stracpy("elinks_ls.db"); diff --git a/src/ecmascript/mujs/console.c b/src/ecmascript/mujs/console.c index 578b09046..7ecd1e6f7 100644 --- a/src/ecmascript/mujs/console.c +++ b/src/ecmascript/mujs/console.c @@ -103,7 +103,7 @@ mjs_console_exit(js_State *J) #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); #endif - if (!get_cmd_opt_bool("test")) { + if (!program.testjs) { js_pushundefined(J); return; } diff --git a/src/ecmascript/quickjs/console.c b/src/ecmascript/quickjs/console.c index 3fb9e2948..1b33dbf59 100644 --- a/src/ecmascript/quickjs/console.c +++ b/src/ecmascript/quickjs/console.c @@ -120,7 +120,7 @@ js_console_exit(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *a #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); #endif - if (!get_cmd_opt_bool("test")) { + if (!program.testjs) { return JS_UNDEFINED; } program.retval = JS_ToBool(ctx, argv[0]) ? RET_ERROR : RET_OK; diff --git a/src/ecmascript/spidermonkey/console.cpp b/src/ecmascript/spidermonkey/console.cpp index 51321d9b0..4dce820e6 100644 --- a/src/ecmascript/spidermonkey/console.cpp +++ b/src/ecmascript/spidermonkey/console.cpp @@ -158,7 +158,7 @@ console_exit(JSContext *ctx, unsigned int argc, JS::Value *vp) JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setUndefined(); - if (!get_cmd_opt_bool("test")) { + if (!program.testjs) { return true; } program.retval = args[0].toBoolean() ? RET_ERROR : RET_OK; diff --git a/src/main/main.c b/src/main/main.c index 513ac878c..450dea7b3 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -176,6 +176,7 @@ init(void) free_string_list(&url_list); return; } + program.testjs = get_cmd_opt_bool("test"); if (!remote_session_flags) { check_stdio(&url_list); diff --git a/src/main/main.h b/src/main/main.h index fa6dcd8b4..96d83bb1c 100644 --- a/src/main/main.h +++ b/src/main/main.h @@ -20,6 +20,7 @@ struct program { int terminate; enum retval retval; char *path; + unsigned int testjs:1; }; extern struct program program; diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index 4f5948ec1..8e7659a78 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -62,6 +62,7 @@ #include "elinks.h" #include "config/options.h" +#include "main/main.h" #include "main/select.h" #include "osdep/osdep.h" #include "osdep/signals.h" @@ -875,7 +876,7 @@ done_draw(void) int get_output_handle(void) { - if (get_cmd_opt_bool("test")) { + if (program.testjs) { return open("/dev/null", O_WRONLY); }