Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/196c2fc845713d7ce2072a48f560f326b90b733a
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/196c2fc845713d7ce2072a48f560f326b90b733a
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/196c2fc845713d7ce2072a48f560f326b90b733a

The branch, master has been updated
       via  196c2fc845713d7ce2072a48f560f326b90b733a (commit)
      from  87be4e7a1771753f5b64550510684098559b7146 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=196c2fc845713d7ce2072a48f560f326b90b733a
commit 196c2fc845713d7ce2072a48f560f326b90b733a
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    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 <[email protected]>

diff --git a/content/handlers/javascript/duktape/Window.bnd 
b/content/handlers/javascript/duktape/Window.bnd
index 3aed299..cbf283f 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()
diff --git a/content/handlers/javascript/duktape/dukky.c 
b/content/handlers/javascript/duktape/dukky.c
index 70e9be8..a828667 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);


-----------------------------------------------------------------------

Summary of changes:
 content/handlers/javascript/duktape/Window.bnd |   33 ++++++++++++++++++++++++
 content/handlers/javascript/duktape/dukky.c    |    7 ++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/content/handlers/javascript/duktape/Window.bnd 
b/content/handlers/javascript/duktape/Window.bnd
index 3aed299..cbf283f 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()
diff --git a/content/handlers/javascript/duktape/dukky.c 
b/content/handlers/javascript/duktape/dukky.c
index 70e9be8..a828667 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);


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to