diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element')
8 files changed, 698 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/content-attribute.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/content-attribute.html new file mode 100644 index 000000000..b4c11b841 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/content-attribute.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/node-document-changes.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/node-document-changes.html new file mode 100644 index 000000000..8027fbb91 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/node-document-changes.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-as-a-descendant.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-as-a-descendant.html new file mode 100644 index 000000000..6a6482daa --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-as-a-descendant.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-content-node-document.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-content-node-document.html new file mode 100644 index 000000000..da76c6b04 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-content-node-document.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-content.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-content.html new file mode 100644 index 000000000..8ed55d0d2 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-content.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-body.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-body.html new file mode 100644 index 000000000..70028c5ec --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-frameset.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-frameset.html new file mode 100644 index 000000000..ce20a7413 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-frameset.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-head.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-head.html new file mode 100644 index 000000000..611ec50bb --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/template-element/template-descendant-head.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> |