tor-browser

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

browser_identityBlock_flicker.js (1380B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /* Tests that the identity icons don't flicker when navigating,
      5 * i.e. the box should show no intermediate identity state. */
      6 
      7 add_task(async function test() {
      8  let tab = await BrowserTestUtils.openNewForegroundTab(
      9    gBrowser,
     10    "about:robots",
     11    true
     12  );
     13  let identityBox = document.getElementById("identity-box");
     14 
     15  is(
     16    identityBox.className,
     17    "localResource",
     18    "identity box has the correct class"
     19  );
     20 
     21  let observerOptions = {
     22    attributes: true,
     23    attributeFilter: ["class"],
     24  };
     25  let classChanges = 0;
     26 
     27  let observer = new MutationObserver(function (mutations) {
     28    for (let mutation of mutations) {
     29      is(mutation.type, "attributes");
     30      is(mutation.attributeName, "class");
     31      classChanges++;
     32      is(
     33        identityBox.className,
     34        "verifiedDomain",
     35        "identity box class changed correctly"
     36      );
     37    }
     38  });
     39  observer.observe(identityBox, observerOptions);
     40 
     41  let loaded = BrowserTestUtils.browserLoaded(
     42    tab.linkedBrowser,
     43    false,
     44    "https://example.com/"
     45  );
     46  BrowserTestUtils.startLoadingURIString(
     47    tab.linkedBrowser,
     48    "https://example.com"
     49  );
     50  await loaded;
     51 
     52  is(classChanges, 1, "Changed the className once");
     53  observer.disconnect();
     54  BrowserTestUtils.removeTab(tab);
     55 });