Bootlin logo

Elixir Cross Referencer

<html>
<head>
    <style>
        div.block { height: 100px; border: 1px solid black; margin:10px; }
    </style>
    <script>
        var resizecount = 0;
        var loaded = false;
        window.onresize = function() {
            resizecount++;
            document.getElementById('count1').innerHTML = resizecount;
        }
    </script>
</head>
<body>
    <div>
        Test how many resize events are emitted during page load and dynamic content generation.

        Do not resize the page. It invalidates the test.
        <p style="text-indent: 10px" id=result1>
        Resize events (should be 0 or 1): <span id=count1>0</span>
    </div>
    <div id=expandingblock>
    </div>
    <script>
        var blockcount = 0;
        function addBlock() {
            var el = document.createElement('div');
            el.setAttribute('class','block');
            document.getElementById('expandingblock').appendChild(el);
            if (++blockcount < 30)
                setTimeout(addBlock, 20);
            else
                finish();
        }
        function finish() {
            var result;
            // 0 or 1 resize events are acceptable.
            if (resizecount < 2)
                result = '<p style="color: green">PASS';
            else
                result = '<p style="color: red">FAIL';
            var resultElement = document.getElementById('result1')
            resultElement.innerHTML += result;
        }
        onload = addBlock;
    </script>