Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / duplicate-ids.html
blob720db87af7e76cdaa9258680ca5b3f7d6075e07a
1 <html>
2 <head>
3 <script>
4 function debug(str) {
5 console = document.getElementById('console');
7 li = document.createElement('li');
8 console.appendChild(li);
9 li.appendChild(document.createTextNode(str));
12 function runTests() {
13 if (window.testRunner) {
14 testRunner.dumpAsText();
16 div = document.getElementById('duplicate');
17 dup1 = div.parentNode.removeChild(div);
19 div = document.getElementById('duplicate');
20 if (!div) {
21 debug('Failed: getElementById returned null');
22 return;
25 if (div.firstChild.nodeValue != 'This is the second duplicate div') {
26 debug('Failed: getElementById returned the wrong div');
27 return;
30 dup2 = div.parentNode.removeChild(div);
31 if (document.getElementById('duplicate')) {
32 debug('Failed: getElementById did not return null');
33 return;
36 // Now insert the nodes again
37 container = document.getElementById('container');
38 container.appendChild(dup1);
39 container.appendChild(dup2);
41 if (!document.getElementById('duplicate')) {
42 debug('Failed: getElementById returned null');
43 return;
46 debug('Success!');
48 </script>
49 </head>
50 <body onLoad="runTests()">
51 This tests that getElementById works as elements with duplicate ids are added and removed. If the test is successful, the text "success" should be shown below.
52 <div id="container">
53 <div id="duplicate">This is the first duplicate div</div>
54 <div id="duplicate">This is the second duplicate div</div>
55 </div>
56 <ul id="console">
57 </li>
58 </body>
59 </html>