tor-browser

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

browser_tabicon_after_bg_tab_crash.js (1685B)


      1 "use strict";
      2 
      3 const { ImageTestUtils } = ChromeUtils.importESModule(
      4  "resource://testing-common/ImageTestUtils.sys.mjs"
      5 );
      6 
      7 const FAVICON =
      8  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAARElEQVQYV2NkYLj3nwEnUGKEMxkYGBghilEFIQBTHKqYOIDFZHQ+DNz7j0MxdoDDGThNRgfoNsEATsXYARbFuAHtFAMAuvMbOrNomdAAAAAASUVORK5CYII=";
      9 const PAGE_URL = `data:text/html,
     10 <html>
     11  <head>
     12    <link rel="shortcut icon" href="${FAVICON}">
     13  </head>
     14  <body>
     15    Favicon!
     16  </body>
     17 </html>`;
     18 
     19 /**
     20 * Tests that if a background tab crashes that it doesn't
     21 * lose the favicon in the tab.
     22 */
     23 add_task(async function test_tabicon_after_bg_tab_crash() {
     24  let originalTab = gBrowser.selectedTab;
     25 
     26  await BrowserTestUtils.withNewTab(
     27    {
     28      gBrowser,
     29      url: PAGE_URL,
     30    },
     31    async function (browser) {
     32      // Because there is debounce logic in FaviconLoader.sys.mjs to reduce the
     33      // favicon loads, we have to wait some time before checking that icon was
     34      // stored properly.
     35      await BrowserTestUtils.waitForCondition(
     36        () => {
     37          return gBrowser.getIcon() != null;
     38        },
     39        "wait for favicon load to finish",
     40        100,
     41        5
     42      );
     43      await ImageTestUtils.assertEqualImage(
     44        window,
     45        browser.mIconURL,
     46        FAVICON,
     47        "Favicon is correctly set."
     48      );
     49 
     50      await BrowserTestUtils.switchTab(gBrowser, originalTab);
     51      await BrowserTestUtils.crashFrame(
     52        browser,
     53        false /* shouldShowTabCrashPage */
     54      );
     55      await ImageTestUtils.assertEqualImage(
     56        window,
     57        browser.mIconURL,
     58        FAVICON,
     59        "Favicon is still set after crash."
     60      );
     61    }
     62  );
     63 });