Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: Source/bindings/v8/ScriptValue.cpp

Issue 314953005: Add an ASSERT about cross-world wrapper leakage into ScriptValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/ScriptValue.cpp
diff --git a/Source/bindings/v8/ScriptValue.cpp b/Source/bindings/v8/ScriptValue.cpp
index 70c0e4189e82f46672b7fb379df18f567f17c77c..bdfbe082258abdd7f5c287e8103bfcddbf034e72 100644
--- a/Source/bindings/v8/ScriptValue.cpp
+++ b/Source/bindings/v8/ScriptValue.cpp
@@ -41,12 +41,29 @@ ScriptValue::~ScriptValue()
{
}
+v8::Handle<v8::Value> ScriptValue::v8Value() const
+{
+ if (isEmpty())
+ return v8::Handle<v8::Value>();
+
+ ASSERT(isolate()->InContext());
+
+ // This is a check to validate that you don't return a ScriptValue to a world different
+ // from the world that created the ScriptValue.
+ // Probably this could be:
+ // if (&m_scriptState->world() == &DOMWrapperWorld::current(isolate()))
+ // return v8::Handle<v8::Value>();
+ // instead of triggering RELEASE_ASSERT.
+ RELEASE_ASSERT(&m_scriptState->world() == &DOMWrapperWorld::current(isolate()));
+ return m_value->newLocal(isolate());
+}
+
bool ScriptValue::toString(String& result) const
{
if (isEmpty())
return false;
- v8::HandleScope handleScope(isolate());
+ ScriptState::Scope scope(m_scriptState.get());
v8::Handle<v8::Value> string = v8Value();
if (string.IsEmpty() || !string->IsString())
return false;

Powered by Google App Engine
This is Rietveld 408576698