// FIXME: There is a lot of duplication with SetTimeoutOrInterval() in V8WorkerGlobalScopeCustom.cpp.
// We should refactor this.
-void WindowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& info, bool singleShot, ExceptionState& exceptionState)
+void windowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& info, bool singleShot, ExceptionState& exceptionState)
{
int argumentCount = info.Length();
return;
DOMWindow* imp = V8Window::toNative(info.Holder());
- if (!imp->document()) {
+ if (!imp->frame() || !imp->document()) {
+ exceptionState.throwDOMException(InvalidAccessError, "No script context is available in which to execute the script.");
+ return;
+ }
+ v8::Handle<v8::Context> context = toV8Context(info.GetIsolate(), imp->frame(), DOMWrapperWorld::current(info.GetIsolate()));
+ if (context.IsEmpty()) {
exceptionState.throwDOMException(InvalidAccessError, "No script context is available in which to execute the script.");
return;
}
return;
}
- if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState))
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), imp->frame(), exceptionState))
return;
OwnPtr<ScheduledAction> action;
// params is passed to action, and released in action's destructor
ASSERT(imp->frame());
- action = adoptPtr(new ScheduledAction(imp->frame()->script().currentWorldContextOrMainWorldContext(), v8::Handle<v8::Function>::Cast(function), paramCount, params.get(), info.GetIsolate()));
+ action = adoptPtr(new ScheduledAction(context, v8::Handle<v8::Function>::Cast(function), paramCount, params.get(), info.GetIsolate()));
} else {
- if (imp->document() && !imp->document()->contentSecurityPolicy()->allowEval()) {
+ if (imp->document() && !imp->document()->contentSecurityPolicy()->allowScriptEval()) {
v8SetReturnValue(info, 0);
return;
}
ASSERT(imp->frame());
- action = adoptPtr(new ScheduledAction(imp->frame()->script().currentWorldContextOrMainWorldContext(), functionString, KURL(), info.GetIsolate()));
+ action = adoptPtr(new ScheduledAction(context, functionString, KURL(), info.GetIsolate()));
}
int32_t timeout = argumentCount >= 2 ? info[1]->Int32Value() : 0;
{
Frame* frame = V8Window::toNative(info.Holder())->frame();
ExceptionState exceptionState(ExceptionState::GetterContext, "event", "Window", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToFrame(frame, exceptionState)) {
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exceptionState)) {
exceptionState.throwIfNeeded();
return;
}
ASSERT(frame);
- v8::Local<v8::Context> context = frame->script().currentWorldContextOrMainWorldContext();
+ v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame, DOMWrapperWorld::current(info.GetIsolate()));
if (context.IsEmpty())
return;
{
Frame* frame = V8Window::toNative(info.Holder())->frame();
ExceptionState exceptionState(ExceptionState::SetterContext, "event", "Window", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToFrame(frame, exceptionState)) {
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exceptionState)) {
exceptionState.throwIfNeeded();
return;
}
ASSERT(frame);
- v8::Local<v8::Context> context = frame->script().currentWorldContextOrMainWorldContext();
+ v8::Local<v8::Context> context = toV8Context(info.GetIsolate(), frame, DOMWrapperWorld::current(info.GetIsolate()));
if (context.IsEmpty())
return;
{
DOMWindow* imp = V8Window::toNative(info.Holder());
ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Window", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToNode(imp->frameElement(), exceptionState)) {
+ if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), imp->frameElement(), exceptionState)) {
v8SetReturnValueNull(info);
exceptionState.throwIfNeeded();
return;
{
DOMWindow* imp = V8Window::toNative(info.Holder());
ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Window", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState)) {
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), imp->frame(), exceptionState)) {
exceptionState.throwIfNeeded();
return;
}
// None of these need to be RefPtr because info and context are guaranteed
// to hold on to them.
DOMWindow* window = V8Window::toNative(info.Holder());
- DOMWindow* source = activeDOMWindow();
+ DOMWindow* source = activeDOMWindow(info.GetIsolate());
ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", "Window", info.Holder(), info.GetIsolate());
inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame, v8::Isolate* isolate)
{
- m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script().currentWorldContextOrMainWorldContext() : v8::Local<v8::Context>();
+ // FIXME: It's wrong to use the current world. Instead we should use the world
+ // from which the modal dialog was requested.
+ m_dialogContext = dialogFrame->frame() ? toV8Context(isolate, dialogFrame->frame(), DOMWrapperWorld::current(isolate)) : v8::Local<v8::Context>();
if (m_dialogContext.IsEmpty())
return;
if (m_dialogArguments.IsEmpty())
{
DOMWindow* impl = V8Window::toNative(info.Holder());
ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDialog", "Window", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState)) {
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
exceptionState.throwIfNeeded();
return;
}
DialogHandler handler(info[1]);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, dialogFeaturesString, info[2]);
- impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), firstDOMWindow(), setUpDialog, &handler);
+ impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(info.GetIsolate()), firstDOMWindow(info.GetIsolate()), setUpDialog, &handler);
v8SetReturnValue(info, handler.returnValue(info.GetIsolate()));
}
{
DOMWindow* impl = V8Window::toNative(info.Holder());
ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Window", info.Holder(), info.GetIsolate());
- if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), exceptionState)) {
+ if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->frame(), exceptionState)) {
exceptionState.throwIfNeeded();
return;
}
}
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullCheck>, windowFeaturesString, info[2]);
- RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeDOMWindow(), firstDOMWindow());
+ RefPtr<DOMWindow> openedWindow = impl->open(urlString, frameName, windowFeaturesString, activeDOMWindow(info.GetIsolate()), firstDOMWindow(info.GetIsolate()));
if (!openedWindow)
return;
void V8Window::setTimeoutMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "setTimeout", "Window", info.Holder(), info.GetIsolate());
- WindowSetTimeoutImpl(info, true, exceptionState);
+ windowSetTimeoutImpl(info, true, exceptionState);
exceptionState.throwIfNeeded();
}
void V8Window::setIntervalMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "setInterval", "Window", info.Holder(), info.GetIsolate());
- WindowSetTimeoutImpl(info, false, exceptionState);
+ windowSetTimeoutImpl(info, false, exceptionState);
exceptionState.throwIfNeeded();
}
return true;
}
- return BindingSecurity::shouldAllowAccessToFrame(target, DoNotReportSecurityError);
+ return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotReportSecurityError);
}
bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
&& !window->HasRealIndexedProperty(index))
return true;
- return BindingSecurity::shouldAllowAccessToFrame(target, DoNotReportSecurityError);
+ return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotReportSecurityError);
}
v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
}
// Otherwise, return the global object associated with this frame.
- v8::Handle<v8::Context> context = frame->script().currentWorldContextOrMainWorldContext();
+ v8::Handle<v8::Context> context = toV8Context(isolate, frame, DOMWrapperWorld::current(isolate));
if (context.IsEmpty())
return v8Undefined();