file_disabled_iframe.html (3107B)
1 <!doctype html> 2 <script> 3 window.is = window.parent.is; 4 window.SimpleTest = window.parent.SimpleTest; 5 </script> 6 <div id="testnodes"><span>hi</span> there <!-- mon ami --></div> 7 <script> 8 let t = document.getElementById('testnodes'); 9 t.innerHTML = null; 10 t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")); 11 t.firstChild.textContent = "<foo>"; 12 is(t.innerHTML, "<svg:svg><foo></svg:svg>"); 13 14 // This test crashes if the style tags are not handled correctly 15 t.innerHTML = `<svg version="1.1"> 16 <style> 17 circle { 18 fill: currentColor; 19 } 20 </style> 21 <g><circle cx="25.8" cy="9.3" r="1.5"/></g> 22 </svg> 23 `; 24 is(t.firstChild.tagName.toLowerCase(), 'svg'); 25 26 // This test crashes if the script tags are not handled correctly 27 t.innerHTML = `<svg version="1.1"> 28 <scri` + `pt> 29 throw "badment, should never fire."; 30 </scri` + `pt> 31 <g><circle cx="25.8" cy="9.3" r="1.5"/></g> 32 </svg>`; 33 is(t.firstChild.tagName.toLowerCase(), 'svg'); 34 35 t.innerHTML = null; 36 t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); 37 is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 38 t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "script")); 39 is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 40 t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 41 is(t.innerHTML, '<svg><script>1&2<3>4 \u003C/script></svg>'); 42 43 t.innerHTML = null; 44 t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); 45 is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 46 t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "style")); 47 is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg"); 48 t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 49 is(t.innerHTML, '<svg><style>1&2<3>4 \u003C/style></svg>'); 50 51 // 52 // Tests for Bug 1673237 53 // 54 55 // This test fails if about:blank renders SVGs 56 t.innerHTML = null; 57 var iframe = document.createElement("iframe"); 58 iframe.setAttribute("src", "about:blank") 59 t.appendChild(iframe); 60 iframe.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")); 61 iframe.firstChild.textContent = "<foo>"; 62 is(iframe.innerHTML, "<svg:svg><foo></svg:svg>"); 63 64 // This test fails if about:blank renders SVGs 65 var win = window.open("about:blank"); 66 win.document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg")) 67 win.document.body.firstChild.textContent = "<foo>"; 68 is(win.document.body.innerHTML, "<svg:svg><foo></svg:svg>"); 69 win.close(); 70 71 // This test fails if about:srcdoc renders SVGs 72 t.innerHTML = null; 73 iframe = document.createElement("iframe"); 74 iframe.srcdoc = "<svg:svg></svg:svg>"; 75 iframe.onload = function() { 76 iframe.contentDocument.body.firstChild.textContent = "<foo>"; 77 is(iframe.contentDocument.body.innerHTML, "<svg:svg><foo></svg:svg>"); 78 SimpleTest.finish(); 79 } 80 t.appendChild(iframe); 81 </script>