Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/689458aa6e1ad02e15dbd8f48d8a87bd933ec149
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/689458aa6e1ad02e15dbd8f48d8a87bd933ec149
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/689458aa6e1ad02e15dbd8f48d8a87bd933ec149

The branch, master has been updated
       via  689458aa6e1ad02e15dbd8f48d8a87bd933ec149 (commit)
       via  3021142aadf58bf65da1619d3ead92281beaffeb (commit)
       via  1146f8bf49eda7f23960e2efdd6dcefb6a98b552 (commit)
       via  f3892c98fdc734a0abca136ab712c94246fe66c0 (commit)
       via  ec0028bdb96a03f83055f2798c498a36142d6b03 (commit)
      from  efdea7757b3bbdb4e092844b30be091d066cfe79 (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=689458aa6e1ad02e15dbd8f48d8a87bd933ec149
commit 689458aa6e1ad02e15dbd8f48d8a87bd933ec149
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    Monkey: Support WINDOW EXEC WIN n cmd...
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/docs/using-monkey.md b/docs/using-monkey.md
index 1d0a96b..8d051cf 100644
--- a/docs/using-monkey.md
+++ b/docs/using-monkey.md
@@ -130,14 +130,22 @@ Commands
     Cause a browser window to reload its current content.
     Expect responses similar to a GO command.
 
+*   `WINDOW EXEC WIN` _%id%_ _%str%_
+
+    Cause a browser window to execute some javascript.  It won't
+    work if the window doesn't have a *finished* HTML content.
+
+    This will send a `WINDOW JS WIN` _%id%_ `RET` `TRUE`/`FALSE`
+    where `FALSE` indicates that some issue prevented the injection of
+    the script.
 
 ### Login commands
 
-*   `LOGIN USERNAME` _%id%_ _%str_
+*   `LOGIN USERNAME` _%id%_ _%str%_
 
     Set the username for the login
 
-*   `LOGIN PASSWORD` _%id%_ _%str_
+*   `LOGIN PASSWORD` _%id%_ _%str%_
 
     Set the password for the login
 
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index 69459fb..50b586f 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -500,6 +500,39 @@ monkey_window_handle_reload(int argc, char **argv)
        }
 }
 
+static void
+monkey_window_handle_exec(int argc, char **argv)
+{
+       struct gui_window *gw;
+       if (argc < 5) {
+               moutf(MOUT_ERROR, "WINDOW EXEC ARGS BAD\n");
+       }
+
+       gw = monkey_find_window_by_num(atoi(argv[2]));
+
+       if (gw == NULL) {
+               moutf(MOUT_ERROR, "WINDOW NUM BAD");
+       } else {
+               /* Gather argv[4] onward into a string to pass to js_exec */
+               int total = 0;
+               for (int i = 4; i < argc; ++i) {
+                       total += strlen(argv[i]) + 1;
+               }
+               char *cmd = calloc(total, 1);
+               strcpy(cmd, argv[4]);
+               for (int i = 5; i < argc; ++i) {
+                       strcat(cmd, " ");
+                       strcat(cmd, argv[i]);
+               }
+               /* Now execute the JS */
+
+               moutf(MOUT_WINDOW, "JS WIN %d RET %s", atoi(argv[2]),
+                     browser_window_exec(gw->bw, cmd, total - 1) ? "TRUE" : 
"FALSE");
+
+               free(cmd);
+       }
+}
+
 
 void
 monkey_window_handle_command(int argc, char **argv)
@@ -517,6 +550,8 @@ monkey_window_handle_command(int argc, char **argv)
                monkey_window_handle_redraw(argc, argv);
        } else if (strcmp(argv[1], "RELOAD") == 0) {
                monkey_window_handle_reload(argc, argv);
+       } else if (strcmp(argv[1], "EXEC") == 0) {
+               monkey_window_handle_exec(argc, argv);
        } else {
                moutf(MOUT_ERROR, "WINDOW COMMAND UNKNOWN %s\n", argv[1]);
        }


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

    Support content_exec for content_html
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index 9c60c7b..a47725b 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -2504,6 +2504,90 @@ bool html_get_id_offset(hlcache_handle *h, lwc_string 
*frag_id, int *x, int *y)
        return false;
 }
 
