chromium/third_party/blink/web_tests/fast/dom/SelectorAPI/id-fastpath.html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>This tests that the querySelector and querySelectorAll fast path for IDs is not overzelous.</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
setup({ single_test: true });

var root = document.createElement('div');
var correctNode = document.createElement('div');
correctNode.setAttribute("id", "testid");
root.appendChild(correctNode);
document.body.appendChild(root);

assert_equals(document.querySelector('div#testid'), correctNode);
assert_equals(document.querySelector('#testid'), correctNode);
assert_equals(document.querySelector('ul#testid'), null);
assert_equals(document.querySelector('ul #testid'), null);
assert_equals(document.querySelector('#testid[attr]'), null);
assert_equals(document.querySelector('#testid:not(div)'), null);

assert_equals(document.querySelectorAll('div#testid').length, 1);
assert_equals(document.querySelectorAll('div#testid').item(0), correctNode);
assert_equals(document.querySelectorAll('#testid').length, 1);
assert_equals(document.querySelectorAll('#testid').item(0), correctNode);
assert_equals(document.querySelectorAll('ul#testid').length, 0);
assert_equals(document.querySelectorAll('ul #testid').length, 0);
assert_equals(document.querySelectorAll('#testid[attr]').length, 0);
assert_equals(document.querySelectorAll('#testid:not(div)').length, 0);
done();
</script>
</body>
</html>