Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
body { margin: 0; }
#anchor { anchor-name: --a; width: 20px; height: 20px; }
#target { position: absolute; position-anchor: --a; top: anchor(bottom); left: anchor(left); width: 20px; height: 20px; }
.box { position: absolute; top: 100px; width: 100px; height: 100px; }
.clipped { clip-path: inset(2px); }
.lift { transform: translateX(1px); }
#a { left: 0; }
#b { left: 150px; overflow: scroll; }
#b > div { width: 400px; height: 400px; }
#c { left: 300px; }
#d { left: 450px; }
</style>
<div id="anchor"></div>
<div id="target"></div>
<div id="a" class="box clipped lift"></div>
<div id="b" class="box clipped lift"><div></div></div>
<div id="c" class="box clipped lift"></div>
<div id="d" class="box"></div>
<script>
const swap = (from, to, className) => {
from.classList.remove(className);
to.classList.add(className);
};
visualContextTest({
setup: async () => {
internals.forceIncompatibleVisualContextTreeRebuild();
while (internals.frameSchedulerState() !== "idle")
await new Promise(resolve => setTimeout(resolve, 0));
},
steps: [
{
name: "clip swap",
mutate: () => swap(a, d, "clipped"),
expect: `
update DIRTY-PATH
div#a.box.lift clip-path RELEASED
div#d.box.clipped clip-path ALLOCATED
div#d.box.clipped clip-path ALLOCATED
epoch NEW
recording NEEDED
`,
},
{
name: "transform swap",
mutate: () => swap(a, d, "lift"),
expect: `
update DIRTY-PATH
div#a.box transform RELEASED
div#d.box.clipped.lift transform ALLOCATED
div#d.box.clipped.lift clip-path REPURPOSED
div#d.box.clipped.lift clip-path RELEASED
epoch NEW
recording NEEDED
`,
},
// Flipping the viewport's wheel overflow changes the tree inputs, which rebuilds every
// box in place; the swap in the same update must not renumber the untouched boxes.
{
name: "clip swap while every box is rebuilt",
mutate: () => {
swap(d, a, "clipped");
document.documentElement.style.overflow = "hidden";
},
expect: `
update DIRTY-PATH -> EVERY-BOX
div#a.box.clipped clip-path ALLOCATED
div#a.box.clipped clip-path ALLOCATED
div#b.box.clipped.lift clip-path UPDATED
div#b.box.clipped.lift scroll UPDATED
div#c.box.clipped.lift clip-path UPDATED
div#d.box.lift clip-path RELEASED
epoch NEW
recording NEEDED
`,
},
{
name: "transform swap while every box is rebuilt",
mutate: () => {
swap(d, a, "lift");
document.documentElement.style.overflow = "auto";
},
expect: `
update DIRTY-PATH -> EVERY-BOX
div#a.box.clipped.lift transform ALLOCATED
div#a.box.clipped.lift clip-path REPURPOSED
div#a.box.clipped.lift clip-path RELEASED
div#b.box.clipped.lift clip-path UPDATED
div#b.box.clipped.lift scroll UPDATED
div#c.box.clipped.lift clip-path UPDATED
div#d.box transform RELEASED
epoch NEW
recording NEEDED
`,
},
],
});
</script>