summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharaken <haraken@chromium.org>2016-01-05 00:46:36 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-05 08:47:39 +0000
commitb2eed16e7e44ed1f57d249b5525def01dd5518fd (patch)
tree58dba4716d0392e11d2faec6fe6e7afa52bd51c8
parent72affa46023afe3caf07116cd9fa85e7adab897e (diff)
downloadchromium_src-b2eed16e7e44ed1f57d249b5525def01dd5518fd.zip
chromium_src-b2eed16e7e44ed1f57d249b5525def01dd5518fd.tar.gz
chromium_src-b2eed16e7e44ed1f57d249b5525def01dd5518fd.tar.bz2
toV8Context should handle a case where WindowProxy::context() returns an empty handle.
windowProxy()->context() can return nullptr if the windowProxy() failed at initializing the context for some reason. Thus the caller site of windowProxy()->context() need to handle a case where the windowProxy()->context() returns an empty handle. This CL renames WindowProxy::context() to WindowProxy::contextIfInitialized() for clarity. BUG=571720 TEST=None. The test case reported by the clusterfuzz is too large to minimize. Review URL: https://codereview.chromium.org/1546253003 Cr-Commit-Position: refs/heads/master@{#367498}
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp13
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp4
-rw-r--r--third_party/WebKit/Source/bindings/core/v8/WindowProxy.h2
3 files changed, 11 insertions, 8 deletions
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
index dbc24fd..eb0cc56 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
@@ -251,18 +251,19 @@ bool ScriptController::bindToWindowObject(LocalFrame* frame, const String& key,
void ScriptController::enableEval()
{
- if (!m_windowProxyManager->mainWorldProxy()->isContextInitialized())
- return;
v8::HandleScope handleScope(isolate());
- m_windowProxyManager->mainWorldProxy()->context()->AllowCodeGenerationFromStrings(true);
+ v8::Local<v8::Context> v8Context = m_windowProxyManager->mainWorldProxy()->contextIfInitialized();
+ if (v8Context.IsEmpty())
+ return;
+ v8Context->AllowCodeGenerationFromStrings(true);
}
void ScriptController::disableEval(const String& errorMessage)
{
- if (!m_windowProxyManager->mainWorldProxy()->isContextInitialized())
- return;
v8::HandleScope handleScope(isolate());
- v8::Local<v8::Context> v8Context = m_windowProxyManager->mainWorldProxy()->context();
+ v8::Local<v8::Context> v8Context = m_windowProxyManager->mainWorldProxy()->contextIfInitialized();
+ if (v8Context.IsEmpty())
+ return;
v8Context->AllowCodeGenerationFromStrings(false);
v8Context->SetErrorMessageForCodeGenerationFromStrings(v8String(isolate(), errorMessage));
}
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp
index b4830c5f..bd44979 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.cpp
@@ -790,6 +790,8 @@ v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world)
if (!frame)
return v8::Local<v8::Context>();
v8::Local<v8::Context> context = toV8ContextEvenIfDetached(frame, world);
+ if (context.IsEmpty())
+ return v8::Local<v8::Context>();
ScriptState* scriptState = ScriptState::from(context);
if (scriptState->contextIsValid()) {
ASSERT(toFrameIfNotDetached(context) == frame);
@@ -801,7 +803,7 @@ v8::Local<v8::Context> toV8Context(Frame* frame, DOMWrapperWorld& world)
v8::Local<v8::Context> toV8ContextEvenIfDetached(Frame* frame, DOMWrapperWorld& world)
{
ASSERT(frame);
- return frame->windowProxy(world)->context();
+ return frame->windowProxy(world)->contextIfInitialized();
}
void crashIfIsolateIsDead(v8::Isolate* isolate)
diff --git a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h
index c21737b..fbcb3f4 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h
+++ b/third_party/WebKit/Source/bindings/core/v8/WindowProxy.h
@@ -58,7 +58,7 @@ public:
~WindowProxy();
DECLARE_TRACE();
- v8::Local<v8::Context> context() const { return m_scriptState ? m_scriptState->context() : v8::Local<v8::Context>(); }
+ v8::Local<v8::Context> contextIfInitialized() const { return m_scriptState ? m_scriptState->context() : v8::Local<v8::Context>(); }
ScriptState* scriptState() const { return m_scriptState.get(); }
// Update document object of the frame.