/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// nsIEditor.passwordMask is the same for all editors. Therefore, we just grab // it from the URL bar for simplicity. const PASSWORD_MASK = gURLBar.inputField.editor.passwordMask;
/** *Testdatahastheformatof: *{ *desc{String}descriptionforbetterlogging *id{String}givenaccessibleDOMNodeID *expected{String}expectedvalueforagivenaccessible *action{?AsyncFunction}anoptionalactionthatawaitsavaluechange *attrs{?Array}anoptionallistofattributestoupdate *waitFor{?Number}anoptionalvaluechangeeventtowaitfor *}
*/ const valueTests = [
{
desc: "Initially value is set to 1st element of select",
id: "select",
expected: "1st",
},
{
desc: "Value should update to 3rd when 3 is pressed",
id: "select",
async action(browser) {
await invokeFocus(browser, "select");
await invokeContentTask(browser, [], () => { const { ContentTaskUtils } = ChromeUtils.importESModule( "resource://testing-common/ContentTaskUtils.sys.mjs"
); const EventUtils = ContentTaskUtils.getEventUtils(content);
EventUtils.synthesizeKey("3", {}, content);
});
},
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: "3rd",
},
{
desc: "Initially value is set to @aria-valuenow for slider",
id: "slider",
expected: ["5", 5, 0, 7, 0],
},
{
desc: "Value should change when @aria-valuenow is updated",
id: "slider",
attrs: [
{
attr: "aria-valuenow",
value: "6",
},
],
waitFor: EVENT_VALUE_CHANGE,
expected: ["6", 6, 0, 7, 0],
},
{
desc: "Value should change when @aria-valuetext is set",
id: "slider",
attrs: [
{
attr: "aria-valuetext",
value: "plain",
},
],
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: ["plain", 6, 0, 7, 0],
},
{
desc: "Value should change when @aria-valuetext is updated",
id: "slider",
attrs: [
{
attr: "aria-valuetext",
value: "hey!",
},
],
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: ["hey!", 6, 0, 7, 0],
},
{
desc: "Value should change to @aria-valuetext when @aria-valuenow is removed",
id: "slider",
attrs: [
{
attr: "aria-valuenow",
},
],
expected: ["hey!", 3.5, 0, 7, 0],
},
{
desc: "Initially value is not set for combobox",
id: "combobox",
expected: "",
},
{
desc: "Value should change when @value attribute is updated",
id: "combobox",
attrs: [
{
attr: "value",
value: "hello",
},
],
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: "hello",
},
{
desc: "Initially value corresponds to @value attribute for progress",
id: "progress",
expected: "22%",
},
{
desc: "Value should change when @value attribute is updated",
id: "progress",
attrs: [
{
attr: "value",
value: "50",
},
],
waitFor: EVENT_VALUE_CHANGE,
expected: "50%",
},
{
desc: "Setting currentValue on a progress accessible should fail",
id: "progress",
async action(browser, acc) {
acc.QueryInterface(nsIAccessibleValue); try {
acc.currentValue = 25;
ok(false, "Setting currValue on progress element should fail");
} catch (e) {}
},
expected: "50%",
},
{
desc: "Initially value corresponds to @value attribute for range",
id: "range",
expected: "6",
},
{
desc: "Value should change when slider is moved",
id: "range",
async action(browser) {
await invokeFocus(browser, "range");
await invokeContentTask(browser, [], () => { const { ContentTaskUtils } = ChromeUtils.importESModule( "resource://testing-common/ContentTaskUtils.sys.mjs"
); const EventUtils = ContentTaskUtils.getEventUtils(content);
EventUtils.synthesizeKey("VK_LEFT", {}, content);
});
},
waitFor: EVENT_VALUE_CHANGE,
expected: "5",
},
{
desc: "Value should change when currentValue is called",
id: "range",
async action(browser, acc) {
acc.QueryInterface(nsIAccessibleValue);
acc.currentValue = 4;
},
waitFor: EVENT_VALUE_CHANGE,
expected: "4",
},
{
desc: "Initially textbox value is text subtree",
id: "textbox",
expected: "Some rich text",
},
{
desc: "Textbox value changes when subtree changes",
id: "textbox",
async action(browser) {
await invokeContentTask(browser, [], () => {
let boldText = content.document.createElement("strong");
boldText.textContent = " bold";
content.document.getElementById("textbox").appendChild(boldText);
});
},
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: "Some rich text bold",
},
{
desc: "Initially input value reflects @value attribute",
id: "input",
expected: "ab",
},
{
desc: "Input value changes when @value attribute changes",
id: "input",
attrs: [{ attr: "value", value: "c d" }],
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: "c d",
},
{
desc: "Initially textarea value reflects @value attribute",
id: "textarea",
expected: "ab",
},
{
desc: "Textarea value changes when .value property changes",
id: "textarea",
async action(browser) {
await invokeContentTask(browser, [], () => {
content.document.getElementById("textarea").value = "c\nd";
});
},
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: "c\nd",
},
{
desc: "Initially password value reflects @value attribute",
id: "password",
expected: PASSWORD_MASK.repeat(2),
},
{
desc: "Password value changes when @value attribute changes",
id: "password",
attrs: [{ attr: "value", value: "cde" }],
waitFor: EVENT_TEXT_VALUE_CHANGE,
expected: PASSWORD_MASK.repeat(3),
},
];
/** *LiketestValueinaccessible/tests/mochitest/value.js,butwaitsforcache *updates.
*/
async function testValue(acc, value, currValue, minValue, maxValue, minIncr) { const pretty = prettyName(acc);
await untilCacheIs(() => acc.value, value, `Wrong value of ${pretty}`);
await untilCacheIs(
() => acc.currentValue,
currValue,
`Wrong current value of ${pretty}`
);
await untilCacheIs(
() => acc.minimumValue,
minValue,
`Wrong minimum value of ${pretty}`
);
await untilCacheIs(
() => acc.maximumValue,
maxValue,
`Wrong maximum value of ${pretty}`
);
await untilCacheIs(
() => acc.minimumIncrement,
minIncr,
`Wrong minimum increment value of ${pretty}`
);
}
if (selectPopup.isNativeMenu) { // Synthesized events are not available with native menus
selectPopup.activateItem(selectPopup.childNodes[0]);
} else { // Press the up arrow to select the first option (drop-down expanded). // Then, press Enter to confirm the selection and close the dropdown. // We do both of these together to unify testing across platforms, since // events are not entirely consistent on Windows vs. Linux + macOS.
EventUtils.synthesizeKey("VK_UP");
EventUtils.synthesizeKey("VK_RETURN");
}
await p;
// Text as a descendant of the combobox: included in the value.
is(comboDiv1.value, "value", "Combobox value correct");
// Text as the descendant of a listbox: excluded from the value.
is(comboDiv2.value, "", "Combobox value correct");
// Text as the descendant of some other role that includes text in name computation. // Here, the group role contains the text node with "value" in it.
is(comboDiv3.value, "value", "Combobox value correct");
// Some descendant text included, but text descendant of a listbox excluded.
is(comboDiv4.value, "foo", "Combobox value correct");
// Combobox inputs with explicit value report that value.
is(comboInput1.value, "value", "Combobox value correct");
is(comboInput2.value, "value", "Combobox value correct");
// Combobox role with aria-selected reports correct value.
is(comboDivSelected.value, "value", "Combobox value correct");
},
{ chrome: true, iframe: true, remoteIframe: true }
);
/** *Testthevalueofacolorinput.
*/
addAccessibleTask(
`<input id="color" type="color" value="#000000">`,
async function testColor(browser, docAcc) { const color = findAccessibleChildByID(docAcc, "color");
is(color.value, "0% red 0% green 0% blue", "Initial value correct");
info("Setting value attribute to #ffffff");
let changed = waitForEvent(EVENT_TEXT_VALUE_CHANGE, color);
await invokeSetAttribute(browser, "color", "value", "#ffffff");
await changed;
is(
color.value, "100% red 100% green 100% blue", "Value correct after change"
);
info("Setting value property to #ffffff");
changed = waitForEvent(EVENT_TEXT_VALUE_CHANGE, color);
await invokeContentTask(browser, [], () => {
content.document.getElementById("color").value = "#000000";
});
await changed;
is(color.value, "0% red 0% green 0% blue", "Value correct after change");
},
{ chrome: true, topLevel: true }
);
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet am 2026-08-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.