Hello,

now I've commited a version with the failure I described bevore.

I implement it in the following way:


jswrapper.cpp:
bool
CrossCompartmentWrapper::isTransparent(JSContext *cx, HandleObject
wrapper, bool *bp)
{
    return Wrapper::isTransparent(cx, wrapper, bp);
}


I use the following function GetDirectProxyHandlerObject to get the
Handler Object like in the ScriptedProxyHandler, but in this case I get
an assertion in the function "toObjectOrNull()":
Assertion failure: isObjectOrNull(), at ../dist/include/js/Value.h:1157

jsproxy.cpp:


static JSObject *
GetDirectProxyHandlerObject(JSObject *proxy)
{
    return proxy->as<ProxyObject>().extra(0).toObjectOrNull();
}

bool
DirectProxyHandler::isTransparent(JSContext *cx, HandleObject proxy,
bool *bp)
{
    // step 1
    RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));

    // step 2
    JSString* propStr = JS_InternString(cx, "isTransparent");
    JSAtom& atom = propStr->asAtom();
    RootedValue trap(cx);
    if (!JSObject::getProperty(cx, handler, handler,
atom.asPropertyName(), &trap))
        return false;

    // step 3
    if (trap.isUndefined())
    {
        *bp = false;
        return true;
    }

    // step 4
    Value argv[] = {
    //    ObjectOrNullValue(target),
    //    value
    };
    RootedValue trapResult(cx);
    if (!Invoke(cx, ObjectValue(*handler), trap, 0, argv, &trapResult))
        return false;

    // step 5
    bool success = ToBoolean(trapResult);

    // step 6
    *bp = success;
    return true;
}

Why can I use this code in the trap of ScriptedDirectProxyHandler but
not in the DirectProxyHandler?
How can I retrieve the correct Object for Step 1 in the
isTransparent()-trap?
Can someone explain me the proxy slots?
PROXY_PRIVATE_SLOT: ;
PROXY_HANDLER_SLOT;
PROXY_EXTRA_SLOT;

Private slot contains the target? Handler slot the handler? But which
values contain the extra slots?

 For the ScriptedDirectProxyHandler the first extra slot contains the
DirectProxyHandler if I'm right:
static JSObject *
GetDirectProxyHandlerObject(JSObject *proxy)
{
    return proxy->as<ProxyObject>().extra(0).toObjectOrNull();
}

But for DirectProxyHandler, where can I get the same Object to call the
trap and test the data?
If I use "proxy->as<ProxyObject>().target()" the trap is undefined.

Thanks
Andreas
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to