Bug 1874684 - Part 4: Prefer const references instead of copying Instant values....
[gecko.git] / devtools / client / memory / test / chrome / test_List_01.html
blob4ffab49620b9a32a924fa54a0de790601d1190f8
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 Test to verify the delete button calls the onDelete handler for an item
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Tree component test</title>
9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
11 </head>
12 <body>
13 <div id="container"></div>
15 <pre id="test">
16 <script src="head.js" type="application/javascript"></script>
17 <script type="application/javascript">
18 "use strict";
19 window.onload = async function() {
20 try {
21 const container = document.getElementById("container");
23 const deletedSnapshots = [];
25 const snapshots = [ TEST_SNAPSHOT, TEST_SNAPSHOT, TEST_SNAPSHOT ]
26 .map((snapshot, index) => immutableUpdate(snapshot, {
27 index: snapshot.index + index,
28 }));
30 await renderComponent(
31 List({
32 itemComponent: SnapshotListItem,
33 onClick: noop,
34 onDelete: (item) => deletedSnapshots.push(item),
35 items: snapshots,
36 }),
37 container
40 const deleteButtons = container.querySelectorAll(".delete");
42 is(container.querySelectorAll(".snapshot-list-item").length, 3,
43 "There are 3 list items\n");
44 is(deletedSnapshots.length, 0,
45 "Not snapshots have been deleted\n");
47 deleteButtons[1].click();
49 is(deletedSnapshots.length, 1, "One snapshot was deleted\n");
50 is(deletedSnapshots[0], snapshots[1],
51 "Deleted snapshot was added to the deleted list\n");
53 deleteButtons[0].click();
55 is(deletedSnapshots.length, 2, "Two snapshots were deleted\n");
56 is(deletedSnapshots[1], snapshots[0],
57 "Deleted snapshot was added to the deleted list\n");
59 deleteButtons[2].click();
61 is(deletedSnapshots.length, 3, "Three snapshots were deleted\n");
62 is(deletedSnapshots[2], snapshots[2],
63 "Deleted snapshot was added to the deleted list\n");
64 } catch (e) {
65 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
66 } finally {
67 SimpleTest.finish();
70 </script>
71 </pre>
72 </body>
73 </html>