summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/xpcshell/test_pause_exceptions-04.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/server/tests/xpcshell/test_pause_exceptions-04.js')
-rw-r--r--devtools/server/tests/xpcshell/test_pause_exceptions-04.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_pause_exceptions-04.js b/devtools/server/tests/xpcshell/test_pause_exceptions-04.js
new file mode 100644
index 0000000000..6246b112e0
--- /dev/null
+++ b/devtools/server/tests/xpcshell/test_pause_exceptions-04.js
@@ -0,0 +1,93 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { waitForTick } = require("resource://devtools/shared/DevToolsUtils.js");
+
+/**
+ * Test that setting pauseOnExceptions to true and then to false will not cause
+ * the debuggee to pause when an exception is thrown.
+ */
+
+add_task(
+ threadFrontTest(
+ async ({ threadFront, client, debuggee, commands }) => {
+ let onResume = null;
+ let packet = null;
+
+ threadFront.once("paused", function (pkt) {
+ packet = pkt;
+ onResume = threadFront.resume();
+ });
+
+ await commands.threadConfigurationCommand.updateConfiguration({
+ pauseOnExceptions: true,
+ ignoreCaughtExceptions: true,
+ });
+
+ await evaluateTestCode(debuggee, "42");
+
+ await onResume;
+
+ Assert.equal(!!packet, true);
+ Assert.equal(packet.why.type, "exception");
+ Assert.equal(packet.why.exception, "42");
+ packet = null;
+
+ threadFront.once("paused", function (pkt) {
+ packet = pkt;
+ onResume = threadFront.resume();
+ });
+
+ await commands.threadConfigurationCommand.updateConfiguration({
+ pauseOnExceptions: false,
+ ignoreCaughtExceptions: true,
+ });
+
+ await evaluateTestCode(debuggee, "43");
+
+ // Test that the paused listener callback hasn't been called
+ // on the thrown error from dontStopMe()
+ Assert.equal(!!packet, false);
+
+ await commands.threadConfigurationCommand.updateConfiguration({
+ pauseOnExceptions: true,
+ ignoreCaughtExceptions: true,
+ });
+
+ await evaluateTestCode(debuggee, "44");
+
+ await onResume;
+
+ // Test that the paused listener callback has been called
+ // on the thrown error from stopMeAgain()
+ Assert.equal(!!packet, true);
+ Assert.equal(packet.why.type, "exception");
+ Assert.equal(packet.why.exception, "44");
+ },
+ {
+ // Bug 1508289, exception tests fails in worker scope
+ doNotRunWorker: true,
+ }
+ )
+);
+
+async function evaluateTestCode(debuggee, throwValue) {
+ await waitForTick();
+ try {
+ // prettier-ignore
+ Cu.evalInSandbox(
+ ` // 1
+ function stopMeAgain() { // 2
+ throw ${throwValue}; // 3
+ } // 4
+ stopMeAgain(); // 5
+ `, // 6
+ debuggee,
+ "1.8",
+ "test_pause_exceptions-04.js",
+ 1
+ );
+ } catch (e) {}
+}