summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/unit/test_profiler_getsharedlibraryinformation.js
blob: a36577320f488abe2c0e4c1bf8fde524f783c676 (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
40
41
42
43
44
45
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Tests whether the profiler responds to "getSharedLibraryInformation" adequately.
 */

const Profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);

function run_test()
{
  get_chrome_actors((client, form) => {
    let actor = form.profilerActor;
    test_getsharedlibraryinformation(client, actor, () => {
      client.close().then(() => {
        do_test_finished();
      });
    });
  });

  do_test_pending();
}

function test_getsharedlibraryinformation(client, actor, callback)
{
  client.request({ to: actor, type: "getSharedLibraryInformation" }, response => {
    do_check_eq(typeof response.sharedLibraryInformation, "string");
    let libs = [];
    try {
      libs = JSON.parse(response.sharedLibraryInformation);
    } catch (e) {
      do_check_true(false);
    }
    do_check_eq(typeof libs, "object");
    do_check_true(libs.length >= 1);
    do_check_eq(typeof libs[0], "object");
    do_check_eq(typeof libs[0].name, "string");
    do_check_eq(typeof libs[0].start, "number");
    do_check_eq(typeof libs[0].end, "number");
    do_check_true(libs[0].start <= libs[0].end);
    callback();
  });
}