chromium/third_party/blink/web_tests/fast/dom/HTMLTemplateElement/ownerDocument.html

<!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.js"></script>
<script>

description('Test HTMLTemplateElement content ownerDocument');

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>