void JSLocation::setHash(ExecState* exec, JSValue value) { String hash = value.toString(exec)->value(exec); if (exec->hadException()) return; impl()->setHash(hash, activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSLocation::setPort(ExecState* exec, JSValue value) { UString port = value.toString(exec)->value(exec); if (exec->hadException()) return; impl()->setPort(ustringToString(port), activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSLocation::setHref(ExecState* exec, JSValue value) { UString href = value.toString(exec); if (exec->hadException()) return; impl()->setHref(ustringToString(href), activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSLocation::setPathname(ExecState* exec, JSValue value) { String pathname = value.toString(exec)->value(exec); if (exec->hadException()) return; impl().setPathname(pathname, activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSLocation::setPort(ExecState* exec, JSValue value) { String port = value.toWTFString(exec); if (exec->hadException()) return; impl().setPort(port, activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSLocation::setHost(ExecState* exec, JSValue value) { String host = value.toString(exec)->value(exec); if (exec->hadException()) return; impl().setHost(host, activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSLocation::setSearch(ExecState* exec, JSValue value) { UString pathname = value.toString(exec)->value(exec); if (exec->hadException()) return; impl()->setSearch(ustringToString(pathname), activeDOMWindow(exec), firstDOMWindow(exec)); }
static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data) { DOMWindow* firstWindow = firstDOMWindow(); if (!firstWindow->isCurrentlyDisplayedInFrame()) return; String errorMessage = toWebCoreString(message->Get()); v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); RefPtr<ScriptCallStack> callStack; // Currently stack trace is only collected when inspector is open. if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture); v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString(); String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName); RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn()); // messageHandlerInMainThread can be called while we're creating a new context. // Since we cannot create a wrapper in the intermediate timing, we need to skip // creating a wrapper for |event|. DOMWrapperWorld* world = DOMWrapperWorld::current(); Frame* frame = firstWindow->document()->frame(); if (world && frame && frame->script()->existingWindowShell(world)) { v8::Local<v8::Value> wrappedEvent = toV8(event.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent()); if (!wrappedEvent.IsEmpty()) { ASSERT(wrappedEvent->IsObject()); v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data); } } AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin; firstWindow->document()->reportException(event.release(), callStack, corsStatus); }
JSValue JSLocation::assign(ExecState* exec) { UString urlString = exec->argument(0).toString(exec); if (exec->hadException()) return jsUndefined(); impl()->assign(ustringToString(urlString), activeDOMWindow(exec), firstDOMWindow(exec)); return jsUndefined(); }
JSValue JSLocation::replace(ExecState* exec) { String urlString = exec->argument(0).toString(exec)->value(exec); if (exec->hadException()) return jsUndefined(); impl()->replace(urlString, activeDOMWindow(exec), firstDOMWindow(exec)); return jsUndefined(); }
void JSLocation::setProtocol(ExecState* exec, JSValue value) { UString protocol = value.toString(exec); if (exec->hadException()) return; ExceptionCode ec = 0; impl()->setProtocol(ustringToString(protocol), activeDOMWindow(exec), firstDOMWindow(exec), ec); setDOMException(exec, ec); }
void V8Location::pathnameAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { Location* impl = V8Location::toNative(info.Holder()); BindingState* state = BindingState::instance(); // FIXME: Handle exceptions correctly. String pathname = toWebCoreString(value); impl->setPathname(pathname, activeDOMWindow(state), firstDOMWindow(state)); }
v8::Handle<v8::Value> V8Location::assignCallback(const v8::Arguments& args) { Location* impl = V8Location::toNative(args.Holder()); BindingState* state = BindingState::instance(); // FIXME: Handle exceptions correctly. String urlString = toWebCoreString(args[0]); impl->assign(urlString, activeDOMWindow(state), firstDOMWindow(state)); return v8::Undefined(); }
void JSDocument::setLocation(ExecState* exec, JSValue value) { String locationString = value.toString(exec)->value(exec); if (exec->hadException()) return; RefPtr<Frame> frame = impl().frame(); if (!frame) return; if (RefPtr<Location> location = frame->document()->domWindow()->location()) location->setHref(locationString, activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSDocument::setLocation(ExecState* exec, JSValue value) { Frame* frame = static_cast<Document*>(impl())->frame(); if (!frame) return; String locationString = value.toString(exec)->value(exec); if (exec->hadException()) return; if (Location* location = frame->document()->domWindow()->location()) location->setHref(locationString, activeDOMWindow(exec), firstDOMWindow(exec)); }
void V8Location::protocolAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { Location* impl = V8Location::toNative(info.Holder()); BindingState* state = BindingState::instance(); // FIXME: Handle exceptions correctly. String protocol = toWebCoreString(value); ExceptionCode ec = 0; impl->setProtocol(protocol, activeDOMWindow(state), firstDOMWindow(state), ec); if (UNLIKELY(ec)) setDOMException(ec, info.GetIsolate()); }
void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { DOMWindow* impl = V8Window::toNative(args.Holder()); if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame())) return; // FIXME: Handle exceptions properly. String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]); DialogHandler handler(args[1]); String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2]); impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), firstDOMWindow(), setUpDialog, &handler); v8SetReturnValue(args, handler.returnValue()); }
void V8Window::locationAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { DOMWindow* imp = V8Window::toNative(info.Holder()); DOMWindow* active = activeDOMWindow(); if (!active) return; DOMWindow* first = firstDOMWindow(); if (!first) return; if (Location* location = imp->location()) location->setHref(active, first, toWebCoreString(value)); }
JSValue JSDOMWindow::showModalDialog(ExecState* exec) { String urlString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); if (exec->hadException()) return jsUndefined(); String dialogFeaturesString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(2)); if (exec->hadException()) return jsUndefined(); DialogHandler handler(exec); impl()->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(exec), firstDOMWindow(exec), setUpDialog, &handler); return handler.returnValue(); }
void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) { DOMWindow* impl = V8Window::toNative(info.Holder()); ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDialog", "Window", info.Holder(), info.GetIsolate()); if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState)) { exceptionState.throwIfNeeded(); return; } // FIXME: Handle exceptions properly. String urlString = toCoreStringWithUndefinedOrNullCheck(info[0]); DialogHandler handler(info[1]); String dialogFeaturesString = toCoreStringWithUndefinedOrNullCheck(info[2]); impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), firstDOMWindow(), setUpDialog, &handler); v8SetReturnValue(info, handler.returnValue(info.GetIsolate())); }
void V8Document::locationAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { Document* document = V8Document::toNative(info.Holder()); if (!document->frame()) return; DOMWindow* active = activeDOMWindow(); if (!active) return; DOMWindow* first = firstDOMWindow(); if (!first) return; DOMWindow* window = document->domWindow(); if (Location* location = window->location()) location->setHref(active, first, toWebCoreString(value)); }
static void reportUncaughtException(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data) { DOMWindow* firstWindow = firstDOMWindow(BindingState::instance()); if (!firstWindow->isCurrentlyDisplayedInFrame()) return; String errorMessage = toWebCoreString(message->Get()); v8::Handle<v8::StackTrace> stackTrace = message->GetStackTrace(); RefPtr<ScriptCallStack> callStack; // Currently stack trace is only collected when inspector is open. if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) callStack = createScriptCallStack(stackTrace, ScriptCallStack::maxCallStackSizeToCapture); v8::Handle<v8::Value> resourceName = message->GetScriptResourceName(); bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString(); String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName); firstWindow->document()->reportException(errorMessage, message->GetLineNumber(), resource, callStack); }
void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { Document* document = V8Document::toNative(info.Holder()); if (!document->frame()) return; BindingState* state = BindingState::instance(); DOMWindow* active = activeDOMWindow(state); if (!active) return; DOMWindow* first = firstDOMWindow(state); if (!first) return; DOMWindow* window = document->domWindow(); if (Location* location = window->location()) location->setHref(toWebCoreString(value), active, first); }
void JSDOMWindow::setLocation(ExecState* exec, JSValue value) { #if ENABLE(DASHBOARD_SUPPORT) // To avoid breaking old widgets, make "var location =" in a top-level frame create // a property named "location" instead of performing a navigation (<rdar://problem/5688039>). if (Frame* activeFrame = activeDOMWindow(exec).frame()) { if (activeFrame->settings().usesDashboardBackwardCompatibilityMode() && !activeFrame->tree().parent()) { if (BindingSecurity::shouldAllowAccessToDOMWindow(exec, impl())) putDirect(exec->vm(), Identifier(exec, "location"), value); return; } } #endif String locationString = value.toString(exec)->value(exec); if (exec->hadException()) return; if (Location* location = impl().location()) location->setHref(locationString, activeDOMWindow(exec), firstDOMWindow(exec)); }
void JSDOMWindow::setLocation(ExecState& state, JSValue value) { VM& vm = state.vm(); auto scope = DECLARE_THROW_SCOPE(vm); #if ENABLE(DASHBOARD_SUPPORT) // To avoid breaking old widgets, make "var location =" in a top-level frame create // a property named "location" instead of performing a navigation (<rdar://problem/5688039>). if (Frame* activeFrame = activeDOMWindow(&state).frame()) { if (activeFrame->settings().usesDashboardBackwardCompatibilityMode() && !activeFrame->tree().parent()) { if (BindingSecurity::shouldAllowAccessToDOMWindow(&state, wrapped())) putDirect(state.vm(), Identifier::fromString(&state, "location"), value); return; } } #endif String locationString = value.toString(&state)->value(&state); RETURN_IF_EXCEPTION(scope, void()); if (Location* location = wrapped().location()) location->setHref(activeDOMWindow(&state), firstDOMWindow(&state), locationString); }
JSValue JSDOMWindow::showModalDialog(ExecState& state) { VM& vm = state.vm(); auto scope = DECLARE_THROW_SCOPE(vm); if (UNLIKELY(state.argumentCount() < 1)) return throwException(&state, scope, createNotEnoughArgumentsError(&state)); String urlString = convert<IDLNullable<IDLDOMString>>(state, state.argument(0)); RETURN_IF_EXCEPTION(scope, JSValue()); String dialogFeaturesString = convert<IDLNullable<IDLDOMString>>(state, state.argument(2)); RETURN_IF_EXCEPTION(scope, JSValue()); DialogHandler handler(state); wrapped().showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state), [&handler](DOMWindow& dialog) { handler.dialogCreated(dialog); }); return handler.returnValue(); }
JSValue JSDOMWindow::open(ExecState* exec) { String urlString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)); if (exec->hadException()) return jsUndefined(); AtomicString frameName = exec->argument(1).isUndefinedOrNull() ? "_blank" : exec->argument(1).toString(exec)->value(exec); if (exec->hadException()) return jsUndefined(); String windowFeaturesString = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(2)); if (exec->hadException()) return jsUndefined(); RefPtr<DOMWindow> openedWindow = impl()->open(urlString, frameName, windowFeaturesString, activeDOMWindow(exec), firstDOMWindow(exec)); if (!openedWindow) return jsUndefined(); return toJS(exec, openedWindow.get()); }
JSValue JSDOMWindow::open(ExecState& state) { VM& vm = state.vm(); auto scope = DECLARE_THROW_SCOPE(vm); String urlString = convert<IDLNullable<IDLUSVString>>(state, state.argument(0)); RETURN_IF_EXCEPTION(scope, JSValue()); JSValue targetValue = state.argument(1); AtomicString target = targetValue.isUndefinedOrNull() ? AtomicString("_blank", AtomicString::ConstructFromLiteral) : targetValue.toString(&state)->toAtomicString(&state); RETURN_IF_EXCEPTION(scope, JSValue()); String windowFeaturesString = convert<IDLNullable<IDLDOMString>>(state, state.argument(2)); RETURN_IF_EXCEPTION(scope, JSValue()); RefPtr<DOMWindow> openedWindow = wrapped().open(urlString, target, windowFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state)); if (!openedWindow) return jsNull(); return toJS(&state, openedWindow.get()); }
// FIXME: We should remove or at least deprecate this function. Callers can use firstDOMWindow directly. Frame* toDynamicFrame(ExecState* exec) { return firstDOMWindow(exec)->frame(); }
void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) { DOMWindow* impl = V8Window::toNative(args.Holder()); if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame())) return; // FIXME: Handle exceptions properly. String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]); AtomicString frameName = (args[1]->IsUndefined() || args[1]->IsNull()) ? "_blank" : AtomicString(toWebCoreString(args[1])); String windowFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2]); RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeDOMWindow(), firstDOMWindow()); if (!openedWindow) return; v8SetReturnValue(args, toV8Fast(openedWindow.release(), args, impl)); }