/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
let NO_MOVE = { unexpected: [[EVENT_REORDER, "container"]] };
let MOVE = { expected: [[EVENT_REORDER, "container"]] };
// Set last ordinal child as aria-owned, should produce no reorder.
addAccessibleTask(
`
Test
`,
async function (browser, accDoc) {
let containerAcc = findAccessibleChildByID(accDoc, "container");
testChildrenIds(containerAcc, ["a"]);
await contentSpawnMutation(browser, NO_MOVE, function () {
// aria-own ordinal child in place, should be a no-op.
content.document
.getElementById("container")
.setAttribute("aria-owns", "a");
});
testChildrenIds(containerAcc, ["a"]);
}
);
// Add a new ordinal child to a container with an aria-owned child.
// Order should respect aria-owns.
addAccessibleTask(
`
Test
`,
async function (browser, accDoc) {
let containerAcc = findAccessibleChildByID(accDoc, "container");
testChildrenIds(containerAcc, ["a"]);
await contentSpawnMutation(browser, MOVE, function () {
let container = content.document.getElementById("container");
container.setAttribute("aria-owns", "a");
let aa = content.document.createElement("li");
aa.id = "aa";
container.appendChild(aa);
});
testChildrenIds(containerAcc, ["aa", "a"]);
await contentSpawnMutation(browser, MOVE, function () {
content.document.getElementById("container").removeAttribute("aria-owns");
});
testChildrenIds(containerAcc, ["a", "aa"]);
}
);
// Remove a no-move aria-owns attribute, should result in a no-move.
addAccessibleTask(
`
Test
`,
async function (browser, accDoc) {
let containerAcc = findAccessibleChildByID(accDoc, "container");
testChildrenIds(containerAcc, ["a"]);
await contentSpawnMutation(browser, NO_MOVE, function () {
// remove aria-owned child that is already ordinal, should be no-op.
content.document.getElementById("container").removeAttribute("aria-owns");
});
testChildrenIds(containerAcc, ["a"]);
}
);
// Attempt to steal an aria-owned child. The attempt should fail.
addAccessibleTask(
`
Test
`,
async function (browser, accDoc) {
let containerAcc = findAccessibleChildByID(accDoc, "container");
testChildrenIds(containerAcc, []);
await contentSpawnMutation(browser, NO_MOVE, function () {
content.document
.getElementById("container")
.setAttribute("aria-owns", "a");
});
testChildrenIds(containerAcc, []);
}
);
// Don't aria-own children of