gecko-dev/layout/reftests/meta-viewport/desktop-mode.html
Daniel Holbert 78b9e93f55 Bug 1915025 part 2: Add reftest 'desktop-mode-cleanup.html' to restore a setting that gets modified in reftest 'desktop-mode.html'. r=hiro
The reftest desktop-mode.html modifies `forceDesktopViewport`, and it needs
that modification to still be in-effect when its reftest snapshot is taken.
However, we also need to undo that modification, to avoid having an impact on
subsequent reftests.  This patch adds a "dummy" reftest to do that cleanup
work, which will now be run immediately after desktop-mode.html.

Differential Revision: https://phabricator.services.mozilla.com/D220495
2024-08-29 05:44:09 +00:00

60 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<style>
html {
height: 100%;
width: 100%;
}
body {
height: 2000px;
width: 200%;
margin: 0px;
padding: 0px;
}
div {
width: 20px;
height: 100%;
top: 0px;
background-color: green;
}
</style>
<div style="right: 0px; position: fixed;"></div>
<div style="right: 25px; position: absolute;"></div>
<script>
async function go() {
let win = SpecialPowers.wrap(window);
let origVal = await SpecialPowers.spawnChrome([win.browsingContext.id],
id => {
// We enable 'forceDesktopViewport' (which is otherwise off-by-default)
// and we test our rendering under that condition. It's important that we
// are followed by reftest "desktop-mode-cleanup.html" which will revert
// this change for us, so that forceDesktopViewport doesn't remain on for
// subsequent tests.
let ctx = BrowsingContext.get(id);
let origVal = ctx.forceDesktopViewport;
ctx.forceDesktopViewport = true;
return origVal;
});
if (origVal) {
// UNEXPECTED: if we get here, then forceDesktopViewport was somehow
// true already (when it should be at its default 'false')! Either we've
// got the wrong assumption about the default value, or some earlier test
// enabled it and forgot to clean up after themselves.
//
// NOTE: We could signal a test-failure in this circumstance,
// by e.g. setting the background to red...
// document.body.style.background = "red";
// ...but that also makes this test trivially fail in 'test-verify' runs
// per bug 1915025 comment 17 through 19, so let's not do that for now.
// So for now, we handle this unexpected condition silently/gracefully.
// I'm leaving this (no-op) if-check in the test in case it's useful
// for debugging/logging at some point, though.
}
document.documentElement.classList.remove('reftest-wait');
}
go();
</script>
</html>