fune/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

60 lines
1.5 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!)
PluginManager.gmpCrashes.set(1, {
pluginID: 1,
pluginName: "GlobalTestPlugin",
});
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."
);
}
);
});