From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../tests/browser_containers_name_input.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 browser/components/preferences/tests/browser_containers_name_input.js (limited to 'browser/components/preferences/tests/browser_containers_name_input.js') diff --git a/browser/components/preferences/tests/browser_containers_name_input.js b/browser/components/preferences/tests/browser_containers_name_input.js new file mode 100644 index 0000000000..38785d3cb0 --- /dev/null +++ b/browser/components/preferences/tests/browser_containers_name_input.js @@ -0,0 +1,72 @@ +const CONTAINERS_URL = + "chrome://browser/content/preferences/dialogs/containers.xhtml"; + +add_setup(async function () { + await openPreferencesViaOpenPreferencesAPI("containers", { leaveOpen: true }); + registerCleanupFunction(async function () { + BrowserTestUtils.removeTab(gBrowser.selectedTab); + }); +}); + +add_task(async function () { + async function openDialog() { + let doc = gBrowser.selectedBrowser.contentDocument; + + let dialogPromise = promiseLoadSubDialog(CONTAINERS_URL); + + let addButton = doc.getElementById("containersAdd"); + addButton.doCommand(); + + let dialog = await dialogPromise; + + return dialog.document; + } + + let { contentDocument } = gBrowser.selectedBrowser; + let containerNodes = Array.from( + contentDocument.querySelectorAll("[data-category=paneContainers]") + ); + ok( + containerNodes.find(node => node.getBoundingClientRect().width > 0), + "Should actually be showing the container nodes." + ); + + let doc = await openDialog(); + + let name = doc.getElementById("name"); + let btnApplyChanges = doc.querySelector("dialog").getButton("accept"); + + Assert.equal(name.value, "", "The name textbox should initlally be empty"); + Assert.ok( + btnApplyChanges.disabled, + "The done button should initially be disabled" + ); + + function setName(value) { + name.value = value; + + let event = new doc.defaultView.InputEvent("input", { data: value }); + SpecialPowers.dispatchEvent(doc.defaultView, name, event); + } + + setName("test"); + + Assert.ok( + !btnApplyChanges.disabled, + "The done button should be enabled when the value is not empty" + ); + + setName(""); + + Assert.ok( + btnApplyChanges.disabled, + "The done button should be disabled when the value is empty" + ); + + setName("\u0009\u000B\u000C\u0020\u00A0\uFEFF\u000A\u000D\u2028\u2029"); + + Assert.ok( + btnApplyChanges.disabled, + "The done button should be disabled when the value contains only whitespaces" + ); +}); -- cgit v1.2.3