test_bug419527.xhtml (2231B)
1 <?xml version="1.0"?> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=419527 5 --> 6 <head> 7 <title>Test for Bug 419527</title> 8 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <template id="template"><span>Foo</span></template> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=419527">Mozilla Bug 419527</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 17 </div> 18 <pre id="test"> 19 <script class="testbody" type="text/javascript"> 20 <![CDATA[ 21 22 /** Test for Bug 419527 */ 23 customElements.define("custom-element", class extends HTMLElement { 24 constructor() { 25 super(); 26 const template = document.getElementById("template"); 27 const shadowRoot = this.attachShadow({mode: "open"}) 28 .appendChild(template.content.cloneNode(true)); 29 } 30 connectedCallback() { 31 var win = window; 32 var span = this.shadowRoot.children[0]; 33 win.ok(span.textContent == "Foo", "Right span."); 34 win.ok(span.localName == "span", "Wrong anon node!"); 35 var range = document.createRange(); 36 range.selectNode(span.firstChild); 37 win.ok(range.startContainer == span, "Wrong start container!"); 38 win.ok(range.endContainer == span, "Wrong end container!"); 39 var newSubTree = win.newSubTree; 40 newSubTree.appendChild(this); 41 range.setStart(newSubTree.firstChild, 0); 42 win.ok(range.startContainer == newSubTree.firstChild, 43 "Range should have been collapsed to newSubTree.firstChild!"); 44 win.ok(range.endContainer == newSubTree.firstChild, 45 "Range should have been collapsed to newSubTree.firstChild!"); 46 SimpleTest.finish(); 47 } 48 }); 49 50 var d; 51 52 function runRangeTest() { 53 window.newSubTree = document.createElementNS("http://www.w3.org/1999/xhtml", "div"); 54 newSubTree.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "div")); 55 56 d = document.createElementNS("http://www.w3.org/1999/xhtml", "custom-element"); 57 document.body.appendChild(d); 58 } 59 60 SimpleTest.waitForExplicitFinish(); 61 setTimeout(runRangeTest, 0); 62 63 ]]> 64 </script> 65 </pre> 66 </body> 67 </html>