jscript: Add function name to its scope chain in ES5 mode.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c7fc18a6c7
commit
1985f330f8
|
@ -661,6 +661,14 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ECMA-262 5.1 Edition 13 */
|
||||||
|
if(func->name && ctx->version >= SCRIPTLANGUAGEVERSION_ES5 && !wcscmp(identifier, func->name)) {
|
||||||
|
TRACE("returning a function from scope chain\n");
|
||||||
|
ret->type = EXPRVAL_JSVAL;
|
||||||
|
ret->u.val = jsval_obj(jsdisp_addref(scope->frame->function_instance));
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(scope->jsobj)
|
if(scope->jsobj)
|
||||||
hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
|
hres = jsdisp_get_id(scope->jsobj, identifier, fdexNameImplicit, &id);
|
||||||
|
|
|
@ -534,3 +534,39 @@ sync_test("delete_prop", function() {
|
||||||
todo_wine.
|
todo_wine.
|
||||||
ok(!("globalprop4" in obj), "globalprop4 is still in obj");
|
ok(!("globalprop4" in obj), "globalprop4 is still in obj");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var func_scope_val = 1;
|
||||||
|
|
||||||
|
sync_test("func_scope", function() {
|
||||||
|
var func_scope_val = 2;
|
||||||
|
|
||||||
|
var f = function func_scope_val() {
|
||||||
|
return func_scope_val;
|
||||||
|
};
|
||||||
|
|
||||||
|
func_scope_val = 3;
|
||||||
|
if(document.documentMode < 9) {
|
||||||
|
ok(f() === 3, "f() = " + f());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ok(f === f(), "f() = " + f());
|
||||||
|
|
||||||
|
f = function func_scope_val(a) {
|
||||||
|
func_scope_val = 4;
|
||||||
|
return func_scope_val;
|
||||||
|
};
|
||||||
|
|
||||||
|
func_scope_val = 3;
|
||||||
|
ok(f === f(), "f() = " + f());
|
||||||
|
ok(func_scope_val === 3, "func_scope_val = " + func_scope_val);
|
||||||
|
ok(window.func_scope_val === 1, "window.func_scope_val = " + window.func_scope_val);
|
||||||
|
|
||||||
|
f = function func_scope_val(a) {
|
||||||
|
return (function() { return a ? func_scope_val(false) : func_scope_val; })();
|
||||||
|
};
|
||||||
|
|
||||||
|
ok(f === f(true), "f(true) = " + f(true));
|
||||||
|
|
||||||
|
window = 1;
|
||||||
|
ok(window === window.self, "window = " + window);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue