mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 921448 - Implement sane default behavior for fun_toString for all proxies. r=ejpbruel
This commit is contained in:
parent
581d9cf944
commit
bab206627b
@ -782,7 +782,7 @@ JSString *
|
||||
fun_toStringHelper(JSContext *cx, HandleObject obj, unsigned indent)
|
||||
{
|
||||
if (!obj->is<JSFunction>()) {
|
||||
if (obj->is<FunctionProxyObject>())
|
||||
if (obj->is<ProxyObject>())
|
||||
return Proxy::fun_toString(cx, obj, indent);
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
|
@ -308,7 +308,10 @@ BaseProxyHandler::className(JSContext *cx, HandleObject proxy)
|
||||
JSString *
|
||||
BaseProxyHandler::fun_toString(JSContext *cx, HandleObject proxy, unsigned indent)
|
||||
{
|
||||
MOZ_ASSUME_UNREACHABLE("callable proxies should implement fun_toString trap");
|
||||
if (proxy->isCallable())
|
||||
return JS_NewStringCopyZ(cx, "function () {\n [native code]\n}");
|
||||
ReportIsNotFunction(cx, ObjectValue(*proxy));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2691,12 +2694,8 @@ Proxy::fun_toString(JSContext *cx, HandleObject proxy, unsigned indent)
|
||||
AutoEnterPolicy policy(cx, handler, proxy, JSID_VOIDHANDLE,
|
||||
BaseProxyHandler::GET, /* mayThrow = */ false);
|
||||
// Do the safe thing if the policy rejects.
|
||||
if (!policy.allowed()) {
|
||||
if (proxy->isCallable())
|
||||
return JS_NewStringCopyZ(cx, "function () {\n [native code]\n}");
|
||||
ReportIsNotFunction(cx, ObjectValue(*proxy));
|
||||
return NULL;
|
||||
}
|
||||
if (!policy.allowed())
|
||||
return handler->BaseProxyHandler::fun_toString(cx, proxy, indent);
|
||||
return handler->fun_toString(cx, proxy, indent);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user