Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<script src="work-test.js"></script>
<style>
body { margin: 0; }
#spacer { width: 100px; height: 50px; }
#cached {
width: 300px;
overflow: hidden;
}
#inner { width: 120px; height: 40px; margin-top: 10px; }
#deep { width: 60px; height: 20px; }
</style>
<div id="spacer"></div>
<div id="cached">
<div id="inner">
<div id="deep"></div>
</div>
</div>
<script>
let before;
layoutTest({
steps: [
{
name: "growing a sibling reuses and moves the subtree",
mutate: () => {
before = deep.getBoundingClientRect();
spacer.style.height = "80px";
},
expect: `
layout FULL
@viewport/block RUN (cache=bypass)
BlockContainer<HTML>/block RUN (cache=miss)
BlockContainer<DIV>#cached/block REUSE SUBTREE
`,
check: equal => {
equal(before.left, 0, "deep left before");
equal(before.top, 60, "deep top before");
equal(before.width, 60, "deep width before");
equal(before.height, 20, "deep height before");
const rect = deep.getBoundingClientRect();
equal(rect.left, 0, "deep left");
equal(rect.top, 90, "deep top");
equal(rect.width, 60, "deep width");
equal(rect.height, 20, "deep height");
},
},
],
});
</script>