summaryrefslogtreecommitdiff
path: root/javascript/dukky.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-08-09 18:54:37 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-08-09 18:54:37 +0100
commit0df3439eb26914466b91ce529e7f3366094030d6 (patch)
tree9a8a8011efff300ad46f994718304b646bac62e9 /javascript/dukky.c
parent3d7de6cf8d67bd7761a907cb171d8a4af8088a08 (diff)
downloadnetsurf-0df3439eb26914466b91ce529e7f3366094030d6.tar.gz
netsurf-0df3439eb26914466b91ce529e7f3366094030d6.tar.bz2
Fix constructor injection to use new constructor type, add test
Diffstat (limited to 'javascript/dukky.c')
-rw-r--r--javascript/dukky.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/javascript/dukky.c b/javascript/dukky.c
index 8f69d23c8..6c8c531fe 100644
--- a/javascript/dukky.c
+++ b/javascript/dukky.c
@@ -247,7 +247,27 @@ dukky_push_node(duk_context *ctx, struct dom_node *node)
return dukky_push_node_stacked(ctx);
}
+static duk_ret_t
+dukky_bad_constructor(duk_context *ctx)
+{
+ duk_error(ctx, DUK_ERR_ERROR, "Bad constructor");
+ return 0;
+}
+void
+dukky_inject_not_ctr(duk_context *ctx, int idx, const char *name)
+{
+ /* ... p[idx] ... proto */
+ duk_push_c_function(ctx, dukky_bad_constructor, 0);
+ /* ... p[idx] ... proto cons */
+ duk_insert(ctx, -2);
+ /* ... p[idx] ... cons proto */
+ duk_put_prop_string(ctx, -2, "prototype");
+ /* ... p[idx] ... cons[proto] */
+ duk_put_prop_string(ctx, idx, name);
+ /* ... p ... */
+ return;
+}
/**************************************** js.h ******************************/
struct jscontext {