| Index: third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-body-token.html
|
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-body-token.html b/third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-body-token.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4549f5fecc881a67ada179b1e20373ee216e2c9a
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-body-token.html
|
| @@ -0,0 +1,132 @@
|
| +<!DOCTYPE html>
|
| +<html>
|
| +<head>
|
| +<title>HTML Templates: In body insertion mode: parser should ignore BODY token</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="http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-body-addition">
|
| +<link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-body-addition">
|
| +<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">
|
| +
|
| +/*
|
| + * According to http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-contents-insertion-mode
|
| + * when parser is in "template content" mode and meets <body> tag it should be switched to
|
| + * "in body" insertion mode.
|
| + * According to http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-body-addition
|
| + * this token (BODY) should be ignored
|
| + */
|
| +
|
| +
|
| +test(function() {
|
| + var doc = newHTMLDocument();
|
| + var template = doc.createElement('template');
|
| +
|
| + template.innerHTML = '<body></body>';
|
| +
|
| + doc.body.appendChild(template);
|
| +
|
| + assert_equals(template.content.childNodes.length, 0,
|
| + 'Template cannot contain BODY element');
|
| +
|
| +}, 'Ignore BODY token. Test empty BODY element assigned to template innerHTML');
|
| +
|
| +
|
| +test(function() {
|
| + var doc = newHTMLDocument();
|
| + var template = doc.createElement('template');
|
| +
|
| + template.innerHTML = '<body><div>Some content</div></body>';
|
| +
|
| + doc.body.appendChild(template);
|
| +
|
| + assert_equals(template.content.childNodes.length, 1,
|
| + 'Wrong number of template content children');
|
| + assert_equals(template.content.firstChild.nodeName, 'DIV',
|
| + 'Template should contain children of ignored BODY element');
|
| +
|
| +}, 'Ignore BODY token. Test not empty BODY element assigned to template innerHTML');
|
| +
|
| +
|
| +test(function() {
|
| + var doc = newHTMLDocument();
|
| + var template = doc.createElement('template');
|
| +
|
| + template.innerHTML = '<body><div <div id="div1">Some content</div></body><div id="div2">Some valid content</div>';
|
| +
|
| + doc.body.appendChild(template);
|
| +
|
| + assert_equals(template.content.childNodes.length, 2,
|
| + 'Wrong number of template content children');
|
| + assert_not_equals(template.content.querySelector('#div1'), null,
|
| + 'Template should contain children of the ignored BODY element');
|
| + assert_not_equals(template.content.querySelector('#div2'), null,
|
| + 'Template should contain valid element');
|
| +
|
| +}, 'Ignore BODY token. '
|
| + + 'Test BODY element and some valid element after BODY tag assigned to template innerHTML');
|
| +
|
| +
|
| +test(function() {
|
| + var doc = newHTMLDocument();
|
| + var template = doc.createElement('template');
|
| +
|
| + template.innerHTML = '<div id="div1">Some valid content</div><body><div id="div2">Some content</div></body>';
|
| +
|
| + doc.body.appendChild(template);
|
| +
|
| + assert_equals(template.content.childNodes.length, 2,
|
| + 'Template cannot contain BODY element');
|
| + assert_not_equals(template.content.querySelector('#div1'), null,
|
| + 'Template should contain valid element');
|
| + assert_not_equals(template.content.querySelector('#div2'), null,
|
| + 'Template should contain children of the ignored BODY element');
|
| +
|
| +}, 'Ignore BODY token. '
|
| + + 'Test BODY element and some valid element before BODY tag assigned to template innerHTML');
|
| +
|
| +
|
| +test(function() {
|
| + var doc = newHTMLDocument();
|
| + var template = doc.createElement('template');
|
| +
|
| + template.innerHTML = '<template id="t2"><body><span>Body!<span></body></template>';
|
| +
|
| + doc.body.appendChild(template);
|
| +
|
| + assert_equals(template.content.childNodes.length, 1,
|
| + 'Template should contain nested template');
|
| + assert_not_equals(template.content.querySelector('#t2'), null,
|
| + 'Template should contain nested element');
|
| +
|
| + var nestedTemplate = template.content.querySelector('#t2');
|
| +
|
| + assert_equals(nestedTemplate.content.childNodes.length, 1,
|
| + 'Template cannot contain BODY element');
|
| + assert_equals(nestedTemplate.content.firstChild.nodeName, 'SPAN',
|
| + 'Template cannot contain BODY element');
|
| +
|
| +}, 'Ignore BODY token. '
|
| + + 'Test template with not empty BODY element inside assigned to another '
|
| + + 'template\'s innerHTML');
|
| +
|
| +
|
| +testInIFrame('/html/semantics/scripting-1/the-template-element/resources/template-contents-body.html', function(context) {
|
| + var doc = context.iframes[0].contentDocument;
|
| +
|
| + var template = doc.body.querySelector('template');
|
| +
|
| + assert_equals(template.content.childNodes.length, 0,
|
| + 'Template cannot contain BODY element');
|
| +
|
| +}, 'Ignore BODY token. '
|
| + + 'Test loading a HTML file with BODY tag inside template');
|
| +
|
| +</script>
|
| +</body>
|
| +</html>
|
|
|