Bug 1538054 - Toggle off 'Pause on Exception' immediately. r=loganfsmyth
authorjaril <jarilvalenciano@gmail.com>
Tue, 23 Apr 2019 16:30:03 +0000
changeset 470512 c31ccea52937e0c889f392b8d52094ad367c5f60
parent 470511 6569e4cca483da6fb943a60e3e60ed4c052f7fc6
child 470513 71d205b6e9c7380a9f86736627bbefd8c020c0cd
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersloganfsmyth
bugs1538054
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1538054 - Toggle off 'Pause on Exception' immediately. r=loganfsmyth After toggling off 'Pause on exceptions' in the debugger, exceptions were still being paused on once. This was because the server's exception-pausing behavior was not toggled off until an exception was paused on. This patch makes it so that the behavior is changed immediately after unchecking the 'Pause on exceptions' checkbox in the debugger. Differential Revision: https://phabricator.services.mozilla.com/D27453
devtools/server/actors/thread.js
devtools/server/tests/unit/test_pause_exceptions-04.js
devtools/server/tests/unit/xpcshell.ini
--- a/devtools/server/actors/thread.js
+++ b/devtools/server/actors/thread.js
@@ -1015,16 +1015,18 @@ const ThreadActor = ActorClassWithSpec(t
   },
 
   /**
    * Set the debugging hook to pause on exceptions if configured to do so.
    */
   maybePauseOnExceptions: function() {
     if (this._options.pauseOnExceptions) {
       this.dbg.onExceptionUnwind = this.onExceptionUnwind.bind(this);
+    } else {
+      this.dbg.onExceptionUnwind = undefined;
     }
   },
 
   /**
    * Helper method that returns the next frame when stepping.
    */
   _getNextStepFrame: function(frame, rewinding) {
     const endOfFrame =
new file mode 100644
--- /dev/null
+++ b/devtools/server/tests/unit/test_pause_exceptions-04.js
@@ -0,0 +1,96 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable no-shadow */
+
+"use strict";
+
+/**
+ * Test that setting pauseOnExceptions to true and then to false will not cause
+ * the debuggee to pause when an exception is thrown.
+ */
+
+add_task(threadClientTest(async ({ threadClient, client, debuggee }) => {
+  let packet = null;
+
+  threadClient.addOneTimeListener("paused", function(event, pkt) {
+    packet = pkt;
+    threadClient.resume();
+  });
+
+  await threadClient.pauseOnExceptions(true, true);
+  try {
+    /* eslint-disable */
+    Cu.evalInSandbox(
+      `                                   // 1
+      function stopMe() {                 // 2
+        throw 42;                         // 3
+      }                                   // 4
+      stopMe();                           // 5
+      `,                                  // 6
+      debuggee,
+      "1.8",
+      "test_pause_exceptions-04.js",
+      1
+    );
+    /* eslint-enable */
+  } catch (e) {}
+
+  Assert.equal(!!packet, true);
+  Assert.equal(packet.why.type, "exception");
+  Assert.equal(packet.why.exception, "42");
+  packet = null;
+
+  threadClient.addOneTimeListener("paused", function(event, pkt) {
+    packet = pkt;
+    threadClient.resume();
+  });
+
+  await threadClient.pauseOnExceptions(false, true);
+  try {
+    /* eslint-disable */
+    Cu.evalInSandbox(
+      `                                   // 1
+      function dontStopMe() {             // 2
+        throw 43;                         // 3
+      }                                   // 4
+      dontStopMe();                       // 5
+      `,                                  // 6
+      debuggee,
+      "1.8",
+      "test_pause_exceptions-04.js",
+      1
+    );
+    /* eslint-enable */
+  } catch (e) {}
+
+  // Test that the paused listener callback hasn't been called
+  // on the thrown error from dontStopMe()
+  Assert.equal(!!packet, false);
+
+  await threadClient.pauseOnExceptions(true, true);
+  try {
+    /* eslint-disable */
+    Cu.evalInSandbox(
+      `                                   // 1
+      function stopMeAgain() {            // 2
+        throw 44;                         // 3
+      }                                   // 4
+      stopMeAgain();                      // 5
+      `,                                  // 6
+      debuggee,
+      "1.8",
+      "test_pause_exceptions-04.js",
+      1
+    );
+    /* eslint-enable */
+  } catch (e) {}
+
+  // 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,
+}));
--- a/devtools/server/tests/unit/xpcshell.ini
+++ b/devtools/server/tests/unit/xpcshell.ini
@@ -190,16 +190,17 @@ skip-if = true # breakpoint sliding is n
 [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]
 [test_pause_exceptions-02.js]
 [test_pause_exceptions-03.js]
+[test_pause_exceptions-04.js]
 [test_longstringactor.js]
 [test_longstringgrips-01.js]
 [test_longstringgrips-02.js]
 [test_source-01.js]
 [test_source-02.js]
 [test_source-03.js]
 [test_source-04.js]
 [test_wasm_source-01.js]