summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/test/unit/test_crash_modules.js
blob: 89eae2d2024884c4c2b70ede5a2409bbc6d8334e (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
46
add_task(async function run_test() {
  if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
    dump(
      "INFO | test_crash_modules.js | Can't test crashreporter in a non-libxul build.\n"
    );
    return;
  }

  await do_crash(
    function() {
      const { ctypes } = ChromeUtils.import(
        "resource://gre/modules/ctypes.jsm"
      );
      // Load and unload a DLL so that it will show up as unloaded in the minidump
      let lib = ctypes.open("wininet");
      lib.close();
    },
    async function(mdump, extra, extraFile) {
      runMinidumpAnalyzer(mdump);

      // Refresh updated extra data
      let data = await OS.File.read(extraFile.path);
      let decoder = new TextDecoder();
      extra = JSON.parse(decoder.decode(data));

      // Check unloaded modules
      const unloadedModules = extra.StackTraces.unloaded_modules;
      Assert.ok(!!unloadedModules, "The unloaded_modules field exists");
      Assert.notEqual(unloadedModules.find(e => e.filename == "wininet.DLL"));

      // Check the module signature information
      const sigInfo = JSON.parse(extra.ModuleSignatureInfo);
      Assert.ok(
        !!sigInfo["Microsoft Windows"],
        "The module signature info contains valid data"
      );
      Assert.greater(
        sigInfo["Microsoft Windows"].length,
        0,
        "Multiple signed binaries were found"
      );
    },
    // process will exit with a zero exit status
    true
  );
});