Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission/unipro #135

Merged
merged 25 commits into from
Sep 13, 2013
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
11476f1
adding tests for chapter "Definitions"
alsemenov Jul 4, 2013
89104cf
Changes according Yuta's review notes
Jul 8, 2013
96334d6
tests for 'The TEMPLate element' spec chapter
Jul 12, 2013
f339050
Tests for the following chaptesr of the specification:
Jul 15, 2013
bfda331
Tests for 'Clearing the stack back to a given context' and 'Additions…
Jul 16, 2013
38a1a3e
Minor changes according the Dmitry's review notes (mainly variable re…
Jul 17, 2013
031c273
Tests for 'Additions to the "in head" insertion mode' chapter of the …
Jul 17, 2013
69a29fe
Tests for the following chapters of the spec:
Jul 18, 2013
9678228
Tests for the folowing chapters:
Jul 19, 2013
3b73631
Ignore HTML, FRAMESET, HEAD and BODY tokens tests are moved to 7.9 (a…
Jul 30, 2013
756cf95
Renamed array of HTML aelements and added isVoidElement() function
Jul 30, 2013
6c4b5f4
Code style improved and assertion wording
Jul 30, 2013
d674cc8
Misplaced files removed (moved to parsing-html-templates/ folder)
Jul 30, 2013
60d2f9e
Use generate_test() for the overlaped tests
Jul 30, 2013
77dbab7
Tests rewritten to use generate_tests()
Jul 30, 2013
c8a6207
use generate_tests() to check all HTML5 elements
Jul 30, 2013
86c25f3
Use assert_readonly() to check that content is readonly
Jul 30, 2013
c5d2538
Changed wording, codestyle and ownerDocument to check
Jul 30, 2013
e14273c
Rewritten using generate_tests()
Jul 30, 2013
6a16b52
Ref tests files renamed to .xht
Aug 1, 2013
7d6fb28
Newline character added ath the end of the file
Aug 15, 2013
d8da3f6
assert_true(... != null) replaced by assert_not_null(...)
Aug 15, 2013
86ab14e
Tests for "7.10 Additions to the "in table" insertion mode" and for "…
Aug 15, 2013
7274759
Use assert_(not)_undefined to check undefined and use === instead of ==
Aug 19, 2013
381f0eb
assert_(not)_null and assert_(not)_undefined functions removed
Sep 9, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions html-templates/additions-to-parsing-xhtml-documents/node-document.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<!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_null(template, 'Template element should not be null');
assert_not_null(template.content, '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_null(template, 'Template element should not be null');
assert_not_null(template.content, '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_null(template, 'Template element should not be null');
assert_equals(template.ownerDocument, doc, 'Wrong template node owner document');
assert_not_null(template.content, 'Content attribute of template element should not be null');

var nestedTemplate = template.content.querySelector('#tmpl2');
assert_not_null(nestedTemplate, 'Nested template element should not be null');
assert_not_null(nestedTemplate.content, '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_null(template.content,
'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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<title>Template Reftest Reference</title>
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"/>
<body>
<p>Test passes if there's no anything below this line.</p>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>Template Test: check that template content is invisible by default</title>
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#css-additions">
<meta name="assert" content="Test checks that the template contents are hidden implicitly">
<link rel="match" href="css-user-agent-style-sheet-test-001-ref.xht">
<body>
<p>Test passes if there's no anything below this line.</p>
<template>
<span style="color:red">Test fails if you can see this text</span>
</template>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<title>Template Test: check that template content is invisible by default</title>
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#css-additions">
<meta name="assert" content="The template element itself must be hidden by default">
<link rel="match" href="css-user-agent-style-sheet-test-001-ref.xht">
<body>
<p>Test passes if there's no anything below this line.</p>
<template style="border: 1px solid; width: 100px; height: 100px">
<span style="color:red">Test fails if you can see this text or border around it</span>
</template>
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>HTML Templates: template content is invisible by default</title>
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#css-additions">
<meta name="assert" content="The template element itself must be hidden by default">
<link rel="match" href="css-user-agent-style-sheet-test-001-ref.xht">
<style>
template {
border: 1px solid;
width: 100px;
height: 100px;
}
</style>
<body>
<p>Test passes if there's no anything below this line.</p>
<template>
<span style="color:red">Test fails if you can see this text or border around it</span>
</template>
</body>
Loading