Index: third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js |
index 72693cadfdd036e221785df59aa9a22d9f65462d..a2e2e4cb38b070c21469aa2554c7a35b1e7129f3 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js |
@@ -41,6 +41,12 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
target.registerDebuggerDispatcher(new SDK.DebuggerDispatcher(this)); |
this._agent = target.debuggerAgent(); |
this._runtimeModel = /** @type {!SDK.RuntimeModel} */ (target.model(SDK.RuntimeModel)); |
+ this._runtimeModel.addEventListener(SDK.RuntimeModel.Events.ExecutionContextDestroyed, this._executionContextDestroyed, this); |
+ |
+ /** @type {!SDK.SourceMapManager<!SDK.Script>} */ |
+ this._sourceMapManager = new SDK.SourceMapManager(target); |
+ /** @type {!Map<string, !SDK.Script>} */ |
+ this._sourceMapIdToScript = new Map(); |
/** @type {?SDK.DebuggerPausedDetails} */ |
this._debuggerPausedDetails = null; |
@@ -65,6 +71,28 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
/** @type {!Map<string, string>} */ |
this._stringMap = new Map(); |
+ this._sourceMapManager.setEnabled(Common.moduleSetting('jsSourceMapsEnabled').get()); |
+ Common.moduleSetting('jsSourceMapsEnabled') |
+ .addChangeListener(event => this._sourceMapManager.setEnabled(/** @type {boolean} */ (event.data))); |
+ } |
+ |
+ /** |
+ * @param {string} executionContextId |
+ * @param {string} sourceURL |
+ * @param {?string} sourceMapURL |
+ * @return {?string} |
+ */ |
+ static _sourceMapId(executionContextId, sourceURL, sourceMapURL) { |
+ if (!sourceMapURL) |
+ return null; |
+ return executionContextId + ':' + sourceURL + ':' + sourceMapURL; |
+ } |
+ |
+ /** |
+ * @return {!SDK.SourceMapManager<!SDK.Script>} |
+ */ |
+ sourceMapManager() { |
+ return this._sourceMapManager; |
} |
/** |
@@ -318,6 +346,10 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
this._scriptsBySourceURL.clear(); |
this._stringMap.clear(); |
this._discardableScripts = []; |
+ |
+ for (var scriptWithSourceMap of this._sourceMapIdToScript.values()) |
+ this._sourceMapManager.detachSourceMap(scriptWithSourceMap); |
+ this._sourceMapIdToScript.clear(); |
} |
/** |
@@ -486,6 +518,16 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
this.dispatchEventToListeners(SDK.DebuggerModel.Events.ParsedScriptSource, script); |
else |
this.dispatchEventToListeners(SDK.DebuggerModel.Events.FailedToParseScriptSource, script); |
+ |
+ var sourceMapId = SDK.DebuggerModel._sourceMapId(script.executionContextId, script.sourceURL, script.sourceMapURL); |
+ if (sourceMapId && !hasSyntaxError) { |
+ var previousSourceMapClient = this._sourceMapIdToScript.get(sourceMapId); |
+ if (previousSourceMapClient) |
+ this._sourceMapManager.detachSourceMap(previousSourceMapClient); |
+ this._sourceMapIdToScript.set(sourceMapId, script); |
+ this._sourceMapManager.attachSourceMap(script, script.sourceURL, script.sourceMapURL); |
+ } |
+ |
var isDiscardable = hasSyntaxError && script.isAnonymousScript(); |
if (isDiscardable) { |
this._discardableScripts.push(script); |
@@ -496,6 +538,33 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
/** |
* @param {!SDK.Script} script |
+ * @param {string} newSourceMapURL |
+ */ |
+ setSourceMapURL(script, newSourceMapURL) { |
+ var sourceMapId = SDK.DebuggerModel._sourceMapId(script.executionContextId, script.sourceURL, script.sourceMapURL); |
+ if (sourceMapId && this._sourceMapIdToScript.get(sourceMapId) === script) |
+ this._sourceMapIdToScript.delete(sourceMapId); |
+ this._sourceMapManager.detachSourceMap(script); |
+ |
+ script.sourceMapURL = newSourceMapURL; |
+ sourceMapId = SDK.DebuggerModel._sourceMapId(script.executionContextId, script.sourceURL, script.sourceMapURL); |
+ this._sourceMapIdToScript.set(sourceMapId, script); |
+ this._sourceMapManager.attachSourceMap(script, script.sourceURL, script.sourceMapURL); |
+ } |
+ |
+ /** |
+ * @param {!Common.Event} event |
+ */ |
+ _executionContextDestroyed(event) { |
+ var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); |
+ for (var script of this._sourceMapIdToScript.values()) { |
+ if (script.executionContextId === executionContext.id) |
+ this._sourceMapManager.detachSourceMap(script); |
+ } |
+ } |
+ |
+ /** |
+ * @param {!SDK.Script} script |
*/ |
_registerScript(script) { |
this._scripts[script.scriptId] = script; |
@@ -772,6 +841,7 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
* @override |
*/ |
dispose() { |
+ this._runtimeModel.removeEventListener(SDK.RuntimeModel.Events.ExecutionContextDestroyed, this._executionContextDestroyed, this); |
Common.moduleSetting('pauseOnExceptionEnabled').removeChangeListener(this._pauseOnExceptionStateChanged, this); |
Common.moduleSetting('pauseOnCaughtException').removeChangeListener(this._pauseOnExceptionStateChanged, this); |
Common.moduleSetting('enableAsyncStackTraces').removeChangeListener(this.asyncStackTracesStateChanged, this); |
@@ -818,6 +888,14 @@ SDK.DebuggerModel = class extends SDK.SDKModel { |
this._stringMap.set(string, string); |
return this._stringMap.get(string); |
} |
+ |
+ /** |
+ * @override |
+ */ |
+ dispose() { |
+ super.dispose(); |
+ this._sourceMapManager.dispose(); |
+ } |
}; |
SDK.SDKModel.register(SDK.DebuggerModel, SDK.Target.Capability.JS, true); |
@@ -847,8 +925,7 @@ SDK.DebuggerModel.Events = { |
DiscardedAnonymousScriptSource: Symbol('DiscardedAnonymousScriptSource'), |
GlobalObjectCleared: Symbol('GlobalObjectCleared'), |
CallFrameSelected: Symbol('CallFrameSelected'), |
- ConsoleCommandEvaluatedInSelectedCallFrame: Symbol('ConsoleCommandEvaluatedInSelectedCallFrame'), |
- SourceMapURLAdded: Symbol('SourceMapURLAdded') |
+ ConsoleCommandEvaluatedInSelectedCallFrame: Symbol('ConsoleCommandEvaluatedInSelectedCallFrame') |
}; |
/** @enum {string} */ |