OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>HTML Templates: Parsing XHTML: Node's node document</title> |
| 5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 6 <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru
"> |
| 7 <meta name="assert" content="Parsing XHTML: Node's node document must be set to
that of the element to which it will be appended"> |
| 8 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#par
sing-xhtml-documents"> |
| 9 <script src="../../../../../../../resources/testharness.js"></script> |
| 10 <script src="../../../../../../../resources/testharnessreport.js"></script> |
| 11 <script src='../testcommon.js'></script> |
| 12 <link rel="stylesheet" href="../../../../../../../resources/testharness.css"> |
| 13 </head> |
| 14 <body> |
| 15 <div id="log"></div> |
| 16 <script type="text/javascript"> |
| 17 |
| 18 |
| 19 |
| 20 test(function() { |
| 21 var doc = newXHTMLDocument(); |
| 22 doc.body = doc.createElement('body'); |
| 23 doc.body.innerHTML = '<template id="tmpl"></template>'; |
| 24 |
| 25 var template = doc.querySelector('#tmpl'); |
| 26 |
| 27 assert_not_equals(template, null, 'Template element should not be null'); |
| 28 assert_not_equals(template.content, undefined, |
| 29 'Content attribute of template element should not be undefined'); |
| 30 assert_not_equals(template.content, null, |
| 31 'Content attribute of template element should not be null'); |
| 32 |
| 33 assert_equals(template.ownerDocument, doc.body.ownerDocument, |
| 34 'Wrong template node owner document'); |
| 35 assert_equals(template.content.ownerDocument, doc, |
| 36 'Wrong template content owner document'); |
| 37 |
| 38 }, 'Parsing XHTML: Node\'s node document must be set to that of the element ' |
| 39 + 'to which it will be appended. Test empty template'); |
| 40 |
| 41 |
| 42 |
| 43 test(function() { |
| 44 var doc = newXHTMLDocument(); |
| 45 |
| 46 doc.body = doc.createElement('body'); |
| 47 doc.body.innerHTML = '<template id="tmpl"><div>Div content</div></template>'
; |
| 48 |
| 49 var template = doc.querySelector('#tmpl'); |
| 50 |
| 51 assert_equals(template.ownerDocument, doc.body.ownerDocument, |
| 52 'Wrong template node owner document'); |
| 53 |
| 54 assert_not_equals(template, null, 'Template element should not be null'); |
| 55 assert_not_equals(template.content, undefined, |
| 56 'Content attribute of template element should not be undefined'); |
| 57 assert_not_equals(template.content, null, |
| 58 'Content attribute of template element should not be null'); |
| 59 |
| 60 var div = template.content.querySelector('div'); |
| 61 assert_equals(template.content.ownerDocument, div.ownerDocument, |
| 62 'Wrong DIV node owner document'); |
| 63 |
| 64 }, 'Parsing XHTML: Node\'s node document must be set to that of the element ' |
| 65 + 'to which it will be appended. Test not empty template'); |
| 66 |
| 67 |
| 68 |
| 69 test(function() { |
| 70 var doc = newXHTMLDocument(); |
| 71 doc.body = doc.createElement('body'); |
| 72 doc.body.innerHTML = '' |
| 73 + '<template id="tmpl"><div>Div content</div> And some more text' |
| 74 + '<template id="tmpl2"><div>Template content</div></template>' |
| 75 + '</template>'; |
| 76 |
| 77 var template = doc.querySelector('#tmpl'); |
| 78 assert_not_equals(template, null, 'Template element should not be null'); |
| 79 assert_equals(template.ownerDocument, doc, 'Wrong template node owner docume
nt'); |
| 80 assert_not_equals(template.content, undefined, |
| 81 'Content attribute of template element should not be undefined'); |
| 82 assert_not_equals(template.content, null, |
| 83 'Content attribute of template element should not be null'); |
| 84 |
| 85 var nestedTemplate = template.content.querySelector('#tmpl2'); |
| 86 assert_not_equals(nestedTemplate, null, 'Nested template element should not
be null'); |
| 87 assert_not_equals(nestedTemplate.content, undefined, |
| 88 'Content attribute of nested template element should not be undefine
d'); |
| 89 assert_not_equals(nestedTemplate.content, null, |
| 90 'Content attribute of nested template element should not be null'); |
| 91 |
| 92 assert_equals(nestedTemplate.ownerDocument, template.content.ownerDocument, |
| 93 'Wrong nested template node owner document'); |
| 94 |
| 95 |
| 96 var div = nestedTemplate.content.querySelector('div'); |
| 97 assert_equals(nestedTemplate.content.ownerDocument, div.ownerDocument, |
| 98 'Wrong DIV node owner document'); |
| 99 |
| 100 }, 'Parsing XHTML: Node\'s node document must be set to that of the element ' |
| 101 + 'to which it will be appended. Test nested templates'); |
| 102 |
| 103 |
| 104 |
| 105 testInIFrame('../resources/template-child-nodes-div.xhtml', function(context) { |
| 106 var doc = context.iframes[0].contentDocument; |
| 107 |
| 108 var template = doc.querySelector('template'); |
| 109 |
| 110 assert_equals(template.ownerDocument, doc, 'Wrong template node owner docume
nt'); |
| 111 |
| 112 assert_not_equals(template.content, undefined, |
| 113 'Content attribute of template element should not be undefined'); |
| 114 assert_not_equals(template.content, null, |
| 115 'Content attribute of template element should not be null'); |
| 116 |
| 117 var div = template.content.querySelector('div'); |
| 118 assert_equals(template.content.ownerDocument, div.ownerDocument, |
| 119 'Wrong DIV node owner document'); |
| 120 |
| 121 }, 'Parsing XHTML: Node\'s node document must be set to that of the element ' |
| 122 + 'to which it will be appended. Test loading XHTML document from a file'); |
| 123 |
| 124 |
| 125 |
| 126 testInIFrame('../resources/template-child-nodes-nested.xhtml', function(context)
{ |
| 127 var doc = context.iframes[0].contentDocument; |
| 128 |
| 129 var template = doc.querySelector('template'); |
| 130 |
| 131 assert_equals(template.ownerDocument, doc, 'Wrong template node owner docume
nt'); |
| 132 |
| 133 var nestedTemplate = template.content.querySelector('template'); |
| 134 |
| 135 assert_equals(nestedTemplate.ownerDocument, template.content.ownerDocument, |
| 136 'Wrong template node owner document'); |
| 137 |
| 138 var div = nestedTemplate.content.querySelector('div'); |
| 139 assert_equals(nestedTemplate.content.ownerDocument, div.ownerDocument, |
| 140 'Wrong DIV node owner document'); |
| 141 |
| 142 }, 'Parsing XHTML: Node\'s node document must be set to that of the element ' |
| 143 + 'to which it will be appended. Test loading of XHTML document ' |
| 144 + 'with nested templates from a file'); |
| 145 |
| 146 </script> |
| 147 </body> |
| 148 </html> |
OLD | NEW |