Skip to content

Truly independent web browser

2.7 KB
Raw Blame
<!DOCTYPE html>
<script src="include.js"></script>
<script src="work-test.js"></script>
<style>
    body { margin: 0; }
    table { border-spacing: 0; width: 300px; }
    td { padding: 0; font: 20px/20px SerenitySans; }
    #cell { height: 100px; }
    #nested { display: inline-block; width: 80px; }
</style>
<table><tr><td id="cell"><div id="nested">some words that wrap</div></td></tr></table>
<script>
    layoutTest({
        steps: [
            {
                name: "the cell lays out its changed inline-block once",
                mutate: () => {
                    nested.textContent = "other words that wrap";
                },
                expect: `
                    layout FULL
                      @viewport/block RUN (cache=bypass)
                        BlockContainer<HTML>/block RUN (cache=miss)
                          BlockContainer<TD>#cell MEASURE min-content inline (cache=miss) FROM ITEMS
                          TableWrapper(anonymous)/block RUN (cache=miss)
                            Box<TABLE>/table RUN (cache=miss)
                              BlockContainer<TD>#cell MEASURE min-content inline (cache=hit)
                              BlockContainer<TD>#cell/block RUN (cache=miss)
                                BlockContainer<DIV>#nested/block RUN (cache=miss)
                `,
                check: equal => {
                    equal(nested.getBoundingClientRect().width, 80, "nested width");
                },
            },
            {
                name: "the cell reuses its unchanged inline-block from the previous pass",
                mutate: () => {
                    cell.style.height = "120px";
                },
                expect: `
                    layout FULL
                      @viewport/block RUN (cache=bypass)
                        BlockContainer<HTML>/block RUN (cache=miss)
                          BlockContainer<TD>#cell MEASURE min-content inline (cache=miss) FROM ITEMS
                          TableWrapper(anonymous)/block RUN (cache=miss)
                            Box<TABLE>/table RUN (cache=miss)
                              BlockContainer<TD>#cell MEASURE min-content inline (cache=hit)
                              BlockContainer<TD>#cell/block RUN (cache=miss)
                                BlockContainer<DIV>#nested/block REUSE SUBTREE
                `,
                check: equal => {
                    const rect = nested.getBoundingClientRect();
                    equal(rect.width, 80, "nested width");
                    equal(rect.height, 80, "nested height");
                    equal(cell.getBoundingClientRect().height, 120, "cell height");
                },
            },
        ],
    });
</script>