Created
April 22, 2019 14:37
-
-
Save jasonLaster/d0a5064a1a0e1a5d86832af54cf17264 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 4e88cff4ea86a7ea17098b97bbf7a03ceae84fc7 | |
Author: Jason Laster <jlaster@mozilla.com> | |
Date: Fri Jan 25 15:44:22 2019 -0500 | |
Bug 1517514 - Convert the GeneratedLocation class to a general Location class in the server. r=lsmyth | |
Tags: #secure-revision | |
Differential Revision: https://phabricator.services.mozilla.com/D17687 | |
diff --git a/devtools/server/actors/breakpoint.js b/devtools/server/actors/breakpoint.js | |
index c5a86e4faea7..67f912d6dab2 100644 | |
--- a/devtools/server/actors/breakpoint.js | |
+++ b/devtools/server/actors/breakpoint.js | |
@@ -42,16 +42,16 @@ const BreakpointActor = ActorClassWithSpec(breakpointSpec, { | |
* | |
* @param ThreadActor threadActor | |
* The parent thread actor that contains this breakpoint. | |
- * @param GeneratedLocation generatedLocation | |
+ * @param SourceLocation location | |
* The generated location of the breakpoint. | |
*/ | |
- initialize: function(threadActor, generatedLocation) { | |
+ initialize: function(threadActor, location) { | |
// The set of Debugger.Script instances that this breakpoint has been set | |
// upon. | |
this.scripts = new Set(); | |
this.threadActor = threadActor; | |
- this.generatedLocation = generatedLocation; | |
+ this.location = location; | |
this.condition = null; | |
this.isPending = true; | |
}, | |
@@ -140,13 +140,13 @@ const BreakpointActor = ActorClassWithSpec(breakpointSpec, { | |
// Don't pause if we are currently stepping (in or over) or the frame is | |
// black-boxed. | |
const { | |
- generatedSourceActor, | |
- generatedLine, | |
- generatedColumn, | |
+ sourceActor, | |
+ line, | |
+ column, | |
} = this.threadActor.sources.getFrameLocation(frame); | |
- const url = generatedSourceActor.url; | |
+ const url = sourceActor.url; | |
- if (this.threadActor.sources.isBlackBoxed(url, generatedLine, generatedColumn) | |
+ if (this.threadActor.sources.isBlackBoxed(url, line, column) | |
|| this.threadActor.skipBreakpoints | |
|| frame.onStep) { | |
return undefined; | |
@@ -154,10 +154,10 @@ const BreakpointActor = ActorClassWithSpec(breakpointSpec, { | |
// If we're trying to pop this frame, and we see a breakpoint at | |
// the spot at which popping started, ignore it. See bug 970469. | |
- const locationAtFinish = frame.onPop && frame.onPop.generatedLocation; | |
+ const locationAtFinish = frame.onPop && frame.onPop.location; | |
if (locationAtFinish && | |
- locationAtFinish.generatedLine === generatedLine && | |
- locationAtFinish.generatedColumn === generatedColumn) { | |
+ locationAtFinish.line === line && | |
+ locationAtFinish.column === column) { | |
return undefined; | |
} | |
@@ -192,8 +192,8 @@ const BreakpointActor = ActorClassWithSpec(breakpointSpec, { | |
*/ | |
delete: function() { | |
// Remove from the breakpoint store. | |
- if (this.generatedLocation) { | |
- this.threadActor.breakpointActorMap.deleteActor(this.generatedLocation); | |
+ if (this.location) { | |
+ this.threadActor.breakpointActorMap.deleteActor(this.location); | |
} | |
this.threadActor.threadLifetimePool.removeActor(this); | |
// Remove the actual breakpoint from the associated scripts. | |
diff --git a/devtools/server/actors/common.js b/devtools/server/actors/common.js | |
index 89c6709dac08..fb91d51efe1e 100644 | |
--- a/devtools/server/actors/common.js | |
+++ b/devtools/server/actors/common.js | |
@@ -105,16 +105,16 @@ ActorPool.prototype = { | |
exports.ActorPool = ActorPool; | |
/** | |
- * A GeneratedLocation represents a location in a generated source. | |
+ * A SourceLocation represents a location in a source. | |
* | |
* @param SourceActor actor | |
- * A SourceActor representing a generated source. | |
+ * A SourceActor representing a source. | |
* @param Number line | |
* A line within the given source. | |
* @param Number column | |
* A column within the given line. | |
*/ | |
-function GeneratedLocation(actor, line, column, lastColumn) { | |
+function SourceLocation(actor, line, column, lastColumn) { | |
this._connection = actor ? actor.conn : null; | |
this._actorID = actor ? actor.actorID : undefined; | |
this._line = line; | |
@@ -122,68 +122,49 @@ function GeneratedLocation(actor, line, column, lastColumn) { | |
this._lastColumn = (lastColumn !== undefined) ? lastColumn : column + 1; | |
} | |
-GeneratedLocation.prototype = { | |
- get originalSourceActor() { | |
- throw new Error(); | |
- }, | |
- | |
- get originalUrl() { | |
- throw new Error("Shouldn't access originalUrl from a GeneratedLocation"); | |
- }, | |
- | |
- get originalLine() { | |
- throw new Error("Shouldn't access originalLine from a GeneratedLocation"); | |
- }, | |
- | |
- get originalColumn() { | |
- throw new Error("Shouldn't access originalColumn from a GeneratedLocation"); | |
- }, | |
- | |
- get originalName() { | |
- throw new Error("Shouldn't access originalName from a GeneratedLocation"); | |
- }, | |
+SourceLocation.prototype = { | |
- get generatedSourceActor() { | |
+ get sourceActor() { | |
return this._connection ? this._connection.getActor(this._actorID) : null; | |
}, | |
- get generatedUrl() { | |
- const actor = this.generatedSourceActor; | |
+ get url() { | |
+ const actor = this.sourceActor; | |
const source = actor.source; | |
return source ? source.url : actor._originalUrl; | |
}, | |
- get generatedLine() { | |
+ get line() { | |
return this._line; | |
}, | |
- get generatedColumn() { | |
+ get column() { | |
return this._column; | |
}, | |
- get generatedLastColumn() { | |
+ get lastColumn() { | |
return this._lastColumn; | |
}, | |
equals: function(other) { | |
- return this.generatedSourceActor.url == other.generatedSourceActor.url && | |
- this.generatedLine === other.generatedLine && | |
- (this.generatedColumn === undefined || | |
- other.generatedColumn === undefined || | |
- this.generatedColumn === other.generatedColumn); | |
+ return this.sourceActor.url == other.sourceActor.url && | |
+ this.line === other.line && | |
+ (this.column === undefined || | |
+ other.column === undefined || | |
+ this.column === other.column); | |
}, | |
toJSON: function() { | |
return { | |
- source: this.generatedSourceActor.form(), | |
- line: this.generatedLine, | |
- column: this.generatedColumn, | |
- lastColumn: this.generatedLastColumn, | |
+ source: this.sourceActor.form(), | |
+ line: this.line, | |
+ column: this.column, | |
+ lastColumn: this.lastColumn, | |
}; | |
}, | |
}; | |
-exports.GeneratedLocation = GeneratedLocation; | |
+exports.SourceLocation = SourceLocation; | |
/** | |
* A method decorator that ensures the actor is in the expected state before | |
diff --git a/devtools/server/actors/frame.js b/devtools/server/actors/frame.js | |
index 381a5914ed65..14f7dfab9e35 100644 | |
--- a/devtools/server/actors/frame.js | |
+++ b/devtools/server/actors/frame.js | |
@@ -82,11 +82,11 @@ const FrameActor = ActorClassWithSpec(frameSpec, { | |
return {} | |
} | |
- const generatedLocation = this.threadActor.sources.getFrameLocation(this.frame); | |
+ const location = this.threadActor.sources.getFrameLocation(this.frame); | |
return { | |
- source: generatedLocation.generatedSourceActor.actorID, | |
- line: generatedLocation.generatedLine, | |
- column: generatedLocation.generatedColumn, | |
+ source: location.sourceActor.actorID, | |
+ line: location.line, | |
+ column: location.column, | |
}; | |
}, | |
diff --git a/devtools/server/actors/source.js b/devtools/server/actors/source.js | |
index 02fa3f38f1e7..4b6932a49bde 100644 | |
--- a/devtools/server/actors/source.js | |
+++ b/devtools/server/actors/source.js | |
@@ -9,7 +9,7 @@ | |
const { Cc, Ci } = require("chrome"); | |
const Services = require("Services"); | |
const { BreakpointActor, setBreakpointAtEntryPoints } = require("devtools/server/actors/breakpoint"); | |
-const { GeneratedLocation } = require("devtools/server/actors/common"); | |
+const { SourceLocation } = require("devtools/server/actors/common"); | |
const { createValueGrip } = require("devtools/server/actors/object/utils"); | |
const { ActorClassWithSpec } = require("devtools/shared/protocol"); | |
const DevToolsUtils = require("devtools/shared/DevToolsUtils"); | |
@@ -569,7 +569,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
* response. | |
*/ | |
setBreakpoint: function(line, column, condition, noSliding) { | |
- const location = new GeneratedLocation(this, line, column); | |
+ const location = new SourceLocation(this, line, column); | |
const actor = this._getOrCreateBreakpointActor( | |
location, | |
condition, | |
@@ -581,7 +581,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
isPending: actor.isPending, | |
}; | |
- const actualLocation = actor.generatedLocation; | |
+ const actualLocation = actor.location; | |
if (!actualLocation.equals(location)) { | |
response.actualLocation = actualLocation.toJSON(); | |
} | |
@@ -590,13 +590,13 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
}, | |
/** | |
- * Get or create a BreakpointActor for the given location in the generated | |
+ * Get or create a BreakpointActor for the given location in the | |
* source, and ensure it is set as a breakpoint handler on all scripts that | |
* match the given location. | |
* | |
- * @param GeneratedLocation generatedLocation | |
- * A GeneratedLocation representing the location of the breakpoint in | |
- * the generated source. | |
+ * @param SourceLocation location | |
+ * A SourceLocation representing the location of the breakpoint in | |
+ * the source. | |
* @param String condition | |
* A string that is evaluated whenever the breakpoint is hit. If the | |
* string evaluates to false, the breakpoint is ignored. | |
@@ -606,12 +606,12 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
* @returns BreakpointActor | |
* A BreakpointActor representing the breakpoint. | |
*/ | |
- _getOrCreateBreakpointActor: function(generatedLocation, condition, noSliding) { | |
- let actor = this.breakpointActorMap.getActor(generatedLocation); | |
+ _getOrCreateBreakpointActor: function(location, condition, noSliding) { | |
+ let actor = this.breakpointActorMap.getActor(location); | |
if (!actor) { | |
- actor = new BreakpointActor(this.threadActor, generatedLocation); | |
+ actor = new BreakpointActor(this.threadActor, location); | |
this.threadActor.threadLifetimePool.addActor(actor); | |
- this.breakpointActorMap.setActor(generatedLocation, actor); | |
+ this.breakpointActorMap.setActor(location, actor); | |
} | |
actor.condition = condition; | |
@@ -621,7 +621,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
/* | |
* Ensure the given BreakpointActor is set as a breakpoint handler on all | |
- * scripts that match its location in the generated source. | |
+ * scripts that match its location in the source. | |
* | |
* If there are no scripts that match the location of the BreakpointActor, | |
* we slide its location to the next closest line (for line breakpoints) or | |
@@ -642,14 +642,14 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
* @returns A Promise that resolves to the given BreakpointActor. | |
*/ | |
_setBreakpoint: function(actor, noSliding) { | |
- const { generatedLocation } = actor; | |
- const { generatedLine, generatedSourceActor } = generatedLocation; | |
+ const { location } = actor; | |
+ const { line, sourceActor } = location; | |
const isWasm = this.source && this.source.introductionType === "wasm"; | |
- if (!this._setBreakpointAtGeneratedLocation(actor, generatedLocation) && | |
+ if (!this._setBreakpointAtLocation(actor, location) && | |
!noSliding && | |
!isWasm) { | |
- const scripts = this._findDebuggeeScripts({ line: generatedLine }); | |
+ const scripts = this._findDebuggeeScripts({ line: line }); | |
// Never do breakpoint sliding for column breakpoints. | |
// Additionally, never do breakpoint sliding if no scripts | |
@@ -669,7 +669,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
// script gets GCed, that means that all parents scripts are | |
// GCed as well, and no scripts will exist on those lines | |
// anymore. We will never slide through a GCed script. | |
- if (generatedLocation.generatedColumn || scripts.length === 0) { | |
+ if (location.column || scripts.length === 0) { | |
return actor; | |
} | |
@@ -683,10 +683,10 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
}); | |
const maxLine = largestScript.startLine + largestScript.lineCount - 1; | |
- let actualLine = generatedLine; | |
+ let actualLine = line; | |
for (; actualLine <= maxLine; actualLine++) { | |
- const loc = new GeneratedLocation(this, actualLine); | |
- if (this._setBreakpointAtGeneratedLocation(actor, loc)) { | |
+ const loc = new SourceLocation(this, actualLine); | |
+ if (this._setBreakpointAtLocation(actor, loc)) { | |
break; | |
} | |
} | |
@@ -708,14 +708,14 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
// Update the actor to use the new location (reusing a | |
// previous breakpoint if it already exists on that line). | |
- const actualLocation = new GeneratedLocation(generatedSourceActor, actualLine); | |
+ const actualLocation = new SourceLocation(sourceActor, actualLine); | |
const existingActor = this.breakpointActorMap.getActor(actualLocation); | |
- this.breakpointActorMap.deleteActor(generatedLocation); | |
+ this.breakpointActorMap.deleteActor(location); | |
if (existingActor) { | |
actor.delete(); | |
actor = existingActor; | |
} else { | |
- actor.generatedLocation = actualLocation; | |
+ actor.location = actualLocation; | |
this.breakpointActorMap.setActor(actualLocation, actor); | |
} | |
} | |
@@ -723,56 +723,43 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
return actor; | |
}, | |
- _setBreakpointAtAllGeneratedLocations: function(actor, generatedLocations) { | |
- let success = false; | |
- for (const generatedLocation of generatedLocations) { | |
- if (this._setBreakpointAtGeneratedLocation( | |
- actor, | |
- generatedLocation | |
- )) { | |
- success = true; | |
- } | |
- } | |
- return success; | |
- }, | |
- | |
/* | |
* Ensure the given BreakpointActor is set as breakpoint handler on all | |
- * scripts that match the given location in the generated source. | |
+ * scripts that match the given location in the source. | |
* | |
* @param BreakpointActor actor | |
* The BreakpointActor to be set as a breakpoint handler. | |
- * @param GeneratedLocation generatedLocation | |
- * A GeneratedLocation representing the location in the generated | |
+ * @param SourceLocation location | |
+ * A SourceLocation representing the location in the | |
* source for which the given BreakpointActor is to be set as a | |
* breakpoint handler. | |
* | |
* @returns A Boolean that is true if the BreakpointActor was set as a | |
* breakpoint handler on at least one script, and false otherwise. | |
*/ | |
- _setBreakpointAtGeneratedLocation: function(actor, generatedLocation) { | |
+ _setBreakpointAtLocation: function(actor, location) { | |
const { | |
- generatedSourceActor, | |
- generatedLine, | |
- generatedColumn, | |
- generatedLastColumn, | |
- } = generatedLocation; | |
+ sourceActor, | |
+ line, | |
+ column, | |
+ lastColumn, | |
+ } = location; | |
// Find all scripts that match the given source actor and line | |
// number. | |
- let scripts = generatedSourceActor._findDebuggeeScripts( | |
- { line: generatedLine } | |
+ let scripts = sourceActor._findDebuggeeScripts( | |
+ { line: line } | |
); | |
scripts = scripts.filter((script) => !actor.hasScript(script)); | |
// Find all entry points that correspond to the given location. | |
const entryPoints = []; | |
- if (generatedColumn === undefined) { | |
+ if (column === undefined) { | |
// This is a line breakpoint, so we are interested in all offsets | |
// that correspond to the given line number. | |
for (const script of scripts) { | |
- const offsets = script.getLineOffsets(generatedLine); | |
+ const offsets = script.getLineOffsets(line); | |
if (offsets.length > 0) { | |
entryPoints.push({ script, offsets }); | |
} | |
@@ -784,7 +771,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
[ | |
script, | |
script.getAllColumnOffsets() | |
- .filter(({ lineNumber }) => lineNumber === generatedLine), | |
+ .filter(({ lineNumber }) => lineNumber === line), | |
] | |
); | |
@@ -792,7 +779,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
// offsets that correspond to the given line *and* column number. | |
for (const [script, columnToOffsetMap] of columnToOffsetMaps) { | |
for (const { columnNumber: column, offset } of columnToOffsetMap) { | |
- if (column >= generatedColumn && column <= generatedLastColumn) { | |
+ if (column >= column && column <= lastColumn) { | |
entryPoints.push({ script, offsets: [offset] }); | |
} | |
} | |
@@ -807,8 +794,8 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
// of caution by handling it here. | |
const closestScripts = findClosestScriptBySource( | |
columnToOffsetMaps.map(pair => pair[0]), | |
- generatedLine, | |
- generatedColumn, | |
+ line, | |
+ column, | |
); | |
const columnToOffsetLookup = new Map(columnToOffsetMaps); | |
@@ -819,11 +806,11 @@ const SourceActor = ActorClassWithSpec(sourceSpec, { | |
const firstColumnOffset = columnToOffsetMap[0]; | |
const lastColumnOffset = columnToOffsetMap[columnToOffsetMap.length - 1]; | |
- if (generatedColumn < firstColumnOffset.columnNumber) { | |
+ if (column < firstColumnOffset.columnNumber) { | |
entryPoints.push({ script, offsets: [firstColumnOffset.offset] }); | |
} | |
- if (generatedColumn > lastColumnOffset.columnNumber) { | |
+ if (column > lastColumnOffset.columnNumber) { | |
entryPoints.push({ script, offsets: [lastColumnOffset.offset] }); | |
} | |
} | |
diff --git a/devtools/server/actors/thread.js b/devtools/server/actors/thread.js | |
index 5691eae6ad78..f74d8fb7be57 100644 | |
--- a/devtools/server/actors/thread.js | |
+++ b/devtools/server/actors/thread.js | |
@@ -471,21 +471,21 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
packet.why = reason; | |
const { | |
- generatedSourceActor, | |
- generatedLine, | |
- generatedColumn, | |
+ sourceActor, | |
+ line, | |
+ column, | |
} = this.sources.getFrameLocation(frame); | |
- if (!generatedSourceActor) { | |
+ if (!sourceActor) { | |
// If the frame location is in a source that not pass the 'allowSource' | |
// check and thus has no actor, we do not bother pausing. | |
return undefined; | |
} | |
packet.frame.location = { | |
- sourceId: generatedSourceActor.actorID, | |
- line: generatedLine, | |
- column: generatedColumn, | |
+ sourceId: sourceActor.actorID, | |
+ line: line, | |
+ column: column, | |
}; | |
const pkt = onPacket(packet); | |
@@ -513,9 +513,9 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
_makeOnEnterFrame: function({ pauseAndRespond, rewinding }) { | |
return frame => { | |
- const { generatedSourceActor } = this.sources.getFrameLocation(frame); | |
+ const { sourceActor } = this.sources.getFrameLocation(frame); | |
- const url = generatedSourceActor.url; | |
+ const url = sourceActor.url; | |
// When rewinding into a frame, we end up at the point when it is being popped. | |
if (rewinding) { | |
@@ -533,10 +533,10 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
_makeOnPop: function({ thread, pauseAndRespond, startLocation, steppingType }) { | |
const result = function(completion) { | |
// onPop is called with 'this' set to the current frame. | |
- const generatedLocation = thread.sources.getFrameLocation(this); | |
+ const location = thread.sources.getFrameLocation(this); | |
- const { generatedSourceActor } = generatedLocation; | |
- const url = generatedSourceActor.url; | |
+ const { sourceActor } = location; | |
+ const url = sourceActor.url; | |
if (thread.sources.isBlackBoxed(url)) { | |
return undefined; | |
@@ -553,12 +553,12 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
// replaying, as we can't use its contents after resuming. | |
const ncompletion = thread.dbg.replaying ? null : completion; | |
const { onStep, onPop } = thread._makeSteppingHooks( | |
- generatedLocation, "next", false, ncompletion | |
+ location, "next", false, ncompletion | |
); | |
if (thread.dbg.replaying) { | |
- const parentGeneratedLocation = thread.sources.getFrameLocation(parentFrame); | |
+ const parentLocation = thread.sources.getFrameLocation(parentFrame); | |
const offsets = | |
- thread._findReplayingStepOffsets(parentGeneratedLocation, parentFrame, | |
+ thread._findReplayingStepOffsets(parentLocation, parentFrame, | |
/* rewinding = */ false); | |
parentFrame.setReplayingOnStep(onStep, offsets); | |
} else { | |
@@ -586,12 +586,12 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
// When stepping out, we don't want to stop at a breakpoint that | |
// happened to be set exactly at the spot where we stepped out. | |
- // See bug 970469. We record the generated location here and check | |
+ // See bug 970469. We record the location here and check | |
// it when a breakpoint is hit. Furthermore we store this on the | |
// function because, while we could store it directly on the | |
// frame, if we did we'd also have to find the appropriate spot to | |
// clear it. | |
- result.generatedLocation = startLocation; | |
+ result.location = startLocation; | |
return result; | |
}, | |
@@ -612,17 +612,17 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
// 2. The source has pause points and we change locations. | |
// 3. The source does not have pause points and we change lines. | |
- const generatedLocation = this.sources.getScriptOffsetLocation(script, offset); | |
+ const location = this.sources.getScriptOffsetLocation(script, offset); | |
// Case 1. | |
- if (startLocation.generatedUrl !== generatedLocation.generatedUrl) { | |
+ if (startLocation.url !== location.url) { | |
return true; | |
} | |
- const pausePoints = generatedLocation.generatedSourceActor.pausePoints; | |
- const lineChanged = startLocation.generatedLine !== generatedLocation.generatedLine; | |
+ const pausePoints = location.sourceActor.pausePoints; | |
+ const lineChanged = startLocation.line !== location.line; | |
const columnChanged = | |
- startLocation.generatedColumn !== generatedLocation.generatedColumn; | |
+ startLocation.column !== location.column; | |
if (!pausePoints) { | |
// Case 3. | |
@@ -636,7 +636,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
// When pause points are specified for the source, | |
// we should pause when we are at a stepOver pause point | |
- const pausePoint = findPausePointForLocation(pausePoints, generatedLocation); | |
+ const pausePoint = findPausePointForLocation(pausePoints, location); | |
if (pausePoint) { | |
return pausePoint.step; | |
@@ -658,15 +658,15 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
return function() { | |
// onStep is called with 'this' set to the current frame. | |
- const generatedLocation = thread.sources.getFrameLocation(this); | |
+ const location = thread.sources.getFrameLocation(this); | |
// Always continue execution if either: | |
// | |
// 1. We are in a source mapped region, but inside a null mapping | |
- // (doesn't correlate to any region of generated source) | |
+ // (doesn't correlate to any region of source) | |
// 2. The source we are in is black boxed. | |
- if (generatedLocation.generatedUrl == null | |
- || thread.sources.isBlackBoxed(generatedLocation.generatedUrl)) { | |
+ if (location.url == null | |
+ || thread.sources.isBlackBoxed(location.url)) { | |
return undefined; | |
} | |
@@ -792,9 +792,9 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
return true; | |
} | |
- const generatedLocation = this.sources.getFrameLocation(this.youngestFrame); | |
+ const location = this.sources.getFrameLocation(this.youngestFrame); | |
const { onEnterFrame, onPop, onStep } = this._makeSteppingHooks( | |
- generatedLocation, | |
+ location, | |
steppingType, | |
rewinding | |
); | |
@@ -816,7 +816,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
if (stepFrame.script) { | |
if (this.dbg.replaying) { | |
const offsets = | |
- this._findReplayingStepOffsets(generatedLocation, stepFrame, rewinding); | |
+ this._findReplayingStepOffsets(location, stepFrame, rewinding); | |
stepFrame.setReplayingOnStep(onStep, offsets); | |
} else { | |
stepFrame.onStep = onStep; | |
@@ -1741,8 +1741,8 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
onDebuggerStatement: function(frame) { | |
// Don't pause if we are currently stepping (in or over) or the frame is | |
// black-boxed. | |
- const { generatedSourceActor } = this.sources.getFrameLocation(frame); | |
- const url = generatedSourceActor ? generatedSourceActor.url : null; | |
+ const { sourceActor } = this.sources.getFrameLocation(frame); | |
+ const url = sourceActor ? sourceActor.url : null; | |
if (this.skipBreakpoints || this.sources.isBlackBoxed(url) || frame.onStep) { | |
return undefined; | |
@@ -1819,8 +1819,8 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
return undefined; | |
} | |
- const { generatedSourceActor } = this.sources.getFrameLocation(youngestFrame); | |
- const url = generatedSourceActor ? generatedSourceActor.url : null; | |
+ const { sourceActor } = this.sources.getFrameLocation(youngestFrame); | |
+ const url = sourceActor ? sourceActor.url : null; | |
// Don't pause on exceptions thrown while inside an evaluation being done on | |
// behalf of the client. | |
@@ -1942,7 +1942,7 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
const bpActors = [...this.breakpointActorMap.findActors()] | |
.filter((actor) => { | |
- const bpSource = actor.generatedLocation.generatedSourceActor; | |
+ const bpSource = actor.location.sourceActor; | |
return bpSource.source ? bpSource.source === source : bpSource.url === source.url; | |
}); | |
@@ -1960,10 +1960,11 @@ const ThreadActor = ActorClassWithSpec(threadSpec, { | |
// function when source maps are disabled. | |
for (const actor of bpActors) { | |
if (actor.isPending) { | |
- actor.generatedLocation.generatedSourceActor._setBreakpoint(actor); | |
+ actor.location.sourceActor._setBreakpoint(actor); | |
} else { | |
- actor.generatedLocation.generatedSourceActor._setBreakpointAtGeneratedLocation( | |
- actor, actor.generatedLocation | |
+ actor.location.sourceActor._setBreakpointAtLocation( | |
+ actor, | |
+ actor.location | |
); | |
} | |
} | |
@@ -2110,7 +2111,7 @@ function findEntryPointsForLine(scripts, line) { | |
} | |
function findPausePointForLocation(pausePoints, location) { | |
- const { generatedLine: line, generatedColumn: column } = location; | |
+ const { line: line, column: column } = location; | |
return pausePoints[line] && pausePoints[line][column]; | |
} | |
diff --git a/devtools/server/actors/utils/TabSources.js b/devtools/server/actors/utils/TabSources.js | |
index 2e93b888d94a..fb6c3f267ab3 100644 | |
--- a/devtools/server/actors/utils/TabSources.js | |
+++ b/devtools/server/actors/utils/TabSources.js | |
@@ -7,7 +7,7 @@ | |
const DevToolsUtils = require("devtools/shared/DevToolsUtils"); | |
const { assert } = DevToolsUtils; | |
const EventEmitter = require("devtools/shared/event-emitter"); | |
-const { GeneratedLocation } = require("devtools/server/actors/common"); | |
+const { SourceLocation } = require("devtools/server/actors/common"); | |
loader.lazyRequireGetter(this, "SourceActor", "devtools/server/actors/source", true); | |
loader.lazyRequireGetter(this, "isEvalSource", "devtools/server/actors/source", true); | |
@@ -305,7 +305,7 @@ TabSources.prototype = { | |
*/ | |
getScriptOffsetLocation: function(script, offset) { | |
const {lineNumber, columnNumber} = script.getOffsetLocation(offset); | |
- return new GeneratedLocation( | |
+ return new SourceLocation( | |
this.createSourceActor(script.source), | |
lineNumber, | |
columnNumber | |
@@ -323,7 +323,7 @@ TabSources.prototype = { | |
*/ | |
getFrameLocation: function(frame) { | |
if (!frame || !frame.script) { | |
- return new GeneratedLocation(); | |
+ return new SourceLocation(); | |
} | |
return this.getScriptOffsetLocation(frame.script, frame.offset); | |
}, | |
diff --git a/devtools/server/actors/utils/breakpoint-actor-map.js b/devtools/server/actors/utils/breakpoint-actor-map.js | |
index be0f5375c945..8d205e276e5a 100644 | |
--- a/devtools/server/actors/utils/breakpoint-actor-map.js | |
+++ b/devtools/server/actors/utils/breakpoint-actor-map.js | |
@@ -6,7 +6,7 @@ | |
"use strict"; | |
-const { GeneratedLocation } = require("devtools/server/actors/common"); | |
+const { SourceLocation } = require("devtools/server/actors/common"); | |
/** | |
* A BreakpointActorMap is a map from locations to instances of BreakpointActor. | |
@@ -31,10 +31,10 @@ BreakpointActorMap.prototype = { | |
* Generate all BreakpointActors that match the given location in | |
* this BreakpointActorMap. | |
* | |
- * @param GeneratedLocation location | |
+ * @param SourceLocation location | |
* The location for which matching BreakpointActors should be generated. | |
*/ | |
- findActors: function* (location = new GeneratedLocation()) { | |
+ findActors: function* (location = new SourceLocation()) { | |
// Fast shortcut for when we know we won't find any actors. Surprisingly | |
// enough, this speeds up refreshing when there are no breakpoints set by | |
// about 2x! | |
@@ -55,23 +55,23 @@ BreakpointActorMap.prototype = { | |
} | |
const query = { | |
- sourceActorID: location.generatedSourceActor | |
- ? location.generatedSourceActor.actorID | |
+ sourceActorID: location.sourceActor | |
+ ? location.sourceActor.actorID | |
: undefined, | |
- line: location.generatedLine, | |
+ line: location.line, | |
}; | |
// If location contains a line, assume we are searching for a whole line | |
// breakpoint, and set begin/endColumn accordingly. Otherwise, we are | |
// searching for all breakpoints, so begin/endColumn should be left unset. | |
- if (location.generatedLine) { | |
- query.beginColumn = location.generatedColumn ? location.generatedColumn : 0; | |
- query.endColumn = location.generatedColumn | |
- ? location.generatedColumn + 1 | |
+ if (location.line) { | |
+ query.beginColumn = location.column ? location.column : 0; | |
+ query.endColumn = location.column | |
+ ? location.column + 1 | |
: Infinity; | |
} else { | |
- query.beginColumn = location.generatedColumn ? query.generatedColumn : undefined; | |
- query.endColumn = location.generatedColumn ? query.generatedColumn + 1 : undefined; | |
+ query.beginColumn = location.column ? query.column : undefined; | |
+ query.endColumn = location.column ? query.column + 1 : undefined; | |
} | |
for (const sourceActorID of findKeys(this._actors, query.sourceActorID)) { | |
@@ -91,14 +91,14 @@ BreakpointActorMap.prototype = { | |
* Return the BreakpointActor at the given location in this | |
* BreakpointActorMap. | |
* | |
- * @param GeneratedLocation location | |
+ * @param SourceLocation location | |
* The location for which the BreakpointActor should be returned. | |
* | |
* @returns BreakpointActor actor | |
* The BreakpointActor at the given location. | |
*/ | |
- getActor: function(generatedLocation) { | |
- for (const actor of this.findActors(generatedLocation)) { | |
+ getActor: function(location) { | |
+ for (const actor of this.findActors(location)) { | |
return actor; | |
} | |
@@ -109,19 +109,19 @@ BreakpointActorMap.prototype = { | |
* Set the given BreakpointActor to the given location in this | |
* BreakpointActorMap. | |
* | |
- * @param GeneratedLocation location | |
+ * @param SourceLocation location | |
* The location to which the given BreakpointActor should be set. | |
* | |
* @param BreakpointActor actor | |
* The BreakpointActor to be set to the given location. | |
*/ | |
setActor: function(location, actor) { | |
- const { generatedSourceActor, generatedLine, generatedColumn } = location; | |
+ const { sourceActor, line, column } = location; | |
- const sourceActorID = generatedSourceActor.actorID; | |
- const line = generatedLine; | |
- const beginColumn = generatedColumn ? generatedColumn : 0; | |
- const endColumn = generatedColumn ? generatedColumn + 1 : Infinity; | |
+ const sourceActorID = sourceActor.actorID; | |
+ const line = line; | |
+ const beginColumn = column ? column : 0; | |
+ const endColumn = column ? column + 1 : Infinity; | |
if (!this._actors[sourceActorID]) { | |
this._actors[sourceActorID] = []; | |
@@ -142,16 +142,16 @@ BreakpointActorMap.prototype = { | |
* Delete the BreakpointActor from the given location in this | |
* BreakpointActorMap. | |
* | |
- * @param GeneratedLocation location | |
+ * @param SourceLocation location | |
* The location from which the BreakpointActor should be deleted. | |
*/ | |
deleteActor: function(location) { | |
- const { generatedSourceActor, generatedLine, generatedColumn } = location; | |
+ const { sourceActor, line, column } = location; | |
- const sourceActorID = generatedSourceActor.actorID; | |
- const line = generatedLine; | |
- const beginColumn = generatedColumn ? generatedColumn : 0; | |
- const endColumn = generatedColumn ? generatedColumn + 1 : Infinity; | |
+ const sourceActorID = sourceActor.actorID; | |
+ const line = line; | |
+ const beginColumn = column ? column : 0; | |
+ const endColumn = column ? column + 1 : Infinity; | |
if (this._actors[sourceActorID]) { | |
if (this._actors[sourceActorID][line]) { | |
diff --git a/devtools/server/actors/utils/closest-scripts.js b/devtools/server/actors/utils/closest-scripts.js | |
index 4437c9cb5709..05ac9665eaeb 100644 | |
--- a/devtools/server/actors/utils/closest-scripts.js | |
+++ b/devtools/server/actors/utils/closest-scripts.js | |
@@ -6,7 +6,7 @@ | |
const { findSourceOffset } = require("devtools/server/actors/utils/dbg-source"); | |
-function findClosestScriptBySource(scripts, generatedLine, generatedColumn) { | |
+function findClosestScriptBySource(scripts, line, column) { | |
const bySource = new Map(); | |
for (const script of scripts) { | |
const { source } = script; | |
@@ -25,7 +25,7 @@ function findClosestScriptBySource(scripts, generatedLine, generatedColumn) { | |
const closestScripts = []; | |
for (const sourceScripts of bySource.values()) { | |
- const closest = findClosestScript(sourceScripts, generatedLine, generatedColumn); | |
+ const closest = findClosestScript(sourceScripts, line, column); | |
if (closest) { | |
closestScripts.push(closest); | |
} | |
@@ -34,7 +34,7 @@ function findClosestScriptBySource(scripts, generatedLine, generatedColumn) { | |
} | |
exports.findClosestScriptBySource = findClosestScriptBySource; | |
-function findClosestScript(scripts, generatedLine, generatedColumn) { | |
+function findClosestScript(scripts, line, column) { | |
if (scripts.length === 0) { | |
return null; | |
} | |
@@ -42,8 +42,8 @@ function findClosestScript(scripts, generatedLine, generatedColumn) { | |
const offset = findSourceOffset( | |
source, | |
- generatedLine, | |
- generatedColumn, | |
+ line, | |
+ column, | |
); | |
let closest = null; | |
diff --git a/devtools/server/actors/utils/source-actor-store.js b/devtools/server/actors/utils/source-actor-store.js | |
index 339f0d58e80d..3099833f1535 100644 | |
--- a/devtools/server/actors/utils/source-actor-store.js | |
+++ b/devtools/server/actors/utils/source-actor-store.js | |
@@ -23,8 +23,8 @@ SourceActorStore.prototype = { | |
/** | |
* Lookup an existing actor id that represents this source, if available. | |
*/ | |
- getReusableActorId: function(source, originalUrl) { | |
- const url = this.getUniqueKey(source, originalUrl); | |
+ getReusableActorId: function(source, url) { | |
+ const url = this.getUniqueKey(source, url); | |
if (url && url in this._sourceActorIds) { | |
return this._sourceActorIds[url]; | |
} | |
@@ -34,8 +34,8 @@ SourceActorStore.prototype = { | |
/** | |
* Update a source with an actorID. | |
*/ | |
- setReusableActorId: function(source, originalUrl, actorID) { | |
- const url = this.getUniqueKey(source, originalUrl); | |
+ setReusableActorId: function(source, url, actorID) { | |
+ const url = this.getUniqueKey(source, url); | |
if (url) { | |
this._sourceActorIds[url] = actorID; | |
} | |
@@ -44,12 +44,7 @@ SourceActorStore.prototype = { | |
/** | |
* Make a unique URL from a source that identifies it across reloads. | |
*/ | |
- getUniqueKey: function(source, originalUrl) { | |
- if (originalUrl) { | |
- // Original source from a sourcemap. | |
- return originalUrl; | |
- } | |
- | |
+ getUniqueKey: function(source) { | |
return getSourceURL(source); | |
}, | |
}; | |
diff --git a/devtools/server/tests/unit/test_breakpoint-actor-map.js b/devtools/server/tests/unit/test_breakpoint-actor-map.js | |
index 145b2e86e7ec..62bae2158761 100644 | |
--- a/devtools/server/tests/unit/test_breakpoint-actor-map.js | |
+++ b/devtools/server/tests/unit/test_breakpoint-actor-map.js | |
@@ -19,13 +19,13 @@ function run_test() { | |
function test_get_actor() { | |
const bpStore = new BreakpointActorMap(); | |
const location = { | |
- generatedSourceActor: { actor: "actor1" }, | |
- generatedLine: 3, | |
+ sourceActor: { actor: "actor1" }, | |
+ line: 3, | |
}; | |
const columnLocation = { | |
- generatedSourceActor: { actor: "actor2" }, | |
- generatedLine: 5, | |
- generatedColumn: 15, | |
+ sourceActor: { actor: "actor2" }, | |
+ line: 5, | |
+ column: 15, | |
}; | |
// Shouldn't have breakpoint | |
@@ -57,9 +57,9 @@ function test_set_actor() { | |
// Breakpoint with column | |
const bpStore = new BreakpointActorMap(); | |
let location = { | |
- generatedSourceActor: { actor: "actor1" }, | |
- generatedLine: 10, | |
- generatedColumn: 9, | |
+ sourceActor: { actor: "actor1" }, | |
+ line: 10, | |
+ column: 9, | |
}; | |
bpStore.setActor(location, {}); | |
Assert.ok(!!bpStore.getActor(location), | |
@@ -67,8 +67,8 @@ function test_set_actor() { | |
// Breakpoint without column (whole line breakpoint) | |
location = { | |
- generatedSourceActor: { actor: "actor2" }, | |
- generatedLine: 103, | |
+ sourceActor: { actor: "actor2" }, | |
+ line: 103, | |
}; | |
bpStore.setActor(location, {}); | |
Assert.ok(!!bpStore.getActor(location), | |
@@ -79,9 +79,9 @@ function test_delete_actor() { | |
// Breakpoint with column | |
const bpStore = new BreakpointActorMap(); | |
let location = { | |
- generatedSourceActor: { actor: "actor1" }, | |
- generatedLine: 10, | |
- generatedColumn: 9, | |
+ sourceActor: { actor: "actor1" }, | |
+ line: 10, | |
+ column: 9, | |
}; | |
bpStore.setActor(location, {}); | |
bpStore.deleteActor(location); | |
@@ -90,8 +90,8 @@ function test_delete_actor() { | |
// Breakpoint without column (whole line breakpoint) | |
location = { | |
- generatedSourceActor: { actor: "actor2" }, | |
- generatedLine: 103, | |
+ sourceActor: { actor: "actor2" }, | |
+ line: 103, | |
}; | |
bpStore.setActor(location, {}); | |
bpStore.deleteActor(location); | |
@@ -101,14 +101,14 @@ function test_delete_actor() { | |
function test_find_actors() { | |
const bps = [ | |
- { generatedSourceActor: { actor: "actor1" }, generatedLine: 10 }, | |
- { generatedSourceActor: { actor: "actor1" }, generatedLine: 10, generatedColumn: 3 }, | |
- { generatedSourceActor: { actor: "actor1" }, generatedLine: 10, generatedColumn: 10 }, | |
- { generatedSourceActor: { actor: "actor1" }, generatedLine: 23, generatedColumn: 89 }, | |
- { generatedSourceActor: { actor: "actor2" }, generatedLine: 10, generatedColumn: 1 }, | |
- { generatedSourceActor: { actor: "actor2" }, generatedLine: 20, generatedColumn: 5 }, | |
- { generatedSourceActor: { actor: "actor2" }, generatedLine: 30, generatedColumn: 34 }, | |
- { generatedSourceActor: { actor: "actor2" }, generatedLine: 40, generatedColumn: 56 }, | |
+ { sourceActor: { actor: "actor1" }, line: 10 }, | |
+ { sourceActor: { actor: "actor1" }, line: 10, column: 3 }, | |
+ { sourceActor: { actor: "actor1" }, line: 10, column: 10 }, | |
+ { sourceActor: { actor: "actor1" }, line: 23, column: 89 }, | |
+ { sourceActor: { actor: "actor2" }, line: 10, column: 1 }, | |
+ { sourceActor: { actor: "actor2" }, line: 20, column: 5 }, | |
+ { sourceActor: { actor: "actor2" }, line: 30, column: 34 }, | |
+ { sourceActor: { actor: "actor2" }, line: 40, column: 56 }, | |
]; | |
const bpStore = new BreakpointActorMap(); | |
@@ -129,9 +129,9 @@ function test_find_actors() { | |
// Breakpoints by URL | |
bpSet = new Set(bps.filter(bp => { | |
- return bp.generatedSourceActor.actorID === "actor1"; | |
+ return bp.sourceActor.actorID === "actor1"; | |
})); | |
- for (const bp of bpStore.findActors({ generatedSourceActor: { actorID: "actor1" } })) { | |
+ for (const bp of bpStore.findActors({ sourceActor: { actorID: "actor1" } })) { | |
bpSet.delete(bp); | |
} | |
Assert.equal(bpSet.size, 0, | |
@@ -140,17 +140,17 @@ function test_find_actors() { | |
// Breakpoints by URL and line | |
bpSet = new Set(bps.filter(bp => { | |
- return bp.generatedSourceActor.actorID === "actor1" && bp.generatedLine === 10; | |
+ return bp.sourceActor.actorID === "actor1" && bp.line === 10; | |
})); | |
let first = true; | |
- for (const bp of bpStore.findActors({ generatedSourceActor: { actorID: "actor1" }, | |
- generatedLine: 10 })) { | |
+ for (const bp of bpStore.findActors({ sourceActor: { actorID: "actor1" }, | |
+ line: 10 })) { | |
if (first) { | |
- Assert.equal(bp.generatedColumn, undefined, | |
+ Assert.equal(bp.column, undefined, | |
"Should always get the whole line breakpoint first"); | |
first = false; | |
} else { | |
- Assert.notEqual(bp.generatedColumn, undefined, | |
+ Assert.notEqual(bp.column, undefined, | |
"Should not get the whole line breakpoint any time other than first."); | |
} | |
bpSet.delete(bp); | |
@@ -164,9 +164,9 @@ function test_duplicate_actors() { | |
// Breakpoint with column | |
let location = { | |
- generatedSourceActor: { actorID: "foo-actor" }, | |
- generatedLine: 10, | |
- generatedColumn: 9, | |
+ sourceActor: { actorID: "foo-actor" }, | |
+ line: 10, | |
+ column: 9, | |
}; | |
bpStore.setActor(location, {}); | |
bpStore.setActor(location, {}); | |
@@ -175,8 +175,8 @@ function test_duplicate_actors() { | |
// Breakpoint without column (whole line breakpoint) | |
location = { | |
- generatedSourceActor: { actorID: "foo-actor" }, | |
- generatedLine: 15, | |
+ sourceActor: { actorID: "foo-actor" }, | |
+ line: 15, | |
}; | |
bpStore.setActor(location, {}); | |
bpStore.setActor(location, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment