| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| |
| <div name='name1' id='id1'/> |
| <div name='name2' id='id2'/> |
| <div name='name3' id='id2'/> |
| |
| <script> |
| description("Test getElementById"); |
| |
| var elem; |
| |
| // element found with exact match |
| elem = document.getElementById('id1'); |
| shouldBe('elem.getAttribute("name")', '"name1"'); |
| |
| // multiple elements having same id return the first one |
| elem = document.getElementById('id2'); |
| shouldBe('elem.getAttribute("name")', '"name2"'); |
| |
| // element with id not found |
| elem = document.getElementById('id3'); |
| shouldBeNull('elem'); |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |