Files
sousa-gecko/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_message_close.js
Nicolas Chevobbe adf92ac7b4 Bug 2035736 - [devtools] Make about:debugging UI consistent with the Nova style. r=devtools-reviewers,fluent-reviewers,flod,jdescottes.
This removes as much custom aboutdebugging CSS as possible to rely on the shared
classes and custom properties used in the other about:* pages as possible.

The sidebar and its items are not migrated yet, as this requires more thought
about the proper way to handle the current design elements there.

`in-content/common-shared.css` is added in the allow list in browser_parsable_css.js
for when the test is run within DevTools as it's now included in aboutdebugging.

Differential Revision: https://phabricator.services.mozilla.com/D307293
2026-06-19 15:39:25 +00:00

84 lines
2.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
const EXTENSION_NAME = "Temporary web extension";
const EXTENSION_ID = "test-devtools@mozilla.org";
// Test that Message component can be closed with the X button
add_task(async function () {
const { document, tab, window } = await openAboutDebugging();
await selectThisFirefoxPage(document, window.AboutDebugging.store);
info("Check that the message can be closed with icon");
let warningMessage = await installExtensionWithWarning(document);
await testCloseMessageWithIcon(warningMessage, document);
await removeTemporaryExtension(EXTENSION_NAME, document);
info("Check that the message can be closed with the button around the icon");
warningMessage = await installExtensionWithWarning(document);
await testCloseMessageWithButton(warningMessage, document);
await removeTemporaryExtension(EXTENSION_NAME, document);
await removeTab(tab);
});
async function testCloseMessageWithIcon(warningMessage, doc) {
const closeButton = warningMessage.querySelector(
".qa-message-button-close-button"
);
const closeIcon = closeButton.shadowRoot.querySelector("img");
ok(!!closeIcon, "The warning message has a close icon");
info("Closing the message and waiting for it to disappear");
closeIcon.click();
const target = findDebugTargetByText(EXTENSION_NAME, doc);
await waitUntil(() => target.querySelector(".qa-message") === null);
}
async function testCloseMessageWithButton(warningMessage, doc) {
const closeButton = warningMessage.querySelector(
".qa-message-button-close-button"
);
ok(!!closeButton, "The warning message has a close button");
info("Click on the button and wait for the message to disappear");
EventUtils.synthesizeMouse(closeButton, 1, 1, {}, doc.defaultView);
const target = findDebugTargetByText(EXTENSION_NAME, doc);
await waitUntil(() => target.querySelector(".qa-message") === null);
}
async function installExtensionWithWarning(doc) {
await pushPref("extensions.webextensions.warnings-as-errors", false);
await installTemporaryExtensionFromXPI(
{
id: EXTENSION_ID,
name: EXTENSION_NAME,
extraProperties: {
// This property is not expected in the manifest and should trigger a warning!
wrongProperty: {},
},
},
doc
);
await SpecialPowers.popPrefEnv();
info("Wait until a debug target item appears");
await waitUntil(() => findDebugTargetByText(EXTENSION_NAME, doc));
const target = findDebugTargetByText(EXTENSION_NAME, doc);
const warningMessage = target.querySelector(".qa-message");
ok(
!!warningMessage,
"A warning message is displayed for the installed addon"
);
return warningMessage;
}