content/base/test/test_bug548463.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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 type="application/javascript" 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">
    24 /** Test for Bug 548463 **/
    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");
    31 function testAdoptFromDOMNodeRemoved(nodeToAppend, nodeRemoved, nodeToAdopt)
    32 {
    33   function reparent(event)
    34   {
    35     if (event.target == nodeRemoved) {
    36       nodeRemoved.removeEventListener("DOMNodeRemoved", arguments.callee, false);
    37       otherDoc.adoptNode(nodeToAdopt);
    38     }
    39   }
    40   nodeRemoved.addEventListener("DOMNodeRemoved", reparent, false);
    42   var thrown = false;
    43   try {
    44     document.getElementById("otherContent").appendChild(nodeToAppend);
    45   }
    46   catch (e) {
    47     thrown = true;
    48   }
    50   ok(!thrown, "adoptNode while appending should not throw");
    51 }
    53 var frag = document.createDocumentFragment();
    54 frag.appendChild(elem1);
    55 frag.appendChild(elem2);
    56 testAdoptFromDOMNodeRemoved(frag, elem1, elem2);
    58 content.appendChild(elem1);
    59 testAdoptFromDOMNodeRemoved(elem1, elem1, content);
    61 content.appendChild(elem1);
    63 var thrown = false;
    65 function changeOwnerDocument()
    66 {
    67   SpecialPowers.wrap(elem1).setUserData("foo", null, null);
    68   otherDoc.adoptNode(elem1);
    69 }
    70 SpecialPowers.wrap(elem1).setUserData("foo", "bar", changeOwnerDocument);
    71 try {
    72   document.adoptNode(elem1);
    73 }
    74 catch (e) {
    75   thrown = true;
    76 }
    78 ok(!thrown, "adoptNode while adopting should not throw");
    80 </script>
    81 </pre>
    82 </body>
    83 </html>

mercurial