tor-browser

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

test_Heap_04.html (4480B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 Test that we show the "hey you're not recording allocation stacks" message at the appropriate times.
      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: "noStack",
     35                         bytes: 1,
     36                         totalBytes: 1,
     37                         count: 1,
     38                         totalCount: 1,
     39                         children: undefined,
     40                         id: 3,
     41                         parent: 1,
     42                       },
     43                     ],
     44                   },
     45                   display: censusDisplays.allocationStack,
     46                 }),
     47               }),
     48             })), container);
     49 
     50             ok(container.querySelector(".no-allocation-stacks"),
     51                "When there are no allocation stacks, we should show the message");
     52 
     53             await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
     54               snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
     55                 census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, {
     56                   report: {
     57                     bytes: 1,
     58                     totalBytes: 1,
     59                     count: 1,
     60                     totalCount: 1,
     61                     id: 1,
     62                     parent: undefined,
     63                     children: [
     64                       {
     65                         name: Cu.getJSTestingFunctions().saveStack(),
     66                         bytes: 1,
     67                         totalBytes: 1,
     68                         count: 1,
     69                         totalCount: 1,
     70                         children: undefined,
     71                         id: 2,
     72                         parent: 1,
     73                       },
     74                       {
     75                         name: "noStack",
     76                         bytes: 1,
     77                         totalBytes: 1,
     78                         count: 1,
     79                         totalCount: 1,
     80                         children: undefined,
     81                         id: 3,
     82                         parent: 1,
     83                       },
     84                     ],
     85                   },
     86                   display: censusDisplays.allocationStack,
     87                 }),
     88               }),
     89             })), container);
     90 
     91             ok(!container.querySelector(".no-allocation-stacks"),
     92                "When there are allocation stacks, we should not show the message");
     93 
     94             await renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
     95               snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
     96                 census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, {
     97                   report: {
     98                     bytes: 1,
     99                     totalBytes: 1,
    100                     count: 1,
    101                     totalCount: 1,
    102                     id: 1,
    103                     parent: undefined,
    104                     children: undefined,
    105                   },
    106                   display: censusDisplays.allocationStack,
    107                 }),
    108               }),
    109             })), container);
    110 
    111             ok(!container.querySelector(".no-allocation-stacks"),
    112                "When there isn't census data, we should not show the message");
    113           } catch (e) {
    114             ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
    115           } finally {
    116             SimpleTest.finish();
    117           }
    118         };
    119        </script>
    120    </pre>
    121 </body>
    122 </html>