summaryrefslogtreecommitdiffstats
path: root/toolkit/components/aboutmemory/tests/xpcshell/test_gpuprocess.js
blob: 1e55f9c024ca9e87fa4602e45eecebc582539a54 (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
35
36
37
38
39
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

function run_test() {
  let gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
  let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService(
    Ci.nsIMemoryReporterManager
  );

  let ok = gfxInfo.controlGPUProcessForXPCShell(true);
  Assert.equal(ok, true);

  let endTesting = function() {
    gfxInfo.controlGPUProcessForXPCShell(false);
    do_test_finished();
  };

  let foundGPUProcess = false;
  let onHandleReport = function(
    aProcess,
    aPath,
    aKind,
    aUnits,
    aAmount,
    aDescription
  ) {
    if (/GPU \(pid \d+\)/.test(aProcess)) {
      foundGPUProcess = true;
    }
  };
  let onFinishReporting = function() {
    Assert.equal(foundGPUProcess, true);
    endTesting();
  };

  mgr.getReports(onHandleReport, null, onFinishReporting, null, false);
  do_test_pending();
}