summaryrefslogtreecommitdiff
path: root/content/handlers/javascript/duktape/Window.bnd
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-25 16:23:37 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-25 16:23:37 +0100
commit196c2fc845713d7ce2072a48f560f326b90b733a (patch)
treef4630fac89607e4f663504ddc42b3a3d0444de11 /content/handlers/javascript/duktape/Window.bnd
parent87be4e7a1771753f5b64550510684098559b7146 (diff)
downloadnetsurf-196c2fc845713d7ce2072a48f560f326b90b733a.tar.gz
netsurf-196c2fc845713d7ce2072a48f560f326b90b733a.tar.bz2
Add dodgy window method to clear callbacks
Until we can determine *how* the compartment isn't cleaning up properly in the duktape context, this will at least mean we don't get unpleasant callback related issues when compartments are reset during browsing. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/javascript/duktape/Window.bnd')
-rw-r--r--content/handlers/javascript/duktape/Window.bnd33
1 files changed, 33 insertions, 0 deletions
diff --git a/content/handlers/javascript/duktape/Window.bnd b/content/handlers/javascript/duktape/Window.bnd
index 3aed29991..cbf283f79 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -179,6 +179,28 @@ static void window_remove_callback_by_handle(duk_context *ctx,
} RING_ITERATE_END(window->schedule_ring, sched);
}
+/* This is the dodgy compartment closedown method */
+static duk_ret_t dukky_window_closedown_compartment(duk_context *ctx)
+{
+ window_private_t *priv = NULL;
+
+ duk_push_global_object(ctx);
+ duk_get_prop_string(ctx, -1, dukky_magic_string_private);
+ priv = duk_get_pointer(ctx, -1);
+ duk_pop_2(ctx);
+
+ if (priv == NULL) {
+ return 0;
+ }
+
+ NSLOG(dukky, DEEPDEBUG, "Closing down compartment");
+ while (priv->schedule_ring != NULL) {
+ window_remove_callback_by_handle(ctx, priv, priv->schedule_ring->handle);
+ }
+
+ return 0;
+}
+
%};
};
@@ -228,6 +250,17 @@ prototype Window()
EXPOSE(encodeURI);
EXPOSE(encodeURIComponent);
#undef EXPOSE
+ /* Add s3kr1t method to close the compartment */
+ duk_dup(ctx, 0);
+ duk_push_string(ctx, MAGIC(closedownCompartment));
+ duk_push_c_function(ctx, dukky_window_closedown_compartment, DUK_VARARGS);
+ duk_def_prop(ctx, -3,
+ DUK_DEFPROP_HAVE_VALUE |
+ DUK_DEFPROP_HAVE_WRITABLE |
+ DUK_DEFPROP_HAVE_ENUMERABLE |
+ DUK_DEFPROP_ENUMERABLE |
+ DUK_DEFPROP_HAVE_CONFIGURABLE);
+ duk_pop(ctx);
%}
getter Window::document()