chromium/third_party/blink/web_tests/fast/dom/Element/id-in-getelement01.html

<html>
<head>
<script src="../../../resources/js-test.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>
</body>
</html>