summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/favicons/browser_missing_favicon.js
blob: 739601c1d7f5f83c597064bcde12c6813d285091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
add_task(async () => {
  let testPath = getRootDirectory(gTestPath);

  // The default favicon would interfere with this test.
  Services.prefs.setBoolPref("browser.chrome.guess_favicon", false);
  registerCleanupFunction(() => {
    Services.prefs.setBoolPref("browser.chrome.guess_favicon", true);
  });

  await BrowserTestUtils.withNewTab(
    { gBrowser, url: "about:blank" },
    async browser => {
      const expectedIcon = testPath + "file_generic_favicon.ico";
      let faviconPromise = waitForLinkAvailable(browser);

      BrowserTestUtils.loadURI(browser, testPath + "file_with_favicon.html");
      await BrowserTestUtils.browserLoaded(browser);

      let iconURI = await faviconPromise;
      is(iconURI, expectedIcon, "Got correct icon.");

      BrowserTestUtils.loadURI(browser, testPath + "blank.html");
      await BrowserTestUtils.browserLoaded(browser);

      is(browser.mIconURL, null, "Should have blanked the icon.");
      is(
        gBrowser.getTabForBrowser(browser).getAttribute("image"),
        "",
        "Should have blanked the tab icon."
      );
    }
  );
});