From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- devtools/client/memory/test/chrome/chrome.ini | 20 ++ devtools/client/memory/test/chrome/head.js | 354 +++++++++++++++++++++ .../memory/test/chrome/test_CensusTreeItem_01.html | 65 ++++ .../test/chrome/test_DominatorTreeItem_01.html | 46 +++ .../memory/test/chrome/test_DominatorTree_01.html | 52 +++ .../memory/test/chrome/test_DominatorTree_02.html | 52 +++ .../memory/test/chrome/test_DominatorTree_03.html | 77 +++++ .../client/memory/test/chrome/test_Heap_01.html | 51 +++ .../client/memory/test/chrome/test_Heap_02.html | 78 +++++ .../client/memory/test/chrome/test_Heap_03.html | 79 +++++ .../client/memory/test/chrome/test_Heap_04.html | 122 +++++++ .../client/memory/test/chrome/test_Heap_05.html | 133 ++++++++ .../client/memory/test/chrome/test_List_01.html | 73 +++++ .../memory/test/chrome/test_ShortestPaths_01.html | 112 +++++++ .../memory/test/chrome/test_ShortestPaths_02.html | 46 +++ .../test/chrome/test_SnapshotListItem_01.html | 53 +++ .../client/memory/test/chrome/test_Toolbar_01.html | 48 +++ .../client/memory/test/chrome/test_TreeMap_01.html | 44 +++ 18 files changed, 1505 insertions(+) create mode 100644 devtools/client/memory/test/chrome/chrome.ini create mode 100644 devtools/client/memory/test/chrome/head.js create mode 100644 devtools/client/memory/test/chrome/test_CensusTreeItem_01.html create mode 100644 devtools/client/memory/test/chrome/test_DominatorTreeItem_01.html create mode 100644 devtools/client/memory/test/chrome/test_DominatorTree_01.html create mode 100644 devtools/client/memory/test/chrome/test_DominatorTree_02.html create mode 100644 devtools/client/memory/test/chrome/test_DominatorTree_03.html create mode 100644 devtools/client/memory/test/chrome/test_Heap_01.html create mode 100644 devtools/client/memory/test/chrome/test_Heap_02.html create mode 100644 devtools/client/memory/test/chrome/test_Heap_03.html create mode 100644 devtools/client/memory/test/chrome/test_Heap_04.html create mode 100644 devtools/client/memory/test/chrome/test_Heap_05.html create mode 100644 devtools/client/memory/test/chrome/test_List_01.html create mode 100644 devtools/client/memory/test/chrome/test_ShortestPaths_01.html create mode 100644 devtools/client/memory/test/chrome/test_ShortestPaths_02.html create mode 100644 devtools/client/memory/test/chrome/test_SnapshotListItem_01.html create mode 100644 devtools/client/memory/test/chrome/test_Toolbar_01.html create mode 100644 devtools/client/memory/test/chrome/test_TreeMap_01.html (limited to 'devtools/client/memory/test/chrome') diff --git a/devtools/client/memory/test/chrome/chrome.ini b/devtools/client/memory/test/chrome/chrome.ini new file mode 100644 index 0000000000..7803bcda35 --- /dev/null +++ b/devtools/client/memory/test/chrome/chrome.ini @@ -0,0 +1,20 @@ +[DEFAULT] +support-files = + head.js + +[test_CensusTreeItem_01.html] +[test_DominatorTree_01.html] +[test_DominatorTree_02.html] +[test_DominatorTree_03.html] +[test_DominatorTreeItem_01.html] +[test_Heap_01.html] +[test_Heap_02.html] +[test_Heap_03.html] +[test_Heap_04.html] +[test_Heap_05.html] +[test_List_01.html] +[test_ShortestPaths_01.html] +[test_ShortestPaths_02.html] +[test_SnapshotListItem_01.html] +[test_Toolbar_01.html] +[test_TreeMap_01.html] diff --git a/devtools/client/memory/test/chrome/head.js b/devtools/client/memory/test/chrome/head.js new file mode 100644 index 0000000000..685fa62928 --- /dev/null +++ b/devtools/client/memory/test/chrome/head.js @@ -0,0 +1,354 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +var { BrowserLoader } = ChromeUtils.import( + "resource://devtools/shared/loader/browser-loader.js" +); +var { require } = BrowserLoader({ + baseURI: "resource://devtools/client/memory/", + window, +}); +var { Assert } = ChromeUtils.importESModule( + "resource://testing-common/Assert.sys.mjs" +); + +var EXPECTED_DTU_ASSERT_FAILURE_COUNT = 0; + +SimpleTest.registerCleanupFunction(function () { + if ( + DevToolsUtils.assertionFailureCount !== EXPECTED_DTU_ASSERT_FAILURE_COUNT + ) { + ok( + false, + "Should have had the expected number of DevToolsUtils.assert() failures." + + "Expected " + + EXPECTED_DTU_ASSERT_FAILURE_COUNT + + ", got " + + DevToolsUtils.assertionFailureCount + ); + } +}); + +var DevToolsUtils = require("resource://devtools/shared/DevToolsUtils.js"); +var { immutableUpdate } = DevToolsUtils; + +var constants = require("resource://devtools/client/memory/constants.js"); +var { + censusDisplays, + diffingState, + labelDisplays, + dominatorTreeState, + snapshotState, + viewState, + censusState, +} = constants; + +const { L10N } = require("resource://devtools/client/memory/utils.js"); + +var models = require("resource://devtools/client/memory/models.js"); + +var Immutable = require("resource://devtools/client/shared/vendor/immutable.js"); +var React = require("resource://devtools/client/shared/vendor/react.js"); +const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); +var ReactDOM = require("resource://devtools/client/shared/vendor/react-dom.js"); +var { createFactory } = React; +var Heap = createFactory( + require("resource://devtools/client/memory/components/Heap.js") +); +var CensusTreeItem = createFactory( + require("resource://devtools/client/memory/components/CensusTreeItem.js") +); +var DominatorTreeComponent = createFactory( + require("resource://devtools/client/memory/components/DominatorTree.js") +); +var DominatorTreeItem = createFactory( + require("resource://devtools/client/memory/components/DominatorTreeItem.js") +); +var ShortestPaths = createFactory( + require("resource://devtools/client/memory/components/ShortestPaths.js") +); +var TreeMap = createFactory( + require("resource://devtools/client/memory/components/TreeMap.js") +); +var SnapshotListItem = createFactory( + require("resource://devtools/client/memory/components/SnapshotListItem.js") +); +var List = createFactory( + require("resource://devtools/client/memory/components/List.js") +); +var Toolbar = createFactory( + require("resource://devtools/client/memory/components/Toolbar.js") +); + +// All tests are asynchronous. +SimpleTest.waitForExplicitFinish(); + +var noop = () => {}; + +var TEST_CENSUS_TREE_ITEM_PROPS = Object.freeze({ + item: Object.freeze({ + bytes: 10, + count: 1, + totalBytes: 10, + totalCount: 1, + name: "foo", + children: [ + Object.freeze({ + bytes: 10, + count: 1, + totalBytes: 10, + totalCount: 1, + name: "bar", + }), + ], + }), + depth: 0, + arrow: ">", + focused: true, + getPercentBytes: () => 50, + getPercentCount: () => 50, + showSign: false, + onViewSourceInDebugger: noop, + inverted: false, +}); + +// Counter for mock DominatorTreeNode ids. +var TEST_NODE_ID_COUNTER = 0; + +/** + * Create a mock DominatorTreeNode for testing, with sane defaults. Override any + * property by providing it on `opts`. Optionally pass child nodes as well. + * + * @param {Object} opts + * @param {Array?} children + * + * @returns {DominatorTreeNode} + */ +function makeTestDominatorTreeNode(opts, children) { + const nodeId = TEST_NODE_ID_COUNTER++; + + const node = Object.assign( + { + nodeId, + label: ["other", "SomeType"], + shallowSize: 1, + retainedSize: (children || []).reduce( + (size, c) => size + c.retainedSize, + 1 + ), + parentId: undefined, + children, + moreChildrenAvailable: true, + }, + opts + ); + + if (children && children.length) { + children.map(c => { + c.parentId = node.nodeId; + }); + } + + return node; +} + +var TEST_DOMINATOR_TREE = Object.freeze({ + dominatorTreeId: 666, + root: (function makeTree(depth = 0) { + let children; + if (depth <= 3) { + children = [ + makeTree(depth + 1), + makeTree(depth + 1), + makeTree(depth + 1), + ]; + } + return makeTestDominatorTreeNode({}, children); + })(), + expanded: new Set(), + focused: null, + error: null, + display: labelDisplays.coarseType, + activeFetchRequestCount: null, + state: dominatorTreeState.LOADED, +}); + +var TEST_DOMINATOR_TREE_PROPS = Object.freeze({ + dominatorTree: TEST_DOMINATOR_TREE, + onLoadMoreSiblings: noop, + onViewSourceInDebugger: noop, + onExpand: noop, + onCollapse: noop, +}); + +var TEST_SHORTEST_PATHS_PROPS = Object.freeze({ + graph: Object.freeze({ + nodes: [ + { id: 1, label: ["other", "SomeType"] }, + { id: 2, label: ["other", "SomeType"] }, + { id: 3, label: ["other", "SomeType"] }, + ], + edges: [ + { from: 1, to: 2, name: "1->2" }, + { from: 1, to: 3, name: "1->3" }, + { from: 2, to: 3, name: "2->3" }, + ], + }), +}); + +var TEST_SNAPSHOT = Object.freeze({ + id: 1337, + selected: true, + path: "/fake/path/to/snapshot", + census: Object.freeze({ + report: Object.freeze({ + objects: Object.freeze({ count: 4, bytes: 400 }), + scripts: Object.freeze({ count: 3, bytes: 300 }), + strings: Object.freeze({ count: 2, bytes: 200 }), + other: Object.freeze({ count: 1, bytes: 100 }), + }), + display: Object.freeze({ + displayName: "Test Display", + tooltip: "Test display tooltup", + inverted: false, + breakdown: Object.freeze({ + by: "coarseType", + objects: Object.freeze({ by: "count", count: true, bytes: true }), + scripts: Object.freeze({ by: "count", count: true, bytes: true }), + strings: Object.freeze({ by: "count", count: true, bytes: true }), + other: Object.freeze({ by: "count", count: true, bytes: true }), + }), + }), + state: censusState.SAVED, + inverted: false, + filter: null, + expanded: new Set(), + focused: null, + parentMap: Object.freeze(Object.create(null)), + }), + dominatorTree: TEST_DOMINATOR_TREE, + error: null, + imported: false, + creationTime: 0, + state: snapshotState.READ, +}); + +var TEST_HEAP_PROPS = Object.freeze({ + onSnapshotClick: noop, + onLoadMoreSiblings: noop, + onCensusExpand: noop, + onCensusCollapse: noop, + onDominatorTreeExpand: noop, + onDominatorTreeCollapse: noop, + onCensusFocus: noop, + onDominatorTreeFocus: noop, + onViewSourceInDebugger: noop, + diffing: null, + view: { state: viewState.CENSUS }, + snapshot: TEST_SNAPSHOT, + sizes: Object.freeze({ shortestPathsSize: 0.5 }), + onShortestPathsResize: noop, +}); + +var TEST_TOOLBAR_PROPS = Object.freeze({ + censusDisplays: [ + censusDisplays.coarseType, + censusDisplays.allocationStack, + censusDisplays.invertedAllocationStack, + ], + censusDisplay: censusDisplays.coarseType, + onTakeSnapshotClick: noop, + onImportClick: noop, + onCensusDisplayChange: noop, + onToggleRecordAllocationStacks: noop, + allocations: models.allocations, + onToggleInverted: noop, + inverted: false, + filterString: null, + setFilterString: noop, + diffing: null, + onToggleDiffing: noop, + view: { state: viewState.CENSUS }, + onViewChange: noop, + labelDisplays: [labelDisplays.coarseType, labelDisplays.allocationStack], + labelDisplay: labelDisplays.coarseType, + onLabelDisplayChange: noop, + snapshots: [], +}); + +function makeTestCensusNode() { + return { + name: "Function", + bytes: 100, + totalBytes: 100, + count: 100, + totalCount: 100, + children: [], + }; +} + +var TEST_TREE_MAP_PROPS = Object.freeze({ + treeMap: Object.freeze({ + report: { + name: null, + bytes: 0, + totalBytes: 400, + count: 0, + totalCount: 400, + children: [ + { + name: "objects", + bytes: 0, + totalBytes: 200, + count: 0, + totalCount: 200, + children: [makeTestCensusNode(), makeTestCensusNode()], + }, + { + name: "other", + bytes: 0, + totalBytes: 200, + count: 0, + totalCount: 200, + children: [makeTestCensusNode(), makeTestCensusNode()], + }, + ], + }, + }), +}); + +var TEST_SNAPSHOT_LIST_ITEM_PROPS = Object.freeze({ + onClick: noop, + onSave: noop, + onDelete: noop, + item: TEST_SNAPSHOT, + index: 1234, +}); + +function onNextAnimationFrame(fn) { + return () => requestAnimationFrame(() => requestAnimationFrame(fn)); +} + +/** + * Render the provided ReactElement in the provided HTML container. + * Returns a Promise that will resolve the rendered element as a React + * component. + */ +function renderComponent(element, container) { + return new Promise(resolve => { + const component = ReactDOM.render( + element, + container, + onNextAnimationFrame(() => { + dumpn("Rendered = " + container.innerHTML); + resolve(component); + }) + ); + }); +} + +function dumpn(msg) { + dump(`MEMORY-TEST: ${msg}\n`); +} diff --git a/devtools/client/memory/test/chrome/test_CensusTreeItem_01.html b/devtools/client/memory/test/chrome/test_CensusTreeItem_01.html new file mode 100644 index 0000000000..21d900b668 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_CensusTreeItem_01.html @@ -0,0 +1,65 @@ + + + + + + Tree component test + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_DominatorTreeItem_01.html b/devtools/client/memory/test/chrome/test_DominatorTreeItem_01.html new file mode 100644 index 0000000000..c8cb6b6036 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_DominatorTreeItem_01.html @@ -0,0 +1,46 @@ + + + + + + Tree component test + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_DominatorTree_01.html b/devtools/client/memory/test/chrome/test_DominatorTree_01.html new file mode 100644 index 0000000000..0067a0f412 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_DominatorTree_01.html @@ -0,0 +1,52 @@ + + + + + + Tree component test + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_DominatorTree_02.html b/devtools/client/memory/test/chrome/test_DominatorTree_02.html new file mode 100644 index 0000000000..66aad95296 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_DominatorTree_02.html @@ -0,0 +1,52 @@ + + + + + + Tree component test + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_DominatorTree_03.html b/devtools/client/memory/test/chrome/test_DominatorTree_03.html new file mode 100644 index 0000000000..6fcfa3d577 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_DominatorTree_03.html @@ -0,0 +1,77 @@ + + + + + + Tree component test + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_Heap_01.html b/devtools/client/memory/test/chrome/test_Heap_01.html new file mode 100644 index 0000000000..2facc3d221 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Heap_01.html @@ -0,0 +1,51 @@ + + + + + + Tree component test + + + + +
+
+        
+
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_Heap_02.html b/devtools/client/memory/test/chrome/test_Heap_02.html new file mode 100644 index 0000000000..343ee66714 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Heap_02.html @@ -0,0 +1,78 @@ + + + + + + Tree component test + + + + +
+
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_Heap_03.html b/devtools/client/memory/test/chrome/test_Heap_03.html new file mode 100644 index 0000000000..69f95f4275 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Heap_03.html @@ -0,0 +1,79 @@ + + + + + + Tree component test + + + + +
+
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_Heap_04.html b/devtools/client/memory/test/chrome/test_Heap_04.html new file mode 100644 index 0000000000..76de5e4826 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Heap_04.html @@ -0,0 +1,122 @@ + + + + + + Tree component test + + + + +
+
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_Heap_05.html b/devtools/client/memory/test/chrome/test_Heap_05.html new file mode 100644 index 0000000000..bd3fc393cc --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Heap_05.html @@ -0,0 +1,133 @@ + + + + + + Tree component test + + + + +
+
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_List_01.html b/devtools/client/memory/test/chrome/test_List_01.html new file mode 100644 index 0000000000..4ffab49620 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_List_01.html @@ -0,0 +1,73 @@ + + + + + + Tree component test + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_ShortestPaths_01.html b/devtools/client/memory/test/chrome/test_ShortestPaths_01.html new file mode 100644 index 0000000000..29905bfaca --- /dev/null +++ b/devtools/client/memory/test/chrome/test_ShortestPaths_01.html @@ -0,0 +1,112 @@ + + + + + + Tree component test + + + + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_ShortestPaths_02.html b/devtools/client/memory/test/chrome/test_ShortestPaths_02.html new file mode 100644 index 0000000000..cbf0370d22 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_ShortestPaths_02.html @@ -0,0 +1,46 @@ + + + + + + Tree component test + + + + + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_SnapshotListItem_01.html b/devtools/client/memory/test/chrome/test_SnapshotListItem_01.html new file mode 100644 index 0000000000..20fc137479 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_SnapshotListItem_01.html @@ -0,0 +1,53 @@ + + + + + + Tree component test + + + + +
+ +
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_Toolbar_01.html b/devtools/client/memory/test/chrome/test_Toolbar_01.html new file mode 100644 index 0000000000..3bf934c77c --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Toolbar_01.html @@ -0,0 +1,48 @@ + + + + + + Tree component test + + + + +
+
+        
+        
+    
+ + diff --git a/devtools/client/memory/test/chrome/test_TreeMap_01.html b/devtools/client/memory/test/chrome/test_TreeMap_01.html new file mode 100644 index 0000000000..7b8b98b9a7 --- /dev/null +++ b/devtools/client/memory/test/chrome/test_TreeMap_01.html @@ -0,0 +1,44 @@ + + + + + + Tree component test + + + + + + + +
+ +
+    
+    
+  
+ + -- cgit v1.2.3