tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug548463.html (1700B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=548463
      5 -->
      6 <head>
      7  <title>Test for Bug 548463</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=548463">Mozilla Bug 548463</a>
     13 <p id="display"></p>
     14 <iframe id="otherDoc"></iframe>
     15 <div id="content" style="display: none">
     16  <p id="elem1"></p>
     17  <p id="elem2"></p>
     18 </div>
     19 <div id="otherContent" style="display: none">
     20 </div>
     21 <pre id="test">
     22 <script type="application/javascript">
     23 
     24 /** Test for Bug 548463 */
     25 
     26 var otherDoc = document.getElementById("otherDoc").contentDocument;
     27 var content = document.getElementById("content");
     28 var elem1 = document.getElementById("elem1");
     29 var elem2 = document.getElementById("elem2");
     30 
     31 function testAdoptFromDOMNodeRemoved(nodeToAppend, nodeRemoved, nodeToAdopt)
     32 {
     33  function reparent(event)
     34  {
     35    if (event.target == nodeRemoved) {
     36      nodeRemoved.removeEventListener("DOMNodeRemoved", arguments.callee);
     37      otherDoc.adoptNode(nodeToAdopt);
     38    }
     39  }
     40  nodeRemoved.addEventListener("DOMNodeRemoved", reparent);
     41 
     42  var thrown = false;
     43  try {
     44    document.getElementById("otherContent").appendChild(nodeToAppend);
     45  }
     46  catch (e) {
     47    thrown = true;
     48  }
     49 
     50  ok(!thrown, "adoptNode while appending should not throw");
     51 }
     52 
     53 var frag = document.createDocumentFragment();
     54 frag.appendChild(elem1);
     55 frag.appendChild(elem2);
     56 testAdoptFromDOMNodeRemoved(frag, elem1, elem2);
     57 
     58 content.appendChild(elem1);
     59 testAdoptFromDOMNodeRemoved(elem1, elem1, content);
     60 
     61 content.appendChild(elem1);
     62 
     63 </script>
     64 </pre>
     65 </body>
     66 </html>