summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/favicons/browser_missing_favicon.js
blob: 40dce7f7a9db381eb05fb8f122c75022a0a04ead (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
34
35
36
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.loadURIString(
        browser,
        testPath + "file_with_favicon.html"
      );
      await BrowserTestUtils.browserLoaded(browser);

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

      BrowserTestUtils.loadURIString(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."
      );
    }
  );
});