+static bool html_exec(struct content *c, const char *src, size_t srclen)
+{
+       html_content *htmlc = (html_content *)c;
+       bool result = false;
+       dom_exception err;
+       dom_html_body_element *body_node;
+       dom_string *dom_src;
+       dom_text *text_node;
+       dom_node *spare_node;
+       dom_html_script_element *script_node;
+       
+       if (htmlc->document == NULL) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no document");
+               goto out_no_string;
+       }
+
+       err = dom_string_create((const uint8_t *)src, srclen, &dom_src);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not create 
string");
+               goto out_no_string;
+       }
+
+       err = dom_html_document_get_body(htmlc->document, &body_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to retrieve body element");
+               goto out_no_body;
+       }
+       
+       err = dom_document_create_text_node(htmlc->document, dom_src, 
&text_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not create 
text node");
+               goto out_no_text_node;
+       }
+       
+       err = dom_document_create_element(htmlc->document, 
corestring_dom_SCRIPT, &script_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not create 
script node");
+               goto out_no_script_node;
+       }
+       
+       err = dom_node_append_child(script_node, text_node, &spare_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not insert 
code node into script node");
+               goto out_unparented;
+       }
+       dom_node_unref(spare_node); /* We do not need the spare ref at all */
+       
+       err = dom_node_append_child(body_node, script_node, &spare_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not insert 
script node into document body");
+               goto out_unparented;
+       }
+       dom_node_unref(spare_node); /* Again no need for the spare ref */
+       
+       /* We successfully inserted the node into the DOM */
+       
+       result = true;
+       
+       /* Now we unwind, starting by removing the script from wherever it
+        * ended up parented
+        */
+       
+       err = dom_node_get_parent_node(script_node, &spare_node);
+       if (err == DOM_NO_ERR && spare_node != NULL) {
+               dom_node *second_spare;
+               err = dom_node_remove_child(spare_node, script_node, 
&second_spare);
+               if (err == DOM_NO_ERR) {
+                       dom_node_unref(second_spare);
+               }
+               dom_node_unref(spare_node);
+       }
+
+out_unparented:
+       dom_node_unref(script_node);
+out_no_script_node:
+       dom_node_unref(text_node);
+out_no_text_node:
+       dom_node_unref(body_node);
+out_no_body:
+       dom_string_unref(dom_src);
+out_no_string:
+       return result;
+}
+
 /**
  * Compute the type of a content
  *
@@ -2546,6 +2630,7 @@ static const content_handler html_content_handler = {
        .clone = html_clone,
        .get_encoding = html_encoding,
        .type = html_content_type,
+       .exec = html_exec,
        .no_share = true,
 };
 


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

    Add browser_window_exec
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/desktop/browser.c b/desktop/browser.c
index 1c8aa95..d26abd0 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -3406,3 +3406,24 @@ int browser_get_dpi(void)
 {
        return FIXTOINT(nscss_screen_dpi);
 }
+
+/* exported interface documented in browser.h */
+bool browser_window_exec(struct browser_window *bw, const char *src, size_t 
srclen)
+{
+       assert(bw != NULL);
+
+       if (!bw->current_content) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no content");
+               return false;
+       }
+
+       if (content_get_status(bw->current_content) != CONTENT_STATUS_DONE) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, content not done");
+               return false;
+       }
+
+       /* Okay it should be safe, forward the request through to the content
+        * itself.  Only HTML contents currently support executing code
+        */
+       return content_exec(bw->current_content, src, srclen);
+}
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 439b078..77a2631 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -725,4 +725,16 @@ nserror browser_window_get_name(struct browser_window *bw, 
const char **name);
  */
 nserror browser_window_set_name(struct browser_window *bw, const char *name);
 
+/**
+ * Execute some JavaScript code in a browsing context.
+ *
+ * Runs the passed in JavaScript code in the browsing context.
+ *
+ * \param bw The browser window
+ * \param src The JavaScript source code
+ * \param srclen The length of the source code
+ * \return Whether the JS function was successfully injected into the content
+ */
+bool browser_window_exec(struct browser_window *bw, const char *src, size_t 
srclen);
+
 #endif


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

    Add content_exec and associated vtable entry
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/content/content.c b/content/content.c
index 8697501..bb5c47b 100644
--- a/content/content.c
+++ b/content/content.c
@@ -545,6 +545,27 @@ void content__request_redraw(struct content *c,
        content_broadcast(c, CONTENT_MSG_REDRAW, &data);
 }
 
