Bug 1534786 - Ensure that breakpoints are visible when you reload formatted files. r=bhackett
authorJason Laster <jlaster@mozilla.com>
Thu, 14 Mar 2019 21:41:40 +0000
changeset 464441 16f9f23229b2
parent 464440 7a382dbe8dc8
child 464442 754f833aaa41
push id35716
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:42:17 +0000
treeherdermozilla-central@8ee97c045359 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1534786
milestone67.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 1534786 - Ensure that breakpoints are visible when you reload formatted files. r=bhackett Differential Revision: https://phabricator.services.mozilla.com/D23386
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/browser_dbg-editor-gutter.js
devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-breakpoints.js
devtools/client/debugger/new/test/mochitest/examples/doc-pretty.html
devtools/client/debugger/new/test/mochitest/examples/pretty.js
devtools/client/debugger/new/test/mochitest/helpers.js
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -588,29 +588,31 @@ support-files =
   examples/wasm-sourcemaps/fib.c
   examples/wasm-sourcemaps/fib.wasm
   examples/wasm-sourcemaps/fib.wasm.map
   examples/wasm-sourcemaps/utils.js
   examples/fetch.js
   examples/doc-xhr.html
   examples/doc-xhr-run-to-completion.html
   examples/doc-scroll-run-to-completion.html
+  examples/pretty.js
   examples/sum/sum.js
   examples/sum/sum.min.js
   examples/sum/sum.min.js.map
   examples/big-sourcemap_files/bundle.js
   examples/big-sourcemap_files/bundle.js.map
   examples/reload/code_reload_1.js
   examples/reload/code_reload_2.js
   examples/reload/doc-reload.html
   examples/reload/sjs_code_reload.sjs
   examples/doc-react-jsx.html
   examples/doc-async.html
   examples/doc-asm.html
   examples/doc-duplicate-functions.html
+  examples/doc-pretty.html
   examples/doc-sourcemapped.html
   examples/doc-content-script-sources.html
   examples/doc-scripts.html
   examples/doc-scripts-debugger.html
   examples/doc-script-mutate.html
   examples/doc-script-switching.html
   examples/doc-exceptions.html
   examples/doc-iframes.html
@@ -720,16 +722,17 @@ skip-if = verify
 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.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]
 skip-if = os == "win"
 [browser_dbg-preview-module.js]
 skip-if = os == "win"
 [browser_dbg-preview-source-maps.js]
 skip-if = os == "win"
--- a/devtools/client/debugger/new/test/mochitest/browser_dbg-editor-gutter.js
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-editor-gutter.js
@@ -11,32 +11,16 @@ const { PromiseTestUtils } = scopedCuImp
 );
 PromiseTestUtils.whitelistRejectionsGlobally(/NS_ERROR_NOT_INITIALIZED/);
 
 // Utilities for interacting with the editor
 function clickGutter(dbg, line) {
   clickElement(dbg, "gutter", line);
 }
 
-function getLineEl(dbg, line) {
-  const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
-  return lines[line - 1];
-}
-
-function assertEditorBreakpoint(dbg, line, shouldExist) {
-  const exists = !!getLineEl(dbg, line).querySelector(".new-breakpoint");
-  ok(
-    exists === shouldExist,
-    "Breakpoint " +
-      (shouldExist ? "exists" : "does not exist") +
-      " on line " +
-      line
-  );
-}
-
 add_task(async function() {
   const dbg = await initDebugger("doc-scripts.html", "simple1.js");
   const {
     selectors: { getBreakpoint, getBreakpointCount },
     getState
   } = dbg;
   const source = findSource(dbg, "simple1.js");
 
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-pretty-print-breakpoints.js
@@ -0,0 +1,21 @@
+/* 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/>. */
+
+// Tests that breakpoints appear when you reload a page
+// with pretty-printed files.
+add_task(async function() {
+  const dbg = await initDebugger("doc-pretty.html", "pretty.js");
+
+  await selectSource(dbg, "pretty.js")
+  await prettyPrint(dbg);
+
+  await addBreakpoint(dbg, "pretty.js:formatted", 5);
+  await closeTab(dbg, "pretty.js:formatted");
+
+  await reload(dbg, "pretty.js");
+  invokeInTab("stuff");
+
+  await waitForPaused(dbg);
+  assertEditorBreakpoint(dbg, 4, true);
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/doc-pretty.html
@@ -0,0 +1,14 @@
+ <!-- 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/. -->
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8"/>
+    <title>Test a file that changes when pretty printed</title>
+  </head>
+
+  <body>
+    <script src="./pretty.js"></script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/pretty.js
@@ -0,0 +1,7 @@
+function a() {}
+
+function stuff() {
+  a(); a();
+  a(); a();
+  debugger
+}
\ No newline at end of file
--- a/devtools/client/debugger/new/test/mochitest/helpers.js
+++ b/devtools/client/debugger/new/test/mochitest/helpers.js
@@ -858,16 +858,21 @@ async function invokeWithBreakpoint(
   await handler(source);
 
   await resume(dbg);
 
   // If the invoke errored later somehow, capture here so the error is reported nicely.
   await invokeResult;
 }
 
+function prettyPrint(dbg) {
+  const sourceId = dbg.selectors.getSelectedSourceId(dbg.store.getState());
+  return dbg.actions.togglePrettyPrint(sourceId);
+}
+
 async function expandAllScopes(dbg) {
   const scopes = await waitForElement(dbg, "scopes");
   const scopeElements = scopes.querySelectorAll(
     '.tree-node[aria-level="1"][data-expandable="true"]:not([aria-expanded="true"])'
   );
   const indices = Array.from(scopeElements, el => {
     return Array.prototype.indexOf.call(el.parentNode.childNodes, el);
   }).reverse();
@@ -1083,16 +1088,32 @@ function isVisible(outerEl, innerEl) {
     innerRect.left >= outerRect.left ||
     innerRect.right <= outerRect.right ||
     (innerRect.left < outerRect.left && innerRect.right > outerRect.right);
 
   const visible = verticallyVisible && horizontallyVisible;
   return visible;
 }
 
+function getEditorLineEl(dbg, line) {
+  const lines = dbg.win.document.querySelectorAll(".CodeMirror-code > div");
+  return lines[line - 1];
+}
+
+function assertEditorBreakpoint(dbg, line, shouldExist) {
+  const exists = !!getEditorLineEl(dbg, line).querySelector(".new-breakpoint");
+  ok(
+    exists === shouldExist,
+    "Breakpoint " +
+      (shouldExist ? "exists" : "does not exist") +
+      " on line " +
+      line
+  );
+}
+
 const selectors = {
   callStackHeader: ".call-stack-pane ._header",
   callStackBody: ".call-stack-pane .pane",
   expressionNode: i =>
     `.expressions-list .expression-container:nth-child(${i}) .object-label`,
   expressionValue: i =>
     `.expressions-list .expression-container:nth-child(${i}) .object-delimiter + *`,
   expressionClose: i =>