test_bug418214.html (3591B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=418214 5 --> 6 <head> 7 <title>Test for Bug 418214</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=418214">Mozilla Bug 418214</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script class="testbody" type="text/javascript"> 19 20 var str = '<root xmlns:html="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:math="http://www.w3.org/1998/Math/MathML"><html:div id="d" style="border:: invalid"/><svg:svg id="s" style="border:: invalid"/><math:math id="m" style="border:: invalid"/></root>'; 21 22 /** Test for Bug 418214 */ 23 var doc = (new DOMParser()).parseFromString(str, "text/xml"); 24 var d = doc.getElementById("d"); 25 var s = doc.getElementById("s"); 26 var m = doc.getElementById("m"); 27 28 is(d.getAttribute("style"), "border:: invalid", 29 "Shouldn't be parsing style on HTML in data documents"); 30 is(s.getAttribute("style"), "border:: invalid", 31 "Shouldn't be parsing style on SVG in data documents"); 32 is(m.getAttribute("style"), "border:: invalid", 33 "Shouldn't be parsing style on MathML in data documents"); 34 35 var d2 = d.cloneNode(true); 36 var s2 = s.cloneNode(true); 37 var m2 = m.cloneNode(true); 38 39 is(d2.getAttribute("style"), "border:: invalid", 40 "Shouldn't be parsing style on HTML on clone"); 41 is(s2.getAttribute("style"), "border:: invalid", 42 "Shouldn't be parsing style on SVG on clone"); 43 is(m2.getAttribute("style"), "border:: invalid", 44 "Shouldn't be parsing style on MathML on clone"); 45 46 d2.style; 47 s2.style; 48 m2.style; 49 50 is(d2.getAttribute("style"), "border:: invalid", 51 "Getting .style shouldn't affect style attribute on HTML"); 52 is(s2.getAttribute("style"), "border:: invalid", 53 "Getting .style shouldn't affect style attribute on SVG"); 54 is(m2.getAttribute("style"), "border:: invalid", 55 "Getting .style shouldn't affect style attribute on MathML"); 56 57 d2.style.color = "green"; 58 s2.style.color = "green"; 59 m2.style.color = "green"; 60 61 is(d2.getAttribute("style"), "color: green;", 62 "Adjusting .style should parse style on HTML"); 63 is(s2.getAttribute("style"), "color: green;", 64 "Adjusting .style should parse style on SVG"); 65 is(m2.getAttribute("style"), "color: green;", 66 "Adjusting .style should parse style on MathML"); 67 68 d = document.adoptNode(d); 69 s = document.adoptNode(s); 70 m = document.adoptNode(m); 71 72 is(d.getAttribute("style"), "border:: invalid", 73 "Adopting should not parse style on HTML"); 74 is(s.getAttribute("style"), "border:: invalid", 75 "Adopting should not parse style on SVG"); 76 is(m.getAttribute("style"), "border:: invalid", 77 "Adopting should not parse style on MathML"); 78 79 $("display").appendChild(d); 80 $("display").appendChild(s); 81 $("display").appendChild(m); 82 83 is(d.getAttribute("style"), "border:: invalid", 84 "Adopting should not parse style on HTML"); 85 is(s.getAttribute("style"), "border:: invalid", 86 "Adopting should not parse style on SVG"); 87 is(m.getAttribute("style"), "border:: invalid", 88 "Adopting should not parse style on MathML"); 89 90 d.style.color = "green"; 91 s.style.color = "green"; 92 m.style.color = "green"; 93 94 is(d.getAttribute("style"), "color: green;", 95 "Adjusting .style should parse style on HTML"); 96 is(s.getAttribute("style"), "color: green;", 97 "Adjusting .style should parse style on SVG"); 98 is(m.getAttribute("style"), "color: green;", 99 "Adjusting .style should parse style on MathML"); 100 101 </script> 102 </pre> 103 </body> 104 </html>