+/* exported interface, documented in content/content.h */
+bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
+{
+       struct content *c = hlcache_handle_get_content(h);
+       
+       assert(c != NULL);
+       
+       if (c->locked) {
+               /* Not safe to do stuff */
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, content locked");
+               return false;
+       }
+       
+       if (c->handler->exec == NULL) {
+               /* Can't exec something on this content */
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no exec function");
+               return false;
+       }
+       
+       return c->handler->exec(c, src, srclen);
+}
 
 /* exported interface, documented in content/content.h */
 bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
diff --git a/content/content.h b/content/content.h
index e555df2..77cc605 100644
--- a/content/content.h
+++ b/content/content.h
@@ -387,6 +387,17 @@ bool content_get_quirks(struct hlcache_handle *h);
 bool content_is_locked(struct hlcache_handle *h);
 
 
+/**
+ * Execute some JavaScript code inside a content object.
+ *
+ * Runs the passed in JavaScript code in the content object's context.
+ *
+ * \param h The handle to the content
+ * \param src The JavaScript source code
+ * \param srclen The length of the source code
+ * \return Whether the JS function was successfully injected into the content
+ */
+bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen);
 
 
 #endif
diff --git a/content/content_protected.h b/content/content_protected.h
index be277a0..99a05cf 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -81,6 +81,7 @@ struct content_handler {
        content_type (*type)(void);
        void (*add_user)(struct content *c);
        void (*remove_user)(struct content *c);
+       bool (*exec)(struct content *c, const char *src, size_t srclen);
 
         /** handler dependant content sensitive internal data interface. */
        void * (*get_internal)(const struct content *c, void *context);


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

    Add SCRIPT to core domstrings
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index b2cbe87..ea8d7de 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -316,6 +316,7 @@ CORESTRING_DOM_STRING(SELECT);
 CORESTRING_DOM_STRING(TEXTAREA);
 CORESTRING_DOM_STRING(BODY);
 CORESTRING_DOM_STRING(HEAD);
+CORESTRING_DOM_STRING(SCRIPT);
 /* DOM input types, not really CSS */
 CORESTRING_DOM_STRING(button);
 CORESTRING_DOM_STRING(image);


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

Summary of changes:
 content/content.c                |   21 ++++++++++
 content/content.h                |   11 +++++
 content/content_protected.h      |    1 +
 content/handlers/html/html.c     |   85 ++++++++++++++++++++++++++++++++++++++
 desktop/browser.c                |   21 ++++++++++
 docs/using-monkey.md             |   12 +++++-
 frontends/monkey/browser.c       |   35 ++++++++++++++++
 include/netsurf/browser_window.h |   12 ++++++
 utils/corestringlist.h           |    1 +
 9 files changed, 197 insertions(+), 2 deletions(-)

diff --git a/content/content.c b/content/content.c
index 8697501..bb5c47b 100644
--- a/content/content.c
+++ b/content/content.c
@@ -545,6 +545,27 @@ void content__request_redraw(struct content *c,
        content_broadcast(c, CONTENT_MSG_REDRAW, &data);
 }
 
+/* exported interface, documented in content/content.h */
+bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen)
+{
+       struct content *c = hlcache_handle_get_content(h);
+       
+       assert(c != NULL);
+       
+       if (c->locked) {
+               /* Not safe to do stuff */
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, content locked");
+               return false;
+       }
+       
+       if (c->handler->exec == NULL) {
+               /* Can't exec something on this content */
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no exec function");
+               return false;
+       }
+       
+       return c->handler->exec(c, src, srclen);
+}
 
 /* exported interface, documented in content/content.h */
 bool content_redraw(hlcache_handle *h, struct content_redraw_data *data,
diff --git a/content/content.h b/content/content.h
index e555df2..77cc605 100644
--- a/content/content.h
+++ b/content/content.h
@@ -387,6 +387,17 @@ bool content_get_quirks(struct hlcache_handle *h);
 bool content_is_locked(struct hlcache_handle *h);
 
 
+/**
+ * Execute some JavaScript code inside a content object.
+ *
+ * Runs the passed in JavaScript code in the content object's context.
+ *
+ * \param h The handle to the content
+ * \param src The JavaScript source code
+ * \param srclen The length of the source code
+ * \return Whether the JS function was successfully injected into the content
+ */
+bool content_exec(struct hlcache_handle *h, const char *src, size_t srclen);
 
 
 #endif
diff --git a/content/content_protected.h b/content/content_protected.h
index be277a0..99a05cf 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -81,6 +81,7 @@ struct content_handler {
        content_type (*type)(void);
        void (*add_user)(struct content *c);
        void (*remove_user)(struct content *c);
+       bool (*exec)(struct content *c, const char *src, size_t srclen);
 
         /** handler dependant content sensitive internal data interface. */
        void * (*get_internal)(const struct content *c, void *context);
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index 9c60c7b..a47725b 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -2504,6 +2504,90 @@ bool html_get_id_offset(hlcache_handle *h, lwc_string 
*frag_id, int *x, int *y)
        return false;
 }
 
+static bool html_exec(struct content *c, const char *src, size_t srclen)
+{
+       html_content *htmlc = (html_content *)c;
+       bool result = false;
+       dom_exception err;
+       dom_html_body_element *body_node;
+       dom_string *dom_src;
+       dom_text *text_node;
+       dom_node *spare_node;
+       dom_html_script_element *script_node;
+       
+       if (htmlc->document == NULL) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no document");
+               goto out_no_string;
+       }
+
+       err = dom_string_create((const uint8_t *)src, srclen, &dom_src);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not create 
string");
+               goto out_no_string;
+       }
+
+       err = dom_html_document_get_body(htmlc->document, &body_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to retrieve body element");
+               goto out_no_body;
+       }
+       
+       err = dom_document_create_text_node(htmlc->document, dom_src, 
&text_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not create 
text node");
+               goto out_no_text_node;
+       }
+       
+       err = dom_document_create_element(htmlc->document, 
corestring_dom_SCRIPT, &script_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not create 
script node");
+               goto out_no_script_node;
+       }
+       
+       err = dom_node_append_child(script_node, text_node, &spare_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not insert 
code node into script node");
+               goto out_unparented;
+       }
+       dom_node_unref(spare_node); /* We do not need the spare ref at all */
+       
+       err = dom_node_append_child(body_node, script_node, &spare_node);
+       if (err != DOM_NO_ERR) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, could not insert 
script node into document body");
+               goto out_unparented;
+       }
+       dom_node_unref(spare_node); /* Again no need for the spare ref */
+       
+       /* We successfully inserted the node into the DOM */
+       
+       result = true;
+       
+       /* Now we unwind, starting by removing the script from wherever it
+        * ended up parented
+        */
+       
+       err = dom_node_get_parent_node(script_node, &spare_node);
+       if (err == DOM_NO_ERR && spare_node != NULL) {
+               dom_node *second_spare;
+               err = dom_node_remove_child(spare_node, script_node, 
&second_spare);
+               if (err == DOM_NO_ERR) {
+                       dom_node_unref(second_spare);
+               }
+               dom_node_unref(spare_node);
+       }
+
+out_unparented:
+       dom_node_unref(script_node);
+out_no_script_node:
+       dom_node_unref(text_node);
+out_no_text_node:
+       dom_node_unref(body_node);
+out_no_body:
+       dom_string_unref(dom_src);
+out_no_string:
+       return result;
+}
+
 /**
  * Compute the type of a content
  *
@@ -2546,6 +2630,7 @@ static const content_handler html_content_handler = {
        .clone = html_clone,
        .get_encoding = html_encoding,
        .type = html_content_type,
+       .exec = html_exec,
        .no_share = true,
 };
 
diff --git a/desktop/browser.c b/desktop/browser.c
index 1c8aa95..d26abd0 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -3406,3 +3406,24 @@ int browser_get_dpi(void)
 {
        return FIXTOINT(nscss_screen_dpi);
 }
+
+/* exported interface documented in browser.h */
+bool browser_window_exec(struct browser_window *bw, const char *src, size_t 
srclen)
+{
+       assert(bw != NULL);
+
+       if (!bw->current_content) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, no content");
+               return false;
+       }
+
+       if (content_get_status(bw->current_content) != CONTENT_STATUS_DONE) {
+               NSLOG(netsurf, DEEPDEBUG, "Unable to exec, content not done");
+               return false;
+       }
+
+       /* Okay it should be safe, forward the request through to the content
+        * itself.  Only HTML contents currently support executing code
+        */
+       return content_exec(bw->current_content, src, srclen);
+}
diff --git a/docs/using-monkey.md b/docs/using-monkey.md
index 1d0a96b..8d051cf 100644
--- a/docs/using-monkey.md
+++ b/docs/using-monkey.md
@@ -130,14 +130,22 @@ Commands
     Cause a browser window to reload its current content.
     Expect responses similar to a GO command.
 
