void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());

    if (args.Length() > 2) {
        if (RefPtr<Frame> frame = htmlDocument->frame()) {
            // Fetch the global object for the frame.
            v8::Local<v8::Context> context = frame->script()->currentWorldContext();
            // Bail out if we cannot get the context.
            if (context.IsEmpty())
                return;
            v8::Local<v8::Object> global = context->Global();
            // Get the open property of the global object.
            v8::Local<v8::Value> function = global->Get(v8::String::NewSymbol("open"));
            // If the open property is not a function throw a type error.
            if (!function->IsFunction()) {
                throwTypeError("open is not a function", args.GetIsolate());
                return;
            }
            // Wrap up the arguments and call the function.
            OwnArrayPtr<v8::Local<v8::Value> > params = adoptArrayPtr(new v8::Local<v8::Value>[args.Length()]);
            for (int i = 0; i < args.Length(); i++)
                params[i] = args[i];

            v8SetReturnValue(args, frame->script()->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get()));
            return;
        }
    }

    htmlDocument->open(activeDOMWindow()->document());
    v8SetReturnValue(args, args.Holder());
}
예제 #2
0
void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());

    if (info.Length() > 2) {
        if (RefPtr<LocalFrame> frame = htmlDocument->frame()) {
            // Fetch the global object for the frame.
            v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame.get(), DOMWrapperWorld::current(info.GetIsolate()));
            // Bail out if we cannot get the context.
            if (context.IsEmpty())
                return;
            v8::Local<v8::Object> global = context->Global();
            // Get the open property of the global object.
            v8::Local<v8::Value> function = global->Get(v8AtomicString(info.GetIsolate(), "open"));
            // Failed; return without throwing (new) exception.
            if (function.IsEmpty())
                return;
            // If the open property is not a function throw a type error.
            if (!function->IsFunction()) {
                throwTypeError("open is not a function", info.GetIsolate());
                return;
            }
            // Wrap up the arguments and call the function.
            OwnPtr<v8::Local<v8::Value>[]> params = adoptArrayPtr(new v8::Local<v8::Value>[info.Length()]);
            for (int i = 0; i < info.Length(); i++)
                params[i] = info[i];

            v8SetReturnValue(info, frame->script().callFunction(v8::Local<v8::Function>::Cast(function), global, info.Length(), params.get()));
            return;
        }
    }

    ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Document", info.Holder(), info.GetIsolate());
    htmlDocument->open(callingDOMWindow(info.GetIsolate())->document(), exceptionState);
    if (exceptionState.throwIfNeeded())
        return;

    v8SetReturnValue(info, info.Holder());
}
void testBoundary(HTMLDocument& document, HTMLTextFormControlElement& textControl)
{
    for (unsigned i = 0; i < textControl.innerEditorValue().length(); i++) {
        textControl.setSelectionRange(i, i);
        Position position = document.frame()->selection().start();
        SCOPED_TRACE(::testing::Message() << "offset " << position.computeEditingOffset() << " of " << nodePositionAsStringForTesting(position.anchorNode()).ascii().data());
        {
            SCOPED_TRACE("HTMLTextFormControlElement::startOfWord");
            testFunctionEquivalence(position, HTMLTextFormControlElement::startOfWord, startOfWord);
        }
        {
            SCOPED_TRACE("HTMLTextFormControlElement::endOfWord");
            testFunctionEquivalence(position, HTMLTextFormControlElement::endOfWord, endOfWord);
        }
        {
            SCOPED_TRACE("HTMLTextFormControlElement::startOfSentence");
            testFunctionEquivalence(position, HTMLTextFormControlElement::startOfSentence, startOfSentence);
        }
        {
            SCOPED_TRACE("HTMLTextFormControlElement::endOfSentence");
            testFunctionEquivalence(position, HTMLTextFormControlElement::endOfSentence, endOfSentence);
        }
    }
}