chromium/third_party/blink/web_tests/fast/dom/clone-node-style.html

<p>This test checks for a crash that once happened due to cloned nodes copying style
declaration pointers without retaining them.
</p>
<hr>
<p>PASS: You didn't crash.</p>

<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>
<div style="width: 100px;">hello world</div>

<script>
function garbageCollect()
{
    if (window.GCController) {
        GCController.collect();
        return;
    }
    
    for (var i = 0; i < 10000; i++) {
        var o = new Object();
    }
}

if (window.testRunner)
    testRunner.dumpAsText();

// Create an army of clones, removing the originals.

var divs = document.getElementsByTagName('div');
var divClones = new Array();

var div;
while (div = divs[0]) {
    divClones.push(div.cloneNode(false));
    div.parentNode.removeChild(div);
}

// Garbage collect to force destruction of the originals.

garbageCollect();

// Now try setting properties on the clones' style declarations.

for (var i = 0; i < divClones.length; i++) {
    divClones[i].style.width = "100px";
}
</script>