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

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..02e46b195c12c8f4c3a204df9a15cadbd2cf94e6 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 Nullable<SourceMap> parseSourceMapFromDataUrl(const String& url)
+{
+ KURL sourceMapURL(ParsedURLString, url);
dgozman 2016/01/13 01:28:49 KURL kurl(KURL(), url);
kozy 2016/01/13 20:47:57 Done.
+ if (sourceMapURL.isEmpty() || !sourceMapURL.isValid())
+ return Nullable<SourceMap>();
+ WebString mimetype;
+ WebString charset;
+ RefPtr<SharedBuffer> data = PassRefPtr<SharedBuffer>(Platform::current()->parseDataURL(sourceMapURL, mimetype, charset));
+ if (!data)
+ return Nullable<SourceMap>();
+ 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()) {
+ Nullable<SourceMap::Entry> entry = itSourceMap->value.findEntry(frame->line(), frame->column());
+ if (!entry.isNull())
+ scriptURL = entry.get().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);
+ Nullable<SourceMap> sourceMap = parseSourceMapFromDataUrl(sourceMapURL);
+ if (!sourceMap.isNull())
+ m_sourceMaps.set(parsedScript.scriptId, sourceMap.get());
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