browser_tooltip_zoom.js (1276B)
1 add_task(async function test_zoom_tooltip() { 2 const TEST_PAGE_URL = 'data:text/html,<html title="tooltiptext">'; 3 await BrowserTestUtils.withNewTab(TEST_PAGE_URL, async function (browser) { 4 FullZoom.setZoom(2.0, browser); 5 6 const tooltip = document.getElementById("remoteBrowserTooltip"); 7 const popupShown = new Promise(resolve => { 8 tooltip.addEventListener("popupshown", resolve, { once: true }); 9 }); 10 11 // Fire a mousemove to trigger the tooltip. 12 // Margin from the anchor and stuff depends on the platform, but these 13 // should be big enough so that all platforms pass, but not big enough so 14 // that it'd pass even when messing up the coordinates would. 15 const DISTANCE = 300; 16 const EPSILON = 25; 17 18 EventUtils.synthesizeMouse(browser, DISTANCE, DISTANCE, { 19 type: "mousemove", 20 }); 21 22 await popupShown; 23 ok( 24 true, 25 `popup should be shown (coords: ${tooltip.screenX}, ${tooltip.screenY})` 26 ); 27 28 isfuzzy( 29 tooltip.screenX, 30 browser.screenX + DISTANCE, 31 EPSILON, 32 "Should be at the right x position, more or less" 33 ); 34 isfuzzy( 35 tooltip.screenY, 36 browser.screenY + DISTANCE, 37 EPSILON, 38 "Should be at the right y position, more or less" 39 ); 40 }); 41 });