Bug 1476289 Added event.stopPropagation to snapshot onClick delete function to prevent selected snapshot from being cleared from view r=julienw
authorsreeise <reeisesean@gmail.com>
Tue, 04 Dec 2018 04:43:03 +0000
changeset 508513 c9a3e8cf52603bce8be325693b284f7bed93e9f2
parent 508512 12750da9341c19c43c322eb28db4a7d347bd78ce
child 508514 77b100d5fe369ba2cc7ae86c66ee5c4bd9a6519a
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjulienw
bugs1476289
milestone65.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 1476289 Added event.stopPropagation to snapshot onClick delete function to prevent selected snapshot from being cleared from view r=julienw Differential Revision: https://phabricator.services.mozilla.com/D13117
devtools/client/memory/components/SnapshotListItem.js
devtools/client/memory/test/browser/browser_memory_clear_snapshots.js
--- a/devtools/client/memory/components/SnapshotListItem.js
+++ b/devtools/client/memory/components/SnapshotListItem.js
@@ -87,17 +87,20 @@ class SnapshotListItem extends Component
     }
 
     const saveLink = !snapshot.path ? void 0 : dom.a({
       onClick: () => onSave(snapshot),
       className: "save",
     }, L10N.getStr("snapshot.io.save"));
 
     const deleteButton = !snapshot.path ? void 0 : dom.button({
-      onClick: () => onDelete(snapshot),
+      onClick: (event) => {
+        event.stopPropagation();
+        onDelete(snapshot);
+      },
       className: "delete",
       title: L10N.getStr("snapshot.io.delete"),
     });
 
     return (
       dom.li({ className, onClick },
         dom.span({
           className: `snapshot-title ${wantThrobber ? " devtools-throbber" : ""}`,
--- a/devtools/client/memory/test/browser/browser_memory_clear_snapshots.js
+++ b/devtools/client/memory/test/browser/browser_memory_clear_snapshots.js
@@ -16,23 +16,43 @@ this.test = makeMemoryTest(TEST_URL, asy
 
   let snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
   is(getState().snapshots.length, 0, "Starts with no snapshots in store");
   is(snapshotEls.length, 0, "No snapshots visible");
 
   info("Take two snapshots");
   takeSnapshot(panel.panelWin);
   takeSnapshot(panel.panelWin);
+  takeSnapshot(panel.panelWin);
   await waitUntilState(gStore, state =>
-  state.snapshots.length === 2 &&
-  state.snapshots[0].treeMap && state.snapshots[1].treeMap &&
-  state.snapshots[0].treeMap.state === treeMapState.SAVED &&
-  state.snapshots[1].treeMap.state === treeMapState.SAVED);
+    state.snapshots.length === 3 &&
+    state.snapshots[0].treeMap && state.snapshots[1].treeMap &&
+    state.snapshots[2].treeMap &&
+    state.snapshots[0].treeMap.state === treeMapState.SAVED &&
+    state.snapshots[1].treeMap.state === treeMapState.SAVED &&
+    state.snapshots[2].treeMap.state === treeMapState.SAVED);
 
   snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
+  is(snapshotEls.length, 3, "Three snapshots visible");
+  is(document.querySelectorAll(".selected").length, 1, "One selected snapshot visible");
+  ok(snapshotEls[2].classList.contains("selected"), "Third snapshot selected");
+
+  info("Clicking on first snapshot delete button");
+  document.querySelectorAll(".delete")[0].click();
+
+  await waitUntilState(gStore, state =>
+    state.snapshots.length === 2 &&
+    state.snapshots[0].treeMap && state.snapshots[1].treeMap &&
+    state.snapshots[0].treeMap.state === treeMapState.SAVED &&
+    state.snapshots[1].treeMap.state === treeMapState.SAVED);
+
+  snapshotEls = document.querySelectorAll(".snapshot-list-item");
   is(snapshotEls.length, 2, "Two snapshots visible");
+  // Bug 1476289
+  ok(!snapshotEls[0].classList.contains("selected"), "First snapshot not selected");
+  ok(snapshotEls[1].classList.contains("selected"), "Second snapshot selected");
 
   info("Click on Clear Snapshots");
   await clearSnapshots(panel.panelWin);
   is(getState().snapshots.length, 0, "No snapshots in store");
   snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
   is(snapshotEls.length, 0, "No snapshot visible");
 });