+*   `WINDOW EXEC WIN` _%id%_ _%str%_
+
+    Cause a browser window to execute some javascript.  It won't
+    work if the window doesn't have a *finished* HTML content.
+
+    This will send a `WINDOW JS WIN` _%id%_ `RET` `TRUE`/`FALSE`
+    where `FALSE` indicates that some issue prevented the injection of
+    the script.
 
 ### Login commands
 
-*   `LOGIN USERNAME` _%id%_ _%str_
+*   `LOGIN USERNAME` _%id%_ _%str%_
 
     Set the username for the login
 
-*   `LOGIN PASSWORD` _%id%_ _%str_
+*   `LOGIN PASSWORD` _%id%_ _%str%_
 
     Set the password for the login
 
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index 69459fb..50b586f 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -500,6 +500,39 @@ monkey_window_handle_reload(int argc, char **argv)
        }
 }
 
+static void
+monkey_window_handle_exec(int argc, char **argv)
+{
+       struct gui_window *gw;
+       if (argc < 5) {
+               moutf(MOUT_ERROR, "WINDOW EXEC ARGS BAD\n");
+       }
+
+       gw = monkey_find_window_by_num(atoi(argv[2]));
+
+       if (gw == NULL) {
+               moutf(MOUT_ERROR, "WINDOW NUM BAD");
+       } else {
+               /* Gather argv[4] onward into a string to pass to js_exec */
+               int total = 0;
+               for (int i = 4; i < argc; ++i) {
+                       total += strlen(argv[i]) + 1;
+               }
+               char *cmd = calloc(total, 1);
+               strcpy(cmd, argv[4]);
+               for (int i = 5; i < argc; ++i) {
+                       strcat(cmd, " ");
+                       strcat(cmd, argv[i]);
+               }
+               /* Now execute the JS */
+
+               moutf(MOUT_WINDOW, "JS WIN %d RET %s", atoi(argv[2]),
+                     browser_window_exec(gw->bw, cmd, total - 1) ? "TRUE" : 
"FALSE");
+
+               free(cmd);
+       }
+}
+
 
 void
 monkey_window_handle_command(int argc, char **argv)
