desktop-mode-wide-device.html (2546B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <meta name="viewport" content="initial-scale=1,width=device-width,minimum-scale=1"> 4 <style> 5 html, body { 6 margin: 0; 7 width: 100%; 8 height: 100%; 9 scrollbar-width: none; 10 } 11 div { 12 position: absolute; 13 top: 0; 14 left: 0; 15 /* 16 * The failure mode this test is intended to catch is if the initial 17 * containing block width is incorrectly chosen to be 600px (from the 18 * browser.viewport.desktopWidth=600 in reftest.list), so that the 19 * width of this element becomes 300px, not matching the 400px in the 20 * reference page. 21 */ 22 width: 50%; 23 height: 100px; 24 background: green; 25 } 26 </style> 27 <div></div> 28 <script> 29 async function go() { 30 let win = SpecialPowers.wrap(window); 31 let origVal = await SpecialPowers.spawnChrome([win.browsingContext.id], 32 id => { 33 // We enable 'forceDesktopViewport' (which is otherwise off-by-default) 34 // and we test our rendering under that condition. It's important that we 35 // are followed by reftest "desktop-mode-cleanup.html" which will revert 36 // this change for us, so that forceDesktopViewport doesn't remain on for 37 // subsequent tests. 38 let ctx = BrowsingContext.get(id); 39 let origVal = ctx.forceDesktopViewport; 40 ctx.forceDesktopViewport = true; 41 return origVal; 42 }); 43 44 if (origVal) { 45 // UNEXPECTED: if we get here, then forceDesktopViewport was somehow 46 // true already (when it should be at its default 'false')! Either we've 47 // got the wrong assumption about the default value, or some earlier test 48 // enabled it and forgot to clean up after themselves. 49 // 50 // NOTE: We could signal a test-failure in this circumstance, 51 // by e.g. setting the background to red... 52 // document.body.style.background = "red"; 53 // ...but that also makes this test trivially fail in 'test-verify' runs 54 // per bug 1915025 comment 17 through 19, so let's not do that for now. 55 // So for now, we handle this unexpected condition silently/gracefully. 56 // I'm leaving this (no-op) if-check in the test in case it's useful 57 // for debugging/logging at some point, though. 58 } 59 60 // Force a reflow to make sure the forceDesktopViewport flag is 61 // picked up. 62 document.documentElement.style.display = "none"; 63 document.documentElement.getBoundingClientRect(); 64 document.documentElement.style.display = "block"; 65 document.documentElement.getBoundingClientRect(); 66 67 document.documentElement.classList.remove('reftest-wait'); 68 } 69 70 go(); 71 </script>