Bug 1534786 - Add test.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 15 Apr 2019 14:29:25 -1000
changeset 469753 7a56f4bec684
parent 469752 0f3a9d72b563
child 469754 57904fc5ae57
push id35881
push usercbrindusan@mozilla.com
push dateWed, 17 Apr 2019 09:38:58 +0000
treeherdermozilla-central@bbca68b2af26 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1534786
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 1534786 - Add test.
devtools/client/debugger/test/mochitest/browser.ini
devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js
--- a/devtools/client/debugger/test/mochitest/browser.ini
+++ b/devtools/client/debugger/test/mochitest/browser.ini
@@ -784,8 +784,9 @@ skip-if = os == "win"
 skip-if = os == "win"
 [browser_dbg-wasm-sourcemaps.js]
 skip-if = true
 [browser_dbg-windowless-workers.js]
 [browser_dbg-windowless-workers-early-breakpoint.js]
 [browser_dbg-event-handler.js]
 [browser_dbg-eval-throw.js]
 [browser_dbg-sourceURL-breakpoint.js]
+[browser_dbg-old-breakpoint.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-old-breakpoint.js
@@ -0,0 +1,90 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that we show a breakpoint in the UI when there is an old pending
+// breakpoint with an invalid original location.
+add_task(async function() {
+  clearDebuggerPreferences();
+
+  const pending = {
+    bp1: {
+      location: {
+        sourceId: "",
+        sourceUrl: EXAMPLE_URL + "nowhere2.js",
+        line: 5
+      },
+      generatedLocation: {
+        sourceUrl: EXAMPLE_URL + "simple1.js",
+        line: 4
+      },
+      options: {},
+      disabled: false
+    },
+    bp2: {
+      location: {
+        sourceId: "",
+        sourceUrl: EXAMPLE_URL + "nowhere.js",
+        line: 5
+      },
+      generatedLocation: {
+        sourceUrl: EXAMPLE_URL + "simple3.js",
+        line: 2
+      },
+      options: {},
+      disabled: false
+    },
+  };
+  asyncStorage.setItem("debugger.pending-breakpoints", pending);
+
+  const toolbox = await openNewTabAndToolbox(EXAMPLE_URL + "doc-scripts.html", "jsdebugger");
+  const dbg = createDebuggerContext(toolbox);
+
+  // Pending breakpoints are installed asynchronously, keep invoking the entry
+  // function until the debugger pauses.
+  await waitUntil(() => {
+    invokeInTab("main");
+    return isPaused(dbg);
+  });
+
+  ok(true, "paused at unmapped breakpoint");
+  await waitForState(dbg, state => dbg.selectors.getBreakpointCount(state) == 2);
+  ok(true, "unmapped breakpoints shown in UI");
+});
+
+// Test that if we show a breakpoint with an old generated location, it is
+// removed after we load the original source and find the new generated
+// location.
+add_task(async function() {
+  clearDebuggerPreferences();
+
+  const pending = {
+    bp1: {
+      location: {
+        sourceId: "",
+        sourceUrl: "webpack:///entry.js",
+        line: 15,
+        column: 0
+      },
+      generatedLocation: {
+        sourceUrl: EXAMPLE_URL + "sourcemaps/bundle.js",
+        line: 47,
+        column: 16
+      },
+      astLocation: {},
+      options: {},
+      disabled: false
+    },
+  };
+  asyncStorage.setItem("debugger.pending-breakpoints", pending);
+
+  const toolbox = await openNewTabAndToolbox(EXAMPLE_URL + "doc-sourcemaps.html", "jsdebugger");
+  const dbg = createDebuggerContext(toolbox);
+
+  await waitForState(dbg, state => {
+    const bps = dbg.selectors.getBreakpointsList(state);
+    return bps.length == 1
+        && bps[0].location.sourceUrl.includes("entry.js")
+        && bps[0].location.line == 15;
+  });
+  ok(true, "removed old breakpoint during sync");
+});