@@ -517,6 +550,8 @@ monkey_window_handle_command(int argc, char **argv)
                monkey_window_handle_redraw(argc, argv);
        } else if (strcmp(argv[1], "RELOAD") == 0) {
                monkey_window_handle_reload(argc, argv);
+       } else if (strcmp(argv[1], "EXEC") == 0) {
+               monkey_window_handle_exec(argc, argv);
        } else {
                moutf(MOUT_ERROR, "WINDOW COMMAND UNKNOWN %s\n", argv[1]);
        }
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index 439b078..77a2631 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -725,4 +725,16 @@ nserror browser_window_get_name(struct browser_window *bw, 
const char **name);
  */
 nserror browser_window_set_name(struct browser_window *bw, const char *name);
 
+/**
+ * Execute some JavaScript code in a browsing context.
+ *
+ * Runs the passed in JavaScript code in the browsing context.
+ *
+ * \param bw The browser window
+ * \param src The JavaScript source code
+ * \param srclen The length of the source code
+ * \return Whether the JS function was successfully injected into the content
+ */
+bool browser_window_exec(struct browser_window *bw, const char *src, size_t 
srclen);
+
 #endif
diff --git a/utils/corestringlist.h b/utils/corestringlist.h
index b2cbe87..ea8d7de 100644
--- a/utils/corestringlist.h
+++ b/utils/corestringlist.h
@@ -316,6 +316,7 @@ CORESTRING_DOM_STRING(SELECT);
 CORESTRING_DOM_STRING(TEXTAREA);
 CORESTRING_DOM_STRING(BODY);
 CORESTRING_DOM_STRING(HEAD);
+CORESTRING_DOM_STRING(SCRIPT);
 /* DOM input types, not really CSS */
 CORESTRING_DOM_STRING(button);
 CORESTRING_DOM_STRING(image);


-- 
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