Skip to content

Commit b29f175

Browse files
committed
don't create v8 context in willHandleNavigationPolicy
The new window's URL is empty in this context so Node access is failed to be enabled for this frame.
1 parent 18fd9a0 commit b29f175

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/renderer/nw_extensions_renderer_hooks.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#include "third_party/blink/public/web/web_view.h"
4242
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
4343
#include "third_party/blink/public/web/blink.h"
44+
#include "third_party/blink/renderer/platform/bindings/dom_wrapper_world.h"
45+
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
46+
#include "third_party/blink/renderer/platform/wtf/casting.h"
47+
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
4448

4549
#include "third_party/node-nw/src/node_webkit.h"
4650

@@ -532,8 +536,11 @@ void willHandleNavigationPolicy(content::RenderView* rv,
532536
if (!f->IsWebLocalFrame())
533537
return;
534538
blink::WebLocalFrame* local_frame = f->ToWebLocalFrame();
535-
v8::Handle<v8::Context> v8_context =
536-
local_frame->MainWorldScriptContext();
539+
blink::LocalFrame* core_frame = blink::To<blink::WebLocalFrameImpl>(local_frame)->GetFrame();
540+
541+
if (core_frame->ContextNotReady(blink::DOMWrapperWorld::MainWorld()))
542+
return;
543+
v8::Handle<v8::Context> v8_context = local_frame->MainWorldScriptContext();
537544
ScriptContext* script_context =
538545
g_dispatcher->script_context_set().GetByV8Context(v8_context);
539546
v8::Context::Scope cscope (v8_context);

0 commit comments

Comments
 (0)