tor-browser

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

browser_aboutdebugging_tab_favicons.js (1860B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const { ImageTestUtils } = ChromeUtils.importESModule(
      7  "resource://testing-common/ImageTestUtils.sys.mjs"
      8 );
      9 
     10 /**
     11 * Check that about:debugging uses the favicon of tab targets as the icon of their debug
     12 * target item, and doesn't always use the default globe icon.
     13 */
     14 
     15 // PlaceUtils will not store any favicon for data: uris so we need to use a dedicated page
     16 // here.
     17 const TAB_URL =
     18  "https://example.com/browser/devtools/client/aboutdebugging/" +
     19  "test/browser/test-tab-favicons.html";
     20 
     21 const EXPECTED_FAVICON =
     22  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAV0lEQVRYR+2UMQ4AIAgD4f+P1m6KcVQ7eMZBJCHNUcgWoTtOzoHeJan4dD4RYCewtvl2z3f1yx8CnhOwmxABdgLsAQjYTYgAOwGmAAJ2EyLAToAp+J5ABzgDn/EwCmG5AAAAAElFTkSuQmCC";
     23 
     24 add_task(async function () {
     25  const faviconTab = await addTab(TAB_URL, { background: true });
     26  const { document, tab, window } = await openAboutDebugging();
     27  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     28 
     29  await waitUntil(() => {
     30    const target = findDebugTargetByText("Favicon tab", document);
     31    if (!target) {
     32      return false;
     33    }
     34    // We may get a default globe.svg icon for a short period of time while
     35    // the target tab is still loading.
     36    return target
     37      .querySelector(".qa-debug-target-item-icon")
     38      .src.includes("data:");
     39  });
     40  const faviconTabTarget = findDebugTargetByText("Favicon tab", document);
     41  const faviconTabIcon = faviconTabTarget.querySelector(
     42    ".qa-debug-target-item-icon"
     43  );
     44 
     45  await ImageTestUtils.assertEqualImage(
     46    window,
     47    faviconTabIcon.src,
     48    EXPECTED_FAVICON,
     49    "The debug target item for the tab shows the favicon of the tab"
     50  );
     51 
     52  await removeTab(tab);
     53  await removeTab(faviconTab);
     54 });