blob: e9136bf1db72591f2685b06b682c2a23bf9de452 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<template id="outerTemplate"><template id="innerTemplate"><span>Contents</span></template></template>
<iframe></iframe>
<script src="../../../resources/js-test-pre.js"></script>
<script>
description('Test that template contents are cloned when the template element is imported via importNode');
if (!window.HTMLTemplateElement)
testFailed('This test requires ENABLE(TEMPLATE_ELEMENT)');
var anotherDocument = document.querySelector('iframe').contentDocument;
var outerTemplate = document.getElementById('outerTemplate');
evalAndLog('importedOuterTemplate = anotherDocument.importNode(outerTemplate, true)');
shouldBe('outerTemplate.ownerDocument', 'document');
shouldBe('importedOuterTemplate.ownerDocument', 'anotherDocument');
shouldNotBe('importedOuterTemplate.content', 'outerTemplate.content');
shouldBe('importedOuterTemplate.content.childNodes.length', '1');
evalAndLog('innerTemplate = outerTemplate.content.firstChild');
evalAndLog('importedInnerTemplate = importedOuterTemplate.content.firstChild');
shouldBe('importedInnerTemplate.outerHTML', 'innerTemplate.outerHTML');
shouldNotBe('innerTemplate.ownerDocument', 'importedInnerTemplate.ownerDocument');
shouldNotBe('importedInnerTemplate.content', 'innerTemplate.content');
shouldBe('innerTemplate.content.childNodes.length', '1');
shouldBe('importedInnerTemplate.content.childNodes.length', '1');
shouldBe('innerTemplate.content.firstChild.outerHTML', 'importedInnerTemplate.content.firstChild.outerHTML');
var successfullyParsed = true;
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>