browser_test_scroll_substring.js (1666B)
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 loadScripts({ name: "layout.js", dir: MOCHITESTS_DIR }); 9 10 add_setup(async function () { 11 await SpecialPowers.pushPrefEnv({ 12 set: [["test.wait300msAfterTabSwitch", true]], 13 }); 14 }); 15 16 /** 17 * Test nsIAccessibleText::scrollSubstringTo. 18 */ 19 addAccessibleTask( 20 ` 21 <style> 22 @font-face { 23 font-family: Ahem; 24 src: url(${CURRENT_CONTENT_DIR}e10s/fonts/Ahem.sjs); 25 } 26 pre { 27 font: 20px/20px Ahem; 28 height: 40px; 29 overflow-y: scroll; 30 } 31 </style> 32 <pre id="text"> 33 34 35 36 37 38 It's a jetpack, Michael. What could possibly go wrong? 39 40 41 42 43 44 The only thing I found in the fridge was a dead dove in a bag. 45 </pre>`, 46 async function (browser, docAcc) { 47 let text = findAccessibleChildByID(docAcc, "text", [nsIAccessibleText]); 48 let [, containerY, , containerHeight] = getBounds(text); 49 let getCharY = () => { 50 let objY = {}; 51 text.getCharacterExtents(7, {}, objY, {}, {}, COORDTYPE_SCREEN_RELATIVE); 52 return objY.value; 53 }; 54 Assert.less( 55 containerHeight, 56 getCharY(), 57 "Character is outside of container bounds" 58 ); 59 text.scrollSubstringTo(7, 8, SCROLL_TYPE_TOP_EDGE); 60 61 await waitForContentPaint(browser); 62 await untilCacheIs( 63 getCharY, 64 containerY, 65 "Character is scrolled to top of container" 66 ); 67 }, 68 { 69 topLevel: true, 70 iframe: true, 71 remoteIframe: true, 72 chrome: true, 73 } 74 );