summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/favicons/browser_bug408415.js
blob: 2614e8abd5655c057f772c9f3fe6a5505d87d45c (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
add_task(async function test() {
  let testPath = getRootDirectory(gTestPath);

  await BrowserTestUtils.withNewTab(
    { gBrowser, url: "about:blank" },
    async function (tabBrowser) {
      const URI = testPath + "file_with_favicon.html";
      const expectedIcon = testPath + "file_generic_favicon.ico";
      let faviconPromise = waitForLinkAvailable(tabBrowser);

      BrowserTestUtils.startLoadingURIString(tabBrowser, URI);

      let iconURI = await faviconPromise;
      is(iconURI, expectedIcon, "Correct icon before pushState.");

      faviconPromise = waitForLinkAvailable(tabBrowser);

      await SpecialPowers.spawn(tabBrowser, [], function () {
        content.location.href += "#foo";
      });

      TestUtils.executeSoon(() => {
        faviconPromise.cancel();
      });

      try {
        await faviconPromise;
        ok(false, "Should not have seen a new icon load.");
      } catch (e) {
        ok(true, "Should have been able to cancel the promise.");
      }
    }
  );
});