browser_test_reset_scaling_zoom.js (1533B)
1 add_task(async function setup_pref() { 2 let isWindows = navigator.platform.indexOf("Win") == 0; 3 await SpecialPowers.pushPrefEnv({ 4 set: [["apz.test.fails_with_native_injection", isWindows]], 5 }); 6 }); 7 8 add_task(async function test_main() { 9 function httpURL(filename) { 10 let chromeURL = getRootDirectory(gTestPath) + filename; 11 return chromeURL.replace( 12 "chrome://mochitests/content/", 13 "http://mochi.test:8888/" 14 ); 15 } 16 17 const pageUrl = httpURL("helper_test_reset_scaling_zoom.html"); 18 19 await BrowserTestUtils.withNewTab(pageUrl, async function (browser) { 20 let getResolution = function () { 21 return content.window.SpecialPowers.getDOMWindowUtils( 22 content.window 23 ).getResolution(); 24 }; 25 26 let doZoomIn = async function () { 27 await content.window.wrappedJSObject.doZoomIn(); 28 }; 29 30 let resolution = await ContentTask.spawn(browser, null, getResolution); 31 is(resolution, 1.0, "Initial page resolution should be 1.0"); 32 33 await ContentTask.spawn(browser, null, doZoomIn); 34 resolution = await ContentTask.spawn(browser, null, getResolution); 35 isnot(resolution, 1.0, "Expected resolution to be bigger than 1.0"); 36 37 document.getElementById("cmd_fullZoomReset").doCommand(); 38 // Spin the event loop once just to make sure the message gets through 39 await new Promise(resolve => setTimeout(resolve, 0)); 40 41 resolution = await ContentTask.spawn(browser, null, getResolution); 42 is(resolution, 1.0, "Expected resolution to be reset to 1.0"); 43 }); 44 });