Commit c72a48ad authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[DevTools] Fix location.script().sourceURL

Script can be null.

BUG=607532
R=lushnikov@chromium.org

Review-Url: https://codereview.chromium.org/2198443004
Cr-Commit-Position: refs/heads/master@{#408843}
parent b0d782e7
......@@ -85,9 +85,12 @@ WebInspector.BlackboxManager.prototype = {
*/
isBlackboxedRawLocation: function(location)
{
var positions = this._scriptPositions(location.script());
var script = location.script();
if (!script)
return false;
var positions = this._scriptPositions(script);
if (!positions)
return this._isBlackboxedScript(location.script());
return this._isBlackboxedScript(script);
var index = positions.lowerBound(location, comparator);
return !!(index % 2);
......
......@@ -110,7 +110,10 @@ WebInspector.CompilerScriptMapping.prototype = {
var entry = sourceMap.findEntry(lineNumber, columnNumber);
if (!entry || !entry.sourceURL)
return null;
var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(/** @type {string} */ (entry.sourceURL), rawLocation.script());
var script = rawLocation.script();
if (!script)
return null;
var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(/** @type {string} */ (entry.sourceURL), script);
if (!uiSourceCode)
return null;
return uiSourceCode.uiLocation(/** @type {number} */ (entry.sourceLineNumber), /** @type {number} */ (entry.sourceColumnNumber));
......
......@@ -157,7 +157,7 @@ WebInspector.DebuggerWorkspaceBinding.prototype = {
createCallFrameLiveLocation: function(location, updateDelegate, locationPool)
{
var target = location.target();
this._ensureInfoForScript(location.script());
this._ensureInfoForScript(/** @type {!WebInspector.Script} */(location.script()));
var liveLocation = this.createLiveLocation(location, updateDelegate, locationPool);
this._registerCallFrameLiveLocation(target, liveLocation);
return liveLocation;
......
......@@ -64,6 +64,8 @@ WebInspector.ResourceScriptMapping.prototype = {
{
var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (rawLocation);
var script = debuggerModelLocation.script();
if (!script)
return null;
var uiSourceCode = this._workspaceUISourceCodeForScript(script);
if (!uiSourceCode)
return null;
......
......@@ -337,7 +337,7 @@ WebInspector.DebuggerModel.prototype = {
/**
* @param {!RuntimeAgent.ScriptId} scriptId
* @return {!WebInspector.Script}
* @return {?WebInspector.Script}
*/
scriptForId: function(scriptId)
{
......@@ -933,7 +933,7 @@ WebInspector.DebuggerModel.Location.prototype = {
},
/**
* @return {!WebInspector.Script}
* @return {?WebInspector.Script}
*/
script: function()
{
......
......@@ -248,7 +248,8 @@ WebInspector.ScriptSnippetModel.prototype = {
if (mapping.evaluationIndex(uiSourceCode) !== evaluationIndex)
return;
mapping._addScript(executionContext.debuggerModel.scriptForId(scriptId || exceptionDetails.scriptId), uiSourceCode);
var script = /** @type {!WebInspector.Script} */(executionContext.debuggerModel.scriptForId(scriptId || exceptionDetails.scriptId));
mapping._addScript(script, uiSourceCode);
if (!scriptId) {
this._printRunOrCompileScriptResultFailure(target, exceptionDetails, evaluationUrl);
return;
......
......@@ -447,7 +447,8 @@ WebInspector.CallStackSidebarPane.CallFrame = function(functionName, location, l
this._asyncCallFrame = asyncCallFrame;
if (asyncCallFrame) {
var locationElement = linkifier.linkifyRawLocation(location, location.script().sourceURL);
var script = location.script();
var locationElement = linkifier.linkifyRawLocation(location, script ? script.sourceURL : "");
this.subtitleElement.appendChild(locationElement);
} else {
this._liveLocationPool = new WebInspector.LiveLocationPool();
......
......@@ -24,6 +24,8 @@ WebInspector.FormatterScriptMapping.prototype = {
{
var debuggerModelLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (rawLocation);
var script = debuggerModelLocation.script();
if (!script)
return null;
var uiSourceCode = this._editorAction._uiSourceCodes.get(script);
if (!uiSourceCode)
return null;
......
......@@ -263,6 +263,8 @@ WebInspector.SourceMapNamesResolver._resolveExpression = function(callFrame, uiS
return Promise.resolve("");
var script = rawLocation.script();
if (!script)
return Promise.resolve("");
var sourceMap = WebInspector.debuggerWorkspaceBinding.sourceMapForScript(script);
if (!sourceMap)
return Promise.resolve("");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment