fune/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
Gijs Kruitbosch 603d7b7137 Bug 1660608 - fix plugin crash notification bar message for GMP crashes to include plugin name, r=mconley
The test abstraction meant we missed that this broke in the refactor. This
fixes the bug and makes sure the test actually tests it.

Differential Revision: https://phabricator.services.mozilla.com/D88012
2020-08-24 16:48:27 +00:00

63 lines
1.7 KiB
JavaScript

"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."
);
}
);
});