| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>HTML Templates: In body insertion mode: parser should ignore FRAMESET 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="If parser is in 'in body' insertion mode and meets HTML token it should be ignored"> |
| <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> |
| <link rel="stylesheet" href="/resources/testharness.css"> |
| </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 <frameset> tag it should be switched to |
| * "in body" insertion mode. |
| * According to https://html.spec.whatwg.org/multipage/#parsing-main-inbody |
| * this token (FRAMESET) should be ignored |
| */ |
| |
| test(function() { |
| var doc = newHTMLDocument(); |
| var template = doc.createElement('template'); |
| |
| template.innerHTML = '<frameset cols="25%,*,25%">' |
| + '<frame src="frame_a.htm">' |
| + '<frame src="frame_b.htm">' + '<frame src="frame_c.htm">' |
| + '</frameset>'; |
| |
| doc.body.appendChild(template); |
| |
| assert_equals(template.content.childNodes.length, 0, |
| 'Template cannot contain FRAMESET element'); |
| |
| }, 'Ignore frameset token. Test FRAMESET element assigned to template innerHTML'); |
| |
| |
| test(function() { |
| var doc = newHTMLDocument(); |
| var template = doc.createElement('template'); |
| |
| template.innerHTML = '<div id="div1">Some text</div>' |
| + '<frameset cols="25%,*,25%">' |
| + '<frame src="frame_a.htm">' |
| + '<frame src="frame_b.htm">' |
| + '<frame src="frame_c.htm">' |
| + '</frameset>'; |
| |
| doc.body.appendChild(template); |
| |
| assert_equals(template.content.childNodes.length, 1, |
| 'Template cannot contain FRAMESET element'); |
| assert_not_equals(template.content.querySelector('#div1'), null, |
| 'Template should contain valid element'); |
| |
| }, 'Ignore frameset token. ' |
| + 'Test FRAMESET element and some valid element before it, assigned ' |
| + 'to the template\'s innerHTML'); |
| |
| |
| test(function() { |
| var doc = newHTMLDocument(); |
| var template = doc.createElement('template'); |
| |
| template.innerHTML = '<frameset cols="25%,*,25%">' |
| + '<frame src="frame_a.htm">' |
| + '<frame src="frame_b.htm">' |
| + '<frame src="frame_c.htm">' |
| + '</frameset><div id="div1">Some text</div>'; |
| |
| doc.body.appendChild(template); |
| |
| assert_equals(template.content.childNodes.length, 1, |
| 'Template cannot contain FRAMESET element'); |
| assert_not_equals(template.content.querySelector('#div1'), null, |
| 'Template should contain valid element'); |
| |
| }, 'Ignore frameset token. ' |
| + 'Test FRAMESET element and some valid element after it, assigned ' |
| + 'to the template\'s innerHTML'); |
| |
| |
| test(function() { |
| var doc = newHTMLDocument(); |
| var template = doc.createElement('template'); |
| |
| template.innerHTML = '<template id="t2">' |
| + '<frameset cols="25%,*,25%">' |
| + '<frame src="frame_a.htm">' |
| + '<frame src="frame_b.htm">' |
| + '<frame src="frame_c.htm">' |
| + '</frameset></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, 0, |
| 'Template cannot contain FRAMESET element'); |
| |
| }, 'Ignore frameset token. ' |
| + 'Test FRAMESET tag inside template tag assigned to another template\'s innerHTML'); |
| |
| |
| testInIFrame('/html/semantics/scripting-1/the-template-element/resources/template-contents-frameset.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 FRAMESET element'); |
| }, 'Ignore frameset token. Test loading a HTML file with FRAMESET tag inside template'); |
| |
| </script> |
| </body> |
| </html> |