<!DOCTYPE html>
<html>
<body>
<p>This tests that when nodes are foster-parented after being adopted into another document,
they are adopted back into the ownerDocument of their foster parent. </p>
<table>
<tr>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var doc = document.implementation.createHTMLDocument();
var div = document.createElement('div');
doc.adoptNode(div);
div.appendChild(document.querySelector('table'))
</script>
<div id=fosterChild></div>
</tr>
</table>
<script>
var fosterChild = div.querySelector('#fosterChild');
if (fosterChild.ownerDocument === fosterChild.parentNode.ownerDocument)
document.body.appendChild(document.createTextNode('PASS.'));
</script>
</body>
</html>