commit 87737acc9eebab9a034dadbd278d73d49357d69e parent 481ed92a1239fbee2107982f177f171115234f87 Author: Julien Wajsberg <felash@gmail.com> Date: Thu, 8 Jan 2026 10:17:48 +0000 Bug 2006354 - Add tests for the 'type' attribute of the various moz-inputs r=mkennedy Differential Revision: https://phabricator.services.mozilla.com/D277995 Diffstat:
11 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/toolkit/content/tests/widgets/lit-test-helpers.js b/toolkit/content/tests/widgets/lit-test-helpers.js @@ -163,8 +163,10 @@ class InputTestHelpers extends LitTestHelpers { * all reusable moz- input elements. * * @param {string} elementName - HTML tag of the element under test. + * @param {object} options - Custom properties to assert. Currently only type is supported. + * @param {string} options.type - The input type to verify. Defaults to "text". */ - async testCommonInputProperties(elementName) { + async testCommonInputProperties(elementName, { type = "text" } = {}) { await this.verifyLabel(elementName); await this.verifyAriaLabel(elementName); await this.verifyAriaDescription(elementName); @@ -176,6 +178,7 @@ class InputTestHelpers extends LitTestHelpers { await this.verifySupportPage(elementName); await this.verifyAccesskey(elementName); await this.verifyNoWhitespace(elementName); + await this.verifyType(elementName, type); if (this.activatedProperty) { await this.verifyActivated(elementName); await this.verifyNestedFields(elementName); @@ -767,6 +770,12 @@ class InputTestHelpers extends LitTestHelpers { ); } + async verifyType(selector, type) { + let renderTarget = await this.renderTemplate(); + let firstInput = renderTarget.querySelector(selector); + is(firstInput.inputEl.type, type, `The input type is ${type}`); + } + async testTextBasedInputEvents(selector) { let { trackEvent, verifyEvents } = this.getInputEventHelpers(); let target = await this.renderTemplate(); diff --git a/toolkit/content/tests/widgets/test_moz_checkbox.html b/toolkit/content/tests/widgets/test_moz_checkbox.html @@ -32,7 +32,9 @@ }); add_task(async function testMozCheckboxProperties() { - await testHelpers.testCommonInputProperties("moz-checkbox"); + await testHelpers.testCommonInputProperties("moz-checkbox", { + type: "checkbox", + }); }); add_task(async function testCheckboxEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_input_email.html b/toolkit/content/tests/widgets/test_moz_input_email.html @@ -28,7 +28,9 @@ }); add_task(async function testMozInputEmailProperties() { - await testHelpers.testCommonInputProperties("moz-input-email"); + await testHelpers.testCommonInputProperties("moz-input-email", { + type: "email", + }); }); add_task(async function testMozInputEmailEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_input_number.html b/toolkit/content/tests/widgets/test_moz_input_number.html @@ -54,6 +54,7 @@ await testHelpers.verifySupportPage("moz-input-number"); await testHelpers.verifyAccesskey("moz-input-number"); await testHelpers.verifyNoWhitespace("moz-input-number"); + await testHelpers.verifyType("moz-input-number", "number"); }); add_task(async function testMozInputNumberEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_input_password.html b/toolkit/content/tests/widgets/test_moz_input_password.html @@ -28,7 +28,9 @@ }); add_task(async function testMozInputPasswordProperties() { - await testHelpers.testCommonInputProperties("moz-input-password"); + await testHelpers.testCommonInputProperties("moz-input-password", { + type: "password", + }); }); add_task(async function testMozInputPasswordEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_input_search.html b/toolkit/content/tests/widgets/test_moz_input_search.html @@ -28,7 +28,9 @@ }); add_task(async function testMozInputSearchProperties() { - await testHelpers.testCommonInputProperties("moz-input-search"); + await testHelpers.testCommonInputProperties("moz-input-search", { + type: "search", + }); }); add_task(async function testMozInputSearchEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_input_tel.html b/toolkit/content/tests/widgets/test_moz_input_tel.html @@ -28,7 +28,9 @@ }); add_task(async function testMozInputTelProperties() { - await testHelpers.testCommonInputProperties("moz-input-tel"); + await testHelpers.testCommonInputProperties("moz-input-tel", { + type: "tel", + }); }); add_task(async function testMozInputTelEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_input_url.html b/toolkit/content/tests/widgets/test_moz_input_url.html @@ -28,7 +28,9 @@ }); add_task(async function testMozInputUrlProperties() { - await testHelpers.testCommonInputProperties("moz-input-url"); + await testHelpers.testCommonInputProperties("moz-input-url", { + type: "url", + }); }); add_task(async function testMozInputUrlEvents() { diff --git a/toolkit/content/tests/widgets/test_moz_radio.html b/toolkit/content/tests/widgets/test_moz_radio.html @@ -31,7 +31,9 @@ }); add_task(async function testMozRadioProperties() { - await testHelpers.testCommonInputProperties("moz-radio"); + await testHelpers.testCommonInputProperties("moz-radio", { + type: "radio", + }); }); </script> </head> diff --git a/toolkit/content/tests/widgets/test_moz_select.html b/toolkit/content/tests/widgets/test_moz_select.html @@ -29,7 +29,9 @@ }); add_task(async function testMozSelectProperties() { - await testHelpers.testCommonInputProperties("moz-select"); + await testHelpers.testCommonInputProperties("moz-select", { + type: "select-one", + }); }); add_task(async function testMozSelectChange() { diff --git a/toolkit/content/tests/widgets/test_moz_toggle.html b/toolkit/content/tests/widgets/test_moz_toggle.html @@ -33,7 +33,9 @@ }); add_task(async function testMozToggleProperties() { - await testHelpers.testCommonInputProperties("moz-toggle"); + await testHelpers.testCommonInputProperties("moz-toggle", { + type: "button", + }); }); add_task(async function testMozToggleInteraction() {