content/base/test/test_bug548463.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=548463
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 548463</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=548463">Mozilla Bug 548463</a>
michael@0 13 <p id="display"></p>
michael@0 14 <iframe id="otherDoc"></iframe>
michael@0 15 <div id="content" style="display: none">
michael@0 16 <p id="elem1"></p>
michael@0 17 <p id="elem2"></p>
michael@0 18 </div>
michael@0 19 <div id="otherContent" style="display: none">
michael@0 20 </div>
michael@0 21 <pre id="test">
michael@0 22 <script type="application/javascript">
michael@0 23
michael@0 24 /** Test for Bug 548463 **/
michael@0 25
michael@0 26 var otherDoc = document.getElementById("otherDoc").contentDocument;
michael@0 27 var content = document.getElementById("content");
michael@0 28 var elem1 = document.getElementById("elem1");
michael@0 29 var elem2 = document.getElementById("elem2");
michael@0 30
michael@0 31 function testAdoptFromDOMNodeRemoved(nodeToAppend, nodeRemoved, nodeToAdopt)
michael@0 32 {
michael@0 33 function reparent(event)
michael@0 34 {
michael@0 35 if (event.target == nodeRemoved) {
michael@0 36 nodeRemoved.removeEventListener("DOMNodeRemoved", arguments.callee, false);
michael@0 37 otherDoc.adoptNode(nodeToAdopt);
michael@0 38 }
michael@0 39 }
michael@0 40 nodeRemoved.addEventListener("DOMNodeRemoved", reparent, false);
michael@0 41
michael@0 42 var thrown = false;
michael@0 43 try {
michael@0 44 document.getElementById("otherContent").appendChild(nodeToAppend);
michael@0 45 }
michael@0 46 catch (e) {
michael@0 47 thrown = true;
michael@0 48 }
michael@0 49
michael@0 50 ok(!thrown, "adoptNode while appending should not throw");
michael@0 51 }
michael@0 52
michael@0 53 var frag = document.createDocumentFragment();
michael@0 54 frag.appendChild(elem1);
michael@0 55 frag.appendChild(elem2);
michael@0 56 testAdoptFromDOMNodeRemoved(frag, elem1, elem2);
michael@0 57
michael@0 58 content.appendChild(elem1);
michael@0 59 testAdoptFromDOMNodeRemoved(elem1, elem1, content);
michael@0 60
michael@0 61 content.appendChild(elem1);
michael@0 62
michael@0 63 var thrown = false;
michael@0 64
michael@0 65 function changeOwnerDocument()
michael@0 66 {
michael@0 67 SpecialPowers.wrap(elem1).setUserData("foo", null, null);
michael@0 68 otherDoc.adoptNode(elem1);
michael@0 69 }
michael@0 70 SpecialPowers.wrap(elem1).setUserData("foo", "bar", changeOwnerDocument);
michael@0 71 try {
michael@0 72 document.adoptNode(elem1);
michael@0 73 }
michael@0 74 catch (e) {
michael@0 75 thrown = true;
michael@0 76 }
michael@0 77
michael@0 78 ok(!thrown, "adoptNode while adopting should not throw");
michael@0 79
michael@0 80 </script>
michael@0 81 </pre>
michael@0 82 </body>
michael@0 83 </html>

mercurial