Bug 1869065 - Re-visit some of the element property names used in moz-message-bar. r=hjones,reusable-components-reviewers,omc-reviewers,aminomancer

Differential Revision: https://phabricator.services.mozilla.com/D207897
This commit is contained in:
gravyant 2024-04-23 21:27:46 +00:00
parent bf7d83f943
commit c7fdfabf96
7 changed files with 30 additions and 27 deletions

View file

@ -107,7 +107,7 @@ add_task(async function react_to_trigger() {
"Notification has default priority"
);
// Dismiss the notification
notificationStack.currentNotification.closeButtonEl.click();
notificationStack.currentNotification.closeButton.click();
});
add_task(async function dismiss_telemetry() {
@ -128,7 +128,7 @@ add_task(async function dismiss_telemetry() {
// Remove any IMPRESSION pings
dispatchStub.reset();
infobar.notification.closeButtonEl.click();
infobar.notification.closeButton.click();
await BrowserTestUtils.waitForCondition(
() => infobar.notification === null,
@ -204,7 +204,7 @@ add_task(async function prevent_multiple_messages() {
Assert.equal(dispatchStub.callCount, 2, "Impression count did not increase");
// Dismiss the first notification
infobar.notification.closeButtonEl.click();
infobar.notification.closeButton.click();
Assert.equal(InfoBar._activeInfobar, null, "Cleared the active notification");
// Reset impressions count
@ -218,6 +218,6 @@ add_task(async function prevent_multiple_messages() {
Assert.ok(InfoBar._activeInfobar, "activeInfobar is set");
Assert.equal(dispatchStub.callCount, 2, "Called twice with IMPRESSION");
// Dismiss the notification again
infobar.notification.closeButtonEl.click();
infobar.notification.closeButton.click();
Assert.equal(InfoBar._activeInfobar, null, "Cleared the active notification");
});

View file

@ -184,7 +184,7 @@ add_task(async function waitForScriptTest() {
});
// Click the "Close" button this time, we shouldn't get a callback at all.
notification.currentNotification.closeButtonEl.click();
notification.currentNotification.closeButton.click();
// send another hang pulse, we should not get a notification here
Services.obs.notifyObservers(hangReport, "process-hang-report");

View file

@ -292,7 +292,7 @@ add_task(async function test_other_ignored() {
Assert.ok(notification, "There should be a notification");
// Dismiss notification, creating the .dmp.ignore file
notification.closeButtonEl.click();
notification.closeButton.click();
gNotificationBox.removeNotification(notification, true);
await waitForIgnoredReports(toIgnore);
@ -525,7 +525,7 @@ add_task(async function test_can_ignore() {
Assert.ok(notification, "There should be a notification");
// Dismiss the notification by clicking on the "X" button.
notification.closeButtonEl.click();
notification.closeButton.click();
// We'll not wait for the notification to finish its transition -
// we'll just remove it right away.
gNotificationBox.removeNotification(notification, true);
@ -599,7 +599,7 @@ add_task(async function test_shutdown_while_not_showing() {
Assert.ok(notification, "There should be a notification");
// Dismiss the notification by clicking on the "X" button.
notification.closeButtonEl.click();
notification.closeButton.click();
// We'll not wait for the notification to finish its transition -
// we'll just remove it right away.
gNotificationBox.removeNotification(notification, true);

View file

@ -123,7 +123,7 @@ class TestSafeBrowsingNotificationBar(WindowManagerMixin, MarionetteTestCase):
message = notification_box.find_element(
By.CSS_SELECTOR, "notification-message[value=blocked-badware-page]"
)
button = message.get_property("closeButtonEl")
button = message.get_property("closeButton")
button.click()
Wait(self.marionette, timeout=self.marionette.timeout.page_load).until(

View file

@ -1,23 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>MozMessageBar tests</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="module" src="chrome://global/content/elements/moz-message-bar.mjs"></script>
</head>
<body>
<p id="display"></p>
<div id="content">
<moz-message-bar id="infoMessage" heading="Heading" message="Test message"></moz-message-bar>
<moz-message-bar id="infoMessage2" dismissable message="Test message"></moz-message-bar>
<moz-message-bar id="warningMessage" type="warning" message="Test message"></moz-message-bar>
<moz-message-bar id="successMessage" type="success" message="Test message"></moz-message-bar>
<moz-message-bar id="errorMessage" type="error" message="Test message"></moz-message-bar>
</div>
<pre id="test">
<p id="display"></p>
<div id="content">
<moz-message-bar id="infoMessage" heading="Heading" message="Test message"></moz-message-bar>
<moz-message-bar id="infoMessage2" dismissable message="Test message"></moz-message-bar>
<moz-message-bar id="warningMessage" type="warning" message="Test message"></moz-message-bar>
<moz-message-bar id="successMessage" type="success" message="Test message"></moz-message-bar>
<moz-message-bar id="errorMessage" type="error" message="Test message"></moz-message-bar>
</div>
<pre id="test">
<script class="testbody" type="application/javascript">
add_task(async function test_component_declaration() {
const mozMessageBar = document.querySelector("#infoMessage");
@ -48,11 +50,11 @@
add_task(async function test_close_button() {
const notDismissableComponent = document.querySelector("#infoMessage");
let closeButton = notDismissableComponent.closeButtonEl;
let closeButton = notDismissableComponent.closeButton;
ok(!closeButton, "Close button doesn't show when the message bar isn't dismissable.");
let dismissableComponent = document.querySelector("#infoMessage2");
closeButton = dismissableComponent.closeButtonEl;
closeButton = dismissableComponent.closeButton;
ok(closeButton, "Close button is shown when the message bar is dismissable.");
closeButton.click();
@ -89,4 +91,5 @@
</script>
</pre>
</body>
</html>

View file

@ -49,10 +49,10 @@ const messageTypeToIconData = {
export default class MozMessageBar extends MozLitElement {
static queries = {
actionsSlotEl: "slot[name=actions]",
actionsSlot: "slot[name=actions]",
actionsEl: ".actions",
closeButtonEl: "moz-button.close",
supportLinkSlotEl: "slot[name=support-link]",
closeButton: "moz-button.close",
supportLinkSlot: "slot[name=support-link]",
};
static properties = {
@ -72,7 +72,7 @@ export default class MozMessageBar extends MozLitElement {
}
onSlotchange() {
let actions = this.actionsSlotEl.assignedNodes();
let actions = this.actionsSlot.assignedNodes();
this.actionsEl.classList.toggle("active", actions.length);
}
@ -87,7 +87,7 @@ export default class MozMessageBar extends MozLitElement {
}
get supportLinkEls() {
return this.supportLinkSlotEl.assignedElements();
return this.supportLinkSlot.assignedElements();
}
iconTemplate() {

View file

@ -657,7 +657,7 @@ add_task(async function checkDiscopaneNotice() {
messageBar = win.document.querySelector("moz-message-bar.discopane-notice");
ok(messageBar, "Recommended notice should exist in disco view");
messageBar.closeButtonEl.click();
messageBar.closeButton.click();
messageBar = win.document.querySelector("moz-message-bar.discopane-notice");
ok(!messageBar, "Recommended notice should not exist in disco view");
await switchToNonDiscoView(win);