Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/c98b7d3ad46eb3b7c4f3691391668e89c222a0a0
...commit
http://git.netsurf-browser.org/netsurf.git/commit/c98b7d3ad46eb3b7c4f3691391668e89c222a0a0
...tree
http://git.netsurf-browser.org/netsurf.git/tree/c98b7d3ad46eb3b7c4f3691391668e89c222a0a0
The branch, dsilvers/eventtarget has been updated
discards 0a71be2d486f4911cd5f84f59b0134b39c945925 (commit)
discards e92298ab273128516d52def52adbe6f7a5da2063 (commit)
discards 3691a643bf9e964a7f4d621a4a26a06dcd08a482 (commit)
discards 512b568c24f3fdadd38e9a7874489729acde9055 (commit)
via c98b7d3ad46eb3b7c4f3691391668e89c222a0a0 (commit)
via c14b5a3c9227e588e48da38d3862a7d6d40f5a35 (commit)
via e4a339f82a72b055c027f42a9f8e5e0a5e47ec71 (commit)
via ed3bef9ac2ade3adb3d281a245f9591e74a3c082 (commit)
via 51062e55b00b8b307d9f45cb150dcefa4d710cfc (commit)
via 4b3f2bb946ad201f99a20ddaff980ecea05e5ebc (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (0a71be2d486f4911cd5f84f59b0134b39c945925)
\
N -- N -- N (c98b7d3ad46eb3b7c4f3691391668e89c222a0a0)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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=c98b7d3ad46eb3b7c4f3691391668e89c222a0a0
commit c98b7d3ad46eb3b7c4f3691391668e89c222a0a0
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Record that we have implemented EventTarget
diff --git a/Docs/UnimplementedJavascript.txt b/Docs/UnimplementedJavascript.txt
index 2b3a7d9..1b851b8 100644
--- a/Docs/UnimplementedJavascript.txt
+++ b/Docs/UnimplementedJavascript.txt
@@ -439,9 +439,6 @@ setter EventSource::onopen(user);\n
getter EventSource::readyState(unsigned short);\n
getter EventSource::url(string);\n
getter EventSource::withCredentials(boolean);\n
-method EventTarget::addEventListener();\n
-method EventTarget::dispatchEvent();\n
-method EventTarget::removeEventListener();\n
getter Event::timeStamp(user);\n
method External::AddSearchProvider();\n
method External::IsSearchProviderInstalled();\n
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c14b5a3c9227e588e48da38d3862a7d6d40f5a35
commit c14b5a3c9227e588e48da38d3862a7d6d40f5a35
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Add dom change event test
diff --git a/test/js/dom-change-event.html b/test/js/dom-change-event.html
new file mode 100644
index 0000000..a6d77b8
--- /dev/null
+++ b/test/js/dom-change-event.html
@@ -0,0 +1,17 @@
+<html>
+ <head>
+ <title>DOM Change event handling</title>
+ <script type="text/javascript">
+ document.addEventListener("DOMNodeInserted",
+ function(ev) {
+ console.log("\n\nHELLO WORLD!\n\n");
+ console.log(ev);
+ console.log("\n\n");
+ }, false);
+ console.log("Moooo!");
+ </script>
+ </head>
+ <body>
+ <div>I got inserted</div>
+ </body>
+</html>
diff --git a/test/js/index.html b/test/js/index.html
index f282ca4..2abe954 100644
--- a/test/js/index.html
+++ b/test/js/index.html
@@ -90,6 +90,7 @@
<li><a href="event-onload.html">window.onload</a></li>
<li><a href="event-onloadfrombody.html">body.onload</a></li>
<li><a href="event-onclick.html">button.onclick</a></li>
+<li><a href="dom-change-event.html">DOMNodeInserted</a></li>
</ul>
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=e4a339f82a72b055c027f42a9f8e5e0a5e47ec71
commit e4a339f82a72b055c027f42a9f8e5e0a5e47ec71
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
rework: Add EventTarget binding
diff --git a/content/handlers/javascript/duktape/EventTarget.bnd
b/content/handlers/javascript/duktape/EventTarget.bnd
new file mode 100644
index 0000000..4e168b9
--- /dev/null
+++ b/content/handlers/javascript/duktape/EventTarget.bnd
@@ -0,0 +1,277 @@
+/* Event Target binding for browser using duktape and libdom
+ *
+ * Copyright 2016 Daniel Silverstone <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+class EventTarget {
+ private bool is_node;
+ private bool capture_registered;
+ private bool bubbling_registered;
+};
+
+prologue EventTarget()
+%{
+
+static event_listener_flags event_listener_pop_options(duk_context *ctx)
+{
+ event_listener_flags ret = ELF_NONE;
+ /* ... options */
+ duk_get_prop_string(ctx, -1, "capture");
+ if (duk_to_boolean(ctx, -1))
+ ret |= ELF_CAPTURE;
+ duk_pop(ctx);
+ duk_get_prop_string(ctx, -1, "passive");
+ if (duk_to_boolean(ctx, -1))
+ ret |= ELF_PASSIVE;
+ duk_pop(ctx);
+ duk_get_prop_string(ctx, -1, "once");
+ if (duk_to_boolean(ctx, -1))
+ ret |= ELF_CAPTURE;
+ duk_pop_2(ctx);
+ /* ... */
+ return ret;
+}
+
+static void event_target_register_listener(duk_context *ctx,
+ event_listener_flags flags)
+{
+ /* ... listeners callback */
+ /* If the given callback with the given flags is already present,
+ * we do not re-add it, otherwise we need to add to listeners
+ * a tuple of the callback and flags
+ */
+ duk_uarridx_t idx = 0;
+ while (duk_get_prop_index(ctx, -1, idx)) {
+ /* ... listeners callback candidate */
+ duk_get_prop_index(ctx, -1, 0);
+ duk_get_prop_index(ctx, -2, 1);
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ if (duk_strict_equals(ctx, -1, -3) &&
+ duk_get_int(ctx, -1) == (duk_int_t)flags) {
+ /* already present, nothing to do */
+ duk_pop_n(ctx, 5);
+ /* ... */
+ return;
+ }
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ duk_pop_3(ctx);
+ /* ... listeners callback */
+ idx++;
+ }
+ /* ... listeners callback undefined */
+ duk_pop(ctx);
+ /* ... listeners callback */
+ duk_push_array(ctx);
+ /* ... listeners callback newcandidate */
+ duk_insert(ctx, -2);
+ /* ... listeners newcandidate callback */
+ duk_put_prop_index(ctx, -2, 0);
+ /* ... listeners newcandidate */
+ duk_push_int(ctx, (duk_int_t)flags);
+ /* ... listeners newcandidate flags */
+ duk_put_prop_index(ctx, -2, 1);
+ /* ... listeners newcandidate */
+ duk_put_prop_index(ctx, -2, idx);
+ /* ... listeners */
+ duk_pop(ctx);
+ /* ... */
+}
+
+static void event_target_unregister_listener(duk_context *ctx,
+ event_listener_flags flags)
+{
+ /* ... listeners callback */
+ /* If the given callback with the given flags is present,
+ * we remove it and shuffle the rest up.
+ */
+ duk_uarridx_t idx = 0;
+ while (duk_get_prop_index(ctx, -1, idx)) {
+ /* ... listeners callback candidate */
+ duk_get_prop_index(ctx, -1, 0);
+ duk_get_prop_index(ctx, -2, 1);
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ if (duk_strict_equals(ctx, -1, -3) &&
+ duk_get_int(ctx, -1) == (duk_int_t)flags) {
+ /* present */
+ duk_pop(ctx);
+ /* ... listeners callback candidate candidatecallback */
+ duk_put_prop_index(ctx, -2, 2);
+ /* ... listeners callback candidate */
+ duk_pop(ctx);
+ /* ... listeners callback */
+ duk_push_int(ctx, idx);
+ /* ... listeners callback found_at */
+ break;
+ }
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ duk_pop_3(ctx);
+ /* ... listeners callback */
+ idx++;
+ }
+ /* ... listeners callback undefined/found_at */
+ if (duk_is_undefined(ctx, -1)) {
+ /* not found, clean up and come out */
+ duk_pop_3(ctx);
+ return;
+ }
+ idx = duk_to_int(ctx, -1);
+ duk_pop_2(ctx);
+ /* ... listeners */
+ dukky_shuffle_array(ctx, idx);
+ /* ... listeners */
+ duk_pop(ctx);
+ /* ... */
+}
+
+
+%}
+
+init EventTarget()
+%{
+ priv->is_node = false;
+ priv->capture_registered = false;
+ priv->bubbling_registered = false;
+%}
+
+method EventTarget::addEventListener()
+%{
+ dom_exception exc;
+ event_listener_flags flags = ELF_NONE;
+ /* Incoming stack is: type callback [options] */
+ if (duk_get_top(ctx) < 2) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) > 3) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) == 2) {
+ duk_push_object(ctx);
+ /* type callback options */
+ }
+ if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT) {
+ /* legacy support, if not object, it's the capture value */
+ duk_push_object(ctx);
+ /* ... capture options */
+ duk_insert(ctx, -2);
+ /* ... options capture */
+ duk_put_prop_string(ctx, -2, "capture");
+ /* ... options */
+ }
+ /* type callback options */
+ flags = event_listener_pop_options(ctx);
+ /* type callback */
+ duk_dup(ctx, -2);
+ /* type callback type */
+ duk_push_this(ctx);
+ /* type callback type this(=EventTarget) */
+ if (dukky_event_target_push_listeners(ctx, false) && priv->is_node) {
+ /* Take a moment to register a JS callback */
+ duk_size_t ev_ty_l;
+ const char *ev_ty = duk_to_lstring(ctx, -3, &ev_ty_l);
+ dom_string *ev_ty_s;
+ exc = dom_string_create((const uint8_t*)ev_ty, ev_ty_l,
+ &ev_ty_s);
+ if (exc != DOM_NO_ERR) {
+ LOG("Oh dear, failed to create dom_string in
addEventListener()");
+ return 0;
+ }
+ dukky_register_event_listener_for(
+ ctx, (dom_element *)((node_private_t *)priv)->node,
+ ev_ty_s,
+ !!(flags & ELF_CAPTURE));
+ dom_string_unref(ev_ty_s);
+ }
+ /* type callback typelisteners */
+ duk_insert(ctx, -2);
+ /* type typelisteners callback */
+ event_target_register_listener(ctx, flags);
+ /* type */
+ return 0;
+%}
+
+method EventTarget::removeEventListener()
+%{
+ event_listener_flags flags = ELF_NONE;
+ /* Incoming stack is: type callback [options] */
+ if (duk_get_top(ctx) < 2) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) > 3) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) == 2) {
+ duk_push_object(ctx);
+ /* type callback options */
+ }
+ if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT) {
+ /* legacy support, if not object, it's the capture value */
+ duk_push_object(ctx);
+ /* ... capture options */
+ duk_insert(ctx, -2);
+ /* ... options capture */
+ duk_put_prop_string(ctx, -2, "capture");
+ /* ... options */
+ }
+ /* type callback options */
+ flags = event_listener_pop_options(ctx);
+ /* type callback */
+ duk_dup(ctx, -2);
+ /* type callback type */
+ duk_push_this(ctx);
+ /* type callback type this(=EventTarget) */
+ if (dukky_event_target_push_listeners(ctx, true)) {
+ /* nothing to do because the listener wasn't there at all */
+ duk_pop_3(ctx);
+ return 0;
+ }
+ /* type callback typelisteners */
+ duk_insert(ctx, -2);
+ /* type typelisteners callback */
+ event_target_unregister_listener(ctx, flags);
+ /* type */
+ return 0;
+%}
+
+
+
+method EventTarget::dispatchEvent()
+%{
+ dom_exception exc;
+ if (!dukky_instanceof(ctx, 0, PROTO_NAME(EVENT))) return 0;
+
+ duk_get_prop_string(ctx, 0, PRIVATE_MAGIC);
+ event_private_t *evpriv = duk_get_pointer(ctx, -1);
+ duk_pop(ctx);
+
+ dom_event *evt = evpriv->evt;
+
+ /* Dispatch event logic, see:
+ * https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
+ */
+ bool in_dispatch;
+ if (dom_event_in_dispatch(evt, &in_dispatch) != DOM_NO_ERR) return 0;
+ if (in_dispatch) {
+ /** \todo Raise InvalidStateException */
+ return 0;
+ }
+
+ bool is_initialised;
+ if (dom_event_is_initialised(evt, &is_initialised) != DOM_NO_ERR)
return 0;
+ if (is_initialised == false) {
+ /** \todo Raise InvalidStateException */
+ return 0;
+ }
+
+ if (dom_event_set_is_trusted(evt, false) != DOM_NO_ERR) return 0;
+
+ /** \todo work out how to dispatch against non-node things */
+ if (priv->is_node == false) return 0;
+
+ bool success;
+ /* Event prepared, dispatch against ourselves */
+ exc = dom_event_target_dispatch_event(
+ ((node_private_t *)priv)->node,
+ evt,
+ &success);
+ if (exc != DOM_NO_ERR) return 0; /**< \todo raise correct exception */
+
+ duk_push_boolean(ctx, success);
+ return 1;
+%}
diff --git a/content/handlers/javascript/duktape/Node.bnd
b/content/handlers/javascript/duktape/Node.bnd
index f237c87..f14cfc1 100644
--- a/content/handlers/javascript/duktape/Node.bnd
+++ b/content/handlers/javascript/duktape/Node.bnd
@@ -16,6 +16,7 @@ init Node(struct dom_node *node)
%{
priv->node = node;
dom_node_ref(node);
+ priv->parent.is_node = true;
%}
fini Node()
diff --git a/content/handlers/javascript/duktape/netsurf.bnd
b/content/handlers/javascript/duktape/netsurf.bnd
index 4aca475..2a56ccc 100644
--- a/content/handlers/javascript/duktape/netsurf.bnd
+++ b/content/handlers/javascript/duktape/netsurf.bnd
@@ -54,6 +54,7 @@ struct dom_html_br_element;
};
+#include "EventTarget.bnd"
#include "Console.bnd"
#include "Window.bnd"
#include "Document.bnd"
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=ed3bef9ac2ade3adb3d281a245f9591e74a3c082
commit ed3bef9ac2ade3adb3d281a245f9591e74a3c082
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
rework: Add the support for event target handlers to dukky
diff --git a/content/handlers/javascript/duktape/dukky.c
b/content/handlers/javascript/duktape/dukky.c
index 66d1b05..4a6b9c3 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -46,6 +46,7 @@
#define EVENT_MAGIC MAGIC(EVENT_MAP)
#define HANDLER_LISTENER_MAGIC MAGIC(HANDLER_LISTENER_MAP)
#define HANDLER_MAGIC MAGIC(HANDLER_MAP)
+#define EVENT_LISTENER_JS_MAGIC MAGIC(EVENT_LISTENER_JS_MAP)
static duk_ret_t dukky_populate_object(duk_context *ctx)
{
@@ -809,6 +810,8 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
dom_exception exc;
dom_event_target *targ;
dom_event_flow_phase phase;
+ duk_uarridx_t idx;
+ event_listener_flags flags;
/* Retrieve the JS context from the Duktape context */
duk_get_memory_functions(ctx, &funcs);
@@ -840,6 +843,12 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
return;
}
+ /* If we're capturing right now, we skip the 'event handler'
+ * and go straight to the extras
+ */
+ if (phase == DOM_CAPTURING_PHASE)
+ goto handle_extras;
+
/* ... */
if (dukky_push_node(ctx, (dom_node *)targ) == false) {
dom_string_unref(name);
@@ -850,13 +859,9 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
/* ... node */
if (dukky_get_current_value_of_event_handler(
ctx, name, (dom_event_target *)targ) == false) {
- dom_node_unref(targ);
- dom_string_unref(name);
- return;
+ /* ... */
+ goto handle_extras;
}
- /** @todo handle other kinds of event than the generic case */
- dom_node_unref(targ);
- dom_string_unref(name);
/* ... handler node */
dukky_push_event(ctx, evt);
/* ... handler node event */
@@ -882,7 +887,7 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
duk_pop_n(ctx, 6);
/* ... */
- return;
+ goto handle_extras;
}
/* ... result */
if (duk_is_boolean(ctx, -1) &&
@@ -890,7 +895,107 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
dom_event_prevent_default(evt);
}
duk_pop(ctx);
+handle_extras:
/* ... */
+ duk_push_lstring(ctx, dom_string_data(name), dom_string_length(name));
+ dukky_push_node(ctx, (dom_node *)targ);
+ /* ... type node */
+ if (dukky_event_target_push_listeners(ctx, true)) {
+ /* Nothing to do */
+ duk_pop(ctx);
+ goto out;
+ }
+ /* ... sublisteners */
+ duk_push_array(ctx);
+ /* ... sublisteners copy */
+ idx = 0;
+ while (duk_get_prop_index(ctx, -2, idx)) {
+ /* ... sublisteners copy handler */
+ duk_get_prop_index(ctx, -1, 1);
+ /* ... sublisteners copy handler flags */
+ if ((event_listener_flags)duk_to_int(ctx, -1) & ELF_ONCE) {
+ duk_dup(ctx, -4);
+ /* ... subl copy handler flags subl */
+ dukky_shuffle_array(ctx, idx);
+ duk_pop(ctx);
+ /* ... subl copy handler flags */
+ }
+ duk_pop(ctx);
+ /* ... sublisteners copy handler */
+ duk_put_prop_index(ctx, -2, idx);
+ /* ... sublisteners copy */
+ idx++;
+ }
+ /* ... sublisteners copy undefined */
+ duk_pop(ctx);
+ /* ... sublisteners copy */
+ duk_insert(ctx, -2);
+ /* ... copy sublisteners */
+ duk_pop(ctx);
+ /* ... copy */
+ idx = 0;
+ while (duk_get_prop_index(ctx, -1, idx++)) {
+ /* ... copy handler */
+ if (duk_get_prop_index(ctx, -1, 2)) {
+ /* ... copy handler meh */
+ duk_pop_2(ctx);
+ continue;
+ }
+ duk_pop(ctx);
+ duk_get_prop_index(ctx, -1, 0);
+ duk_get_prop_index(ctx, -2, 1);
+ /* ... copy handler callback flags */
+ flags = (event_listener_flags)duk_get_int(ctx, -1);
+ duk_pop(ctx);
+ /* ... copy handler callback */
+ if (((phase == DOM_CAPTURING_PHASE) && !(flags & ELF_CAPTURE))
||
+ ((phase != DOM_CAPTURING_PHASE) && (flags & ELF_CAPTURE))) {
+ duk_pop_2(ctx);
+ /* ... copy */
+ continue;
+ }
+ /* ... copy handler callback */
+ dukky_push_node(ctx, (dom_node *)targ);
+ /* ... copy handler callback node */
+ dukky_push_event(ctx, evt);
+ /* ... copy handler callback node event */
+ (void) nsu_getmonotonic_ms(&jsctx->exec_start_time);
+ if (duk_pcall_method(ctx, 1) != 0) {
+ /* Failed to run the method */
+ /* ... copy handler err */
+ LOG("OH NOES! An error running a callback. Meh.");
+ exc = dom_event_stop_immediate_propagation(evt);
+ if (exc != DOM_NO_ERR)
+ LOG("WORSE! could not stop propagation");
+ duk_get_prop_string(ctx, -1, "name");
+ duk_get_prop_string(ctx, -2, "message");
+ duk_get_prop_string(ctx, -3, "fileName");
+ duk_get_prop_string(ctx, -4, "lineNumber");
+ duk_get_prop_string(ctx, -5, "stack");
+ /* ... err name message fileName lineNumber stack */
+ LOG("Uncaught error in JS: %s: %s",
duk_safe_to_string(ctx, -5),
+ duk_safe_to_string(ctx, -4));
+ LOG(" was at: %s line %s",
duk_safe_to_string(ctx, -3),
+ duk_safe_to_string(ctx, -2));
+ LOG(" Stack trace: %s", duk_safe_to_string(ctx,
-1));
+
+ duk_pop_n(ctx, 7);
+ /* ... copy */
+ continue;
+ }
+ /* ... copy handler result */
+ if (duk_is_boolean(ctx, -1) &&
+ duk_to_boolean(ctx, -1) == 0) {
+ dom_event_prevent_default(evt);
+ }
+ duk_pop_2(ctx);
+ /* ... copy */
+ }
+ duk_pop_2(ctx);
+out:
+ /* ... */
+ dom_node_unref(targ);
+ dom_string_unref(name);
}
void dukky_register_event_listener_for(duk_context *ctx,
@@ -939,6 +1044,71 @@ void dukky_register_event_listener_for(duk_context *ctx,
dom_event_listener_unref(listen);
}
+/* The sub-listeners are a list of {callback,flags} tuples */
+/* We return true if we created a new sublistener table */
+/* If we're told to not create, but we want to, we still return true */
+bool dukky_event_target_push_listeners(duk_context *ctx, bool dont_create)
+{
+ bool ret = false;
+ /* ... type this */
+ duk_get_prop_string(ctx, -1, EVENT_LISTENER_JS_MAGIC);
+ if (duk_is_undefined(ctx, -1)) {
+ /* ... type this null */
+ duk_pop(ctx);
+ duk_push_object(ctx);
+ duk_dup(ctx, -1);
+ /* ... type this listeners listeners */
+ duk_put_prop_string(ctx, -3, EVENT_LISTENER_JS_MAGIC);
+ /* ... type this listeners */
+ }
+ /* ... type this listeners */
+ duk_insert(ctx, -3);
+ /* ... listeners type this */
+ duk_pop(ctx);
+ /* ... listeners type */
+ duk_dup(ctx, -1);
+ /* ... listeners type type */
+ duk_get_prop(ctx, -3);
+ /* ... listeners type ??? */
+ if (duk_is_undefined(ctx, -1)) {
+ /* ... listeners type ??? */
+ if (dont_create == true) {
+ duk_pop_3(ctx);
+ duk_push_undefined(ctx);
+ return true;
+ }
+ duk_pop(ctx);
+ duk_push_array(ctx);
+ duk_dup(ctx, -2);
+ duk_dup(ctx, -2);
+ /* ... listeners type sublisteners type sublisteners */
+ duk_put_prop(ctx, -5);
+ /* ... listeners type sublisteners */
+ ret = true;
+ }
+ duk_insert(ctx, -3);
+ /* ... sublisteners listeners type */
+ duk_pop_2(ctx);
+ /* ... sublisteners */
+ return ret;
+}
+
+/* Shuffle a duktape array "down" one. This involves iterating from
+ * the index provided, shuffling elements down, until we reach an
+ * undefined
+ */
+void dukky_shuffle_array(duk_context *ctx, duk_uarridx_t idx)
+{
+ /* ... somearr */
+ while (duk_get_prop_index(ctx, -1, idx + 1)) {
+ duk_put_prop_index(ctx, -2, idx);
+ idx++;
+ }
+ /* ... somearr undefined */
+ duk_del_prop_index(ctx, -2, idx + 1);
+ duk_pop(ctx);
+}
+
void js_handle_new_element(jscontext *ctx, struct dom_element *node)
{
diff --git a/content/handlers/javascript/duktape/dukky.h
b/content/handlers/javascript/duktape/dukky.h
index 1d6baee..b5809aa 100644
--- a/content/handlers/javascript/duktape/dukky.h
+++ b/content/handlers/javascript/duktape/dukky.h
@@ -42,5 +42,15 @@ void dukky_register_event_listener_for(duk_context *ctx,
bool dukky_get_current_value_of_event_handler(duk_context *ctx,
dom_string *name,
dom_event_target *et);
+bool dukky_event_target_push_listeners(duk_context *ctx, bool dont_create);
+
+typedef enum {
+ ELF_CAPTURE = 1 << 0,
+ ELF_PASSIVE = 1 << 1,
+ ELF_ONCE = 1 << 2,
+ ELF_NONE = 0
+} event_listener_flags;
+
+void dukky_shuffle_array(duk_context *ctx, duk_uarridx_t idx);
#endif
-----------------------------------------------------------------------
Summary of changes:
test/Makefile | 10 +++++-----
test/hashtable.c | 7 +++++++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index fd54fb9..d5e9d00 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -13,13 +13,13 @@ TESTS := \
time #llcache
# nsurl sources
-nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
+nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c utils/punycode.c \
test/log.c test/nsurl.c
# url database test sources
urldbtest_SRCS := content/urldb.c \
utils/idna.c utils/bloom.c utils/nsoption.c utils/nsurl.c \
- utils/corestrings.c \
+ utils/corestrings.c utils/punycode.c \
utils/hashtable.c utils/messages.c utils/time.c utils/utils.c \
test/log.c test/urldbtest.c
@@ -51,7 +51,7 @@ urlescape_SRCS := utils/url.c test/log.c test/urlescape.c
# utility test sources
utils_SRCS := utils/utils.c utils/messages.c utils/hashtable.c \
- utils/corestrings.c utils/nsurl.c utils/idna.c \
+ utils/corestrings.c utils/nsurl.c utils/idna.c utils/punycode.c
\
test/log.c test/utils.c
# time test sources
@@ -113,11 +113,11 @@ TESTCFLAGS := -std=c99 -g \
-D_XOPEN_SOURCE=600 \
-Itest -Iinclude -Icontent/handlers -Ifrontends -I. -I.. \
-Dnsgtk \
- $(shell pkg-config --cflags libcurl libparserutils libwapcaplet
libdom libnsutils libutf8proc libidn) \
+ $(shell pkg-config --cflags libcurl libparserutils libwapcaplet
libdom libnsutils libutf8proc) \
$(LIB_CFLAGS) \
$(COV_CFLAGS)
-TESTLDFLAGS := $(shell pkg-config --libs libcurl libparserutils libwapcaplet
libdom libnsutils libutf8proc libidn) -lz \
+TESTLDFLAGS := $(shell pkg-config --libs libcurl libparserutils libwapcaplet
libdom libnsutils libutf8proc) -lz \
$(LIB_LDFLAGS)\
$(COV_LDFLAGS)
diff --git a/test/hashtable.c b/test/hashtable.c
index 9f46e4c..11c58c6 100644
--- a/test/hashtable.c
+++ b/test/hashtable.c
@@ -32,6 +32,9 @@
#include "utils/hashtable.h"
+/* Limit for hash table tests which use /usr/share/dict/words */
+#define DICT_TEST_WORD_COUNT 100000
+
#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
struct test_pairs {
@@ -91,6 +94,7 @@ static void dict_hashtable_create(int dict_hash_size)
{
FILE *dictf;
char keybuf[BUFSIZ], valbuf[BUFSIZ];
+ uint32_t counter = 0;
dictf = fopen("/usr/share/dict/words", "r");
ck_assert(dictf != NULL);
@@ -102,6 +106,7 @@ static void dict_hashtable_create(int dict_hash_size)
fscanf(dictf, "%s", keybuf);
fscanf(dictf, "%s", valbuf);
hash_add(dict_hash, keybuf, valbuf);
+ if (counter++ > DICT_TEST_WORD_COUNT) break;
}
fclose(dictf);
@@ -227,6 +232,7 @@ START_TEST(hashtable_dict_test)
FILE *dictf;
char keybuf[BUFSIZ], valbuf[BUFSIZ];
const char *res;
+ uint32_t counter = 0;
dictf = fopen("/usr/share/dict/words", "r");
ck_assert(dictf != NULL);
@@ -238,6 +244,7 @@ START_TEST(hashtable_dict_test)
res = hash_get(dict_hash, keybuf);
ck_assert(res != NULL);
ck_assert_str_eq(res, valbuf);
+ if (counter++ > DICT_TEST_WORD_COUNT) break;
}
fclose(dictf);
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org