chromium/third_party/blink/web_tests/fast/dom/SelectorAPI/dumpNodeList-2.html

<!doctype html>
<html>
<head>
<title>fast/dom/SelectorAPI/dumpNodeList-2.html</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div id="test">
    <div></div>
    <div>
      <div class="target"></div>
    </div>
    <div>
      <div class="target"></div>
      <div></div>
    </div>
    <div id="test2" class="target">line 4</div>
    <div id="test3"></div>
    <p>line 5</p>
</div>
<pre id="console"></pre>
<script>
setup({ single_test: true });
NodeList.prototype.dump = function ()
{
  var result = "";
  var length = this.length;
  for (var i = 0; i < length; i++)
    result += this[i] + ", ";
  result += "length: " + length;
  return result;
};

function testQuerySelectorAll(node, selectorString)
{
  try {
    return node.querySelectorAll(selectorString).dump();
  } catch (e) {
    return "" + e;
  }
}

assert_equals(testQuerySelectorAll(document, ".target + div"), "[object HTMLDivElement], [object HTMLDivElement], length: 2");
assert_equals(testQuerySelectorAll(document.getElementById("test"), ".target + div"), "[object HTMLDivElement], [object HTMLDivElement], length: 2");
assert_equals(testQuerySelectorAll(document.getElementById("test2"), ".target + div"), "length: 0");
assert_equals(testQuerySelectorAll(document.getElementById("test3"), ".target + div"), "length: 0");
done();
</script>
</body>
</html>