OSDN Git Service

Cherry-pick https://bugs.webkit.org/show_bug.cgi?id=37150
authorAndrei Popescu <andreip@google.com>
Tue, 6 Apr 2010 15:34:40 +0000 (16:34 +0100)
committerAndrei Popescu <andreip@google.com>
Tue, 6 Apr 2010 15:34:40 +0000 (16:34 +0100)
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

index 6d2f41c..dc28f32 100644 (file)
 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());