mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
|
|
@ -0,0 +1,150 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Parsing XHTML: Node's node document</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Parsing XHTML: Node's node document must be set to that of the element to which it will be appended">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#parsing-xhtml-documents">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newXHTMLDocument();
|
||||
doc.body = doc.createElement('body');
|
||||
doc.body.innerHTML = '<template id="tmpl"></template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl');
|
||||
|
||||
assert_not_equals(template, null, 'Template element should not be null');
|
||||
assert_not_equals(template.content, undefined,
|
||||
'Content attribute of template element should not be undefined');
|
||||
assert_not_equals(template.content, null,
|
||||
'Content attribute of template element should not be null');
|
||||
|
||||
assert_equals(template.ownerDocument, doc.body.ownerDocument,
|
||||
'Wrong template node owner document');
|
||||
var ownerDoc = template.content.ownerDocument;
|
||||
assert_not_equals(ownerDoc, doc, 'Wrong template content owner document');
|
||||
assert_not_equals(ownerDoc, document, 'Wrong template content owner document');
|
||||
assert_equals(ownerDoc.defaultView, null,
|
||||
'Template content owner document should not have a browsing context');
|
||||
|
||||
}, 'Parsing XHTML: Node\'s node document must be set to that of the element '
|
||||
+ 'to which it will be appended. Test empty template');
|
||||
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newXHTMLDocument();
|
||||
|
||||
doc.body = doc.createElement('body');
|
||||
doc.body.innerHTML = '<template id="tmpl"><div>Div content</div></template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl');
|
||||
|
||||
assert_equals(template.ownerDocument, doc.body.ownerDocument,
|
||||
'Wrong template node owner document');
|
||||
|
||||
assert_not_equals(template, null, 'Template element should not be null');
|
||||
assert_not_equals(template.content, undefined,
|
||||
'Content attribute of template element should not be undefined');
|
||||
assert_not_equals(template.content, null,
|
||||
'Content attribute of template element should not be null');
|
||||
|
||||
var div = template.content.querySelector('div');
|
||||
assert_equals(template.content.ownerDocument, div.ownerDocument,
|
||||
'Wrong DIV node owner document');
|
||||
|
||||
}, 'Parsing XHTML: Node\'s node document must be set to that of the element '
|
||||
+ 'to which it will be appended. Test not empty template');
|
||||
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newXHTMLDocument();
|
||||
doc.body = doc.createElement('body');
|
||||
doc.body.innerHTML = ''
|
||||
+ '<template id="tmpl"><div>Div content</div> And some more text'
|
||||
+ '<template id="tmpl2"><div>Template content</div></template>'
|
||||
+ '</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl');
|
||||
assert_not_equals(template, null, 'Template element should not be null');
|
||||
assert_equals(template.ownerDocument, doc, 'Wrong template node owner document');
|
||||
assert_not_equals(template.content, undefined,
|
||||
'Content attribute of template element should not be undefined');
|
||||
assert_not_equals(template.content, null,
|
||||
'Content attribute of template element should not be null');
|
||||
|
||||
var nestedTemplate = template.content.querySelector('#tmpl2');
|
||||
assert_not_equals(nestedTemplate, null, 'Nested template element should not be null');
|
||||
assert_not_equals(nestedTemplate.content, undefined,
|
||||
'Content attribute of nested template element should not be undefined');
|
||||
assert_not_equals(nestedTemplate.content, null,
|
||||
'Content attribute of nested template element should not be null');
|
||||
|
||||
assert_equals(nestedTemplate.ownerDocument, template.content.ownerDocument,
|
||||
'Wrong nested template node owner document');
|
||||
|
||||
|
||||
var div = nestedTemplate.content.querySelector('div');
|
||||
assert_equals(nestedTemplate.content.ownerDocument, div.ownerDocument,
|
||||
'Wrong DIV node owner document');
|
||||
|
||||
}, 'Parsing XHTML: Node\'s node document must be set to that of the element '
|
||||
+ 'to which it will be appended. Test nested templates');
|
||||
|
||||
|
||||
|
||||
testInIFrame('../resources/template-child-nodes-div.xhtml', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.ownerDocument, doc, 'Wrong template node owner document');
|
||||
|
||||
assert_not_equals(template.content, undefined,
|
||||
'Content attribute of template element should not be undefined');
|
||||
assert_not_equals(template.content, null,
|
||||
'Content attribute of template element should not be null');
|
||||
|
||||
var div = template.content.querySelector('div');
|
||||
assert_equals(template.content.ownerDocument, div.ownerDocument,
|
||||
'Wrong DIV node owner document');
|
||||
|
||||
}, 'Parsing XHTML: Node\'s node document must be set to that of the element '
|
||||
+ 'to which it will be appended. Test loading XHTML document from a file');
|
||||
|
||||
|
||||
|
||||
testInIFrame('../resources/template-child-nodes-nested.xhtml', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.ownerDocument, doc, 'Wrong template node owner document');
|
||||
|
||||
var nestedTemplate = template.content.querySelector('template');
|
||||
|
||||
assert_equals(nestedTemplate.ownerDocument, template.content.ownerDocument,
|
||||
'Wrong template node owner document');
|
||||
|
||||
var div = nestedTemplate.content.querySelector('div');
|
||||
assert_equals(nestedTemplate.content.ownerDocument, div.ownerDocument,
|
||||
'Wrong DIV node owner document');
|
||||
|
||||
}, 'Parsing XHTML: Node\'s node document must be set to that of the element '
|
||||
+ 'to which it will be appended. Test loading of XHTML document '
|
||||
+ 'with nested templates from a file');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Child nodes of template element in XHTML documents</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Child nodes of template element in XHTML documents are always appended to the template content (instead of template itself)">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#parsing-xhtml-documents">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newXHTMLDocument();
|
||||
|
||||
doc.body = doc.createElement('body');
|
||||
doc.body.innerHTML = '<template id="tmpl1">'
|
||||
+ '<div id="div1">This is div inside template</div>'
|
||||
+ '<div id="div2">This is another div inside template</div>'
|
||||
+ '</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
|
||||
assert_equals(template.childNodes.length, 0,
|
||||
'Wrong number of template child nodes');
|
||||
assert_equals(template.content.childNodes.length, 2,
|
||||
'Wrong number of template content child nodes');
|
||||
|
||||
}, 'Child nodes of template element in XHTML documents must be appended to template content');
|
||||
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newXHTMLDocument();
|
||||
doc.body = doc.createElement('body');
|
||||
doc.body.innerHTML = '<template id="tmpl1">'
|
||||
+ '<div id="div1">This is div inside template</div>'
|
||||
+ '<div id="div2">This is another div inside template</div>'
|
||||
+ '<template id="tmpl2">'
|
||||
+ '<div id="div3">This is div inside nested template</div>'
|
||||
+ '<div id="div4">This is another div inside nested template</div>'
|
||||
+ '</template>' + '</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
|
||||
assert_equals(template.childNodes.length, 0,
|
||||
'Wrong number of template child nodes');
|
||||
assert_equals(template.content.childNodes.length, 3,
|
||||
'Wrong number of template content child nodes');
|
||||
|
||||
var nestedTemplate = template.content.querySelector('#tmpl2');
|
||||
|
||||
assert_equals(nestedTemplate.childNodes.length, 0,
|
||||
'Wrong number of template child nodes');
|
||||
assert_equals(nestedTemplate.content.childNodes.length, 2,
|
||||
'Wrong number of nested template content child nodes');
|
||||
|
||||
}, 'Child nodes of nested template element in XHTML documents must be appended to template content');
|
||||
|
||||
|
||||
|
||||
testInIFrame('../resources/template-child-nodes-div.xhtml', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.childNodes.length, 0,
|
||||
'Wrong number of template child nodes');
|
||||
assert_equals(template.content.querySelectorAll('div').length, 2,
|
||||
'Wrong number of template content child nodes');
|
||||
|
||||
}, 'Child nodes of template element in XHTML documents must be appended to template content. '
|
||||
+ 'Test loading XHTML document from a file');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-child-nodes-nested.xhtml', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.childNodes.length, 0,
|
||||
'Wrong number of template child nodes');
|
||||
|
||||
var nestedTemplate = template.content.querySelector('template');
|
||||
|
||||
assert_equals(nestedTemplate.childNodes.length, 0,
|
||||
'Wrong number of template child nodes');
|
||||
|
||||
assert_equals(nestedTemplate.content.querySelectorAll('div').length, 2,
|
||||
'Wrong number of template content child nodes');
|
||||
|
||||
}, 'Child nodes of nested template element in XHTML documents must be appended to template content. '
|
||||
+ 'Test loading XHTML document from a file');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: serialize template contents instead of template element</title>
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Template contents should be serialized instead of template element if serializing template element in XHTML document">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#serializing-xhtml-documents">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
test(function () {
|
||||
var doc = newXHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
div.innerHTML = 'some text';
|
||||
template.content.appendChild(div);
|
||||
|
||||
assert_equals(template.outerHTML, '<template xmlns="http://www.w3.org/1999/xhtml"><div id="div1">some text</div></template>',
|
||||
'template element is serialized incorrectly');
|
||||
|
||||
}, 'Template contents should be serialized instead of template element if serializing template element');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newXHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var nestedTemplate = doc.createElement('template');
|
||||
|
||||
template.content.appendChild(nestedTemplate);
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
div.innerHTML = 'some text';
|
||||
nestedTemplate.content.appendChild(div);
|
||||
|
||||
assert_equals(template.outerHTML, '<template xmlns="http://www.w3.org/1999/xhtml"><template><div id="div1">some text</div></template></template>',
|
||||
'template element is serialized incorrectly');
|
||||
|
||||
|
||||
}, 'Template contents should be serialized instead of template element if serializing template element. '
|
||||
+ 'Test nested template');
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newXHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
div.innerHTML = 'some text';
|
||||
template.content.appendChild(div);
|
||||
doc.body = doc.createElement('body');
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(doc.documentElement.outerHTML, '<html xmlns="http://www.w3.org/1999/xhtml"><body><template><div id="div1">some text</div></template></body></html>',
|
||||
'template element is serialized incorrectly');
|
||||
|
||||
}, 'Template contents should be serialized instead of template element if serializing template element. '
|
||||
+ 'Test serializing whole document');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Template Reftest Reference</title>
|
||||
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"/>
|
||||
<body>
|
||||
<p>Test passes if there's no anything below this line.</p>
|
||||
</body>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Template Test: check that template content is invisible by default</title>
|
||||
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#css-additions">
|
||||
<meta name="assert" content="Test checks that the template contents are hidden implicitly">
|
||||
<link rel="match" href="css-user-agent-style-sheet-test-001-ref.html">
|
||||
<body>
|
||||
<p>Test passes if there's no anything below this line.</p>
|
||||
<template>
|
||||
<span style="color:red">Test fails if you can see this text</span>
|
||||
</template>
|
||||
</body>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Template Test: check that template content is invisible by default</title>
|
||||
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#css-additions">
|
||||
<meta name="assert" content="The template element itself must be hidden by default">
|
||||
<link rel="match" href="css-user-agent-style-sheet-test-001-ref.html">
|
||||
<body>
|
||||
<p>Test passes if there's no anything below this line.</p>
|
||||
<template style="border: 1px solid; width: 100px; height: 100px">
|
||||
<span style="color:red">Test fails if you can see this text or border around it</span>
|
||||
</template>
|
||||
</body>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<title>HTML Templates: template content is invisible by default</title>
|
||||
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#css-additions">
|
||||
<meta name="assert" content="The template element itself must be hidden by default">
|
||||
<link rel="match" href="css-user-agent-style-sheet-test-001-ref.html">
|
||||
<style>
|
||||
template {
|
||||
border: 1px solid;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<p>Test passes if there's no anything below this line.</p>
|
||||
<template>
|
||||
<span style="color:red">Test fails if you can see this text or border around it</span>
|
||||
</template>
|
||||
</body>
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Clone template node: All the children of template content are copied if 'copy children flag' set to true</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="Clone template node: all the children of template content are copied if 'copy children flag' set to true">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#node-clone-additions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode(true);
|
||||
|
||||
assert_not_equals(copy.content, undefined, 'Template clone content attribute should not be undefined');
|
||||
assert_not_equals(copy.content, null, 'Template clone content attribute should not be null');
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 2,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
assert_not_equals(copy.content.querySelector('#div1'), null,
|
||||
'Template child node should be copied');
|
||||
assert_not_equals(copy.content.querySelector('#div2'), null,
|
||||
'Template child node should be copied');
|
||||
|
||||
}, 'Clone template node. Test call to cloneNode(true)');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode();
|
||||
|
||||
assert_not_equals(copy.content, undefined, 'Template clone content attribute should not be undefined');
|
||||
assert_not_equals(copy.content, null, 'Template clone content attribute should not be null');
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 0,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
|
||||
}, 'Clone template node. Test call to cloneNode() with the default parameter '
|
||||
+ '(false by default)');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode(false);
|
||||
|
||||
assert_not_equals(copy.content, undefined, 'Template clone content attribute is undefined');
|
||||
assert_not_equals(copy.content, null, 'Template clone content attribute is null');
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 0,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
|
||||
}, 'Clone template node. Test call to cloneNode(false)');
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: ownerDocument of cloned template content is set to template content owner</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
|
||||
<meta name="assert" content="ownerDocument of cloned template content is set to template content owner">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#node-clone-additions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
function checkOwnerDocument(node, doc) {
|
||||
if ((node !== null) && (node !== undefined)) {
|
||||
assert_equals(node.ownerDocument, doc,
|
||||
'Wrong ownerDocument of the template copy\'s node ' + node.nodeName);
|
||||
for (var i = 0; i < node.childNodes.length; i++) {
|
||||
if (node.childNodes[i].nodeType === Node.ELEMENT_NODE) {
|
||||
checkOwnerDocument(node.childNodes[i], doc);
|
||||
if (node.childNodes[i].nodeName === 'TEMPLATE') {
|
||||
checkOwnerDocument(node.childNodes[i].content, doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode(true);
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 2,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
checkOwnerDocument(copy.content, template.content.ownerDocument);
|
||||
|
||||
}, 'ownerDocument of cloned template content is set to template content owner. '
|
||||
+ 'Test cloning with children');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode(false);
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 0,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
checkOwnerDocument(copy.content, template.content.ownerDocument);
|
||||
|
||||
}, 'ownerDocument of cloned template content is set to template content owner. '
|
||||
+ 'Test cloning without children');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode();
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 0,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
checkOwnerDocument(copy.content, template.content.ownerDocument);
|
||||
|
||||
}, 'ownerDocument of cloned template content is set to template content owner. '
|
||||
+ 'Test cloneNode() with no arguments (false by default)');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="tmpl1">' +
|
||||
'<div id="div1">This is div inside template</div>' +
|
||||
'<div id="div2">This is another div inside template</div>' +
|
||||
'<template id="tmpl2">' +
|
||||
'<div id="div3">This is div inside nested template</div>' +
|
||||
'<div id="div4">This is another div inside nested template</div>' +
|
||||
'</template>' +
|
||||
'</template>';
|
||||
|
||||
var template = doc.querySelector('#tmpl1');
|
||||
var copy = template.cloneNode(true);
|
||||
|
||||
assert_equals(copy.content.childNodes.length, 3,
|
||||
'Wrong number of template content\'s copy child nodes');
|
||||
checkOwnerDocument(copy.content, template.content.ownerDocument);
|
||||
|
||||
}, 'ownerDocument of cloned template content is set to template content owner. '
|
||||
+ 'Test cloning nested template');
|
||||
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.body.querySelector('template');
|
||||
var copy = template.cloneNode(true);
|
||||
|
||||
checkOwnerDocument(copy.content, template.content.ownerDocument);
|
||||
|
||||
}, 'ownerDocument of cloned template content is set to template content owner. '
|
||||
+ 'Test loading HTML document from file');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: The template contents owner document type is HTML document</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="The template contents owner document type is HTML document, if template is declared in HTML document">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#definitions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
var template = doc.querySelector('template');
|
||||
var content_owner = template.content.ownerDocument;
|
||||
|
||||
assert_class_string(content_owner, 'Document',
|
||||
'Template content owner should be a document');
|
||||
assert_equals(content_owner.createElement('DIV').localName, 'div',
|
||||
'Template content owner should be an HTML document');
|
||||
|
||||
}, 'The template contents owner document type is HTML document ' +
|
||||
'(case when document has browsing context and the template ' +
|
||||
'is created by HTML parser)');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
var template = doc.createElement('template');
|
||||
var content_owner = template.content.ownerDocument;
|
||||
var div = doc.createElement('DIV');
|
||||
template.appendChild(div);
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_class_string(content_owner, 'Document',
|
||||
'Template content owner should be a document');
|
||||
assert_equals(div.localName, 'div',
|
||||
'Template content owner should be an HTML document');
|
||||
|
||||
}, 'The template contents owner document type is HTML document ' +
|
||||
'(case when document has browsing context and the template ' +
|
||||
'is created by createElement())');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var content_owner = template.content.ownerDocument;
|
||||
var div = doc.createElement('DIV');
|
||||
template.appendChild(div);
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_class_string(content_owner, 'Document',
|
||||
'Template content owner should be a document');
|
||||
assert_equals(div.localName, 'div',
|
||||
'Template content owner should be an HTML document');
|
||||
|
||||
}, 'The template contents owner document type is HTML document ' +
|
||||
'(case when document has no browsing context and the template is created ' +
|
||||
'by createElement())');
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template><div>Hello!</div></template>';
|
||||
var template = doc.querySelector('template');
|
||||
var content_owner = template.content.ownerDocument;
|
||||
|
||||
assert_class_string(content_owner, 'Document',
|
||||
'Template content owner should be a document');
|
||||
assert_equals(content_owner.createElement('DIV').localName, 'div',
|
||||
'Template content owner should be an HTML document');
|
||||
|
||||
}, 'The template contents owner document type is HTML document ' +
|
||||
'(case when document has no browsing context and the template is created via innerHTML)');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: The template contents owner document (no browsing context)</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="Even if template's enclosing document has no browsing context, it gets its own template contents owner">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#definitions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_not_equals(template.content.ownerDocument, doc, 'Wrong template content owner');
|
||||
|
||||
}, 'Test the template contents owner document when enclosing document has '
|
||||
+ 'no browsing content. Template element is created by createElement()');
|
||||
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
|
||||
doc.body.innerHTML = '<template><div>some text</div></template>';
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_not_equals(template.content.ownerDocument, doc, 'Wrong template content owner');
|
||||
|
||||
}, 'Test the template contents owner document when enclosing document has '
|
||||
+ 'no browsing content. Template element is created by innerHTML');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: The template contents owner document (there's browsing context)</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="If template's enclosing document has browsing context, then templates content owner must be a new Document node without browsing context">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#definitions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
testInIFrame(null, function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
var template = doc.createElement('template');
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
|
||||
template.appendChild(div);
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
// doc has browsing context. There should be another document as a template
|
||||
// content owner
|
||||
assert_not_equals(template.content.ownerDocument, doc, 'Wrong template owner document');
|
||||
|
||||
}, 'The template contents owner document must be different from template owner document,' +
|
||||
' which has browsing context. Template element is created by createElement()');
|
||||
|
||||
|
||||
|
||||
testInIFrame(null, function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
doc.body.innerHTML = '<template><div>some text</div></template>';
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
// doc has browsing context. There should be another document as a template
|
||||
// content owner
|
||||
assert_not_equals(template.content.ownerDocument, doc, 'Wrong template owner document');
|
||||
|
||||
}, 'The template contents owner document must be different from template owner document,' +
|
||||
' which has browsing context. Template element is created via innerHTML');
|
||||
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
// doc has browsing context. There should be another document as a template
|
||||
// content owner
|
||||
assert_not_equals(template.content.ownerDocument, doc, 'Wrong template owner document');
|
||||
|
||||
}, 'The template contents owner document must be different from template owner document,' +
|
||||
' which has browsing context. Template element is created by HTML parser');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: The template contents is a DocumentFragment</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="assert" content="The template contents must be a DocumentFragment">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#definitions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a DocumentFragment');
|
||||
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (empty template)');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
template.innerHTML = '<div>This is a div</div><span>This is a span</span>';
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a DocumentFragment');
|
||||
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (non empty template)');
|
||||
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
template.innerHTML = '<div>This is a div</div>';
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (non empty template '
|
||||
+ 'containing div which is an Element instance)');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
template.innerHTML = 'Some text';
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (not empty template '
|
||||
+ 'containing text node)');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
template.innerHTML = '<template id="t2">Some text</template>';
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
var nestedTemplate = template.content.querySelector("#t2");
|
||||
assert_equals(nestedTemplate.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Nested template content should be a documentFragment');
|
||||
|
||||
assert_class_string(nestedTemplate.content, 'DocumentFragment',
|
||||
'Nested template content class should be a DocumentFragment');
|
||||
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (nested template '
|
||||
+ 'containing a text node)');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents-empty.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (the empty template tag '
|
||||
+ 'inside HTML file loaded in iframe)');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (non empty template '
|
||||
+ 'tag inside HTML file loaded in iframe)');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents-text.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (the template tag '
|
||||
+ 'with some text inside HTML file loaded in iframe)');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents-nested.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_equals(template.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Template content should be a documentFragment');
|
||||
assert_class_string(template.content, 'DocumentFragment',
|
||||
'Template content class should be a DocumentFragment');
|
||||
|
||||
var nestedTemplate = template.content.querySelector("template");
|
||||
|
||||
assert_equals(nestedTemplate.content.nodeType, Node.DOCUMENT_FRAGMENT_NODE,
|
||||
'Nested template content should be a documentFragment');
|
||||
assert_class_string(nestedTemplate.content, 'DocumentFragment',
|
||||
'Nested template content class should be a DocumentFragment');
|
||||
|
||||
}, 'The template contents must be a DocumentFragment (the template tag '
|
||||
+ 'with nested template tag inside HTML file loaded in iframe)');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: innerHTML of template element replaces all referenced by the content attribute</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
|
||||
<meta name="assert" content="innerHTML of template element replaces all referenced by the content attribute">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#innerhtml-on-templates">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
var div1 = doc.createElement('div');
|
||||
div1.setAttribute('id', 'div1');
|
||||
template.content.appendChild(div1);
|
||||
|
||||
assert_not_equals(template.content.querySelector('#div1'), null,
|
||||
'Element should present in template content');
|
||||
|
||||
template.innerHTML = '<div id="div2"></div>';
|
||||
|
||||
assert_equals(template.content.querySelector('#div1'), null,
|
||||
'Template content should be replaced by innerHTML');
|
||||
assert_not_equals(template.content.querySelector('#div2'), null,
|
||||
'Element should present in template content');
|
||||
|
||||
}, 'innerHTML of template element replaces all referenced by the content attribute');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var nestedTemplate = doc.createElement('template');
|
||||
|
||||
template.content.appendChild(nestedTemplate);
|
||||
|
||||
var div1 = doc.createElement('div');
|
||||
div1.setAttribute('id', 'div1');
|
||||
nestedTemplate.content.appendChild(div1);
|
||||
|
||||
assert_not_equals(nestedTemplate.content.querySelector('#div1'), null,
|
||||
'Element should present in template content');
|
||||
|
||||
nestedTemplate.innerHTML = '<div id="div2"></div>';
|
||||
|
||||
assert_equals(nestedTemplate.content.querySelector('#div1'), null,
|
||||
'Template content should be replaced by innerHTML');
|
||||
assert_not_equals(nestedTemplate.content.querySelector('#div2'), null,
|
||||
'Element should present in template content');
|
||||
|
||||
}, 'innerHTML of template element replaces all referenced by the content attribute. '
|
||||
+ 'Test nested template');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
assert_not_equals(template.content.querySelector('div'), null,
|
||||
'Div element should present in template content');
|
||||
|
||||
template.innerHTML = '<span>span internals</span>';
|
||||
|
||||
assert_equals(template.content.querySelector('div'), null,
|
||||
'div element should be replaced by span in template content');
|
||||
|
||||
assert_not_equals(template.content.querySelector('span'), null,
|
||||
'span element should present in template content');
|
||||
|
||||
|
||||
}, 'innerHTML of template element replaces all referenced by the content attribute. '
|
||||
+ 'Test loading of HTML document from a file');
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The file contains several </template> tag in HTML body without start one</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
</template>
|
||||
<div>The file contains several </template> tag in HTML body without start one</div>
|
||||
</template></template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
</template>
|
||||
<title>The file contains several </template> tag in HTML head without start one</title>
|
||||
</template></template>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</template>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The file contains frameset with the template and frameset end tag in it</title>
|
||||
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
</head>
|
||||
<frameset>
|
||||
<template></frameset></template>
|
||||
</frameset>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The file contains template element with open div tag, but without end div tag, in the head</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<template>
|
||||
<div>Hello, template
|
||||
</template>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The file contains template element with open table, tr, td tags, but without end td, tr, table tags, in the head</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<template>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Hello, cell one!
|
||||
</template>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html tabindex="5">
|
||||
<head>
|
||||
<title>The file contains html root element with attributes and some in the body</title>
|
||||
<link rel="author" title="Sergey G. Grekhovv" href="mailto:sgrekhov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template id="tmpl"><html class="htmlClass"></html></template><html id="htmlId" tabindex="5">
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Template tag with children div tags inside</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/>
|
||||
</head>
|
||||
<body>
|
||||
<p>Template tag with div tags inside</p>
|
||||
<template>
|
||||
<div>This is div inside template</div>
|
||||
<div>This is another div inside template</div>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Template tag with children div tags inside another template tag</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/>
|
||||
</head>
|
||||
<body>
|
||||
<p>Template tag with children div tags inside another template tag</p>
|
||||
<template>
|
||||
<template>
|
||||
<div>This is div inside template</div>
|
||||
<div>This is another div inside template</div>
|
||||
</template>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Empty template tag with attribute content</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<head>
|
||||
<body>
|
||||
<template content='some text'></template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>BODY tag inside template</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<head>
|
||||
<body>
|
||||
<template><body></body></template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Div tag inside template tag</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template>
|
||||
<div>Hello, template
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Empty template tag</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<head>
|
||||
<body>
|
||||
<template>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>FRAMESET tag inside template</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<head>
|
||||
<body>
|
||||
<template><frameset></frameset></template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HEAD tag inside template</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<head>
|
||||
<body>
|
||||
<template><head></head></template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML tag inside template</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<head>
|
||||
<body>
|
||||
<template><html></html></template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Contains second template tag inside template tag</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<body>
|
||||
<template>
|
||||
<template>
|
||||
<div>Inside nested template</div>
|
||||
</template>
|
||||
</template>
|
||||
</body>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The file contains template element with open table, tr, td tags, without end td, tr, table tags</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Hello, cell one!
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Some text inside template tag</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template>Some text</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Div tag inside template tag</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template>
|
||||
<div>Hello, template</div>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Div tag inside template tag</title>
|
||||
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template>
|
||||
<div>Hello, template</div>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Template tag inside frameset</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<frameset>
|
||||
<template>
|
||||
<div>Hello, template</div>
|
||||
</template>
|
||||
</frameset>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Template tag inside head</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<template>
|
||||
<div>Hello, template</div>
|
||||
</template>
|
||||
</head>
|
||||
<body>
|
||||
Nothing interesting here
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The file contains two template elements</title>
|
||||
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
</head>
|
||||
<body>
|
||||
<template id="template1">
|
||||
<div>Hello, template</div>
|
||||
</template>
|
||||
|
||||
<template id="template2">
|
||||
<div>Hello, from second template</div>
|
||||
</template>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: serialize template contents instead of template element</title>
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
|
||||
<meta name="assert" content="template contents should be serialized instead of template element if serializing template element">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#serializing-html-templates">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
div.innerHTML = 'some text';
|
||||
template.content.appendChild(div);
|
||||
|
||||
assert_equals(template.outerHTML, '<template><div id="div1">some text</div></template>',
|
||||
'template element is serialized incorrectly');
|
||||
|
||||
}, 'Template contents should be serialized instead of template element if serializing template element');
|
||||
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var nestedTemplate = doc.createElement('template');
|
||||
|
||||
template.content.appendChild(nestedTemplate);
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
div.innerHTML = 'some text';
|
||||
nestedTemplate.content.appendChild(div);
|
||||
|
||||
assert_equals(template.outerHTML, '<template><template><div id="div1">some text</div></template></template>',
|
||||
'template element is serialized incorrectly');
|
||||
|
||||
|
||||
}, 'Template contents should be serialized instead of template element if serializing template element. '
|
||||
+ 'Test nested template');
|
||||
|
||||
|
||||
test(function () {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
var div = doc.createElement('div');
|
||||
div.setAttribute('id', 'div1');
|
||||
div.innerHTML = 'some text';
|
||||
template.content.appendChild(div);
|
||||
doc.body.appendChild(template);
|
||||
|
||||
assert_equals(doc.documentElement.outerHTML, '<html><head><title>Test Document</title></head><body><template><div id="div1">some text</div></template></body></html>',
|
||||
'template element is serialized incorrectly');
|
||||
|
||||
}, 'Template contents should be serialized instead of template element if serializing template element. '
|
||||
+ 'Test serializing whole document');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Content attribute of template element is read-only</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Content attribute of template element is read-only">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. ' +
|
||||
'Test empty template');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var el1 = doc.createElement('div');
|
||||
var el2 = doc.createElement('span');
|
||||
el1.appendChild(el2);
|
||||
|
||||
template.content.appendChild(el1);
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. ' +
|
||||
'Test not empty template populated by appendchild()');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template>Text<div>DIV</div></template>';
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. ' +
|
||||
'Test not empty template populated by innerHTML');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="template1" content="Some text as a content"></template>';
|
||||
|
||||
var template = doc.querySelector('#template1');
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. ' +
|
||||
'Test that custom content attribute named \'content\' doesn\'t ' +
|
||||
'make content IDL attribute writable');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template id="template1" content="<div id=div1>Div content</div>"></template>';
|
||||
|
||||
var template = doc.querySelector('#template1');
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
assert_equals(template.content.childNodes.length, 0,
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. ' +
|
||||
'Test that custom content attribute named \'content\' doesn\'t ' +
|
||||
'affect content IDL attribute');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents-attribute.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.body.querySelector('template');
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. '
|
||||
+ 'Text value of content attribute of template tag should be ignored, '
|
||||
+ 'when loading document from a file');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc.body.querySelector('template');
|
||||
|
||||
assert_readonly(template, 'content',
|
||||
'Content attribute of template element should be read-only');
|
||||
|
||||
}, 'Content attribute of template element is read-only. '
|
||||
+ 'Test content attribute of a document loaded from a file');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: When node's document changes its owner document should be changed</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="When a template element's node document changes, the template element's content DocumentFragment must be adopted into the new node document's template contents owner document">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc1 = newHTMLDocument();
|
||||
var template = doc1.createElement('template');
|
||||
|
||||
assert_equals(template.ownerDocument, doc1, 'Wrong template node owner document');
|
||||
assert_not_equals(template.content.ownerDocument, doc1,
|
||||
'Wrong template content owner document');
|
||||
|
||||
var doc2 = newHTMLDocument();
|
||||
var template2 = doc2.createElement('template');
|
||||
doc2.body.appendChild(template);
|
||||
|
||||
assert_equals(template.ownerDocument, template2.ownerDocument,
|
||||
'Template node owner document should be changed');
|
||||
assert_equals(template.content.ownerDocument, template2.content.ownerDocument,
|
||||
'Template content owner document should be changed');
|
||||
|
||||
}, 'Changing of template element\'s node document. ' +
|
||||
'Test that ownerDocument of an empty template and its content changes');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc1 = newHTMLDocument();
|
||||
doc1.body.innerHTML = '<template id="tmpl"><div>Div content</div> And some more text</template>';
|
||||
|
||||
var template = doc1.querySelector('#tmpl');
|
||||
|
||||
assert_equals(template.ownerDocument, doc1,
|
||||
'Wrong template node owner document');
|
||||
assert_not_equals(template.content.ownerDocument, doc1,
|
||||
'Wrong template content owner document');
|
||||
|
||||
var doc2 = newHTMLDocument();
|
||||
var template2 = doc2.createElement('template');
|
||||
doc2.body.appendChild(template);
|
||||
|
||||
assert_equals(template.ownerDocument, template2.ownerDocument,
|
||||
'Template node owner document should be changed');
|
||||
assert_equals(template.content.ownerDocument, template2.content.ownerDocument,
|
||||
'Template content owner document should be changed');
|
||||
|
||||
assert_equals(template.content.querySelector('div').ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Template content descendants owner document should be changed');
|
||||
|
||||
}, 'Changing of template element\'s node document. ' +
|
||||
'Test that ownerDocument of a not empty template and its content changes');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc1 = newHTMLDocument();
|
||||
doc1.body.innerHTML = ''
|
||||
+ '<template id="tmpl"><div>Div content</div> And some more text'
|
||||
+ '<template id="tmpl2"><div>Template content</div></template>'
|
||||
+ '</template>';
|
||||
|
||||
var template = doc1.querySelector('#tmpl');
|
||||
|
||||
assert_equals(template.ownerDocument, doc1, 'Wrong template node owner document');
|
||||
assert_not_equals(template.content.ownerDocument, doc1,
|
||||
'Wrong template content owner document');
|
||||
|
||||
var nestedTemplate = template.content.querySelector('#tmpl2');
|
||||
|
||||
assert_equals(nestedTemplate.ownerDocument, template.content.ownerDocument,
|
||||
'Wrong nested template node owner document');
|
||||
assert_equals(nestedTemplate.content.ownerDocument, template.content.ownerDocument,
|
||||
'Wrong nested template content owner document');
|
||||
|
||||
var doc2 = newHTMLDocument();
|
||||
var template2 = doc2.createElement('template');
|
||||
doc2.body.appendChild(template);
|
||||
|
||||
assert_equals(template.ownerDocument, template2.ownerDocument,
|
||||
'Template node owner document should be changed');
|
||||
assert_equals(template.content.ownerDocument, template2.content.ownerDocument,
|
||||
'Template content owner document should be changed');
|
||||
assert_equals(template.content.querySelector('div').ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Template content descendants owner document should be changed');
|
||||
|
||||
assert_equals(nestedTemplate.ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Nested template node owner document should be changed');
|
||||
assert_equals(nestedTemplate.content.ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Nested template content owner document should be changed');
|
||||
assert_equals(nestedTemplate.content.querySelector('div').ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Owner document of the nested template content descendants should be changed');
|
||||
|
||||
}, 'Changing of template element\'s node document. ' +
|
||||
'Test that ownerDocument of nested template and its content changes');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc1 = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc1.body.querySelector('template');
|
||||
|
||||
var doc2 = newHTMLDocument();
|
||||
var template2 = doc2.createElement('template');
|
||||
doc2.body.appendChild(template);
|
||||
|
||||
assert_equals(template.ownerDocument, template2.ownerDocument,
|
||||
'Template node owner document should be changed');
|
||||
assert_equals(template.content.ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Template content owner document should be changed');
|
||||
assert_equals(template.content.querySelector('div').ownerDocument,
|
||||
template2.content.ownerDocument,
|
||||
'Template content descendants owner document should be changed');
|
||||
|
||||
}, 'Changing of template element\'s node document. ' +
|
||||
'Test document loaded from a file');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc1 = context.iframes[0].contentDocument;
|
||||
|
||||
var doc2 = newHTMLDocument();
|
||||
var template = doc2.createElement('template');
|
||||
var div = doc2.createElement('div');
|
||||
template.content.appendChild(div);
|
||||
|
||||
doc1.body.appendChild(template);
|
||||
|
||||
assert_not_equals(template.ownerDocument, doc2,
|
||||
'Template node owner document should be changed');
|
||||
assert_not_equals(template.content.ownerDocument, doc2,
|
||||
'Template content owner document should be changed');
|
||||
assert_not_equals(div.ownerDocument, doc2,
|
||||
'Template content descendants owner document should be changed');
|
||||
|
||||
assert_equals(template.ownerDocument, doc1,
|
||||
'Template node owner document should be changed');
|
||||
// doc1 has browsing context so it cannot be template.content.ownerDocument
|
||||
assert_not_equals(template.content.ownerDocument, doc1,
|
||||
'Template content owner document should be a new document');
|
||||
assert_equals(div.ownerDocument, template.content.ownerDocument,
|
||||
'Template content descendants owner document should be ' +
|
||||
'template content document owner');
|
||||
|
||||
}, 'Changing of template element\'s node document. ' +
|
||||
'Adobt template element into a document that has a browsing context');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(context) {
|
||||
var doc1 = context.iframes[0].contentDocument;
|
||||
|
||||
var template = doc1.querySelector('template');
|
||||
var div = template.content.querySelector('div');
|
||||
var templateContentOwner = template.content.ownerDocument;
|
||||
|
||||
var doc2 = document;
|
||||
|
||||
doc2.body.appendChild(template);
|
||||
|
||||
|
||||
assert_not_equals(template.ownerDocument, doc1,
|
||||
'Template node owner document should be changed');
|
||||
assert_not_equals(template.content.ownerDocument, templateContentOwner,
|
||||
'Template content owner document should be changed');
|
||||
assert_not_equals(div.ownerDocument, templateContentOwner,
|
||||
'Template content descendants owner document should be changed');
|
||||
|
||||
assert_equals(template.ownerDocument, doc2,
|
||||
'Template node owner document should be changed');
|
||||
// doc2 has browsing context, so it cannot be template.content.ownerDocument
|
||||
assert_not_equals(template.content.ownerDocument, doc2,
|
||||
'Template content owner document should be a new document');
|
||||
assert_equals(div.ownerDocument, template.content.ownerDocument,
|
||||
'Template content descendants owner document should be ' +
|
||||
'template content document owner');
|
||||
|
||||
}, 'Changing of template element\'s node document. ' +
|
||||
'Test the case when both old and new owner documents of template element ' +
|
||||
'have browsing context');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Template element as a descendant of the body element.</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Template element can be a descendant of the body element">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
function templateIsAChild(element) {
|
||||
element.innerHTML = '<template>some text</template>';
|
||||
|
||||
assert_not_equals(element.querySelector('template'), null,
|
||||
'Template element should be a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsDisallowedAsAChild(element) {
|
||||
element.innerHTML = '<template>some text</template>';
|
||||
|
||||
assert_equals(element.querySelector('template'), null,
|
||||
'Template element should not be allowed as a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsAnIndirectChild(element) {
|
||||
element.innerHTML = '<div><template>some text</template></div>';
|
||||
|
||||
assert_not_equals(element.querySelector('template'), null,
|
||||
'Template element should be a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsDisallowedAsAnIndirectChild(element) {
|
||||
element.innerHTML = '<div><template>some text</template></div>';
|
||||
|
||||
assert_equals(element.querySelector('template'), null,
|
||||
'Template element should not be allowed as indirect descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsAnAppendedChild(doc, element) {
|
||||
var template = doc.createElement('template');
|
||||
|
||||
element.appendChild(template);
|
||||
|
||||
assert_not_equals(element.querySelector('template'), null,
|
||||
'Template element should be a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsAnAppendedIndirectChild(doc, element) {
|
||||
var template = doc.createElement('template');
|
||||
var div = doc.createElement('div');
|
||||
div.appendChild(template);
|
||||
|
||||
element.appendChild(div);
|
||||
|
||||
assert_not_equals(element.querySelector('template'), null,
|
||||
'Template element should be a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
var doc = newHTMLDocument();
|
||||
var frameset = doc.createElement('frameset');
|
||||
|
||||
var parameters = [['Template element as a descendant of the BODY element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
doc.body],
|
||||
['Template element as a descendant of the HEAD element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
doc.head],
|
||||
];
|
||||
generate_tests(templateIsAChild, parameters,
|
||||
'Template element as a descendant of the HEAD and BODY elements');
|
||||
|
||||
parameters = [['Template element as a descendant of the FRAMESET element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
frameset],
|
||||
];
|
||||
generate_tests(templateIsDisallowedAsAChild, parameters,
|
||||
'Template element should be disallowed as a descendant of the FRAMESET elements');
|
||||
|
||||
|
||||
parameters = [['Template element as an indirect descendant of the BODY element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
doc.body],
|
||||
['Template element as an indirect descendant of the HEAD element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
doc.head],
|
||||
];
|
||||
generate_tests(templateIsAnIndirectChild, parameters,
|
||||
'Template element as an indirect descendant of the HEAD, BODY and FRAMESET elements');
|
||||
|
||||
parameters = [['Template element as a descendant of the FRAMESET element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
frameset],
|
||||
];
|
||||
generate_tests(templateIsDisallowedAsAnIndirectChild, parameters,
|
||||
'Template element should be disallowed as an indirect descendant of the FRAMESET elements');
|
||||
|
||||
|
||||
|
||||
parameters = [['Template element as a descendant of the BODY element. ' +
|
||||
'Template element is appended by appendChild()',
|
||||
doc, doc.body],
|
||||
['Template element as a descendant of the HEAD element. ' +
|
||||
'Template element is appended by appendChild()',
|
||||
doc, doc.head],
|
||||
['Template element as a descendant of the FRAMESET element. ' +
|
||||
'Template element is appended by appendChild()',
|
||||
doc, frameset]
|
||||
];
|
||||
generate_tests(templateIsAnAppendedChild, parameters,
|
||||
'Template element as a descendant of the HEAD, BODY and FRAMESET elements');
|
||||
|
||||
|
||||
|
||||
parameters = [['Template element as an indirect descendant of the BODY element. ' +
|
||||
'Template element is appended by appendChild()',
|
||||
doc, doc.body],
|
||||
['Template element as an indirect descendant of the HEAD element. ' +
|
||||
'Template element is appended by appendChild()',
|
||||
doc, doc.head],
|
||||
['Template element as an indirect descendant of the FRAMESET element. ' +
|
||||
'Template element is appended by appendChild()',
|
||||
doc, frameset]
|
||||
];
|
||||
generate_tests(templateIsAnAppendedIndirectChild, parameters,
|
||||
'Template element as a descendant of the HEAD, BODY and FRAMESET elements');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Node document of the template content attribute must be template contents owner</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Node document of the template content attribute must be template contents owner">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var nestedTemplate = doc.createElement('template');
|
||||
template.appendChild(nestedTemplate);
|
||||
|
||||
assert_equals(nestedTemplate.content.ownerDocument, template.content.ownerDocument,
|
||||
'Wrong node document of the template content attribute');
|
||||
|
||||
}, 'Node document of the template content attribute must be template contents owner. ' +
|
||||
'Nested template element created by createElement');
|
||||
|
||||
|
||||
test(function() {
|
||||
var doc = newHTMLDocument();
|
||||
doc.body.innerHTML = '<template><template></template></template>';
|
||||
var template = doc.querySelector('template');
|
||||
var nestedTemplate = template.content.querySelector('template');
|
||||
|
||||
assert_equals(nestedTemplate.content.ownerDocument, template.content.ownerDocument,
|
||||
'Wrong node document of the template content attribute');
|
||||
|
||||
}, 'Node document of the template content attribute must be template contents owner. ' +
|
||||
'Nested template element created by innerHTML');
|
||||
|
||||
testInIFrame('../resources/two-templates.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var template1 = doc.querySelector('#template1');
|
||||
var template2 = doc.querySelector('#template2');
|
||||
|
||||
// when there is a browsing context, template contents owner is only accessible via template.content.ownerDocument
|
||||
// because template contents owner is bounded to document
|
||||
// verify that multiple templates share the same instance of template contents owner
|
||||
|
||||
assert_equals(template1.content.ownerDocument, template2.content.ownerDocument,
|
||||
'Wrong node document of the template content attribute');
|
||||
}, 'Node document of the template content attribute must be template contents owner. ' +
|
||||
'Load HTML file with multiple template elements');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: HTML elements in template content</title>
|
||||
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Template may contain any element, except the html element, the head element, the body element, or the frameset element">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
var parameters = [];
|
||||
|
||||
HTML5_ELEMENTS.forEach(function(value) {
|
||||
if (value !== 'body' && value !== 'html' && value !== 'head' && value !== 'frameset') {
|
||||
|
||||
var doc = newHTMLDocument();
|
||||
var template = doc.createElement('template');
|
||||
var element = doc.createElement(value);
|
||||
template.content.appendChild(element);
|
||||
var valueToTest = template.content.querySelector(value);
|
||||
|
||||
doc.body.appendChild(template);
|
||||
|
||||
parameters.push([
|
||||
'Template may contain ' + value + ' element',
|
||||
valueToTest,
|
||||
null
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
generate_tests(assert_not_equals, parameters,
|
||||
'Template may contain any element, except the html element, '
|
||||
+ 'the head element, the body element, or the frameset element');
|
||||
|
||||
|
||||
|
||||
|
||||
var parameters = [];
|
||||
|
||||
HTML5_ELEMENTS.forEach(function(value) {
|
||||
if (value !== 'body' && value !== 'html' && value !== 'head' && value !== 'frameset') {
|
||||
|
||||
var doc = newHTMLDocument();
|
||||
|
||||
if (isVoidElement(value)) {
|
||||
doc.body.innerHTML = '<template><' + value + '/></template>';
|
||||
} else {
|
||||
doc.body.innerHTML = '<template><' + value + '></' + value + '></template>';
|
||||
}
|
||||
|
||||
var template = doc.querySelector('template');
|
||||
var element = template.content.querySelector(value);
|
||||
|
||||
parameters.push([
|
||||
'Template may contain ' + value + ' element. '
|
||||
+'The template element and contents are added via body.innerHTML',
|
||||
element,
|
||||
null
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
generate_tests(assert_not_equals, parameters,
|
||||
'Template may contain any element, except the html element, '
|
||||
+ 'the head element, the body element, or the frameset element. '
|
||||
+'The template element and contents are added via body.innerHTML');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Template element as a descendant of the body element.</title>
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Template element can be a descendant of the body element">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
testInIFrame('../resources/template-contents.html', function(ctx) {
|
||||
var doc = ctx.iframes[0].contentDocument;
|
||||
|
||||
assert_not_equals(doc.body.querySelector('template'), null,
|
||||
'Template element should be a descendant of the body element');
|
||||
|
||||
}, 'Template element as a descendant of the body element. Test loading from a file');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Template element as a descendant of the frameset element.</title>
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Template element can not be a descendant of the frameset element">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#parsing-main-inframeset">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
testInIFrame('../resources/template-descendant-frameset.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var frameset = doc.querySelector('frameset');
|
||||
|
||||
assert_equals(frameset.querySelector('template'), null,
|
||||
'Template element should not be a descendant of the frameset element');
|
||||
|
||||
}, 'Template element as a descendant of the frameset element. Test loading from a file');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-descendant-frameset.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var frameset = doc.querySelector('frameset');
|
||||
|
||||
frameset.innerHTML = '';
|
||||
assert_equals(doc.querySelector('template'), null,
|
||||
'Initial conditions are not satisfied');
|
||||
|
||||
frameset.innerHTML = '<template>some text</template>';
|
||||
|
||||
assert_equals(frameset.querySelector('template'), null,
|
||||
'Template element should not be a descendant of the frameset element');
|
||||
|
||||
}, 'Template element as a descendant of the frameset element. '
|
||||
+ 'Test template element is assigned to frameset\'s innerHTML)');
|
||||
|
||||
|
||||
testInIFrame('../resources/template-descendant-frameset.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
var frameset = doc.querySelector('frameset');
|
||||
|
||||
var template = doc.createElement('template');
|
||||
frameset.appendChild(template);
|
||||
|
||||
assert_equals(frameset.querySelectorAll('template').length, 1,
|
||||
'Template element should be a descendant of the frameset element');
|
||||
|
||||
}, 'Template element as a descendant of the frameset element. '
|
||||
+ 'Test template element appended to frameset by appendChild()');
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Templates: Template element as a descendant of the head element.</title>
|
||||
<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
|
||||
<meta name="assert" content="Template element can be a descendant of the head element">
|
||||
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-element">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src='/html/resources/common.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<script type="text/javascript">
|
||||
|
||||
testInIFrame('../resources/template-descendant-head.html', function(context) {
|
||||
var doc = context.iframes[0].contentDocument;
|
||||
|
||||
assert_not_equals(doc.head.querySelector('template'), null,
|
||||
'Template element should be a descendant of the head element');
|
||||
|
||||
}, 'Template element as a descendant of the head element. Test loading from a file');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue