test_bug1885101_screenwindow_sizes.html (2899B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Tests if +WindowOuterSizeExceptIFrame works properly</title> 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 </head> 8 9 <body> 10 <iframe id="mainFrame"></iframe> 11 12 <template id="mainFrameContents"> 13 <script> 14 window.parent.postMessage( 15 { 16 screen: { 17 height: window.screen.height, 18 width: window.screen.width, 19 availHeight: window.screen.availHeight, 20 availWidth: window.screen.availWidth, 21 }, 22 outerHeight, 23 outerWidth, 24 }, 25 "*" 26 ); 27 </script> 28 </template> 29 30 <script> 31 document.addEventListener("DOMContentLoaded", function () { 32 SimpleTest.waitForExplicitFinish(); 33 34 window.addEventListener("message", e => { 35 const data = e.data; 36 37 // Check for outer size 38 SimpleTest.is( 39 data.outerHeight, 40 window.outerHeight, 41 "iframe's window.outerHeight should be equal to window.top.outerHeight" 42 ); 43 44 SimpleTest.is( 45 data.outerWidth, 46 window.outerWidth, 47 "iframe's window.outerWidth should be equal to window.top.outerWidth" 48 ); 49 50 // Check for screen size 51 SimpleTest.is( 52 data.screen.height, 53 window.screen.height, 54 "iframe's window.screen.height should be equal to window.top.screen.height" 55 ); 56 57 SimpleTest.is( 58 data.screen.width, 59 window.screen.width, 60 "iframe's window.screen.width should be equal to window.top.screen.width" 61 ); 62 63 // Check for avail size 64 SimpleTest.is( 65 data.screen.availHeight, 66 window.screen.availHeight, 67 "iframe's window.screen.availHeight should be equal to window.top.screen.availHeight" 68 ); 69 70 SimpleTest.is( 71 data.screen.availWidth, 72 window.screen.availWidth, 73 "iframe's window.screen.availWidth should be equal to window.top.screen.availWidth" 74 ); 75 76 SimpleTest.finish(); 77 }); 78 79 function setFrameSource() { 80 const frame = document.getElementById("mainFrame"); 81 const template = document.getElementById("mainFrameContents"); 82 frame.srcdoc = template.innerHTML; 83 } 84 85 SpecialPowers.pushPrefEnv( 86 { 87 set: [ 88 ["privacy.fingerprintingProtection", true], 89 [ 90 "privacy.fingerprintingProtection.overrides", 91 "+WindowOuterSize,+ScreenRect,+ScreenAvailRect", 92 ], 93 ], 94 }, 95 () => setFrameSource() 96 ); 97 }); 98 </script> 99 </body> 100 </html>