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/definitions | |
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/definitions')
4 files changed, 366 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.html new file mode 100644 index 000000000..d063acded --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-document-type.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-001.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-001.html new file mode 100644 index 000000000..a087f788e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-001.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-002.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-002.html new file mode 100644 index 000000000..cf2e30b64 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents-owner-test-002.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> diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents.html b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents.html new file mode 100644 index 000000000..4a61dc8d3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-template-element/definitions/template-contents.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> |