1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_getElementById.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=933193 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug 933193</title> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=933193">Mozilla Bug 933193</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +</div> 1.21 +<pre id="test"> 1.22 +</pre> 1.23 + <script type="application/javascript"> 1.24 + 1.25 + /** Test for Bug 933193 **/ 1.26 + var kid = document.createElement("span"); 1.27 + kid.id = "test"; 1.28 + var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); 1.29 + svg.appendChild(kid); 1.30 + is(svg.getElementById("test"), kid, 1.31 + "Should find the right node when not in the DOM"); 1.32 + 1.33 + var newKid = document.createElement("span"); 1.34 + newKid.id = "test"; 1.35 + var newKidParent = document.createElement("span"); 1.36 + newKidParent.appendChild(newKid); 1.37 + svg.insertBefore(newKidParent, kid); 1.38 + is(svg.getElementById("test"), newKid, 1.39 + "Should find the first right node when not in the DOM"); 1.40 + newKid.remove(); 1.41 + is(svg.getElementById("test"), kid, 1.42 + "Should find the right node again when not in the DOM"); 1.43 + 1.44 + document.body.appendChild(svg); 1.45 + is(svg.getElementById("test"), kid, 1.46 + "Should find the right node when in the DOM"); 1.47 + 1.48 + is(document.getElementById("test").localName, "pre", 1.49 + "document.getElementById should find the first element in the " + 1.50 + "document with that id"); 1.51 + 1.52 + var frag = document.createDocumentFragment(); 1.53 + is(frag.getElementById("test"), null, "Shouldn't find what does not exist"); 1.54 + frag.appendChild(kid); 1.55 + is(frag.getElementById("test"), kid, 1.56 + "Should find the right node in the document fragment"); 1.57 + is(svg.getElementById("test"), null, 1.58 + "Shouldn't find the kid since it's gone now"); 1.59 + </script> 1.60 +</body> 1.61 +</html>