tor-browser

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

browser_dom_array.js (1322B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_PAGE_URL = URL_ROOT + "page_array.html";
      7 const TEST_ARRAY = [
      8  "a",
      9  "b",
     10  "c",
     11  "d",
     12  "e",
     13  "f",
     14  "g",
     15  "h",
     16  "i",
     17  "j",
     18  "k",
     19  "l",
     20  "m",
     21  "n",
     22  "o",
     23  "p",
     24  "q",
     25  "r",
     26  "s",
     27  "t",
     28  "u",
     29  "v",
     30  "w",
     31  "x",
     32  "y",
     33  "z",
     34 ];
     35 
     36 /**
     37 * Basic test that checks content of the DOM panel.
     38 */
     39 add_task(async function () {
     40  info("Test DOM Panel Array Expansion started");
     41 
     42  const { panel } = await addTestTab(TEST_PAGE_URL);
     43 
     44  // Expand specified row and wait till children are displayed.
     45  await expandRow(panel, "_a");
     46 
     47  // Verify that children is displayed now.
     48  const childRows = getAllRowsForLabel(panel, "_a");
     49 
     50  const item = childRows.pop();
     51  is(item.name, "length", "length property is correct");
     52  is(item.value, 26, "length property value is 26");
     53 
     54  let i = 0;
     55  for (const name in childRows) {
     56    const row = childRows[name];
     57 
     58    is(
     59      parseInt(name, 10),
     60      i++,
     61      `index ${name} is correct and sorted into the correct position`
     62    );
     63    Assert.strictEqual(
     64      typeof row.name,
     65      "number",
     66      "array index is displayed as a number"
     67    );
     68    is(TEST_ARRAY[name], row.value, `value for array[${name}] is ${row.value}`);
     69  }
     70 });