tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_Heap_05.html (4865B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 Test that we show a message when the census results are empty.
      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>
     14    <pre id="test">
     15        <script src="head.js" type="application/javascript"></script>
     16        <script type="application/javascript">
     17         "use strict";
     18         window.onload = async function() {
     19           try {
     20             const container = document.getElementById("container");
     21 
     22             await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
     23               snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
     24                 census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, {
     25                   report: {
     26                     bytes: 1,
     27                     totalBytes: 1,
     28                     count: 1,
     29                     totalCount: 1,
     30                     id: 1,
     31                     parent: undefined,
     32                     children: [
     33                       {
     34                         name: Cu.getJSTestingFunctions().saveStack(),
     35                         bytes: 1,
     36                         totalBytes: 1,
     37                         count: 1,
     38                         totalCount: 1,
     39                         children: undefined,
     40                         id: 2,
     41                         parent: 1,
     42                       },
     43                       {
     44                         name: "noStack",
     45                         bytes: 1,
     46                         totalBytes: 1,
     47                         count: 1,
     48                         totalCount: 1,
     49                         children: undefined,
     50                         id: 3,
     51                         parent: 1,
     52                       },
     53                     ],
     54                   },
     55                   display: censusDisplays.allocationStack,
     56                 }),
     57               }),
     58             })), container);
     59 
     60             ok(!container.querySelector(".empty"),
     61                "When the report is not empty, we should not show the empty message");
     62 
     63             // Empty Census Report
     64 
     65             const emptyCensus = {
     66               report: {
     67                 bytes: 0,
     68                 totalBytes: 0,
     69                 count: 0,
     70                 totalCount: 0,
     71                 id: 1,
     72                 parent: undefined,
     73                 children: undefined,
     74               },
     75               parentMap: Object.create(null),
     76               display: censusDisplays.allocationStack,
     77               filter: null,
     78               expanded: new Set(),
     79               focused: null,
     80               state: censusState.SAVED,
     81             };
     82 
     83             await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
     84               snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
     85                 census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, emptyCensus),
     86               }),
     87             })), container);
     88 
     89             ok(container.querySelector(".empty"),
     90                "When the report is empty in census view, we show the empty message");
     91             ok(container.textContent.includes(L10N.getStr("heapview.empty")));
     92 
     93             // Empty Diffing Report
     94 
     95             await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
     96               view: { state: viewState.DIFFING },
     97               diffing: {
     98                 firstSnapshotId: 1,
     99                 secondSnapshotId: 2,
    100                 census: emptyCensus,
    101                 state: diffingState.TOOK_DIFF,
    102               },
    103               snapshot: null,
    104             })), container);
    105 
    106             ok(container.querySelector(".empty"),
    107                "When the report is empty in diffing view, the empty message is shown");
    108             ok(container.textContent.includes(L10N.getStr("heapview.no-difference")));
    109 
    110             // Empty Filtered Census
    111 
    112             await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
    113               snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
    114                 census: immutableUpdate(
    115                   TEST_HEAP_PROPS.snapshot.census, immutableUpdate(emptyCensus, {
    116                    filter: "zzzz",
    117                   })),
    118               }),
    119             })), container);
    120 
    121             ok(container.querySelector(".empty"),
    122                "When the report is empty in census view w/ filter, we show the empty message");
    123             ok(container.textContent.includes(L10N.getStr("heapview.none-match")));
    124           } catch (e) {
    125             ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
    126           } finally {
    127             SimpleTest.finish();
    128           }
    129         };
    130        </script>
    131    </pre>
    132 </body>
    133 </html>