1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug744830.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,132 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=744830 1.8 +--> 1.9 +<head> 1.10 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.12 +</head> 1.13 +<body> 1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=166235">Mozilla Bug 166235</a> 1.15 +<div id="testnodes"><span>hi</span> there <!-- mon ami --></div> 1.16 +<pre id="test"> 1.17 +<script type="application/javascript"> 1.18 + var t = document.getElementById('testnodes'); 1.19 + is(t.innerHTML, 1.20 + "<span>hi</span> there <!-- mon ami -->", 1.21 + "comment nodes should be included"); 1.22 + 1.23 + var PI = document.createProcessingInstruction('foo', 'bar="1.0"'); 1.24 + t.appendChild(PI); 1.25 + is(t.innerHTML, '<span>hi</span> there <!-- mon ami --><?foo bar="1.0">', 1.26 + "pi nodes should be included"); 1.27 + 1.28 + t.innerHTML = null; 1.29 + t.appendChild(document.createElement("textarea")); 1.30 + t.firstChild.appendChild(document.createTextNode("\nhello")); 1.31 + // This is the old behavior. Spec requires something else. 1.32 + is(t.innerHTML, "<textarea>\nhello</textarea>", 1.33 + "No extra newlines should be inserted to the textarea!"); 1.34 + 1.35 + t.innerHTML = null; 1.36 + t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")); 1.37 + t.firstChild.textContent = "<foo>"; 1.38 + is(t.innerHTML, "<svg><foo></svg>"); 1.39 + 1.40 + t.innerHTML = null; 1.41 + t.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "math:math")); 1.42 + t.firstChild.textContent = "<foo>"; 1.43 + is(t.innerHTML, "<math><foo></math>"); 1.44 + 1.45 + // Prefix is serialized if element isn't HTML/SVG/MathML 1.46 + t.innerHTML = null; 1.47 + t.appendChild(document.createElementNS("http://www.example.org", "ex:example")); 1.48 + t.firstChild.textContent = "<foo>"; 1.49 + is(t.innerHTML, "<ex:example><foo></ex:example>"); 1.50 + 1.51 + t.innerHTML = null; 1.52 + t.appendChild(document.createElementNS("http://www.example.org", "example")); 1.53 + t.firstChild.textContent = "<foo>"; 1.54 + is(t.innerHTML, "<example><foo></example>"); 1.55 + 1.56 + t.firstChild.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang", "us-en"); 1.57 + is(t.innerHTML, '<example xml:lang="us-en"><foo></example>'); 1.58 + 1.59 + t.firstChild.setAttributeNS("http://www.w3.org/1999/xlink", "href", "foo"); 1.60 + is(t.innerHTML, '<example xlink:href="foo" xml:lang="us-en"><foo></example>'); 1.61 + 1.62 + t.firstChild.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://foo"); 1.63 + is(t.innerHTML, '<example xmlns="http://foo" xlink:href="foo" xml:lang="us-en"><foo></example>'); 1.64 + 1.65 + t.firstChild.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:bar", "http://bar"); 1.66 + is(t.innerHTML, '<example xmlns:bar="http://bar" xmlns="http://foo" xlink:href="foo" xml:lang="us-en"><foo></example>'); 1.67 + 1.68 + t.firstChild.setAttributeNS("http://www.helloworldns.org", "hello:world", "!"); 1.69 + is(t.innerHTML, '<example hello:world="!" xmlns:bar="http://bar" xmlns="http://foo" xlink:href="foo" xml:lang="us-en"><foo></example>'); 1.70 + 1.71 + t.firstChild.setAttribute("foo", '-"&\xA0-'); 1.72 + is(t.innerHTML, '<example foo="-"& -" hello:world="!" xmlns:bar="http://bar" xmlns="http://foo" xlink:href="foo" xml:lang="us-en"><foo></example>'); 1.73 + 1.74 + t.innerHTML = null; 1.75 + t.appendChild(document.createElement("div")); 1.76 + t.firstChild.appendChild(document.implementation 1.77 + .createDocument(null, null, null) 1.78 + .createCDATASection("foo")); 1.79 + is(t.innerHTML, '<div>foo</div>'); 1.80 + 1.81 + t.firstChild.textContent = "1&2<3>4\xA0"; 1.82 + is(t.innerHTML, '<div>1&2<3>4 </div>'); 1.83 + 1.84 + t.innerHTML = null; 1.85 + t.appendChild(document.createElement("script")); 1.86 + t.firstChild.textContent = "1&2<3>4\xA0"; 1.87 + is(t.innerHTML, '<script>1&2<3>4\xA0\u003C/script>'); 1.88 + 1.89 + t.innerHTML = null; 1.90 + t.appendChild(document.createElement("style")); 1.91 + t.firstChild.textContent = "1&2<3>4\xA0"; 1.92 + is(t.innerHTML, '<style>1&2<3>4\xA0\u003C/style>'); 1.93 + 1.94 + t.innerHTML = null; 1.95 + t.appendChild(document.createElement("span")); 1.96 + t.firstChild.setAttributeNS("ext", "attr", "foo"); 1.97 + t.firstChild.textContent = "1&2<3>4\xA0"; 1.98 + is(t.innerHTML, '<span attr="foo">1&2<3>4 \u003C/span>'); 1.99 + 1.100 + t.innerHTML = null; 1.101 + t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); 1.102 + is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 1.103 + t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "script")); 1.104 + is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 1.105 + t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 1.106 + is(t.innerHTML, '<svg><script>1&2<3>4 \u003C/script></svg>'); 1.107 + 1.108 + t.innerHTML = null; 1.109 + t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); 1.110 + is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 1.111 + t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "style")); 1.112 + is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 1.113 + t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 1.114 + is(t.innerHTML, '<svg><style>1&2<3>4 \u003C/style></svg>'); 1.115 + 1.116 + t.innerHTML = null; 1.117 + t.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "math")); 1.118 + is(t.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML"); 1.119 + t.firstChild.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "script")); 1.120 + is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML"); 1.121 + t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 1.122 + is(t.innerHTML, '<math><script>1&2<3>4 \u003C/script></math>'); 1.123 + 1.124 + t.innerHTML = null; 1.125 + t.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "math")); 1.126 + is(t.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML"); 1.127 + t.firstChild.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "style")); 1.128 + is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML"); 1.129 + t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 1.130 + is(t.innerHTML, '<math><style>1&2<3>4 \u003C/style></math>'); 1.131 +</script> 1.132 +</pre> 1.133 +</body> 1.134 +</html> 1.135 +