tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

HTMLCollection-iterator.html (1256B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <link rel="help" href="https://dom.spec.whatwg.org/#interface-htmlcollection">
      4 <link rel="help" href="https://webidl.spec.whatwg.org/#es-iterator">
      5 <title>HTMLCollection @@iterator Test</title>
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <p id="1"></p>
      9 <p id="2"></p>
     10 <p id="3"></p>
     11 <p id="4"></p>
     12 <p id="5"></p>
     13 <script>
     14 "use strict";
     15 
     16 const paragraphs = document.getElementsByTagName("p");
     17 
     18 test(() => {
     19  assert_true("length" in paragraphs);
     20 }, "HTMLCollection has length method.");
     21 
     22 test(() => {
     23  assert_false("values" in paragraphs);
     24 }, "HTMLCollection does not have iterable's values method.");
     25 
     26 test(() => {
     27  assert_false("entries" in paragraphs);
     28 }, "HTMLCollection does not have iterable's entries method.");
     29 
     30 test(() => {
     31  assert_false("forEach" in paragraphs);
     32 }, "HTMLCollection does not have iterable's forEach method.");
     33 
     34 test(() => {
     35  assert_true(Symbol.iterator in paragraphs);
     36 }, "HTMLCollection has Symbol.iterator.");
     37 
     38 test(() => {
     39  const ids = "12345";
     40  let idx = 0;
     41  for (const element of paragraphs) {
     42    assert_equals(element.getAttribute("id"), ids[idx++]);
     43  }
     44 }, "HTMLCollection is iterable via for-of loop.");
     45 </script>