Bug 1623607 - Prevent multiple tabs from displaying for a single source r=jlast
authorDavid Walsh <dwalsh@mozilla.com>
Wed, 25 Mar 2020 17:03:47 +0000
changeset 520449 226fadaecac6ba43e035cd128479248fcd724c6d
parent 520448 42851ca92a16c34b5a0f374a69b89c8708144f16
child 520450 9e518dc7be99bcfba229ce2e528c8d45cb9932e7
push id37251
push usermalexandru@mozilla.com
push dateThu, 26 Mar 2020 09:33:08 +0000
treeherdermozilla-central@3e5a7430c8d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1623607
milestone76.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 1623607 - Prevent multiple tabs from displaying for a single source r=jlast Differential Revision: https://phabricator.services.mozilla.com/D67888
devtools/client/debugger/src/actions/sources/select.js
devtools/client/debugger/test/mochitest/browser.ini
devtools/client/debugger/test/mochitest/browser_dbg-tabs-without-urls-selected.js
--- a/devtools/client/debugger/src/actions/sources/select.js
+++ b/devtools/client/debugger/src/actions/sources/select.js
@@ -151,17 +151,17 @@ export function selectLocation(
       keepContext &&
       selectedSource &&
       selectedSource.isOriginal != isOriginalId(location.sourceId)
     ) {
       location = await mapLocation(getState(), sourceMaps, location);
       source = getSourceFromId(getState(), location.sourceId);
     }
 
-    if (tabExists(getState(), source.id)) {
+    if (!tabExists(getState(), source.id)) {
       dispatch(addTab(source));
     }
 
     dispatch(setSelectedLocation(cx, source, location));
 
     await dispatch(loadSourceText({ cx, source }));
     await dispatch(setBreakableLines(cx, source.id));
 
--- a/devtools/client/debugger/test/mochitest/browser.ini
+++ b/devtools/client/debugger/test/mochitest/browser.ini
@@ -155,16 +155,17 @@ skip-if = true
 [browser_dbg-stepping.js]
 skip-if = debug || (verify && (os == 'win')) || (os == "win" && os_version == "6.1")
 [browser_dbg-step-in-uninitialized.js]
 [browser_dbg-tabs.js]
 [browser_dbg-tabs-keyboard.js]
 skip-if = os == "win"
 [browser_dbg-tabs-pretty-print.js]
 [browser_dbg-tabs-without-urls.js]
+[browser_dbg-tabs-without-urls-selected.js]
 [browser_dbg-toggling-tools.js]
 [browser_dbg-react-app.js]
 skip-if = os == "win"
 [browser_dbg-wasm-sourcemaps.js]
 skip-if = true #Bug 1571994
 [browser_dbg-windowless-workers.js]
 [browser_dbg-windowless-workers-early-breakpoint.js]
 [browser_dbg-worker-exception.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-tabs-without-urls-selected.js
@@ -0,0 +1,23 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that URL-less sources have tabs and selecting that location does not
+// create a new tab for the same URL-less source
+add_task(async function() {
+  const dbg = await initDebugger("doc-scripts.html");
+
+  // Create a URL-less source 
+  const { hud } = await dbg.toolbox.selectTool("webconsole");
+  await evaluateExpressionInConsole(hud, `
+    (() => {
+        setTimeout(() => { debugger; }, 100);
+    })();
+  `);
+  await waitForPaused(dbg);
+
+  // Click a frame which shouldn't open a new source tab
+  await clickElement(dbg, "frame", 2);
+
+  // Click the frame to select the same location and ensure there's only 1 tab
+  is(countTabs(dbg), 1);
+});