Skip to content

Truly independent web browser

4.1 KB
Raw Blame
<!doctype html>
<script src="include.js"></script>
<script src="work-test.js"></script>
<style>
    body { margin: 0; }
    #host { display: flex; width: 100px; }
    #item { display: flex; flex-direction: column; flex: 1 1 auto; }
    table { table-layout: fixed; width: 100%; border-spacing: 0; }
    td { padding: 0; position: relative; }
    td > div { width: 40px; height: 20px; }
    .control { position: absolute; width: 10px; height: 10px; }
</style>
<div id="host"><div id="item"><table id="table"><tbody><tr><td id="cell"><div></div></td><td><div></div></td></tr></tbody></table></div></div>
<script>
    layoutTest({
        steps: [
            {
                name: "adding an out-of-flow control reuses table cell measurements",
                mutate: () => {
                    const control = document.createElement("span");
                    control.className = "control";
                    cell.append(control);
                },
                expect: `
                    layout FULL
                      @viewport/block RUN (cache=bypass)
                        BlockContainer<HTML>/block RUN (cache=miss)
                          Box<DIV>#host/flex RUN (cache=miss)
                            Box<DIV>#item MEASURE max-content inline (cache=miss) FROM FLEX ITEMS
                              TableWrapper(anonymous) MEASURE min-content inline (cache=miss) FROM COLUMNS
                              TableWrapper(anonymous) MEASURE min-content inline (cache=hit)
                              TableWrapper(anonymous) MEASURE max-content inline (cache=hit)
                              TableWrapper(anonymous) MEASURE max-content inline (cache=hit)
                            Box<DIV>#item MEASURE min-content inline (cache=hit)
                            Box<DIV>#item MEASURE max-content block (cache=miss)
                              Box<DIV>#item/flex RUN (cache=miss)
                                TableWrapper(anonymous) MEASURE max-content block (cache=miss)
                                  TableWrapper(anonymous)/block RUN (cache=miss)
                                    Box<TABLE>#table/table RUN (cache=miss)
                                      BlockContainer<TD>#cell/block RUN (cache=miss)
                                        BlockContainer<DIV> REUSE IN-FLOW SUBTREE
                                        BlockContainer<SPAN>.control/block RUN (cache=miss)
                                      BlockContainer<TD>/block REUSE SUBTREE
                                TableWrapper(anonymous) MEASURE max-content block (cache=hit)
                                TableWrapper(anonymous) MEASURE max-content block (cache=hit)
                                TableWrapper(anonymous) MEASURE max-content block (cache=hit)
                                TableWrapper(anonymous)/block RUN (cache=miss)
                                  Box<TABLE>#table/table REPLAY FRAGMENTS
                            Box<DIV>#item/flex RUN (cache=miss)
                              TableWrapper(anonymous) MEASURE max-content block (cache=hit)
                              TableWrapper(anonymous) MEASURE max-content block (cache=hit)
                              TableWrapper(anonymous)/block RUN (cache=miss)
                                Box<TABLE>#table/table REPLAY FRAGMENTS
                `,
                check: equal => {
                    equal(table.getBoundingClientRect().width, 100, "table width");
                    equal(table.getBoundingClientRect().height, 20, "table height");
                    equal(cell.getBoundingClientRect().height, 20, "cell height");
                },
            },
            {
                name: "removing the control preserves table sizing",
                mutate: () => cell.querySelector(".control").remove(),
                // The control was positioned against the cell, so nothing is laid out again when it leaves.
                expect: ``,
                check: equal => {
                    equal(table.getBoundingClientRect().width, 100, "table width");
                    equal(table.getBoundingClientRect().height, 20, "table height");
                },
            },
        ],
    });
</script>