summaryrefslogtreecommitdiffstats
path: root/devtools/client/memory/test/browser/browser_memory_transferHeapSnapshot_e10s_01.js
blob: 169a968653682417b580cb66424c2f5c7eda6942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/* global ChromeUtils, HeapSnapshot */

// Test that we can save a heap snapshot and transfer it over the RDP in e10s
// where the child process is sandboxed and so we have to use
// HeapSnapshotFileActor to get the heap snapshot file.

"use strict";

const TEST_URL = "data:text/html,<html><body></body></html>";

this.test = makeMemoryTest(TEST_URL, async function ({ panel }) {
  const memoryFront = panel.panelWin.gStore.getState().front;
  ok(memoryFront, "Should get the MemoryFront");

  const snapshotFilePath = await memoryFront.saveHeapSnapshot({
    // Force a copy so that we go through the HeapSnapshotFileActor's
    // transferHeapSnapshot request and exercise this code path on e10s.
    forceCopy: true,
  });

  ok(
    !!(await IOUtils.stat(snapshotFilePath)),
    "Should have the heap snapshot file"
  );

  const snapshot = ChromeUtils.readHeapSnapshot(snapshotFilePath);
  ok(
    HeapSnapshot.isInstance(snapshot),
    "And we should be able to read a HeapSnapshot instance from the file"
  );
});