<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160037] trunk/LayoutTests/imported/w3c</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160037">160037</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-03 14:19:32 -0800 (Tue, 03 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesresourcestemplatechildnodesdivxhtml">trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-div.xhtml</a></li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesresourcestemplatechildnodesnestedxhtml">trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-nested.xhtml</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/</li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentsnodedocumentexpectedtxt">trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentsnodedocumenthtml">trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentstemplatechildnodesexpectedtxt">trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentstemplatechildnodeshtml">trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes.html</a></li>
<li>trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/</li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesadditionstoserializingxhtmldocumentsouterhtmlexpectedtxt">trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3chtmltemplatesadditionstoserializingxhtmldocumentsouterhtmlhtml">trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (160036 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2013-12-03 21:53:21 UTC (rev 160036)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2013-12-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        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:
+
</ins><span class="cx"> 2013-11-26  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Import W3C tests for cloning template elements and default stylesheet for template element
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentsnodedocumentexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document-expected.txt (0 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document-expected.txt        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+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 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentsnodedocumenthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document.html (0 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/node-document.html        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -0,0 +1,148 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;HTML Templates: Parsing XHTML: Node's node document&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Sergey G. Grekhov&quot; href=&quot;mailto:sgrekhov@unipro.ru&quot;&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;mailto:a.semenov@unipro.ru&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Parsing XHTML: Node's node document must be set to that of the element to which it will be appended&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;http://www.w3.org/TR/2013/WD-html-templates-20130214/#parsing-xhtml-documents&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src='../testcommon.js'&gt;&lt;/script&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;../../../../resources/testharness.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script type=&quot;text/javascript&quot;&gt;
+
+
+
+test(function() {
+    var doc = newXHTMLDocument();
+    doc.body = doc.createElement('body');
+    doc.body.innerHTML = '&lt;template id=&quot;tmpl&quot;&gt;&lt;/template&gt;';
+
+    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 = '&lt;template id=&quot;tmpl&quot;&gt;&lt;div&gt;Div content&lt;/div&gt;&lt;/template&gt;';
+
+    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 = ''
+            + '&lt;template id=&quot;tmpl&quot;&gt;&lt;div&gt;Div content&lt;/div&gt; And some more text'
+            + '&lt;template id=&quot;tmpl2&quot;&gt;&lt;div&gt;Template content&lt;/div&gt;&lt;/template&gt;'
+            + '&lt;/template&gt;';
+
+    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');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentstemplatechildnodesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes-expected.txt (0 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes-expected.txt        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+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 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesadditionstoparsingxhtmldocumentstemplatechildnodeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes.html (0 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/html-templates/additions-to-parsing-xhtml-documents/template-child-nodes.html        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -0,0 +1,103 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;HTML Templates: Child nodes of template element in XHTML documents&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Sergey G. Grekhov&quot; href=&quot;mailto:sgrekhov@unipro.ru&quot;&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;a.semenov@unipro.ru&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Child nodes of template element in XHTML documents are always appended to the template content (instead of template itself)&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;http://www.w3.org/TR/2013/WD-html-templates-20130214/#parsing-xhtml-documents&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src='../testcommon.js'&gt;&lt;/script&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;../../../../resources/testharness.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script type=&quot;text/javascript&quot;&gt;
+
+
+test(function() {
+    var doc = newXHTMLDocument();
+
+    doc.body = doc.createElement('body');
+    doc.body.innerHTML = '&lt;template id=&quot;tmpl1&quot;&gt;'
+            + '&lt;div id=&quot;div1&quot;&gt;This is div inside template&lt;/div&gt;'
+            + '&lt;div id=&quot;div2&quot;&gt;This is another div inside template&lt;/div&gt;'
+            + '&lt;/template&gt;';
+
+    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 = '&lt;template id=&quot;tmpl1&quot;&gt;'
+            + '&lt;div id=&quot;div1&quot;&gt;This is div inside template&lt;/div&gt;'
+            + '&lt;div id=&quot;div2&quot;&gt;This is another div inside template&lt;/div&gt;'
+            + '&lt;template id=&quot;tmpl2&quot;&gt;'
+            + '&lt;div id=&quot;div3&quot;&gt;This is div inside nested template&lt;/div&gt;'
+            + '&lt;div id=&quot;div4&quot;&gt;This is another div inside nested template&lt;/div&gt;'
+            + '&lt;/template&gt;' + '&lt;/template&gt;';
+
+    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');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesadditionstoserializingxhtmldocumentsouterhtmlexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml-expected.txt (0 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml-expected.txt        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+
+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 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesadditionstoserializingxhtmldocumentsouterhtmlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml.html (0 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/html-templates/additions-to-serializing-xhtml-documents/outerhtml.html        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;HTML Templates: serialize template contents instead of template element&lt;/title&gt;
+&lt;meta name=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;a.semenov@unipro.ru&quot;&gt;
+&lt;meta name=&quot;assert&quot; content=&quot;Template contents should be serialized instead of template element if serializing template element in XHTML document&quot;&gt;
+&lt;link rel=&quot;help&quot; href=&quot;http://www.w3.org/TR/2013/WD-html-templates-20130214/#serializing-xhtml-documents&quot;&gt;
+&lt;script src=&quot;../../../../resources/testharness.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../../../resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+&lt;script src='../testcommon.js'&gt;&lt;/script&gt;
+&lt;link rel=&quot;stylesheet&quot; href=&quot;../../../../resources/testharness.css&quot;&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;log&quot;&gt;&lt;/div&gt;
+&lt;script type=&quot;text/javascript&quot;&gt;
+
+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, '&lt;template xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;div id=&quot;div1&quot;&gt;some text&lt;/div&gt;&lt;/template&gt;',
+       '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, '&lt;template xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;template&gt;&lt;div id=&quot;div1&quot;&gt;some text&lt;/div&gt;&lt;/template&gt;&lt;/template&gt;',
+       '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, '&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;body&gt;&lt;template&gt;&lt;div id=&quot;div1&quot;&gt;some text&lt;/div&gt;&lt;/template&gt;&lt;/body&gt;&lt;/html&gt;',
+       'template element is serialized incorrectly');
+
+}, 'Template contents should be serialized instead of template element if serializing template element. '
+    + 'Test serializing whole document');
+
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesresourcestemplatechildnodesdivxhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-div.xhtml (160036 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-div.xhtml        2013-12-03 21:53:21 UTC (rev 160036)
+++ trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-div.xhtml        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
</span><span class="cx"> &lt;head&gt;
</span><span class="cx">         &lt;title&gt;Template tag with children div tags inside&lt;/title&gt;
</span><del>-    &lt;link rel=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;mailto:a.semenov@unipro.ru&quot;&gt;
</del><ins>+    &lt;link rel=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;mailto:a.semenov@unipro.ru&quot;/&gt;
</ins><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="cx">         &lt;p&gt;Template tag with div tags inside&lt;/p&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3chtmltemplatesresourcestemplatechildnodesnestedxhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-nested.xhtml (160036 => 160037)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-nested.xhtml        2013-12-03 21:53:21 UTC (rev 160036)
+++ trunk/LayoutTests/imported/w3c/html-templates/resources/template-child-nodes-nested.xhtml        2013-12-03 22:19:32 UTC (rev 160037)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
</span><span class="cx"> &lt;head&gt;
</span><span class="cx">         &lt;title&gt;Template tag with children div tags inside another template tag&lt;/title&gt;
</span><del>-    &lt;link rel=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;mailto:a.semenov@unipro.ru&quot;&gt;
</del><ins>+    &lt;link rel=&quot;author&quot; title=&quot;Aleksei Yu. Semenov&quot; href=&quot;mailto:a.semenov@unipro.ru&quot;/&gt;
</ins><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="cx">         &lt;p&gt;Template tag with children div tags inside another template tag&lt;/p&gt;
</span></span></pre>
</div>
</div>

</body>
</html>