Chromium Code Reviews| Index: Source/bindings/v8/ScriptDebugServer.cpp |
| diff --git a/Source/bindings/v8/ScriptDebugServer.cpp b/Source/bindings/v8/ScriptDebugServer.cpp |
| index 6678fdd95883da823b24b7ea06323257ad3c7bb7..9b938ac0b0566a1ab36b82e5166bf7d625b9d5cf 100644 |
| --- a/Source/bindings/v8/ScriptDebugServer.cpp |
| +++ b/Source/bindings/v8/ScriptDebugServer.cpp |
| @@ -41,6 +41,7 @@ |
| #include "bindings/v8/V8RecursionScope.h" |
| #include "core/inspector/ScriptDebugListener.h" |
| #include "wtf/StdLibExtras.h" |
| +#include "wtf/StringExtras.h" |
| #include "wtf/Vector.h" |
| namespace WebCore { |
| @@ -85,6 +86,7 @@ v8::Local<v8::Value> ScriptDebugServer::callDebuggerMethod(const char* functionN |
| class ScriptDebugServer::ScriptPreprocessor { |
| WTF_MAKE_NONCOPYABLE(ScriptPreprocessor); |
| public: |
| + |
| explicit ScriptPreprocessor(const String& preprocessorScript) |
| { |
| v8::HandleScope scope; |
| @@ -137,7 +139,13 @@ public: |
| if (resultValue->IsString()) { |
| v8::String::Utf8Value utf8Value(resultValue); |
| - return String::fromUTF8(*utf8Value, utf8Value.length()); |
| + |
| + String preprocessed = String::fromUTF8(*utf8Value, utf8Value.length()); |
| + // Zero bytes crash the page if we are preprocessing injectedScripts |
| + if (preprocessed.length() == 0) |
| + return sourceCode; |
| + |
| + return preprocessed; |
| } |
| return sourceCode; |
| @@ -458,7 +466,12 @@ void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD |
| if (!m_scriptPreprocessor) |
| return; |
| + // Don't preprocess debugger scripts or content scripts |
| + if (V8PerContextDebugData::isSystemScope(eventContext) || V8PerContextDebugData::contextCategory(eventContext) == "injected") |
|
pfeldman
2013/05/01 07:33:55
Please introduce constant for this so that we coul
|
| + return; |
| + |
| OwnPtr<ScriptPreprocessor> preprocessor(m_scriptPreprocessor.release()); |
| + |
| v8::Local<v8::Context> debugContext = v8::Debug::GetDebugContext(); |
| v8::Context::Scope contextScope(debugContext); |
| v8::Handle<v8::Function> getScriptSourceFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScriptSource"))); |
| @@ -469,8 +482,13 @@ void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD |
| v8::Handle<v8::Value> argv1[] = { eventDetails.GetEventData() }; |
| v8::Handle<v8::Value> scriptName = getScriptNameFunction->Call(m_debuggerScript.get(), 1, argv1); |
| + v8::String::Utf8Value scriptNameUtf8Value(scriptName); |
| + String scriptNameString = String::fromUTF8(*scriptNameUtf8Value, scriptNameUtf8Value.length()); |
| + if (scriptNameString.contains("data:text/html,chromewebdata")) |
|
pfeldman
2013/05/01 07:33:55
You can't say "chromewebdata" from blink which is
|
| + return; |
| + |
| v8::Handle<v8::Function> setScriptSourceFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setScriptSource"))); |
| - String patchedScript = preprocessor->preprocessSourceCode(toWebCoreStringWithUndefinedOrNullCheck(script), toWebCoreStringWithUndefinedOrNullCheck(scriptName)); |
| + String patchedScript = preprocessor->preprocessSourceCode(toWebCoreStringWithUndefinedOrNullCheck(script), scriptNameString); |
| v8::Handle<v8::Value> argv2[] = { eventDetails.GetEventData(), v8String(patchedScript, debugContext->GetIsolate()) }; |
| setScriptSourceFunction->Call(m_debuggerScript.get(), 2, argv2); |