/* 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";
/**
* Test details relations for the popovertarget content attribute.
*/
addAccessibleTask(
`
popover
details
`,
async function testPopoverContent(browser, docAcc) {
// The popover is hidden, so nothing should be referring to it.
const hide = findAccessibleChildByID(docAcc, "hide");
await testCachedRelation(hide, RELATION_DETAILS, []);
const toggle1 = findAccessibleChildByID(docAcc, "toggle1");
await testCachedRelation(toggle1, RELATION_DETAILS, []);
const toggle2 = findAccessibleChildByID(docAcc, "toggle2");
await testCachedRelation(toggle2, RELATION_DETAILS, []);
const toggleSibling = findAccessibleChildByID(docAcc, "toggleSibling");
await testCachedRelation(toggleSibling, RELATION_DETAILS, []);
info("Showing popover");
let shown = waitForEvent(EVENT_SHOW, "popover");
toggle1.doAction(0);
const popover = (await shown).accessible;
await testCachedRelation(toggle1, RELATION_DETAILS, popover);
// toggle2 shouldn't have a details relation because it doesn't have a
// popovertarget.
await testCachedRelation(toggle2, RELATION_DETAILS, []);
// hide shouldn't have a details relation because its action is hide.
await testCachedRelation(hide, RELATION_DETAILS, []);
// toggleSibling shouldn't have a details relation because it is a sibling
// of the popover.
await testCachedRelation(toggleSibling, RELATION_DETAILS, []);
await testCachedRelation(popover, RELATION_DETAILS_FOR, toggle1);
info("Setting toggle2 popovertarget");
await invokeSetAttribute(browser, "toggle2", "popovertarget", "popover");
await testCachedRelation(toggle2, RELATION_DETAILS, popover);
await testCachedRelation(popover, RELATION_DETAILS_FOR, [toggle1, toggle2]);
info("Removing toggle2 popovertarget");
await invokeSetAttribute(browser, "toggle2", "popovertarget", null);
await testCachedRelation(toggle2, RELATION_DETAILS, []);
await testCachedRelation(popover, RELATION_DETAILS_FOR, toggle1);
info("Setting aria-details on toggle1");
await invokeSetAttribute(browser, "toggle1", "aria-details", "details");
const details = findAccessibleChildByID(docAcc, "details");
// aria-details overrides popover.
await testCachedRelation(toggle1, RELATION_DETAILS, details);
await testCachedRelation(popover, RELATION_DETAILS_FOR, []);
info("Removing aria-details from toggle1");
await invokeSetAttribute(browser, "toggle1", "aria-details", null);
await testCachedRelation(toggle1, RELATION_DETAILS, popover);
await testCachedRelation(popover, RELATION_DETAILS_FOR, toggle1);
info("Hiding popover");
let hidden = waitForEvent(EVENT_HIDE, popover);
toggle1.doAction(0);
// The relations between toggle1 and popover are removed when popover shuts
// down. However, this doesn't cause a cache update notification. Therefore,
// to avoid timing out in testCachedRelation, we must wait for a hide event
// first.
await hidden;
await testCachedRelation(toggle1, RELATION_DETAILS, []);
},
{ chrome: false, topLevel: true }
);
/**
* Test details relations for the commandfor content attribute.
*/
addAccessibleTask(
`
details
`,
async function testPopoverContent(browser, docAcc) {
// The popover is hidden, so nothing should be referring to it.
const hide = findAccessibleChildByID(docAcc, "hide");
await testCachedRelation(hide, RELATION_DETAILS, []);
const toggle1 = findAccessibleChildByID(docAcc, "toggle1");
await testCachedRelation(toggle1, RELATION_DETAILS, []);
const show = findAccessibleChildByID(docAcc, "show");
await testCachedRelation(show, RELATION_DETAILS, []);
const toggle2 = findAccessibleChildByID(docAcc, "toggle2");
await testCachedRelation(toggle2, RELATION_DETAILS, []);
const showModal = findAccessibleChildByID(docAcc, "showModal");
await testCachedRelation(showModal, RELATION_DETAILS, []);
const invalid = findAccessibleChildByID(docAcc, "invalid");
await testCachedRelation(invalid, RELATION_DETAILS, []);
const custom = findAccessibleChildByID(docAcc, "custom");
await testCachedRelation(custom, RELATION_DETAILS, []);
const toggleSibling = findAccessibleChildByID(docAcc, "toggleSibling");
await testCachedRelation(toggleSibling, RELATION_DETAILS, []);
info("Showing popover");
let shown = waitForEvent(EVENT_SHOW, "popover");
toggle1.doAction(0);
const popover = (await shown).accessible;
await testCachedRelation(toggle1, RELATION_DETAILS, popover);
await testCachedRelation(show, RELATION_DETAILS, popover);
// toggle2 shouldn't have a details relation because it doesn't have a
// commandfor.
await testCachedRelation(toggle2, RELATION_DETAILS, []);
// hide shouldn't have a details relation because its action is hide-popover.
await testCachedRelation(hide, RELATION_DETAILS, []);
// showModal shouldn't have a details relation because it is executing a
// non-popover command.
await testCachedRelation(showModal, RELATION_DETAILS, []);
// invalid shouldn't have a details relation because it has an invalid command.
await testCachedRelation(invalid, RELATION_DETAILS, []);
// custom shouldn't have a details relation because it has a custom command.
await testCachedRelation(invalid, RELATION_DETAILS, []);
// toggleSibling shouldn't have a details relation because it is a sibling
// of the popover.
await testCachedRelation(toggleSibling, RELATION_DETAILS, []);
await testCachedRelation(popover, RELATION_DETAILS_FOR, [toggle1, show]);
info("Setting toggle2 commandfor");
await invokeSetAttribute(browser, "toggle2", "commandfor", "popover");
await testCachedRelation(toggle2, RELATION_DETAILS, popover);
await testCachedRelation(popover, RELATION_DETAILS_FOR, [
toggle1,
show,
toggle2,
]);
info("Removing toggle2 commandfor");
await invokeSetAttribute(browser, "toggle2", "commandfor", null);
await testCachedRelation(toggle2, RELATION_DETAILS, []);
await testCachedRelation(popover, RELATION_DETAILS_FOR, [toggle1, show]);
info("Setting aria-details on toggle1");
await invokeSetAttribute(browser, "toggle1", "aria-details", "details");
const details = findAccessibleChildByID(docAcc, "details");
// aria-details overrides popover.
await testCachedRelation(toggle1, RELATION_DETAILS, details);
await testCachedRelation(popover, RELATION_DETAILS_FOR, [show]);
info("Removing aria-details from toggle1");
await invokeSetAttribute(browser, "toggle1", "aria-details", null);
await testCachedRelation(toggle1, RELATION_DETAILS, popover);
await testCachedRelation(popover, RELATION_DETAILS_FOR, [toggle1, show]);
info("Hiding popover");
let hidden = waitForEvent(EVENT_HIDE, popover);
toggle1.doAction(0);
// The relations between toggle1 and popover are removed when popover shuts
// down. However, this doesn't cause a cache update notification. Therefore,
// to avoid timing out in testCachedRelation, we must wait for a hide event
// first.
await hidden;
await testCachedRelation(toggle1, RELATION_DETAILS, []);
await testCachedRelation(show, RELATION_DETAILS, []);
},
{ chrome: false, topLevel: true }
);
/**
* Test details relations for the popoverTargetElement WebIDL attribute.
*/
addAccessibleTask(
`
between