content/base/test/test_getElementById.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=933193
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug 933193</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=933193">Mozilla Bug 933193</a>
    14 <p id="display"></p>
    15 <div id="content" style="display: none">
    17 </div>
    18 <pre id="test">
    19 </pre>
    20   <script type="application/javascript">
    22   /** Test for Bug 933193 **/
    23     var kid = document.createElement("span");
    24     kid.id = "test";
    25     var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
    26     svg.appendChild(kid);
    27     is(svg.getElementById("test"), kid,
    28        "Should find the right node when not in the DOM");
    30     var newKid = document.createElement("span");
    31     newKid.id = "test";
    32     var newKidParent = document.createElement("span");
    33     newKidParent.appendChild(newKid);
    34     svg.insertBefore(newKidParent, kid);
    35     is(svg.getElementById("test"), newKid,
    36        "Should find the first right node when not in the DOM");
    37     newKid.remove();
    38     is(svg.getElementById("test"), kid,
    39        "Should find the right node again when not in the DOM");
    41     document.body.appendChild(svg);
    42     is(svg.getElementById("test"), kid,
    43        "Should find the right node when in the DOM");
    45     is(document.getElementById("test").localName, "pre",
    46        "document.getElementById should find the first element in the " +
    47        "document with that id");
    49     var frag = document.createDocumentFragment();
    50     is(frag.getElementById("test"), null, "Shouldn't find what does not exist");
    51     frag.appendChild(kid);
    52     is(frag.getElementById("test"), kid,
    53        "Should find the right node in the document fragment");
    54     is(svg.getElementById("test"), null,
    55        "Shouldn't find the kid since it's gone now");
    56   </script>
    57 </body>
    58 </html>

mercurial