Bug 1581530 - Re-apply usage of .enable/.disable accidentally reverted in Bug 997119. r=jlast
authorLogan Smyth <loganfsmyth@gmail.com>
Wed, 16 Oct 2019 18:13:41 +0000
changeset 497943 c29ec6e0195d4af8b30a33e0a72fc70697a018fe
parent 497942 0762a641fec70adb98249fdcf11b879d9506f118
child 497944 3c76c7680baaa5c0927a9e0fcdcf91f2ce614dfa
push id98167
push userloganfsmyth@gmail.com
push dateThu, 17 Oct 2019 00:20:43 +0000
treeherderautoland@c29ec6e0195d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1581530, 997119
milestone71.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 1581530 - Re-apply usage of .enable/.disable accidentally reverted in Bug 997119. r=jlast Differential Revision: https://phabricator.services.mozilla.com/D49382
devtools/client/debugger/test/mochitest/browser.ini
devtools/client/debugger/test/mochitest/browser_dbg-navigation-when-paused.js
devtools/client/debugger/test/mochitest/examples/doc-navigation-when-paused.html
devtools/server/actors/thread.js
--- a/devtools/client/debugger/test/mochitest/browser.ini
+++ b/devtools/client/debugger/test/mochitest/browser.ini
@@ -87,16 +87,17 @@ skip-if = os == "linux" # bug 1351952
 skip-if = verify
 [browser_dbg-outline-pretty.js]
 [browser_dbg-outline-filter.js]
 [browser_dbg-pause-exceptions.js]
 skip-if = !debug && (os == "win" && os_version == "6.1") # Bug 1456441
 [browser_dbg-pause-on-next.js]
 [browser_dbg-pause-ux.js]
 skip-if = os == "win"
+[browser_dbg-navigation-when-paused.js]
 [browser_dbg-navigation.js]
 skip-if = (verify && debug && (os == 'mac')) || (os == 'linux' && debug && bits == 64) || (os == 'mac' && debug) # Bug 1307249
 [browser_dbg-minified.js]
 [browser_dbg-pretty-print.js]
 [browser_dbg-pretty-print-breakpoints.js]
 [browser_dbg-pretty-print-console.js]
 [browser_dbg-pretty-print-paused.js]
 [browser_dbg-preview.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-navigation-when-paused.js
@@ -0,0 +1,33 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+add_task(async function() {
+  const dbg = await initDebugger("doc-navigation-when-paused.html");
+
+  await togglePauseOnExceptions(dbg, true, true);
+
+  clickElementInTab("body");
+
+  await waitForPaused(dbg, "doc-navigation-when-paused.html");
+
+  assertPausedLocation(dbg);
+  assertDebugLine(dbg, 12);
+
+  await navigate(
+    dbg,
+    "doc-navigation-when-paused.html",
+    "doc-navigation-when-paused.html"
+  );
+
+  clickElementInTab("body");
+
+  await waitForPaused(dbg, "doc-navigation-when-paused.html");
+
+  // If breakpoints aren't properly ignored after navigation, this could
+  // potentially pause at line 9. This helper also ensures that the file
+  // source itself has loaded, which may not be the case if navigation cleared
+  // the source and nothing has sent it to the debugger client yet, as was
+  // the case in Bug 1581530.
+  assertDebugLine(dbg, 12);
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/examples/doc-navigation-when-paused.html
@@ -0,0 +1,17 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<html>
+  <head>
+    <script>
+      window.onclick = () => {
+        Promise.resolve().then(() => {
+          throw new Error("Second");
+        });
+
+        throw new Error("First");
+      };
+    </script>
+  </head>
+  <body></body>
+</html>
--- a/devtools/server/actors/thread.js
+++ b/devtools/server/actors/thread.js
@@ -162,17 +162,21 @@ const ThreadActor = ActorClassWithSpec(t
 
   // Used by the ObjectActor to keep track of the depth of grip() calls.
   _gripDepth: null,
 
   get dbg() {
     if (!this._dbg) {
       this._dbg = this._parent.dbg;
       // Keep the debugger disabled until a client attaches.
-      this._dbg.enabled = this._state != "detached";
+      if (this._state === "detached") {
+        this._dbg.disable();
+      } else {
+        this._dbg.enable();
+      }
     }
     return this._dbg;
   },
 
   get globalDebugObject() {
     if (!this._parent.window || this.dbg.replaying) {
       return null;
     }
@@ -1719,17 +1723,17 @@ const ThreadActor = ActorClassWithSpec(t
     this.threadLifetimePool.addActor(actor);
     this.threadLifetimePool.objectActors.set(actor.obj, actor);
   },
 
   _onWindowReady: function({ isTopLevel, isBFCache, window }) {
     if (isTopLevel && this.state != "detached") {
       this.sources.reset();
       this.clearDebuggees();
-      this.dbg.enabled = true;
+      this.dbg.enable();
       this.maybePauseOnExceptions();
       // Update the global no matter if the debugger is on or off,
       // otherwise the global will be wrong when enabled later.
       this.global = window;
     }
 
     // Refresh the debuggee list when a new window object appears (top window or
     // iframe).
@@ -1747,24 +1751,24 @@ const ThreadActor = ActorClassWithSpec(t
   _onWillNavigate: function({ isTopLevel }) {
     if (!isTopLevel) {
       return;
     }
 
     // Proceed normally only if the debuggee is not paused.
     if (this.state == "paused") {
       this.unsafeSynchronize(Promise.resolve(this.doResume()));
-      this.dbg.enabled = false;
+      this.dbg.disable();
     }
     this.disableAllBreakpoints();
   },
 
   _onNavigate: function() {
     if (this.state == "running") {
-      this.dbg.enabled = true;
+      this.dbg.enable();
     }
   },
 
   // JS Debugger API hooks.
   pauseForMutationBreakpoint: function(mutationType) {
     if (
       !["subtreeModified", "nodeRemoved", "attributeModified"].includes(
         mutationType