<!DOCTYPE html>
<html>
<body onload="adopt()">
<p>This tests adopting a parent iframe (i.e. the iframe contains the document into which iframe is adopted). WebKit should not hang and should throw a hierarchy request exception.</p>
<div>Adopting parent frame: <span id="child"></span></div>
<div>Adopting grandparent frame: <span id="grandchild"></span></div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function createFrame(id, parent) {
var iframe = document.createElement('iframe');
if (parent)
parent.contentDocument.body.appendChild(iframe);
else
document.body.appendChild(iframe);
iframe.contentDocument.body.appendChild(iframe.contentDocument.createTextNode(id));
iframe.contentDocument.body.appendChild(iframe.contentDocument.createElement('br'));
iframe.style.width = '70%';
iframe.style.height = '40%';
return iframe;
}
var parent = createFrame('parent');
var child = createFrame('child', parent);
var grandchild = createFrame('grandchild', child);
function log(id, message) {
document.getElementById(id).innerHTML = message;
}
function testChild(id, action) {
try {
action();
} catch(error) {
if (error.name == 'HierarchyRequestError')
log(id, 'PASS');
else
log(id, 'FAIL: got ' + error.name + ' but expected HierarchyRequestError');
return;
}
log(id, 'FAIL: no exceptions thrown but expected HierarchyRequestError');
}
function adopt() {
testChild('child', function () { child.contentDocument.adoptNode(parent); });
testChild('grandchild', function () { grandchild.contentDocument.adoptNode(parent); });
}
</script>
</body>
</html>