Created
April 22, 2018 02:46
-
-
Save jasonLaster/3269714ec81cb0bbfd24af037a4d6142 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
# HG changeset patch | |
# User Jason Laster <jason.laster.11@gmail.com> | |
Add skipPauses | |
diff --git a/devtools/server/actors/breakpoint.js b/devtools/server/actors/breakpoint.js | |
index bda5151..ad920ff 100644 | |
--- a/devtools/server/actors/breakpoint.js | |
+++ b/devtools/server/actors/breakpoint.js | |
@@ -144,16 +144,17 @@ let BreakpointActor = ActorClassWithSpec(breakpointSpec, { | |
originalSourceActor, | |
originalLine, | |
originalColumn | |
} = this.threadActor.unsafeSynchronize( | |
this.threadActor.sources.getOriginalLocation(generatedLocation)); | |
let url = originalSourceActor.url; | |
if (this.threadActor.sources.isBlackBoxed(url) | |
+ || this.threadActor.skipPausing | |
|| frame.onStep) { | |
return undefined; | |
} | |
// 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.originalLocation; | |
if (locationAtFinish && | |
diff --git a/devtools/server/actors/thread.js b/devtools/server/actors/thread.js | |
index 6deee45..f722491 100644 | |
--- a/devtools/server/actors/thread.js | |
+++ b/devtools/server/actors/thread.js | |
@@ -1511,21 +1511,27 @@ 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 generatedLocation = this.sources.getFrameLocation(frame); | |
const { originalSourceActor } = this.unsafeSynchronize( | |
this.sources.getOriginalLocation(generatedLocation)); | |
const url = originalSourceActor ? originalSourceActor.url : null; | |
- return this.sources.isBlackBoxed(url) || frame.onStep | |
+ return this.skipPausing || this.sources.isBlackBoxed(url) || frame.onStep | |
? undefined | |
: this._pauseAndRespond(frame, { type: "debuggerStatement" }); | |
}, | |
+ onSkipPauses: function({ skip }) { | |
+ dump(`>>> onSkipPauses ${JSON.stringify(skip)}\n\n`) | |
+ this.skipPausing = skip; | |
+ return { skip } | |
+ }, | |
+ | |
/** | |
* A function that the engine calls when an exception has been thrown and has | |
* propagated to the specified frame. | |
* | |
* @param youngestFrame Debugger.Frame | |
* The youngest remaining stack frame. | |
* @param value object | |
* The exception that was thrown. | |
@@ -1755,17 +1761,18 @@ Object.assign(ThreadActor.prototype.requestTypes, { | |
"resume": ThreadActor.prototype.onResume, | |
"clientEvaluate": ThreadActor.prototype.onClientEvaluate, | |
"frames": ThreadActor.prototype.onFrames, | |
"interrupt": ThreadActor.prototype.onInterrupt, | |
"eventListeners": ThreadActor.prototype.onEventListeners, | |
"releaseMany": ThreadActor.prototype.onReleaseMany, | |
"sources": ThreadActor.prototype.onSources, | |
"threadGrips": ThreadActor.prototype.onThreadGrips, | |
- "prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties | |
+ "prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties, | |
+ "skipPauses": ThreadActor.prototype.onSkipPauses | |
}); | |
exports.ThreadActor = ThreadActor; | |
/** | |
* Creates a PauseActor. | |
* | |
* PauseActors exist for the lifetime of a given debuggee pause. Used to | |
diff --git a/devtools/server/main.js b/devtools/server/main.js | |
index 8f1075c..c9b084e 100644 | |
--- a/devtools/server/main.js | |
+++ b/devtools/server/main.js | |
@@ -1736,18 +1736,21 @@ DebuggerServerConnection.prototype = { | |
if (forwardTo) { | |
forwardTo.send(packet); | |
return; | |
} | |
separator = to.lastIndexOf("/"); | |
} | |
} | |
+ dump(`packet: ${JSON.stringify(packet)}\n\n`) | |
+ | |
let actor = this._getOrCreateActor(packet.to); | |
if (!actor) { | |
+ dump(`no actor: ${JSON.stringify(packet)}\n\n`); | |
return; | |
} | |
let ret = null; | |
// handle "requestTypes" RDP request. | |
if (packet.type == "requestTypes") { | |
ret = { from: actor.actorID, requestTypes: Object.keys(actor.requestTypes) }; | |
diff --git a/devtools/server/tests/unit/head_dbg.js b/devtools/server/tests/unit/head_dbg.js | |
index d74352f..e057b56 100644 | |
--- a/devtools/server/tests/unit/head_dbg.js | |
+++ b/devtools/server/tests/unit/head_dbg.js | |
@@ -214,16 +214,27 @@ function findSource(sources, url) { | |
return null; | |
} | |
function waitForPause(threadClient) { | |
dump("Waiting for pause.\n"); | |
return waitForEvent(threadClient, "paused"); | |
} | |
+function waitForProperty(dbg, property) { | |
+ return new Promise(resolve => { | |
+ Object.defineProperty(dbg, property, { | |
+ set(newValue) { | |
+ dump(`>>> prop ${property} set ${newValue} \n `); | |
+ resolve(newValue) | |
+ } | |
+ }); | |
+ }) | |
+} | |
+ | |
function setBreakpoint(sourceClient, location) { | |
dump("Setting breakpoint.\n"); | |
return sourceClient.setBreakpoint(location); | |
} | |
function getPrototypeAndProperties(objClient) { | |
dump("getting prototype and properties.\n"); | |
diff --git a/devtools/server/tests/unit/test_breakpoint-02.js b/devtools/server/tests/unit/test_breakpoint-02.js | |
index 076b2eb..df3dff3 100644 | |
--- a/devtools/server/tests/unit/test_breakpoint-02.js | |
+++ b/devtools/server/tests/unit/test_breakpoint-02.js | |
@@ -62,9 +62,19 @@ function test_breakpoint_running() { | |
Cu.evalInSandbox( | |
"var line0 = Error().lineNumber;\n" + | |
"debugger;\n" + | |
"var a = 1;\n" + // line0 + 2 | |
"var b = 2;\n", // line0 + 3 | |
gDebuggee | |
); | |
/* eslint-enable */ | |
+ | |
+ /* eslint-disable */ | |
+ Cu.evalInSandbox( | |
+ "var line0 = Error().lineNumber;\n" + | |
+ "debugger;\n" + | |
+ "var a = 1;\n" + // line0 + 2 | |
+ "var b = 2;\n", // line0 + 3 | |
+ gDebuggee | |
+ ); | |
+ /* eslint-enable */ | |
} | |
diff --git a/devtools/server/tests/unit/test_stepping-01.js b/devtools/server/tests/unit/test_stepping-01.js | |
index d30834a..4d00a63 100644 | |
--- a/devtools/server/tests/unit/test_stepping-01.js | |
+++ b/devtools/server/tests/unit/test_stepping-01.js | |
@@ -73,9 +73,9 @@ function evaluateTestCode() { | |
var a = 1; // 3 | |
var b = 2;`, // 4 | |
gDebuggee, | |
"1.8", | |
"test_stepping-01-test-code.js", | |
1 | |
); | |
/* eslint-disable */ | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/devtools/server/tests/unit/test_stepping-with-skip-pausing.js b/devtools/server/tests/unit/test_stepping-with-skip-pausing.js | |
new file mode 100644 | |
index 0000000..189a460 | |
--- /dev/null | |
+++ b/devtools/server/tests/unit/test_stepping-with-skip-pausing.js | |
@@ -0,0 +1,75 @@ | |
+/* Any copyright is dedicated to the Public Domain. | |
+ http://creativecommons.org/publicdomain/zero/1.0/ */ | |
+/* eslint-disable no-shadow, max-nested-callbacks */ | |
+ | |
+"use strict"; | |
+ | |
+/** | |
+ * Check basic step-over functionality. | |
+ */ | |
+ | |
+var gDebuggee; | |
+var gClient; | |
+var gCallback; | |
+ | |
+function run_test() { | |
+ do_test_pending(); | |
+ run_test_with_server(DebuggerServer, function() { | |
+ run_test_with_server(WorkerDebuggerServer, do_test_finished); | |
+ }); | |
+} | |
+ | |
+function run_test_with_server(server, callback) { | |
+ gCallback = callback; | |
+ initTestDebuggerServer(server); | |
+ gDebuggee = addTestGlobal("test-stepping", server); | |
+ gClient = new DebuggerClient(server.connectPipe()); | |
+ gClient.connect(test_simple_stepping); | |
+} | |
+ | |
+async function test_simple_stepping() { | |
+ const [attachResponse,, threadClient] = await attachTestTabAndResume(gClient, | |
+ "test-stepping"); | |
+ | |
+ info(`1. disable pausing pass over a debugger statement`); | |
+ await threadClient.skipPauses(true); | |
+ executeSoon(evaluateTestCode, gClient); | |
+ | |
+ const prop = await waitForProperty(gDebuggee, 'b') | |
+ equal(prop, 2); | |
+ | |
+ info(`2. enable pausing and pause at a debugger statement and breakpoint`); | |
+ await threadClient.skipPauses(false); | |
+ const paused = await executeOnNextTickAndWaitForPause(evaluateTestCode, gClient); | |
+ let source = threadClient.source(paused.frame.where.source); | |
+ await source.setBreakpoint({ line: 3 }) | |
+ | |
+ resume(threadClient) | |
+ const paused2 = await waitForPause(threadClient) | |
+ equal(paused2.frame.where.line, 3); | |
+ | |
+ info(`3. diable pausing and pass over a breakpoint`); | |
+ // const paused3 = await executeOnNextTickAndWaitForPause(evaluateTestCode, gClient); | |
+ // let source2 = threadClient.source(paused3.frame.where.source); | |
+ // await source2.setBreakpoint({ line: 3 }) | |
+ // await threadClient.skipPauses(false); | |
+ // resume(threadClient) | |
+ | |
+ | |
+ finishClient(gClient, gCallback); | |
+} | |
+ | |
+function evaluateTestCode(value) { | |
+ /* eslint-disable */ | |
+ Cu.evalInSandbox( | |
+ ` // 1 | |
+ debugger; // 2 | |
+ var b = 2;`, // 3 | |
+ gDebuggee, | |
+ "1.8", | |
+ "test.js", | |
+ 1 | |
+ ); | |
+ /* eslint-disable */ | |
+} | |
+ | |
diff --git a/devtools/server/tests/unit/xpcshell.ini b/devtools/server/tests/unit/xpcshell.ini | |
index 2f873f7..dd7662b 100644 | |
--- a/devtools/server/tests/unit/xpcshell.ini | |
+++ b/devtools/server/tests/unit/xpcshell.ini | |
@@ -184,16 +184,17 @@ reason = bug 1104838 | |
[test_stepping-02.js] | |
[test_stepping-03.js] | |
[test_stepping-04.js] | |
[test_stepping-05.js] | |
[test_stepping-06.js] | |
[test_stepping-07.js] | |
[test_stepping-08.js] | |
[test_stepping-with-pause-points.js] | |
+[test_stepping-with-skip-pausing.js] | |
[test_framebindings-01.js] | |
[test_framebindings-02.js] | |
[test_framebindings-03.js] | |
[test_framebindings-04.js] | |
[test_framebindings-05.js] | |
[test_framebindings-06.js] | |
[test_framebindings-07.js] | |
[test_pause_exceptions-01.js] | |
diff --git a/devtools/shared/client/thread-client.js b/devtools/shared/client/thread-client.js | |
index e2aa762..a8e1cff 100644 | |
--- a/devtools/shared/client/thread-client.js | |
+++ b/devtools/shared/client/thread-client.js | |
@@ -390,16 +390,21 @@ ThreadClient.prototype = { | |
* Called with the thread's response. | |
*/ | |
getFrames: DebuggerClient.requester({ | |
type: "frames", | |
start: arg(0), | |
count: arg(1) | |
}), | |
+ skipPauses: DebuggerClient.requester({ | |
+ type: "skipPauses", | |
+ skip: arg(0), | |
+ }), | |
+ | |
/** | |
* An array of cached frames. Clients can observe the framesadded and | |
* framescleared event to keep up to date on changes to this cache, | |
* and can fill it using the fillFrames method. | |
*/ | |
get cachedFrames() { | |
return this._frameCache; | |
}, | |
@@ -416,16 +421,18 @@ ThreadClient.prototype = { | |
* Request the frame environment. | |
* | |
* @param frameId string | |
*/ | |
getEnvironment: function(frameId) { | |
return this.request({ to: frameId, type: "getEnvironment" }); | |
}, | |
+ | |
+ | |
/** | |
* Ensure that at least total stack frames have been loaded in the | |
* ThreadClient's stack frame cache. A framesadded event will be | |
* sent when the stack frame cache is updated. | |
* | |
* @param total number | |
* The minimum number of stack frames to be included. | |
* @param callback function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment