summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
blob: 97cb9db618eb8cc942d742804500b9324e59b738 (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
"use strict";

let { PluginManager } = ChromeUtils.import(
  "resource:///actors/PluginParent.jsm"
);

/**
 * Test that the notification bar for crashed GMPs works.
 */
add_task(async function() {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: "about:blank",
    },
    async function(browser) {
      // Ensure the parent has heard before the client.
      // In practice, this is always true for GMP crashes (but not for NPAPI ones!)
      let props = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
        Ci.nsIWritablePropertyBag2
      );
      props.setPropertyAsUint32("pluginID", 1);
      props.setPropertyAsACString("pluginName", "GlobalTestPlugin");
      props.setPropertyAsACString("pluginDumpID", "1234");
      Services.obs.notifyObservers(props, "gmp-plugin-crash");

      await SpecialPowers.spawn(browser, [], async function() {
        const GMP_CRASH_EVENT = {
          pluginID: 1,
          pluginName: "GlobalTestPlugin",
          submittedCrashReport: false,
          bubbles: true,
          cancelable: true,
          gmpPlugin: true,
        };

        let crashEvent = new content.PluginCrashedEvent(
          "PluginCrashed",
          GMP_CRASH_EVENT
        );
        content.dispatchEvent(crashEvent);
      });

      let notification = await waitForNotificationBar(
        "plugin-crashed",
        browser
      );

      let notificationBox = gBrowser.getNotificationBox(browser);
      ok(notification, "Infobar was shown.");
      is(
        notification.priority,
        notificationBox.PRIORITY_WARNING_MEDIUM,
        "Correct priority."
      );
      is(
        notification.messageText.textContent,
        "The GlobalTestPlugin plugin has crashed.",
        "Correct message."
      );
    }
  );
});