tor-browser

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

browser_storage_sidebar_update.js (1394B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 // Test to verify that the sidebar is not broken when several updates
      6 // come in quick succession. See bug 1260380 - it could happen that the
      7 // "Parsed Value" section gets duplicated.
      8 
      9 "use strict";
     10 
     11 add_task(async function () {
     12  const ITEM_NAME = "ls1";
     13  const UPDATE_COUNT = 3;
     14 
     15  await openTabAndSetupStorage(
     16    MAIN_DOMAIN_SECURED + "storage-complex-values.html"
     17  );
     18 
     19  const updated = gUI.once("sidebar-updated");
     20  await selectTreeItem(["localStorage", "https://test1.example.org"]);
     21  await selectTableItem(ITEM_NAME);
     22  await updated;
     23 
     24  is(gUI.sidebar.hidden, false, "sidebar is visible");
     25 
     26  // do several updates in a row and wait for them to finish
     27  const updates = [];
     28  for (let i = 0; i < UPDATE_COUNT; i++) {
     29    info(`Performing update #${i}`);
     30    updates.push(gUI.once("sidebar-updated"));
     31    gUI.updateObjectSidebar();
     32  }
     33  await Promise.all(updates);
     34 
     35  info("Updates performed, going to verify result");
     36  const parsedScope = gUI.view.getScopeAtIndex(1);
     37  const elements = parsedScope.target.querySelectorAll(
     38    `.name[value="${ITEM_NAME}"]`
     39  );
     40  is(
     41    elements.length,
     42    1,
     43    `There is only one displayed variable named '${ITEM_NAME}'`
     44  );
     45 });