summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/process_error.xul
blob: 62d3d97244a6690c10d4e43388f604dbb56e0a31 (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
47
48
49
50
51
52
53
54
55
56
57
58
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
	orient="vertical">

  <browser id="thebrowser" type="content" remote="true" />
  <script type="application/javascript"><![CDATA[
    Components.utils.import("resource://gre/modules/Services.jsm");

    const ok = window.opener.wrappedJSObject.ok;
    const is = window.opener.wrappedJSObject.is;
    const done = window.opener.wrappedJSObject.done;
    const SimpleTest = window.opener.wrappedJSObject.SimpleTest;

    function getMinidumpDirectory() {
      var dir = Services.dirsvc.get('ProfD', Components.interfaces.nsIFile);
      dir.append("minidumps");
      return dir;
    }

    function removeFile(directory, filename) {
      var file = directory.clone();
      file.append(filename);
      if (file.exists()) {
        file.remove(false);
      }
    }

    function crashObserver(subject, topic, data) {
      is(topic, 'ipc:content-shutdown', 'Received correct observer topic.');
      ok(subject instanceof Components.interfaces.nsIPropertyBag2,
         'Subject implements nsIPropertyBag2.');

      var dumpID;
      if ('nsICrashReporter' in Components.interfaces) {
        dumpID = subject.getPropertyAsAString('dumpID');
        ok(dumpID, "dumpID is present and not an empty string");
      }

      if (dumpID) {
        var minidumpDirectory = getMinidumpDirectory();
        removeFile(minidumpDirectory, dumpID + '.dmp');
        removeFile(minidumpDirectory, dumpID + '.extra');
      }

      Services.obs.removeObserver(crashObserver, 'ipc:content-shutdown');
      done();
    }
    Services.obs.addObserver(crashObserver, 'ipc:content-shutdown', false);

    document.getElementById('thebrowser')
            .QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
            .frameLoader.messageManager
            .loadFrameScript('chrome://mochitests/content/chrome/dom/ipc/tests/process_error_contentscript.js', true);
  ]]></script>

</window>