From ac3608bda09e2bebba7bf8722b7168c048d33008 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 19 May 2007 20:54:08 +0200 Subject: [PATCH] ECMAScript: evaluating onclick, onsubmit etc. done in the right way. Scripts such as onsubmit are called as a function not as a script. [ From commit 688ca8cf31c33b83e2cb9d4ddeaade97edfd6f59 on the witekfl branch. --KON ] --- src/ecmascript/see.c | 4 +++- src/ecmascript/spidermonkey.c | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ecmascript/see.c b/src/ecmascript/see.c index 84bb61fb..3cec180b 100644 --- a/src/ecmascript/see.c +++ b/src/ecmascript/see.c @@ -155,6 +155,7 @@ see_eval_boolback(struct ecmascript_interpreter *interpreter, struct SEE_interpreter *interp = interpreter->backend_data; struct global_object *g = (struct global_object *)interp; struct SEE_input *input = see_input_elinks(interp, code->source); + struct SEE_object *fun; SEE_try_context_t try_ctxt; struct SEE_value result; /* 'volatile' qualifier prevents register allocation which fixes: @@ -165,7 +166,8 @@ see_eval_boolback(struct ecmascript_interpreter *interpreter, g->exec_start = time(NULL); g->ret = NULL; SEE_TRY(interp, try_ctxt) { - SEE_Global_eval(interp, input, &result); + fun = SEE_Function_new(interp, NULL, NULL, input); + SEE_OBJECT_CALL(interp, fun, NULL, 0, NULL, &result); /* history.back() returns SEE_NULL */ if (SEE_VALUE_GET_TYPE(&result) == SEE_NULL) res = 0; diff --git a/src/ecmascript/spidermonkey.c b/src/ecmascript/spidermonkey.c index b326f69f..84d5e06c 100644 --- a/src/ecmascript/spidermonkey.c +++ b/src/ecmascript/spidermonkey.c @@ -288,6 +288,7 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code) { JSContext *ctx; + JSFunction *fun; jsval rval; int ret; @@ -295,8 +296,12 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter, ctx = interpreter->backend_data; setup_safeguard(interpreter, ctx); interpreter->ret = NULL; - ret = JS_EvaluateScript(ctx, JS_GetGlobalObject(ctx), - code->source, code->length, "", 0, &rval); + fun = JS_CompileFunction(ctx, NULL, "", 0, NULL, code->source, + code->length, "", 0); + if (!fun) + return -1; + + ret = JS_CallFunction(ctx, NULL, fun, 0, NULL, &rval); if (ret == 2) { /* onClick="history.back()" */ return 0; } -- 2.11.4.GIT