summaryrefslogtreecommitdiffstats
path: root/dom/ipc/tests/JSWindowActor/browser_crash_report.js
blob: f029f1a85ac9fceac3e9117a30fa9587ba714b43 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

declTest("crash actor", {
  allFrames: true,

  async test(browser) {
    if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
      ok(true, "Cannot test crash annotations without a crash reporter");
      return;
    }

    {
      info("Creating a new tab.");
      let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
      let newTabBrowser = newTab.linkedBrowser;

      let parent =
        newTabBrowser.browsingContext.currentWindowGlobal.getActor(
          "TestWindow"
        );
      ok(parent, "JSWindowActorParent should have value.");

      await SpecialPowers.spawn(newTabBrowser, [], async function () {
        let child = content.windowGlobalChild;
        ok(child, "WindowGlobalChild should have value.");
        is(
          child.isInProcess,
          false,
          "Actor should be loaded in the content process."
        );
        // Make sure that the actor is loaded.
        let actorChild = child.getActor("TestWindow");
        is(
          actorChild.show(),
          "TestWindowChild",
          "actor show should have value."
        );
        is(
          actorChild.manager,
          child,
          "manager should match WindowGlobalChild."
        );
      });

      info(
        "Crashing from withing an actor. We should have an actor name and a message name."
      );
      let report = await BrowserTestUtils.crashFrame(
        newTabBrowser,
        /* shouldShowTabCrashPage = */ false,
        /* shouldClearMinidumps =  */ true,
        /* browsingContext = */ null,
        { asyncCrash: false }
      );

      is(report.JSActorName, "BrowserTestUtils");
      is(report.JSActorMessage, "BrowserTestUtils:CrashFrame");

      BrowserTestUtils.removeTab(newTab);
    }

    {
      info("Creating a new tab for async crash");
      let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
      let newTabBrowser = newTab.linkedBrowser;

      let parent =
        newTabBrowser.browsingContext.currentWindowGlobal.getActor(
          "TestWindow"
        );
      ok(parent, "JSWindowActorParent should have value.");

      await SpecialPowers.spawn(newTabBrowser, [], async function () {
        let child = content.windowGlobalChild;
        ok(child, "WindowGlobalChild should have value.");
        is(
          child.isInProcess,
          false,
          "Actor should be loaded in the content process."
        );
        // Make sure that the actor is loaded.
        let actorChild = child.getActor("TestWindow");
        is(
          actorChild.show(),
          "TestWindowChild",
          "actor show should have value."
        );
        is(
          actorChild.manager,
          child,
          "manager should match WindowGlobalChild."
        );
      });

      info(
        "Crashing from without an actor. We should have neither an actor name nor a message name."
      );
      let report = await BrowserTestUtils.crashFrame(
        newTabBrowser,
        /* shouldShowTabCrashPage = */ false,
        /* shouldClearMinidumps =  */ true,
        /* browsingContext = */ null,
        { asyncCrash: true }
      );

      ok(!report.JSActorName);
      ok(!report.JSActorMessage);

      BrowserTestUtils.removeTab(newTab);
    }
  },
});