Пример #1
0
JSValue JSHTMLDocument::open(ExecState* exec)
{
    // For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
    if (exec->argumentCount() > 2) {
        Frame* frame = static_cast<HTMLDocument*>(impl())->frame();
        if (frame) {
            JSDOMWindowShell* wrapper = toJSDOMWindowShell(frame, currentWorld(exec));
            if (wrapper) {
                JSValue function = wrapper->get(exec, Identifier(exec, "open"));
                CallData callData;
                CallType callType = ::getCallData(function, callData);
                if (callType == CallTypeNone)
                    return throwTypeError(exec);
                return JSC::call(exec, function, callType, callData, wrapper, ArgList(exec));
            }
        }
        return jsUndefined();
    }

    // document.open clobbers the security context of the document and
    // aliases it with the active security context.
    Document* activeDocument = asJSDOMWindow(exec->lexicalGlobalObject())->impl()->document();

    // In the case of two parameters or fewer, do a normal document open.
    static_cast<HTMLDocument*>(impl())->open(activeDocument);
    return this;
}
Пример #2
0
JSValue JSHTMLDocument::open(ExecState& state)
{
    // For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
    if (state.argumentCount() > 2) {
        if (Frame* frame = wrapped().frame()) {
            JSDOMWindowShell* wrapper = toJSDOMWindowShell(frame, currentWorld(&state));
            if (wrapper) {
                JSValue function = wrapper->get(&state, Identifier::fromString(&state, "open"));
                CallData callData;
                CallType callType = ::getCallData(function, callData);
                if (callType == CallTypeNone)
                    return throwTypeError(&state);
                return JSC::call(&state, function, callType, callData, wrapper, ArgList(&state));
            }
        }
        return jsUndefined();
    }

    // document.open clobbers the security context of the document and
    // aliases it with the active security context.
    Document* activeDocument = asJSDOMWindow(state.lexicalGlobalObject())->wrapped().document();

    // In the case of two parameters or fewer, do a normal document open.
    wrapped().open(activeDocument);
    return this;
}