diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/syntax/serializing-html-fragments | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/syntax/serializing-html-fragments')
4 files changed, 411 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/syntax/serializing-html-fragments/.gitkeep b/testing/web-platform/tests/html/syntax/serializing-html-fragments/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/html/syntax/serializing-html-fragments/.gitkeep diff --git a/testing/web-platform/tests/html/syntax/serializing-html-fragments/initial-linefeed-pre.html b/testing/web-platform/tests/html/syntax/serializing-html-fragments/initial-linefeed-pre.html new file mode 100644 index 000000000..d4e30bb60 --- /dev/null +++ b/testing/web-platform/tests/html/syntax/serializing-html-fragments/initial-linefeed-pre.html @@ -0,0 +1,48 @@ +<!doctype html> +<title>innerHTML getter for pre/textarea/listing with initial LF</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<div id="outer"> +<div id="inner"> +<pre id="pre1"> +x</pre> +<pre id="pre2"> + +x</pre> +<textarea id="textarea1"> +x</textarea> +<textarea id="textarea2"> + +x</textarea> +<listing id="listing1"> +x</listing> +<listing id="listing2"> + +x</listing> +</div> +</div> + +<script> +var expected_outer = '\n<div id="inner">\n<pre id="pre1">x</pre>\n<pre id="pre2">\nx</pre>\n<textarea id="textarea1">x</textarea>\n<textarea id="textarea2">\nx</textarea>\n<listing id="listing1">x</listing>\n<listing id="listing2">\nx</listing>\n</div>\n'; +var expected_inner = expected_outer.replace('\n<div id="inner">', '').replace('</div>\n', ''); +var expected_1 = 'x'; +var expected_2 = '\nx'; + +test(function() { + assert_equals(outer.innerHTML, expected_outer); +}, 'outer div'); + +test(function() { + assert_equals(inner.innerHTML, expected_inner); +}, 'inner div'); + +['pre', 'textarea', 'listing'].forEach(function(tag) { + test(function() { + assert_equals(document.getElementById(tag + '1').innerHTML, expected_1); + }, tag + '1'); + + test(function() { + assert_equals(document.getElementById(tag + '2').innerHTML, expected_2); + }, tag + '2'); +}); +</script> diff --git a/testing/web-platform/tests/html/syntax/serializing-html-fragments/outerHTML.html b/testing/web-platform/tests/html/syntax/serializing-html-fragments/outerHTML.html new file mode 100644 index 000000000..2e4805a20 --- /dev/null +++ b/testing/web-platform/tests/html/syntax/serializing-html-fragments/outerHTML.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<html> + <head> + <title>HTML Test: element.outerHTML to verify HTML fragment serialization algorithm</title> + <link rel="author" title="Intel" href="http://www.intel.com/"> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#html-fragment-serialization-algorithm"> + <link rel="help" href="https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#widl-Element-outerHTML"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="../html-element-list.js"></script> + </head> + <body> + <div id="log"></div> + <script> + test(function() { + elements_with_end_tag.forEach(function(ele) { + test(function() { + var e = document.createElement(ele); + assert_equals(e.outerHTML, "<" + ele + "></" + ele + ">", ele + " node created." ); + }, "Node for " + ele); + }); + elements_without_end_tag.forEach(function(ele) { + test(function() { + var e = document.createElement(ele); + assert_equals(e.outerHTML, "<" + ele + ">", ele + " node created." ); + }, "Node for " + ele); + }); + }, document.title); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/syntax/serializing-html-fragments/serializing.html b/testing/web-platform/tests/html/syntax/serializing-html-fragments/serializing.html new file mode 100644 index 000000000..6b7e678a3 --- /dev/null +++ b/testing/web-platform/tests/html/syntax/serializing-html-fragments/serializing.html @@ -0,0 +1,332 @@ +<!DOCTYPE html> +<title>innerHTML in HTML</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> + +<!-- test elments. Each has an expected innerHTML and outerHTML in an array in the <script>--> +<div id="test" style="display:none"> +<span></span> +<span><a></a></span> +<span><a b=c></a></span> +<span><a b='c'></a></span> +<span><a b='&'></a></span> +<span><a b=' '></a></span> +<span><a b='"'></a></span> +<span><a b="<"></a></span> +<span><a b=">"></a></span> +<span><svg xlink:href="a"></svg></span> +<span><svg xmlns:svg="test"></svg></span> +<span>a</span> +<span>&</span> +<span> </span> +<span><</span> +<span>></span> +<span>"</span> +<span><style><&></style></span> +<span><script type="test"><&></script></span> +<span><xmp><&></xmp></span> +<span><iframe><&></iframe></span> +<span><noembed><&></noembed></span> +<span><noframes><&></noframes></span> +<span><noscript><&></noscript></span> +<span><!--data--></span> +<span><a><b><c></c></b><d>e</d><f><g>h</g></f></a></span> +<span b=c></span> +</div> +<!-- TODO: template element --> +<script> + +var test_data = document.getElementById("test").getElementsByTagName("span"); +var expected = [ +["", "<span></span>"], +["<a></a>", "<span><a></a></span>"], +["<a b=\"c\"></a>", "<span><a b=\"c\"></a></span>"], +["<a b=\"c\"></a>", "<span><a b=\"c\"></a></span>"], +["<a b=\"&\"></a>", "<span><a b=\"&\"></a></span>"], +["<a b=\" \"></a>", "<span><a b=\" \"></a></span>"], +["<a b=\""\"></a>", "<span><a b=\""\"></a></span>"], +["<a b=\"<\"></a>", "<span><a b=\"<\"></a></span>"], +["<a b=\">\"></a>", "<span><a b=\">\"></a></span>"], +["<svg xlink:href=\"a\"></svg>", "<span><svg xlink:href=\"a\"></svg></span>"], +["<svg xmlns:svg=\"test\"></svg>", "<span><svg xmlns:svg=\"test\"></svg></span>"], +["a", "<span>a</span>"], +["&", "<span>&</span>"], +[" ", "<span> </span>"], +["<", "<span><</span>"], +[">", "<span>></span>"], +["\"", "<span>\"</span>"], +["<style><&></style>", "<span><style><&></style></span>"], +["<script type=\"test\"><&><\/script>", "<span><script type=\"test\"><&><\/script></span>"], +["<xmp><&></xmp>", "<span><xmp><&></xmp></span>"], +["<iframe><&></iframe>", "<span><iframe><&></iframe></span>"], +["<noembed><&></noembed>", "<span><noembed><&></noembed></span>"], +["<noframes><&></noframes>", "<span><noframes><&></noframes></span>"], +["<noscript><&></noscript>", "<span><noscript><&></noscript></span>"], +["<!--data-->", "<span><!--data--></span>"], +["<a><b><c></c></b><d>e</d><f><g>h</g></f></a>", "<span><a><b><c></c></b><d>e</d><f><g>h</g></f></a></span>"], +["", "<span b=\"c\"></span>"] +]; + +var dom_tests = [ + ["Attribute in the XML namespace", + function() { + var span = document.createElement("span"); + var svg = document.createElement("svg"); + svg.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:foo", "test"); + span.appendChild(svg); + return span; + }, + '<svg xml:foo="test"></svg>', + '<span><svg xml:foo="test"></svg></span>'], + + ["Attribute in the XML namespace with the prefix not set to xml:", + function() { + var span = document.createElement("span"); + var svg = document.createElement("svg"); + svg.setAttributeNS("http://www.w3.org/XML/1998/namespace", "abc:foo", "test"); + span.appendChild(svg); + return span; + }, + '<svg xml:foo="test"></svg>', + '<span><svg xml:foo="test"></svg></span>'], + + ["Non-'xmlns' attribute in the xmlns namespace", + function() { + var span = document.createElement("span"); + var svg = document.createElement("svg"); + svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:foo", "test") + span.appendChild(svg); + return span; + }, + '<svg xmlns:foo="test"></svg>', + '<span><svg xmlns:foo="test"></svg></span>'], + + ["'xmlns' attribute in the xmlns namespace", + function() { + var span = document.createElement("span"); + var svg = document.createElement("svg"); + svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "test") + span.appendChild(svg); + return span; + }, + '<svg xmlns="test"></svg>', + '<span><svg xmlns="test"></svg></span>'], + + ["Attribute in non-standard namespace", + function() { + var span = document.createElement("span"); + var svg = document.createElement("svg"); + svg.setAttributeNS("fake_ns", "abc:def", "test") + span.appendChild(svg); + return span; + }, + '<svg abc:def="test"></svg>', + '<span><svg abc:def="test"></svg></span>'], + + ["<span> starting with U+000A", + function() { + var elem = document.createElement("span"); + elem.appendChild(document.createTextNode("\x0A")); + return elem; + }, + "\x0A", + "<span>\x0A</span>"], + + //TODO: Processing instructions +] + +var text_elements = ["pre", "textarea", "listing"]; + +var text_tests = [ + ["<%text> context starting with U+000A", + function(elem) { + elem.appendChild(document.createTextNode("\x0A")); + return elem; + }, + "\x0A", + "<%text>\x0A</%text>"], + + ["<%text> context not starting with U+000A", + function(elem) { + elem.appendChild(document.createTextNode("a\x0A")); + return elem; + }, + "a\x0A", + "<%text>a\x0A</%text>"], + + ["<%text> non-context starting with U+000A", + function(elem) { + var span = document.createElement("span"); + elem.appendChild(document.createTextNode("\x0A")); + span.appendChild(elem); + return span; + }, + "<%text>\x0A</%text>", + "<span><%text>\x0A</%text></span>"], + + ["<%text> non-context not starting with U+000A", + function(elem) { + var span = document.createElement("span"); + elem.appendChild(document.createTextNode("a\x0A")); + span.appendChild(elem); + return span; + }, + "<%text>a\x0A</%text>", + "<span><%text>a\x0A</%text></span>"], +] + +var void_elements = [ + "area", "base", "basefont", "bgsound", "br", "col", "embed", + "frame", "hr", "img", "input", "keygen", "link", "menuitem", + "meta", "param", "source", "track", "wbr" +]; + +var void_tests = [ + ["Void context node", + function (void_elem) { + return void_elem; + }, + "", + "<%void>" + ], + ["void as first child with following siblings", + function (void_elem) { + var span = document.createElement("span"); + span.appendChild(void_elem); + span.appendChild(document.createElement("a")).appendChild(document.createTextNode("test")); + span.appendChild(document.createElement("b")) + return span + }, + "<%void><a>test</a><b></b>", + "<span><%void><a>test</a><b></b></span>" + ], + ["void as second child with following siblings", + function (void_elem) { + var span = document.createElement("span"); + span.appendChild(document.createElement("a")).appendChild(document.createTextNode("test")); + span.appendChild(void_elem); + span.appendChild(document.createElement("b")) + return span; + }, + "<a>test</a><%void><b></b>", + "<span><a>test</a><%void><b></b></span>" + ], + ["void as last child with preceding siblings", + function (void_elem) { + var span = document.createElement("span"); + span.appendChild(document.createElement("a")).appendChild(document.createTextNode("test")); + span.appendChild(document.createElement("b")) + span.appendChild(void_elem); + return span; + }, + "<a>test</a><b></b><%void>", + "<span><a>test</a><b></b><%void></span>" + ], +] + +function cross_map(a1, a2, f) { + var rv = []; + a1.forEach(function(a1_elem) { + a2.forEach(function(a2_elem) { + rv.push(f(a1_elem, a2_elem)); + }) + }); + return rv; +} + +function innerHTML_test(func, elem, expected) { + assert_equals(func(elem).innerHTML, expected); +} + +function outerHTML_test(func, elem, expected) { + assert_equals(func(elem).outerHTML, expected); +} + + +function make_void(name) { + var rv = document.createElement(name); + rv.appendChild(document.createElement("a")).appendChild(document.createComment("abc")) + rv.appendChild(document.createElement("b")). + appendChild(document.createElement("c")). + appendChild(document.createTextNode("abc")) + return rv; +} + +function make_text(name) { + return document.createElement(name); +} + +generate_tests(innerHTML_test, + expected.map(function(item, i) { + return ["innerHTML " + i + " " + expected[i][0], + function() {return test_data[i]}, + null, + item[0]]; + })) + +generate_tests(outerHTML_test, + expected.map(function(item, i) { + return ["outerHTML " + i + " " + expected[i][1], + function() {return test_data[i]}, + null, + item[1]]; + })) + +generate_tests(innerHTML_test, + dom_tests.map(function(item) { + return ["innerHTML " + item[0], + item[1], + null, + item[2]]; + })) + +generate_tests(outerHTML_test, + dom_tests.map(function(item) { + return ["outerHTML " + item[0], + item[1], + null, + item[3]]; + })) + +generate_tests(innerHTML_test, + cross_map(text_tests, text_elements, + function(test_data, elem_name) { + var rv = ["innerHTML " + test_data[0].replace(/%text/g, elem_name), + test_data[1], + document.createElement(elem_name), + test_data[2].replace(/%text/g, elem_name)]; + return rv; + })) + +generate_tests(outerHTML_test, + cross_map(text_tests, text_elements, + function(test_data, elem_name) { + var rv = ["outerHTML " + test_data[0].replace(/%text/g, elem_name), + test_data[1], + document.createElement(elem_name), + test_data[3].replace(/%text/g, elem_name)]; + return rv; + })) + +generate_tests(innerHTML_test, + cross_map(void_tests, void_elements, + function(test_data, elem_name) { + var rv = ["innerHTML " + test_data[0] + " " + elem_name, + test_data[1], + make_void(elem_name), + test_data[2].replace(/%void/g, elem_name)]; + return rv; + })) + +generate_tests(outerHTML_test, + cross_map(void_tests, void_elements, + function(test_data, elem_name) { + var rv = ["outerHTML " + test_data[0] + " " + elem_name, + test_data[1], + make_void(elem_name), + test_data[3].replace(/%void/g, elem_name)]; + return rv; + })) + +</script> |