Commit 5aef9889 authored by rniwa@webkit.org's avatar rniwa@webkit.org

Import the XHTML parsing and serialization tests for template elements

https://bugs.webkit.org/show_bug.cgi?id=125131

Reviewed by Antti Koivisto.

Import the tests for parsing XHTML documents and fragments at f744661dbd0c29bb6a54c1530f9843838eec1300
after self-closing link elements in template-child-nodes-div.xhtml and template-child-nodes-nested.xhtml
as these two files would encounter parser errors otherwise (I'll be merging these changes back into
the web-platform-tests repository later).

This completes the importation of W3C tests for the HTML template element.

* html-templates/additions-to-parsing-xhtml-documents: Added.
* html-templates/additions-to-parsing-xhtml-documents/node-document-expected.txt: Added.
* html-templates/additions-to-parsing-xhtml-documents/node-document.html: Added.
* html-templates/additions-to-parsing-xhtml-documents/template-child-nodes-expected.txt: Added.
* html-templates/additions-to-parsing-xhtml-documents/template-child-nodes.html: Added.
* html-templates/additions-to-serializing-xhtml-documents: Added.
* html-templates/additions-to-serializing-xhtml-documents/outerhtml-expected.txt: Added.
* html-templates/additions-to-serializing-xhtml-documents/outerhtml.html: Added.
* html-templates/resources/template-child-nodes-div.xhtml:
* html-templates/resources/template-child-nodes-nested.xhtml:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160037 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e53d388d
2013-12-03 Ryosuke Niwa <rniwa@webkit.org>
Import the XHTML parsing and serialization tests for template elements
https://bugs.webkit.org/show_bug.cgi?id=125131
Reviewed by Antti Koivisto.
Import the tests for parsing XHTML documents and fragments at f744661dbd0c29bb6a54c1530f9843838eec1300
after self-closing link elements in template-child-nodes-div.xhtml and template-child-nodes-nested.xhtml
as these two files would encounter parser errors otherwise (I'll be merging these changes back into
the web-platform-tests repository later).
This completes the importation of W3C tests for the HTML template element.
* html-templates/additions-to-parsing-xhtml-documents: Added.
* html-templates/additions-to-parsing-xhtml-documents/node-document-expected.txt: Added.
* html-templates/additions-to-parsing-xhtml-documents/node-document.html: Added.
* html-templates/additions-to-parsing-xhtml-documents/template-child-nodes-expected.txt: Added.
* html-templates/additions-to-parsing-xhtml-documents/template-child-nodes.html: Added.
* html-templates/additions-to-serializing-xhtml-documents: Added.
* html-templates/additions-to-serializing-xhtml-documents/outerhtml-expected.txt: Added.
* html-templates/additions-to-serializing-xhtml-documents/outerhtml.html: Added.
* html-templates/resources/template-child-nodes-div.xhtml:
* html-templates/resources/template-child-nodes-nested.xhtml:
2013-11-26 Ryosuke Niwa <rniwa@webkit.org>
Import W3C tests for cloning template elements and default stylesheet for template element
......
PASS Parsing XHTML: Node's node document must be set to that of the element to which it will be appended. Test empty template
PASS Parsing XHTML: Node's node document must be set to that of the element to which it will be appended. Test not empty template
PASS Parsing XHTML: Node's node document must be set to that of the element to which it will be appended. Test nested templates
PASS 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
PASS 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
<!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='../testcommon.js'></script>
<link rel="stylesheet" href="../../../../resources/testharness.css">
</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');
assert_equals(template.content.ownerDocument, doc,
'Wrong template content owner document');
}, '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>
PASS Child nodes of template element in XHTML documents must be appended to template content
PASS Child nodes of nested template element in XHTML documents must be appended to template content
PASS Child nodes of template element in XHTML documents must be appended to template content. Test loading XHTML document from a file
PASS Child nodes of nested template element in XHTML documents must be appended to template content. Test loading XHTML document from a file
<!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='../testcommon.js'></script>
<link rel="stylesheet" href="../../../../resources/testharness.css">
</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>
PASS Template contents should be serialized instead of template element if serializing template element
PASS Template contents should be serialized instead of template element if serializing template element. Test nested template
PASS Template contents should be serialized instead of template element if serializing template element. Test serializing whole document
<!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='../testcommon.js'></script>
<link rel="stylesheet" href="../../../../resources/testharness.css">
</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>
......@@ -2,7 +2,7 @@
<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">
<link rel="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"/>
</head>
<body>
<p>Template tag with div tags inside</p>
......
......@@ -2,7 +2,7 @@
<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">
<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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment