summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/favicons/browser_bug550565.js
blob: 32a7527bbf0a99866ad26fcada53d3f4d6d59a27 (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
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.loadURIString(tabBrowser, URI);

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

      faviconPromise = waitForLinkAvailable(tabBrowser);

      await SpecialPowers.spawn(tabBrowser, [], function () {
        content.history.pushState("page2", "page2", "page2");
      });

      // We've navigated and shouldn't get a call to onLinkIconAvailable.
      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.");
      }
    }
  );
});