diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2019-08-01 21:40:54 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2019-08-01 21:40:54 +0100 |
commit | f365e75407bc9964c09613f80de0b64eb6055975 (patch) | |
tree | ae52154354474999b9e4fabbf6304fdeec3efb15 /content/handlers/javascript/duktape/dukky.c | |
parent | bb3e0e51f1cbae2134b7891c44a24bccc2f7f255 (diff) | |
download | netsurf-f365e75407bc9964c09613f80de0b64eb6055975.tar.gz netsurf-f365e75407bc9964c09613f80de0b64eb6055975.tar.bz2 |
Dukky: Support console logging better
Add a polyfill for Array.from(), and fix the console formatter so that
it won't keep exploding. This should improve matters in the tests.
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.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index 491c5c276..cd3549e93 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -39,6 +39,7 @@ #include "duktape/binding.h" #include "duktape/generics.js.inc" +#include "duktape/polyfill.js.inc" #include "duktape.h" #include "dukky.h" @@ -681,6 +682,25 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv) duk_push_object(CTX); duk_put_global_string(CTX, EVENT_MAGIC); + /* Now load the polyfills */ + /* ... */ + duk_push_string(CTX, "polyfill.js"); + /* ..., polyfill.js */ + if (duk_pcompile_lstring_filename(CTX, DUK_COMPILE_EVAL, + (const char *)polyfill_js, polyfill_js_len) != 0) { + NSLOG(dukky, CRITICAL, "%s", duk_safe_to_string(CTX, -1)); + NSLOG(dukky, CRITICAL, "Unable to compile polyfill.js, compartment aborted"); + return NULL; + } + /* ..., (generics.js) */ + if (dukky_pcall(CTX, 0, true) != 0) { + NSLOG(dukky, CRITICAL, "Unable to run polyfill.js, compartment aborted"); + return NULL; + } + /* ..., result */ + duk_pop(CTX); + /* ... */ + /* Now load the NetSurf table in */ /* ... */ duk_push_string(CTX, "generics.js"); |