browser_pivot.js (3332B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Tests Pivot API 9 */ 10 addAccessibleTask( 11 ` 12 <h1 id="heading-1-1">Main Title</h1> 13 <h2 id="heading-2-1" aria-hidden="true">First Section Title</h2> 14 <p id="paragraph-1"> 15 Lorem ipsum <strong>dolor</strong> sit amet. Integer vitae urna 16 leo, id <a href="#">semper</a> nulla. 17 </p> 18 <h2 id="heading-2-2" aria-hidden="undefined">Second Section Title</h2> 19 <p id="paragraph-2" aria-hidden=""> 20 Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.</p> 21 <p id="paragraph-3" aria-hidden="true"> 22 <a href="#" id="hidden-link">Maybe</a> it was the other <i>George Michael</i>. 23 You know, the <a href="#">singer-songwriter</a>. 24 </p> 25 <p style="opacity: 0;" id="paragraph-4"> 26 This is completely transparent 27 </p> 28 <iframe 29 src="data:text/html,<html><body>An <i>embedded</i> document.</body></html>"> 30 </iframe> 31 <div id="hide-me">Hide me</div> 32 <p id="links" aria-hidden="false"> 33 <a href="http://mozilla.org" title="Link 1 title">Link 1</a> 34 <a href="http://mozilla.org" title="Link 2 title">Link 2</a> 35 <a href="http://mozilla.org" title="Link 3 title">Link 3</a> 36 </p> 37 <ul> 38 <li>Hello<span> </span></li> 39 <li>World</li> 40 </ul> 41 `, 42 async function (browser, docAcc) { 43 let pivot = gAccService.createAccessiblePivot(docAcc); 44 testPivotSequence(pivot, HeadersTraversalRule, [ 45 "heading-1-1", 46 "heading-2-2", 47 ]); 48 49 testPivotSequence(pivot, ObjectTraversalRule, [ 50 "Main Title", 51 "Lorem ipsum ", 52 "dolor", 53 " sit amet. Integer vitae urna leo, id ", 54 "semper", 55 " nulla. ", 56 "Second Section Title", 57 "Sed accumsan luctus lacus, vitae mollis arcu tristique vulputate.", 58 "An ", 59 "embedded", 60 " document.", 61 "Hide me", 62 "Link 1", 63 "Link 2", 64 "Link 3", 65 "Hello", 66 "World", 67 ]); 68 69 let hideMeAcc = findAccessibleChildByID(docAcc, "hide-me"); 70 let onHide = waitForEvent(EVENT_HIDE, hideMeAcc); 71 invokeContentTask(browser, [], () => { 72 content.document.getElementById("hide-me").remove(); 73 }); 74 75 await onHide; 76 testFailsWithNotInTree( 77 () => pivot.next(hideMeAcc, ObjectTraversalRule), 78 "moveNext from defunct accessible should fail" 79 ); 80 81 let linksAcc = findAccessibleChildByID(docAcc, "links"); 82 83 let removedRootPivot = gAccService.createAccessiblePivot(linksAcc); 84 onHide = waitForEvent(EVENT_HIDE, linksAcc); 85 invokeContentTask(browser, [], () => { 86 content.document.getElementById("links").remove(); 87 }); 88 89 await onHide; 90 testFailsWithNotInTree( 91 () => removedRootPivot.last(ObjectTraversalRule), 92 "moveLast with pivot with defunct root should fail" 93 ); 94 95 let [x, y] = getBounds(findAccessibleChildByID(docAcc, "heading-1-1")); 96 let hitacc = pivot.atPoint(x + 1, y + 1, HeadersTraversalRule); 97 is(getIdOrName(hitacc), "heading-1-1", "Matching accessible at point"); 98 99 hitacc = pivot.atPoint(x - 1, y - 1, HeadersTraversalRule); 100 ok(!hitacc, "No heading at given point"); 101 }, 102 { iframe: true, remoteIframe: true, topLevel: true, chrome: true } 103 );