<script>
	function addFrames() {
	  var parent = document.createElement('iframe');
	  parent.id = 'theframe';
	  document.body.appendChild(parent);
	
	  for (i = 0; i < 150; 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 150 frames. 
		addFrames();

		// Remove the parent frame
		var parent = document.getElementById('theframe');
		parent.parentNode.removeChild(parent);

		// Add 150 frames again.
		addFrames();
		var parent = document.getElementById('theframe');

		if (parent.contentWindow.frames.length != 150)
			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>
