/* 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 live region creation and removal.
*/
addAccessibleTask(
`
Polite region
Assertive region
`,
async (browser, accDoc) => {
let politeRegion = getNativeInterface(accDoc, "polite");
ok(
!politeRegion.attributeNames.includes("AXARIALive"),
"region is not live"
);
let liveRegionAdded = waitForMacEvent("AXLiveRegionCreated", "polite");
await SpecialPowers.spawn(browser, [], () => {
content.document
.getElementById("polite")
.setAttribute("aria-atomic", "true");
content.document
.getElementById("polite")
.setAttribute("aria-live", "polite");
});
await liveRegionAdded;
is(
politeRegion.getAttributeValue("AXARIALive"),
"polite",
"region is now live"
);
ok(politeRegion.getAttributeValue("AXARIAAtomic"), "region is atomic");
is(
politeRegion.getAttributeValue("AXARIARelevant"),
"removals",
"region has defined aria-relevant"
);
let assertiveRegion = getNativeInterface(accDoc, "assertive");
is(
assertiveRegion.getAttributeValue("AXARIALive"),
"assertive",
"region is assertive"
);
ok(
!assertiveRegion.getAttributeValue("AXARIAAtomic"),
"region is not atomic"
);
is(
assertiveRegion.getAttributeValue("AXARIARelevant"),
"additions text",
"region has default aria-relevant"
);
let liveRegionRemoved = waitForEvent(
EVENT_LIVE_REGION_REMOVED,
"assertive"
);
await SpecialPowers.spawn(browser, [], () => {
content.document.getElementById("assertive").removeAttribute("aria-live");
});
await liveRegionRemoved;
ok(!assertiveRegion.getAttributeValue("AXARIALive"), "region is not live");
liveRegionAdded = waitForMacEvent("AXLiveRegionCreated", "new-region");
await SpecialPowers.spawn(browser, [], () => {
let newRegionElm = content.document.createElement("div");
newRegionElm.id = "new-region";
newRegionElm.setAttribute("aria-live", "assertive");
content.document.body.appendChild(newRegionElm);
});
await liveRegionAdded;
let newRegion = getNativeInterface(accDoc, "new-region");
is(
newRegion.getAttributeValue("AXARIALive"),
"assertive",
"region is assertive"
);
let loadComplete = Promise.all([
waitForMacEvent("AXLoadComplete"),
waitForMacEvent("AXLiveRegionCreated", "region-1"),
waitForMacEvent("AXLiveRegionCreated", "region-2"),
waitForMacEvent("AXLiveRegionCreated", "status"),
waitForMacEvent("AXLiveRegionCreated", "output"),
]);
await SpecialPowers.spawn(browser, [], () => {
content.location = `data:text/html;charset=utf-8,
`;
});
let webArea = (await loadComplete)[0];
is(webArea.getAttributeValue("AXRole"), "AXWebArea", "web area yeah");
const searchPred = {
AXSearchKey: "AXLiveRegionSearchKey",
AXResultsLimit: -1,
AXDirection: "AXDirectionNext",
};
const liveRegions = webArea.getParameterizedAttributeValue(
"AXUIElementsForSearchPredicate",
NSDictionary(searchPred)
);
Assert.deepEqual(
liveRegions.map(r => r.getAttributeValue("AXDOMIdentifier")),
["region-1", "region-2", "alert", "status", "output"],
"SearchPredicate returned all live regions"
);
}
);
/**
* Test live region changes
*/
addAccessibleTask(
`