tor-browser

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

browser_bug655270.js (1894B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 /**
      5 * Test for Bug 655273
      6 *
      7 * Call pushState and then make sure that the favicon service associates our
      8 * old favicon with the new URI.
      9 */
     10 
     11 const { PlacesTestUtils } = ChromeUtils.importESModule(
     12  "resource://testing-common/PlacesTestUtils.sys.mjs"
     13 );
     14 
     15 add_task(async function test() {
     16  const testDir = "http://mochi.test:8888/browser/docshell/test/browser/";
     17  const origURL = testDir + "file_bug655270.html";
     18  const newURL = origURL + "?new_page";
     19 
     20  const faviconURL = testDir + "favicon_bug655270.ico";
     21 
     22  let icon1;
     23  let promiseIcon1 = PlacesTestUtils.waitForNotification(
     24    "favicon-changed",
     25    events =>
     26      events.some(e => {
     27        if (e.url == origURL) {
     28          icon1 = e.faviconUrl;
     29          return true;
     30        }
     31        return false;
     32      })
     33  );
     34  let icon2;
     35  let promiseIcon2 = PlacesTestUtils.waitForNotification(
     36    "favicon-changed",
     37    events =>
     38      events.some(e => {
     39        if (e.url == newURL) {
     40          icon2 = e.faviconUrl;
     41          return true;
     42        }
     43        return false;
     44      })
     45  );
     46 
     47  // The page at origURL has a <link rel='icon'>, so we should get a call into
     48  // our observer below when it loads.  Once we verify that we have the right
     49  // favicon URI, we call pushState, which should trigger another favicon change
     50  // event, this time for the URI after pushState.
     51  let tab = BrowserTestUtils.addTab(gBrowser, origURL);
     52  await promiseIcon1;
     53  is(icon1, faviconURL, "FaviconURL for original URI");
     54  // Ignore the promise returned here and wait for the next
     55  // onPageChanged notification.
     56  SpecialPowers.spawn(tab.linkedBrowser, [], function () {
     57    content.history.pushState("", "", "?new_page");
     58  });
     59  await promiseIcon2;
     60  is(icon2, faviconURL, "FaviconURL for new URI");
     61  gBrowser.removeTab(tab);
     62 });