mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 807623 - Reimplement obj_toString and fun_toString traps on BaseProxyHandler. r=ejpbruel
Looks like these got lost in the Direct Proxy Handler refactor.
This commit is contained in:
parent
b90082aa95
commit
dff96799f4
12
js/src/jit-test/tests/basic/bug807623.js
Normal file
12
js/src/jit-test/tests/basic/bug807623.js
Normal file
@ -0,0 +1,12 @@
|
||||
var objectProxy = Proxy.create({});
|
||||
var functionProxy = Proxy.createFunction({}, function() {}, function() {});
|
||||
|
||||
assertEq(Object.prototype.toString.call(objectProxy), '[object Object]');
|
||||
assertEq(Object.prototype.toString.call(functionProxy), '[object Function]');
|
||||
assertEq(Function.prototype.toString.call(functionProxy), 'function () {}');
|
||||
try {
|
||||
Function.prototype.toString.call(objectProxy);
|
||||
assertEq(true, false);
|
||||
} catch (e) {
|
||||
assertEq(!!/incompatible/.exec(e), true);
|
||||
}
|
@ -282,21 +282,26 @@ BaseProxyHandler::construct(JSContext *cx, JSObject *proxy, unsigned argc,
|
||||
JSString *
|
||||
BaseProxyHandler::obj_toString(JSContext *cx, JSObject *proxy)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Object_str, js_toString_str,
|
||||
"object");
|
||||
return NULL;
|
||||
return JS_NewStringCopyZ(cx, IsFunctionProxy(proxy)
|
||||
? "[object Function]"
|
||||
: "[object Object]");
|
||||
}
|
||||
|
||||
JSString *
|
||||
BaseProxyHandler::fun_toString(JSContext *cx, JSObject *proxy, unsigned indent)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Function_str, js_toString_str,
|
||||
"object");
|
||||
return NULL;
|
||||
Value fval = GetCall(proxy);
|
||||
if (IsFunctionProxy(proxy) &&
|
||||
(fval.isPrimitive() || !fval.toObject().isFunction())) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
js_Function_str, js_toString_str,
|
||||
"object");
|
||||
return NULL;
|
||||
}
|
||||
RootedObject obj(cx, &fval.toObject());
|
||||
return fun_toStringHelper(cx, obj, indent);
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
|
Loading…
Reference in New Issue
Block a user