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

Unified Diff: Source/web/WebLocalFrameImpl.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/web/WebLocalFrameImpl.cpp
diff --git a/Source/web/WebLocalFrameImpl.cpp b/Source/web/WebLocalFrameImpl.cpp
index dd6cad8df2d3d1d79ce9261263952911233d1416..b6643073c54dac9564450ffc19a214e00dd23780 100644
--- a/Source/web/WebLocalFrameImpl.cpp
+++ b/Source/web/WebLocalFrameImpl.cpp
@@ -744,6 +744,7 @@ void WebLocalFrameImpl::executeScript(const WebScriptSource& source)
{
ASSERT(frame());
TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), OrdinalNumber::first());
+ v8::HandleScope handleScope(toIsolate(frame()));
frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, source.url, position));
}
@@ -759,6 +760,7 @@ void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, position));
}
+ v8::HandleScope handleScope(toIsolate(frame()));
frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGroup, 0);
}
@@ -826,7 +828,7 @@ v8::Handle<v8::Value> WebLocalFrameImpl::executeScriptAndReturnValue(const WebSc
UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), OrdinalNumber::first());
- return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(source.code, source.url, position)).v8Value();
+ return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(source.code, source.url, position));
}
void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScriptSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local<v8::Value> >* results)
@@ -843,13 +845,14 @@ void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip
}
if (results) {
- Vector<ScriptValue> scriptResults;
+ Vector<v8::Local<v8::Value> > scriptResults;
frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGroup, &scriptResults);
WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size());
for (unsigned i = 0; i < scriptResults.size(); i++)
- v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptResults[i].v8Value());
+ v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptResults[i]);
results->swap(v8Results);
} else {
+ v8::HandleScope handleScope(toIsolate(frame()));
frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGroup, 0);
}
}
@@ -1882,12 +1885,11 @@ void WebLocalFrameImpl::loadJavaScriptURL(const KURL& url)
String script = decodeURLEscapeSequences(url.string().substring(strlen("javascript:")));
UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
- ScriptValue result = frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script));
-
- String scriptResult;
- if (!result.toString(scriptResult))
+ v8::HandleScope handleScope(toIsolate(frame()));
+ v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script));
+ if (result.IsEmpty() || !result->IsString())
return;
-
+ String scriptResult = toCoreString(v8::Handle<v8::String>::Cast(result));
if (!frame()->navigationScheduler().locationChangePending())
frame()->document()->loader()->replaceDocument(scriptResult, ownerDocument.get());
}

Powered by Google App Engine
This is Rietveld 408576698