gecko-dev/browser/base/content/test/plugins/browser_globalplugin_crashinfobar.js
Hanna Jones 614f900ec6 Bug 1845150 - Use moz-message-bar instead of message-bar in notificationbox.js r=webdriver-reviewers,desktop-theme-reviewers,media-playback-reviewers,karlt,whimboo,tgiles,dao,devtools-reviewers
This patch updates the `NotificationMessage` element in `notificationbox.js` so that it extends our newer `moz-message-bar` component instead of the deprecated `message-bar` component. Many of the changes are just dealing with the implications of making things async (so that we can ensure `moz-message-bar.mjs` gets imported). I tried to break out places where I modified related code and tests into separate patches to mitigate some of the review pain here.

This patch solves a longstanding issue where we were loading `in-content/common-shared.css` in the chrome since it gets used by the `message-bar` element. It also makes some small visual changes to our infobars (slight outline, icon colors, adds a bit of spacing).

Differential Revision: https://phabricator.services.mozilla.com/D189872
2024-01-10 18:55:29 +00:00

63 lines
1.8 KiB
JavaScript

"use strict";
let { PluginManager } = ChromeUtils.importESModule(
"resource:///actors/PluginParent.sys.mjs"
);
/**
* 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.trim(),
"The GlobalTestPlugin plugin has crashed.",
"Correct message."
);
}
);
});