1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

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 688ca8cf31 on the witekfl
  branch.  --KON ]
This commit is contained in:
Witold Filipczyk 2007-05-19 20:54:08 +02:00 committed by Kalle Olavi Niemitalo
parent e741932d58
commit ac3608bda0
2 changed files with 10 additions and 3 deletions

View File

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

View File

@ -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;
}