Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Source/bindings/v8/custom/V8WindowCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ void V8Window::parentAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Va
{
DOMWindow* imp = V8Window::toNative(info.Holder());
LocalFrame* frame = imp->frame();
ASSERT(frame);
if (frame->isNwFakeTop()) {
if (frame && frame->isNwFakeTop()) {
v8SetReturnValue(info, toV8(imp, info.Holder(), info.GetIsolate()));
return;
}
Expand All @@ -170,7 +169,7 @@ void V8Window::topAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value
{
DOMWindow* imp = V8Window::toNative(info.Holder());
LocalFrame* frame = imp->frame();
ASSERT(frame);

for (LocalFrame* f = frame; f; f = f->tree().parent()) {
if (f->isNwFakeTop()) {
v8SetReturnValue(info, toV8(f->document()->domWindow(), info.Holder(), info.GetIsolate()));
Expand Down Expand Up @@ -240,18 +239,17 @@ void V8Window::eventAttributeSetterCustom(v8::Local<v8::Value> value, const v8::
void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>& info)
{
DOMWindow* impl = V8Window::toNative(info.Holder());
LocalFrame* frame = impl->frame();
if (frame->isNwFakeTop()) {
v8SetReturnValue(info, v8::Null(info.GetIsolate()));
return;
}
ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Window", info.Holder(), info.GetIsolate());
if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), impl->frameElement(), exceptionState)) {
v8SetReturnValueNull(info);
exceptionState.throwIfNeeded();
return;
}

LocalFrame* frame = impl->frame();
if (frame->isNwFakeTop()) {
v8SetReturnValue(info, v8::Null(info.GetIsolate()));
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you move the block to a later position?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, the frame may have been destroyed and the frame pointer is null. This checking is done by 'BindingSecurity::shouldAllowAccessToNode' (like openerAttributeSetterCustom does), therefore the best approach is to move this block behind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there is some side effect if we move it later.

// The wrapper for an <iframe> should get its prototype from the context of the frame it's in, rather than its own frame.
// So, use its containing document as the creation context when wrapping.
v8::Handle<v8::Value> creationContext = toV8(&impl->frameElement()->document(), v8::Handle<v8::Object>(), info.GetIsolate());
Expand Down