browser_test_zoom_text.js (1788B)
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 async function runTests(browser, accDoc) { 8 const expectedLength = await invokeContentTask(browser, [], () => { 9 const { CommonUtils } = ChromeUtils.importESModule( 10 "chrome://mochitests/content/browser/accessible/tests/browser/Common.sys.mjs" 11 ); 12 const hyperText = CommonUtils.getNode("paragraph", content.document); 13 return Math.floor(hyperText.textContent.length / 2); 14 }); 15 const hyperText = findAccessibleChildByID(accDoc, "paragraph", [ 16 Ci.nsIAccessibleText, 17 ]); 18 const textNode = hyperText.firstChild; 19 20 let [x, y, width, height] = Layout.getBounds( 21 textNode, 22 await getContentDPR(browser) 23 ); 24 25 await testOffsetAtPoint( 26 hyperText, 27 x + width / 2, 28 y + height / 2, 29 COORDTYPE_SCREEN_RELATIVE, 30 expectedLength 31 ); 32 33 await invokeContentTask(browser, [], () => { 34 const { Layout } = ChromeUtils.importESModule( 35 "chrome://mochitests/content/browser/accessible/tests/browser/Layout.sys.mjs" 36 ); 37 38 Layout.zoomDocument(content.document, 2.0); 39 content.document.body.offsetTop; // getBounds doesn't flush layout on its own. 40 }); 41 42 [x, y, width, height] = Layout.getBounds( 43 textNode, 44 await getContentDPR(browser) 45 ); 46 47 await testOffsetAtPoint( 48 hyperText, 49 x + width / 2, 50 y + height / 2, 51 COORDTYPE_SCREEN_RELATIVE, 52 expectedLength 53 ); 54 } 55 56 addAccessibleTask( 57 `<p id="paragraph" style="font-family: monospace;">hello world hello world</p>`, 58 runTests, 59 { 60 iframe: true, 61 remoteIframe: true, 62 iframeAttrs: { style: "width: 600px; height: 600px;" }, 63 } 64 );