summaryrefslogtreecommitdiff
path: root/content/handlers/javascript/duktape
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-21 21:46:52 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-21 21:46:52 +0100
commitdf496cc8bcbe2e4bc0687fd3e8e678686d37b5cc (patch)
treec50b45a9075cf8cc069d594db910fbbab698d7da /content/handlers/javascript/duktape
parent9a3f138f9240f2865f5b15a6892da5b7434c2ae7 (diff)
downloadnetsurf-df496cc8bcbe2e4bc0687fd3e8e678686d37b5cc.tar.gz
netsurf-df496cc8bcbe2e4bc0687fd3e8e678686d37b5cc.tar.bz2
Window: set{Timeout,Interval}() default delay 10ms
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/javascript/duktape')
-rw-r--r--content/handlers/javascript/duktape/Window.bnd20
1 files changed, 8 insertions, 12 deletions
diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd
index e7d45c80d..478f92b99 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -480,13 +480,11 @@ method Window::alert()
method Window::setTimeout()
%{
duk_idx_t argc = duk_get_top(ctx);
- if (argc < 2) {
- /* not enough arguments */
- return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 2, argc);
+ duk_int_t timeout = 10;
+ if (argc >= 2) {
+ timeout = duk_get_int(ctx, 1);
}
-
- /* func, timeout, args... */
- duk_int_t timeout = duk_get_int(ctx, 1);
+ /* func, [timeout, args...] */
if (timeout < 10) { timeout = 10; }
size_t handle = window_alloc_new_callback(ctx, priv, false, (int)timeout);
@@ -497,13 +495,11 @@ method Window::setTimeout()
method Window::setInterval()
%{
duk_idx_t argc = duk_get_top(ctx);
- if (argc < 2) {
- /* not enough arguments */
- return duk_error(ctx, DUK_RET_TYPE_ERROR, dukky_error_fmt_argument, 2, argc);
+ duk_int_t timeout = 10;
+ if (argc >= 2) {
+ timeout = duk_get_int(ctx, 1);
}
-
- /* func, timeout, args... */
- duk_int_t timeout = duk_get_int(ctx, 1);
+ /* func, [timeout, args...] */
if (timeout < 10) { timeout = 10; }
size_t handle = window_alloc_new_callback(ctx, priv, true, (int)timeout);