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

Unified Diff: third_party/WebKit/Source/core/inspector/v8/V8DebuggerAgentImpl.cpp

Issue 1579283002: [DevTools] Blackbox sources with inline source maps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@source-map-backend
Patch Set: Created 4 years, 11 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: 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 e7a98955b4e150fe900fc117c7eaf9e67dbf152f..eaf20fc10faafaa5405e51b4472da909aac5e995 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 OwnPtr<SourceMap> parseSourceMapFromDataUrl(const String& url)
dgozman 2016/01/14 00:03:06 PassOwnPtr
kozy 2016/01/14 00:38:32 Done.
+{
+ 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);
@@ -518,6 +535,12 @@ bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(PassRefPtr<Ja
return true;
bool isBlackboxed = false;
String scriptURL = it->value.sourceURL();
+ 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)
+ scriptURL = entry->sourceURL;
+ }
if (m_cachedSkipStackRegExp && !scriptURL.isEmpty()) {
if (!it->value.getBlackboxedState(m_cachedSkipStackGeneration, &isBlackboxed)) {
isBlackboxed = m_cachedSkipStackRegExp->match(scriptURL) != -1;
@@ -1461,6 +1484,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);
+ if (sourceMap)
+ m_sourceMaps.set(parsedScript.scriptId, sourceMap.release());
const String* sourceMapURLParam = sourceMapURL.isNull() ? nullptr : &sourceMapURL;
const bool* isContentScriptParam = isContentScript ? &isContentScript : nullptr;
@@ -1640,6 +1666,7 @@ void V8DebuggerAgentImpl::reset()
{
m_scheduledDebuggerStep = NoStep;
m_scripts.clear();
+ m_sourceMaps.clear();
m_breakpointIdToDebuggerBreakpointIds.clear();
resetAsyncCallTracker();
m_promiseTracker->clear();

Powered by Google App Engine
This is Rietveld 408576698