browser_test_display_contents.js (1636B)
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 /* import-globals-from ../../mochitest/layout.js */ 8 9 async function testContentBounds(browser, acc) { 10 let [expectedX, expectedY, expectedWidth, expectedHeight] = 11 await getContentBoundsForDOMElm(browser, getAccessibleDOMNodeID(acc)); 12 13 let contentDPR = await getContentDPR(browser); 14 const [x, y, width, height] = await untilCacheCondition( 15 (testX, testY, testW, testH) => 16 testX == expectedX && 17 testY == expectedY && 18 testW == expectedWidth && 19 testH >= expectedHeight, 20 () => getBounds(acc, contentDPR) 21 ); 22 let prettyAccName = prettyName(acc); 23 is(x, expectedX, "Wrong x coordinate of " + prettyAccName); 24 is(y, expectedY, "Wrong y coordinate of " + prettyAccName); 25 is(width, expectedWidth, "Wrong width of " + prettyAccName); 26 Assert.greaterOrEqual( 27 height, 28 expectedHeight, 29 "Wrong height of " + prettyAccName 30 ); 31 } 32 33 async function runTests(browser, accDoc) { 34 let p = findAccessibleChildByID(accDoc, "div"); 35 let p2 = findAccessibleChildByID(accDoc, "p"); 36 37 await testContentBounds(browser, p); 38 await testContentBounds(browser, p2); 39 } 40 41 /** 42 * Test accessible bounds for accs with display:contents 43 */ 44 addAccessibleTask( 45 ` 46 <div id="div">before 47 <ul id="ul" style="display: contents;"> 48 <li id="li" style="display: contents;"> 49 <p id="p">item</p> 50 </li> 51 </ul> 52 </div>`, 53 runTests, 54 { iframe: true, remoteIframe: true } 55 );