Truly independent web browser
<!DOCTYPE html>
<style>
@keyframes slide-in-left {
0% {
display: none;
transform: translateX(-100%);
}
100% {
display: block;
transform: translateX(0);
}
}
dialog.drawer {
position: fixed;
inset: 0;
width: 660px;
height: 100%;
margin: 0;
animation: slide-in-left 100s linear;
animation-play-state: paused;
}
</style>
<div style="display: flex; gap: 24px;">
<button>Produkter</button>
<dialog id="drawer" class="drawer">Drawer contents</dialog>
</div>
<script src="../include.js"></script>
<script>
test(() => {
const drawer = document.getElementById("drawer");
drawer.showModal();
// The animation samples display:none at time zero, so the dialog starts without a box.
// Once display animates to block, its box must be (re)generated even though top layer
// elements lay out as siblings of the root.
const animation = drawer.getAnimations()[0];
animation.currentTime = 0;
const initialRect = drawer.getBoundingClientRect();
if (getComputedStyle(drawer).display !== "none" || initialRect.width > 0 || initialRect.height > 0)
throw new Error("dialog should be boxless at the start of the animation");
animation.currentTime = 1;
const rect = drawer.getBoundingClientRect();
println("modal: " + drawer.matches(":modal"));
println("computed display: " + getComputedStyle(drawer).display);
println("has box: " + (rect.width > 0 && rect.height > 0));
println("width: " + rect.width);
});
</script>