/* 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"; add_setup(async function () { await SpecialPowers.pushPrefEnv({ set: [["test.wait300msAfterTabSwitch", true]], }); }); async function runTests(browser, accDoc) { const dpr = await getContentDPR(browser); await testChildAtPoint( dpr, 3, 3, findAccessibleChildByID(accDoc, "list"), findAccessibleChildByID(accDoc, "listitem"), findAccessibleChildByID(accDoc, "inner").firstChild ); todo( false, "Bug 746974 - children must match on all platforms. On Windows, " + "ChildAtPoint with eDeepestChild is incorrectly ignoring MustPrune " + "for the graphic." ); const txt = findAccessibleChildByID(accDoc, "txt"); await testChildAtPoint(dpr, 1, 1, txt, txt, txt); info( "::MustPrune case, point is outside of textbox accessible but is in document." ); await testChildAtPoint(dpr, -1, -1, txt, null, null); info("::MustPrune case, point is outside of root accessible."); await testChildAtPoint(dpr, -10000, -10000, txt, null, null); info("Not specific case, point is inside of btn accessible."); const btn = findAccessibleChildByID(accDoc, "btn"); await testChildAtPoint(dpr, 1, 1, btn, btn, btn); info("Not specific case, point is outside of btn accessible."); await testChildAtPoint(dpr, -1, -1, btn, null, null); info( "Out of flow accessible testing, do not return out of flow accessible " + "because it's not a child of the accessible even though visually it is." ); await invokeContentTask(browser, [], () => { const { CommonUtils } = ChromeUtils.importESModule( "chrome://mochitests/content/browser/accessible/tests/browser/Common.sys.mjs" ); const doc = content.document; const rectArea = CommonUtils.getNode("area", doc).getBoundingClientRect(); const outOfFlow = CommonUtils.getNode("outofflow", doc); outOfFlow.style.left = rectArea.left + "px"; outOfFlow.style.top = rectArea.top + "px"; }); const area = findAccessibleChildByID(accDoc, "area"); await testChildAtPoint(dpr, 1, 1, area, area, area); info("Test image maps. Their children are not in the layout tree."); await waitForImageMap(browser, accDoc); const imgmap = findAccessibleChildByID(accDoc, "imgmap"); ok(imgmap, "Image map exists"); const theLetterA = imgmap.firstChild; await hitTest(browser, imgmap, theLetterA, theLetterA); await hitTest( browser, findAccessibleChildByID(accDoc, "container"), imgmap, theLetterA ); info("hit testing for element contained by zero-width element"); const container2Input = findAccessibleChildByID(accDoc, "container2_input"); await hitTest( browser, findAccessibleChildByID(accDoc, "container2"), container2Input, container2Input ); info("hittesting table, row, cells -- rows are not in the layout tree"); const table = findAccessibleChildByID(accDoc, "table"); const row = findAccessibleChildByID(accDoc, "row"); const cell1 = findAccessibleChildByID(accDoc, "cell1"); await hitTest(browser, table, row, cell1); info("Testing that an inaccessible child doesn't break hit testing"); const containerWithInaccessibleChild = findAccessibleChildByID( accDoc, "containerWithInaccessibleChild" ); const containerWithInaccessibleChildP2 = findAccessibleChildByID( accDoc, "containerWithInaccessibleChild_p2" ); await hitTest( browser, containerWithInaccessibleChild, containerWithInaccessibleChildP2, containerWithInaccessibleChildP2.firstChild ); info("Testing wrapped text"); const wrappedTextLinkFirstP = findAccessibleChildByID( accDoc, "wrappedTextLinkFirstP" ); const wrappedTextLinkFirstA = findAccessibleChildByID( accDoc, "wrappedTextLinkFirstA" ); await hitTest( browser, wrappedTextLinkFirstP, wrappedTextLinkFirstA, wrappedTextLinkFirstA.firstChild ); const wrappedTextLeafFirstP = findAccessibleChildByID( accDoc, "wrappedTextLeafFirstP" ); const wrappedTextLeafFirstMark = findAccessibleChildByID( accDoc, "wrappedTextLeafFirstMark" ); await hitTest( browser, wrappedTextLeafFirstP, wrappedTextLeafFirstMark, wrappedTextLeafFirstMark.firstChild ); const wrappedTextNestedInlineP = findAccessibleChildByID( accDoc, "wrappedTextNestedInlineP" ); const wrappedTextNestedInlineEm = findAccessibleChildByID( accDoc, "wrappedTextNestedInlineEm" ); const wrappedTextNestedInlineStrong = findAccessibleChildByID( accDoc, "wrappedTextNestedInlineStrong" ); await hitTest( browser, wrappedTextNestedInlineP, wrappedTextNestedInlineEm, wrappedTextNestedInlineStrong.firstChild ); const wrappedTextPre = findAccessibleChildByID(accDoc, "wrappedTextPre"); const wrappedTextPreCode = findAccessibleChildByID( accDoc, "wrappedTextPreCode" ); await hitTest( browser, wrappedTextPre, wrappedTextPreCode, wrappedTextPreCode.firstChild ); // hitTest() can only test the first character. We need to test a subsequent // character for this case. let [x, y, w] = await getContentBoundsForDOMElm( browser, "wrappedTextPreCode" ); // Use the top center of the element. x = x + w / 2; await untilCacheIs( () => getChildAtPoint(wrappedTextPre, x, y, true), wrappedTextPreCode.firstChild, `Wrong deepest child accessible at the point (${x}, ${y}) of wrappedTextPre, sought wrappedTextPreCode leaf` ); info("Testing image"); const imageP = findAccessibleChildByID(accDoc, "imageP"); const image = findAccessibleChildByID(accDoc, "image"); await hitTest(browser, imageP, image, image); info("Testing image map with 0-sized area"); const mapWith0AreaP = findAccessibleChildByID(accDoc, "mapWith0AreaP"); const mapWith0Area = findAccessibleChildByID(accDoc, "mapWith0Area"); await hitTest(browser, mapWith0AreaP, mapWith0Area, mapWith0Area); } addAccessibleTask( `
| hello | world |
hi
bye
ab cd
ab cd
y z
ab cd
e
detailsOpenP
detailsP
before
innerP
exists
// a pseudoelement, ::details-content. Use this as
// our expected target for direct-child hittesting.
await hitTest(
browser,
detailsOpen,
detailsOpenP.parent,
detailsOpenP.firstChild
);
info("Opening details");
let shown = waitForEvent(EVENT_SHOW, "detailsP");
await invokeContentTask(browser, [], () => {
content.document.getElementById("details").open = true;
});
const detailsP = (await shown).accessible;
// There is a