summaryrefslogtreecommitdiff
path: root/content/handlers/javascript/duktape/dukky.c
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/dukky.c
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/dukky.c')
-rw-r--r--content/handlers/javascript/duktape/dukky.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c
index 70e9be881..a828667ef 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -607,11 +607,16 @@ void js_destroycontext(jscontext *ctx)
jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv)
{
assert(ctx != NULL);
- /* Pop any active thread off */
NSLOG(dukky, DEBUG,
"New javascript/duktape compartment, win_priv=%p, doc_priv=%p", win_priv,
doc_priv);
+ /* Pop any active thread off */
if (CTX != NULL) {
+ /* Closing down the extant compartment */
+ NSLOG(dukky, DEEPDEBUG, "Closing down extant compartment...");
+ duk_get_global_string(CTX, MAGIC(closedownCompartment));
+ dukky_pcall(CTX, 0, true);
+ NSLOG(dukky, DEEPDEBUG, "Popping the thread off the stack");
duk_set_top(ctx->ctx, 0);
duk_gc(ctx->ctx, 0);
duk_gc(ctx->ctx, DUK_GC_COMPACT);