Example #1
0
EncodedJSValue JSC_HOST_CALL JSMessageChannelConstructor::constructJSMessageChannel(ExecState* exec)
{
    JSMessageChannelConstructor* jsConstructor = static_cast<JSMessageChannelConstructor*>(exec->callee());
    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
    if (!context)
        return throwVMError(exec, createReferenceError(exec, "MessageChannel constructor associated document is unavailable"));

    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), MessageChannel::create(context))));
}
JSObject* JSMessageChannelConstructor::construct(ExecState* exec, JSObject* constructor, const ArgList&)
{
    JSMessageChannelConstructor* jsConstructor = static_cast<JSMessageChannelConstructor*>(constructor);
    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
    if (!context)
        return throwError(exec, ReferenceError, "MessageChannel constructor associated document is unavailable");

    return asObject(toJS(exec, jsConstructor->globalObject(), MessageChannel::create(context)));
}
EncodedJSValue JSC_HOST_CALL JSMessageChannelConstructor::constructJSMessageChannel(ExecState* exec)
{
    JSMessageChannelConstructor* castedThis = jsCast<JSMessageChannelConstructor*>(exec->callee());
    ScriptExecutionContext* context = castedThis->scriptExecutionContext();
    if (!context)
        return throwVMError(exec, createReferenceError(exec, "MessageChannel constructor associated document is unavailable"));
    RefPtr<MessageChannel> object = MessageChannel::create(*context);
    return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
}