/* 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"; /** * Tests Pivot API */ addAccessibleTask( `

Main Title

Lorem ipsum dolor sit amet. Integer vitae urna leo, id semper nulla.

Second Section Title

Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.

This is completely transparent

Hide me
`, async function (browser, docAcc) { let pivot = gAccService.createAccessiblePivot(docAcc); testPivotSequence(pivot, HeadersTraversalRule, [ "heading-1-1", "heading-2-2", ]); testPivotSequence(pivot, ObjectTraversalRule, [ "Main Title", "Lorem ipsum ", "dolor", " sit amet. Integer vitae urna leo, id ", "semper", " nulla. ", "Second Section Title", "Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.", "An ", "embedded", " document.", "Hide me", "Link 1", "Link 2", "Link 3", "Hello", "World", ]); let hideMeAcc = findAccessibleChildByID(docAcc, "hide-me"); let onHide = waitForEvent(EVENT_HIDE, hideMeAcc); invokeContentTask(browser, [], () => { content.document.getElementById("hide-me").remove(); }); await onHide; testFailsWithNotInTree( () => pivot.next(hideMeAcc, ObjectTraversalRule), "moveNext from defunct accessible should fail" ); let linksAcc = findAccessibleChildByID(docAcc, "links"); let removedRootPivot = gAccService.createAccessiblePivot(linksAcc); onHide = waitForEvent(EVENT_HIDE, linksAcc); invokeContentTask(browser, [], () => { content.document.getElementById("links").remove(); }); await onHide; testFailsWithNotInTree( () => removedRootPivot.last(ObjectTraversalRule), "moveLast with pivot with defunct root should fail" ); let [x, y] = getBounds(findAccessibleChildByID(docAcc, "heading-1-1")); let hitacc = pivot.atPoint(x + 1, y + 1, HeadersTraversalRule); is(getIdOrName(hitacc), "heading-1-1", "Matching accessible at point"); hitacc = pivot.atPoint(x - 1, y - 1, HeadersTraversalRule); ok(!hitacc, "No heading at given point"); }, { iframe: true, remoteIframe: true, topLevel: true, chrome: true } );