zoom-iframe-os-zoom.html (1696B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>OS zoom doesn't stack on iframes</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <iframe srcdoc="Child frame"></iframe> 7 <script> 8 async function setOSZoom(t, factor, expectResize = true) { 9 let resize = expectResize && new Promise(r => addEventListener("resize", r, { once: true })); 10 await SpecialPowers.pushPrefEnv({ 11 set: [ 12 ["ui.textScaleFactor", factor], 13 ["browser.display.os-zoom-behavior", 1] 14 ] 15 }); 16 await resize; 17 t.add_cleanup(async () => { 18 await SpecialPowers.popPrefEnv(); 19 }); 20 } 21 22 const iframe = document.querySelector("iframe"); 23 24 promise_test(async function(t) { 25 await setOSZoom(t, 100, /* expectResize = */ false); 26 let originalDpi = window.devicePixelRatio; 27 assert_equals(originalDpi, iframe.contentWindow.devicePixelRatio, "DPI should match between frame and parent"); 28 await setOSZoom(t, 200); 29 let newDpi = window.devicePixelRatio; 30 assert_equals(newDpi, originalDpi * 2, "OS zoom should've changed DPI"); 31 assert_equals(newDpi, iframe.contentWindow.devicePixelRatio, "DPI should match between frame and parent"); 32 let frameResized = new Promise(r => { 33 iframe.contentWindow.addEventListener("resize", r, { once: true }); 34 }); 35 iframe.style.zoom = 2; 36 await frameResized; 37 assert_equals(iframe.contentWindow.devicePixelRatio, 2 * newDpi, "DPI should have doubled on the frame"); 38 await setOSZoom(t, 100); 39 assert_equals(window.devicePixelRatio, originalDpi, "DPI should have been restored"); 40 assert_equals(iframe.contentWindow.devicePixelRatio, 2 * originalDpi, "DPI should still be zoomed on the frame"); 41 }); 42 </script>