Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-html-token.html

Issue 2657583002: Import wpt@cf62b859e6b890abc34f8140d185ba91df95c5b6 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-html-token.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-html-token.html b/third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-html-token.html
new file mode 100644
index 0000000000000000000000000000000000000000..5c53be84259d5023b4191c4f12a773b1d151a1ce
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/html/syntax/parsing/template/additions-to-the-in-body-insertion-mode/ignore-html-token.html
@@ -0,0 +1,158 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>HTML Templates: In body insertion mode: parser should ignore HTML 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>
+</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 <html> tag it should be switched to
+ * "in body" insertion mode.
+ * According to https://html.spec.whatwg.org/multipage/#parsing-main-inbody
+ * this token (HTML) should be ignored
+ */
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<html><body></body></html>';
+
+ doc.body.appendChild(template);
+
+ assert_equals(template.content.childNodes.length, 0,
+ 'Template cannot contain HTML element');
+
+}, 'Ignore HTML token. Test HTML element assigned to template innerHTML');
+
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<div id="div1">Some text</div><html><body></body></html>';
+
+ doc.body.appendChild(template);
+
+ assert_equals(template.content.childNodes.length, 1,
+ 'Template cannot contain HTML element');
+ assert_not_equals(template.content.querySelector('#div1'), null,
+ 'Template should contain valid element');
+
+}, 'Ignore HTML token.'
+ + 'Test HTML element and some valid element before it, assigned to template innerHTML');
+
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<html><body></body></html><div id="div1">Some text</div>';
+
+ doc.body.appendChild(template);
+
+ assert_equals(template.content.childNodes.length, 1,
+ 'Template cannot contain HTML element');
+ assert_not_equals(template.content.querySelector('#div1'), null,
+ 'Template should contain valid element');
+
+}, 'Ignore HTML token. '
+ + 'Test HEAD element and some valid element after it, assigned to template innerHTML');
+
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<template id="t2"><html><body></body></html></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 HTML element');
+
+}, 'Ignore HTML token. '
+ + 'Test HTML tag inside template tag assigned to another template\'s innerHTML');
+
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<html><div id="div1">Some text</div></html>';
+
+ doc.body.appendChild(template);
+
+ assert_equals(template.content.childNodes.length, 1,
+ 'Template cannot contain HTML element');
+ assert_not_equals(template.content.querySelector('#div1'), null,
+ 'Template should contain a valid element');
+
+}, 'Ignore HTML token. Test some valid element inside HTML element');
+
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<html><body><div id="div1">Some text</div><body></html>';
+
+ doc.body.appendChild(template);
+
+ assert_equals(template.content.childNodes.length, 1,
+ 'Template cannot contain HTML element');
+ assert_not_equals(template.content.querySelector('#div1'), null,
+ 'Template should contain valid element');
+
+}, 'Ignore HTML token. Test valid element inside HTML and BODY elements');
+
+
+test(function() {
+ var doc = newHTMLDocument();
+ var template = doc.createElement('template');
+
+ template.innerHTML = '<html><span id="span1">Span</span><body><div id="div1">Some text</div><body></html>';
+
+ doc.body.appendChild(template);
+
+ assert_equals(template.content.childNodes.length, 2,
+ 'Template cannot contain HTML element');
+ assert_not_equals(template.content.querySelector('#div1'), null,
+ 'Template should contain valid DIV element');
+
+ assert_not_equals(template.content.querySelector('#span1'), null,
+ 'Template should contain valid SPAN element');
+
+}, 'Ignore HTML token. Test valid element inside and between HTML and BODY elements');
+
+
+testInIFrame('/html/semantics/scripting-1/the-template-element/resources/template-contents-html.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 HTML element');
+
+}, 'Ignore HTML token. Test loading a HTML file with HTML tag inside template');
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698