Bootlin logo

Elixir Cross Referencer

<p>This test ensures that document.write after page load is synchronous.</p>
<p>You will get a PASS or FAIL alert message after a few seconds.</p>
window.onload = function() {

    // Build a very long string to write.
    var LIMIT = 17;
    var str = '<p style="display:none">x</p>';
    for (var i=0; i<LIMIT; ++i)
        str += str;

    // Write the string and check the DOM immediately and after a small delay.
    var doc = document.implementation.createHTMLDocument();
    var immediateElementCount = doc.getElementsByTagName('*').length;
    setTimeout(function() {
        var delayedElementCount = doc.getElementsByTagName('*').length;
        var passOrFail = (immediateElementCount === delayedElementCount ? "PASS" : "FAIL");
    }, 100);