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.
This commit is contained in:
parent
a29ef8600c
commit
688ca8cf31
@ -209,6 +209,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;
|
||||
struct SEE_value *e;
|
||||
@ -220,7 +221,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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user