Skip to content

Instantly share code, notes, and snippets.

@jasonLaster jasonLaster/foo.diff
Created Apr 22, 2018

Embed
What would you like to do?
commit a8e8563f3abdc3a39cd6fa9048766c137c0b8318
Author: Jason Laster <jason.laster.11@gmail.com>
Date: Sat Apr 21 22:42:44 2018 -0400
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
@@ -149,6 +149,7 @@ let BreakpointActor = ActorClassWithSpec(breakpointSpec, {
let url = originalSourceActor.url;
if (this.threadActor.sources.isBlackBoxed(url)
+ || this.threadActor.skipPausing
|| frame.onStep) {
return undefined;
}
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
@@ -1516,11 +1516,17 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
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.
@@ -1760,7 +1766,8 @@ Object.assign(ThreadActor.prototype.requestTypes, {
"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;
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
@@ -1741,8 +1741,11 @@ DebuggerServerConnection.prototype = {
}
}
+ dump(`packet: ${JSON.stringify(packet)}\n\n`)
+
let actor = this._getOrCreateActor(packet.to);
if (!actor) {
+ dump(`no actor: ${JSON.stringify(packet)}\n\n`);
return;
}
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
@@ -219,6 +219,17 @@ function waitForPause(threadClient) {
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);
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
@@ -67,4 +67,14 @@ function test_breakpoint_running() {
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
@@ -78,4 +78,4 @@ function evaluateTestCode() {
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
@@ -189,6 +189,7 @@ reason = bug 1104838
[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]
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
@@ -395,6 +395,11 @@ ThreadClient.prototype = {
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,
@@ -421,6 +426,8 @@ ThreadClient.prototype = {
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.