Skip to content

Truly independent web browser

1.2 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<style>
    .item { height: 10px; }
    .item:nth-child(odd) { color: rgb(0, 128, 0); }
</style>
<div id="list"></div>
<div id="text">before</div>
<script>
    // The input a page records before a rendering update lets its style pass fly (inserted elements with inline style,
    // changed text) goes in with the pass, and the style and layout after the frame see all of it.
    asyncTest(async done => {
        const state = await whileRecordingInFlight(() => {
            let html = "";
            for (let i = 0; i < 20; i++)
                html += `<div class="item" style="width: ${i + 1}px">item ${i}</div>`;
            list.innerHTML = html;
            text.firstChild.data = "after";
        }, state => state);
        println(`state in the next task: ${state}`);
        await twoFrames();
        const last = list.lastElementChild;
        println(`items: ${list.children.length}, last: ${last.offsetWidth}x${last.offsetHeight} ${getComputedStyle(last).color}`);
        println(`first: ${getComputedStyle(list.firstElementChild).color}, text: ${text.textContent} ${text.offsetHeight > 0}`);
        done();
    });
</script>