<!DOCTYPE html>
<template id="template"><span><template></template></span></template>
<template id="template2"><span></span></template>
<template id="template3"><svg></svg></template>
<script src="../../../resources/js-test-pre.js"></script>
<script>

description('Test HTMLTemplateElement content ownerDocument');

if (!window.HTMLTemplateElement)
    testFailed('This test requires ENABLE(TEMPLATE_ELEMENT)');

var template = document.getElementById('template');
shouldBe('template.ownerDocument', 'document');

var content = template.content;
var df = document.createDocumentFragment();
template.content = df;
shouldBe('template.content', 'content');

var templateContentOwnerDocument = template.content.ownerDocument;
shouldBeTrue('templateContentOwnerDocument instanceof HTMLDocument');
shouldNotBe('document', 'templateContentOwnerDocument');
shouldBe('template.content.firstChild.ownerDocument', 'templateContentOwnerDocument');

var innerTemplate = template.content.firstChild.firstChild;
shouldBe('innerTemplate.ownerDocument', 'templateContentOwnerDocument');
shouldBe('innerTemplate.content.ownerDocument', 'templateContentOwnerDocument');
shouldBeTrue('innerTemplate.ownerDocument instanceof HTMLDocument');

var template2 = document.getElementById('template2');
shouldBe('template2.ownerDocument', 'document');
shouldBe('template2.content.ownerDocument', 'templateContentOwnerDocument');

var template3 = document.getElementById('template3');
shouldBe('template3.ownerDocument', 'document');
shouldBe('template3.content.ownerDocument', 'templateContentOwnerDocument');
shouldBe('template3.content.firstChild.ownerDocument', 'templateContentOwnerDocument');

</script>
<script src="../../../resources/js-test-post.js"></script>
