<script>
var n = 125;
function addFrames() {
var parent = document.createElement('iframe');
parent.id = 'theframe';
document.body.appendChild(parent);
for (i = 0; i < n; i++) {
var frame = document.createElement("iframe");
frame.setAttribute("src", "data:text/plain," + i);
frame.style.display = 'none';
parent.contentDocument.body.appendChild(frame);
}
}
function runTest() {
if (window.testRunner)
testRunner.dumpAsText();
// Add n frames.
addFrames();
// Remove the parent frame
var parent = document.getElementById('theframe');
parent.parentNode.removeChild(parent);
// Add n frames again.
addFrames();
var parent = document.getElementById('theframe');
if (parent.contentWindow.frames.length != n)
return;
document.getElementById('result').innerHTML = 'SUCCESS';
}
</script>
<body onload="runTest()">
<div>This tests that frames are properly deregistered with the page's counter when removed. If this test is successful, the text "SUCCESS" will be shown below.</div>
<div id="result">FAILURE</div>
</body>