From 3dc27326d844c3fb48cdd88fd22b1c85e0abd0c0 Mon Sep 17 00:00:00 2001 From: Andrei Popescu Date: Tue, 6 Apr 2010 16:34:40 +0100 Subject: [PATCH] Cherry-pick https://bugs.webkit.org/show_bug.cgi?id=37150 Check the frame's context at PageCache save and restore time to avoid crashing when it's null. Fix bug: 2564844 Change-Id: Ifef3fcf271b1366d4f63c42da1a9ac08bb8b78ed --- WebCore/bindings/v8/ScriptCachedFrameData.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/WebCore/bindings/v8/ScriptCachedFrameData.cpp b/WebCore/bindings/v8/ScriptCachedFrameData.cpp index 6d2f41cb1..dc28f32ec 100644 --- a/WebCore/bindings/v8/ScriptCachedFrameData.cpp +++ b/WebCore/bindings/v8/ScriptCachedFrameData.cpp @@ -33,13 +33,17 @@ namespace WebCore { ScriptCachedFrameData::ScriptCachedFrameData(Frame* frame) - : m_domWindow(frame->domWindow()) + : m_domWindow(0) { v8::HandleScope handleScope; // The context can only be the context of the main world. ASSERT(V8Proxy::mainWorldContext(frame) == V8Proxy::context(frame)); m_context.set(V8Proxy::mainWorldContext(frame)); + // The context can be 0, e.g. if JS is disabled in the browser. + if (m_context.get().IsEmpty()) + return; m_global.set(m_context.get()->Global()); + m_domWindow = frame->domWindow(); } DOMWindow* ScriptCachedFrameData::domWindow() const @@ -49,6 +53,9 @@ DOMWindow* ScriptCachedFrameData::domWindow() const void ScriptCachedFrameData::restore(Frame* frame) { + if (m_context.get().IsEmpty()) + return; + v8::HandleScope handleScope; v8::Context::Scope contextScope(m_context.get()); -- 2.11.0