 Chromium Code Reviews
 Chromium Code Reviews Issue 1583383003:
  [DevTools] Send source map content from frontend to backend  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@blackbox-inline-source-map
    
  
    Issue 1583383003:
  [DevTools] Send source map content from frontend to backend  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@blackbox-inline-source-map| Index: third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.cpp | 
| diff --git a/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.cpp b/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.cpp | 
| index 05fc1cfa9744d08b6b2bbf8c5c7c1c8de58cecf1..ee1ab37d532642a5a61dcbf83533a972da52255d 100644 | 
| --- a/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.cpp | 
| +++ b/third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.cpp | 
| @@ -28,6 +28,9 @@ | 
| #include "core/inspector/v8/V8Debugger.h" | 
| #include "core/inspector/v8/V8JavaScriptCallFrame.h" | 
| #include "platform/JSONValues.h" | 
| +#include "platform/SharedBuffer.h" | 
| +#include "platform/weborigin/KURL.h" | 
| +#include "public/platform/Platform.h" | 
| #include "wtf/Optional.h" | 
| #include "wtf/text/StringBuilder.h" | 
| #include "wtf/text/WTFString.h" | 
| @@ -121,6 +124,19 @@ static PassRefPtrWillBeRawPtr<ScriptCallStack> toScriptCallStack(v8::Local<v8::C | 
| return jsCallFrame ? toScriptCallStack(jsCallFrame.get()) : nullptr; | 
| } | 
| +static PassOwnPtr<SourceMap> parseSourceMapFromDataUrl(const String& url) | 
| +{ | 
| + KURL sourceMapURL(KURL(), url); | 
| + if (sourceMapURL.isEmpty() || !sourceMapURL.isValid()) | 
| + return nullptr; | 
| + WebString mimetype; | 
| + WebString charset; | 
| + RefPtr<SharedBuffer> data = PassRefPtr<SharedBuffer>(Platform::current()->parseDataURL(sourceMapURL, mimetype, charset)); | 
| + if (!data) | 
| + return nullptr; | 
| + return SourceMap::parse(String(data->data(), data->size())); | 
| +} | 
| + | 
| PassOwnPtr<V8DebuggerAgent> V8DebuggerAgent::create(InjectedScriptManager* injectedScriptManager, V8Debugger* debugger, int contextGroupId) | 
| { | 
| return adoptPtr(new V8DebuggerAgentImpl(injectedScriptManager, static_cast<V8DebuggerImpl*>(debugger), contextGroupId)); | 
| @@ -217,6 +233,7 @@ void V8DebuggerAgentImpl::disable(ErrorString*) | 
| m_pausedScriptState = nullptr; | 
| m_currentCallStack.Reset(); | 
| m_scripts.clear(); | 
| + m_sourceMaps.clear(); | 
| m_breakpointIdToDebuggerBreakpointIds.clear(); | 
| internalSetAsyncCallStackDepth(0); | 
| m_promiseTracker->setEnabled(false, false); | 
| @@ -519,9 +536,17 @@ bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(PassRefPtr<Ja | 
| return true; | 
| bool isBlackboxed = false; | 
| String scriptURL = it->value.sourceURL(); | 
| - if (m_cachedSkipStackRegExp && !scriptURL.isEmpty()) { | 
| + String sourceMappedScriptURL; | 
| + auto itSourceMap = m_sourceMaps.find(String::number(frame->sourceID())); | 
| + if (itSourceMap != m_sourceMaps.end()) { | 
| + const SourceMap::Entry* entry = itSourceMap->value->findEntry(frame->line(), frame->column()); | 
| + if (entry) | 
| + sourceMappedScriptURL = entry->sourceURL; | 
| + } | 
| + if (m_cachedSkipStackRegExp && (!scriptURL.isEmpty() || !sourceMappedScriptURL.isEmpty())) { | 
| if (!it->value.getBlackboxedState(m_cachedSkipStackGeneration, &isBlackboxed)) { | 
| - isBlackboxed = m_cachedSkipStackRegExp->match(scriptURL) != -1; | 
| + isBlackboxed = !scriptURL.isEmpty() && m_cachedSkipStackRegExp->match(scriptURL) != -1; | 
| + isBlackboxed = isBlackboxed || (!sourceMappedScriptURL.isEmpty() && m_cachedSkipStackRegExp->match(sourceMappedScriptURL) != -1); | 
| it->value.setBlackboxedState(m_cachedSkipStackGeneration, isBlackboxed); | 
| } | 
| } | 
| @@ -1341,6 +1366,20 @@ void V8DebuggerAgentImpl::removeAsyncOperationBreakpoint(ErrorString* errorStrin | 
| m_asyncOperationBreakpoints.remove(operationId); | 
| } | 
| +void V8DebuggerAgentImpl::setSourceMapContent(ErrorString*, const String& scriptId, const String& content) | 
| +{ | 
| + auto it = m_scripts.find(scriptId); | 
| + if (it == m_scripts.end()) | 
| + return; | 
| + if (m_sourceMaps.find(scriptId) != m_sourceMaps.end()) | 
| + return; | 
| + OwnPtr<SourceMap> sourceMap = SourceMap::parse(content); | 
| + if (sourceMap) { | 
| + m_sourceMaps.set(scriptId, sourceMap.release()); | 
| + it->value.invalidateBlackboxedState(); | 
| + } | 
| +} | 
| + | 
| void V8DebuggerAgentImpl::willExecuteScript(int scriptId) | 
| { | 
| changeJavaScriptRecursionLevel(+1); | 
| @@ -1480,6 +1519,9 @@ void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr | 
| bool hasSourceURL = script.hasSourceURL(); | 
| String scriptURL = script.sourceURL(); | 
| String sourceMapURL = sourceMapURLForScript(script, parsedScript.success); | 
| + OwnPtr<SourceMap> sourceMap = parseSourceMapFromDataUrl(sourceMapURL); | 
| 
pfeldman
2016/01/19 19:35:04
It'be nice if it went through the same code path a
 
kozy
2016/01/20 00:41:22
Done.
 | 
| + if (sourceMap) | 
| + m_sourceMaps.set(parsedScript.scriptId, sourceMap.release()); | 
| const String* sourceMapURLParam = sourceMapURL.isNull() ? nullptr : &sourceMapURL; | 
| const bool* isContentScriptParam = isContentScript ? &isContentScript : nullptr; | 
| @@ -1662,6 +1704,7 @@ void V8DebuggerAgentImpl::reset() | 
| { | 
| m_scheduledDebuggerStep = NoStep; | 
| m_scripts.clear(); | 
| + m_sourceMaps.clear(); | 
| m_breakpointIdToDebuggerBreakpointIds.clear(); | 
| resetAsyncCallTracker(); | 
| m_promiseTracker->clear(); |