tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_globalplugin_crashinfobar.js (1812B)


      1 "use strict";
      2 
      3 let { PluginManager } = ChromeUtils.importESModule(
      4  "resource:///actors/PluginParent.sys.mjs"
      5 );
      6 
      7 /**
      8 * Test that the notification bar for crashed GMPs works.
      9 */
     10 add_task(async function () {
     11  await BrowserTestUtils.withNewTab(
     12    {
     13      gBrowser,
     14      url: "about:blank",
     15    },
     16    async function (browser) {
     17      // Ensure the parent has heard before the client.
     18      // In practice, this is always true for GMP crashes (but not for NPAPI ones!)
     19      let props = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
     20        Ci.nsIWritablePropertyBag2
     21      );
     22      props.setPropertyAsUint32("pluginID", 1);
     23      props.setPropertyAsACString("pluginName", "GlobalTestPlugin");
     24      props.setPropertyAsACString("pluginDumpID", "1234");
     25      Services.obs.notifyObservers(props, "gmp-plugin-crash");
     26 
     27      await SpecialPowers.spawn(browser, [], async function () {
     28        const GMP_CRASH_EVENT = {
     29          pluginID: 1,
     30          pluginName: "GlobalTestPlugin",
     31          submittedCrashReport: false,
     32          bubbles: true,
     33          cancelable: true,
     34          gmpPlugin: true,
     35        };
     36 
     37        let crashEvent = new content.PluginCrashedEvent(
     38          "PluginCrashed",
     39          GMP_CRASH_EVENT
     40        );
     41        content.dispatchEvent(crashEvent);
     42      });
     43 
     44      let notification = await waitForNotificationBar(
     45        "plugin-crashed",
     46        browser
     47      );
     48 
     49      let notificationBox = gBrowser.getNotificationBox(browser);
     50      ok(notification, "Infobar was shown.");
     51      is(
     52        notification.priority,
     53        notificationBox.PRIORITY_WARNING_MEDIUM,
     54        "Correct priority."
     55      );
     56      is(
     57        notification.messageText.textContent.trim(),
     58        "The GlobalTestPlugin plugin has crashed.",
     59        "Correct message."
     60      );
     61    }
     62  );
     63 });