tor-browser

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

browser_favicon_cache.js (1696B)


      1 add_task(async () => {
      2  const testPath =
      3    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      4    "http://example.com/browser/browser/base/content/test/favicons/cookie_favicon.html";
      5  const resetPath =
      6    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      7    "http://example.com/browser/browser/base/content/test/favicons/cookie_favicon.sjs?reset";
      8 
      9  let tab = BrowserTestUtils.addTab(gBrowser, testPath);
     10  gBrowser.selectedTab = tab;
     11  let browser = tab.linkedBrowser;
     12 
     13  let faviconPromise = waitForLinkAvailable(browser);
     14  await BrowserTestUtils.browserLoaded(browser);
     15  await faviconPromise;
     16  let cookies = Services.cookies.getCookiesFromHost(
     17    "example.com",
     18    browser.contentPrincipal.originAttributes
     19  );
     20  let seenCookie = false;
     21  for (let cookie of cookies) {
     22    if (cookie.name == "faviconCookie") {
     23      seenCookie = true;
     24      is(cookie.value, "1", "Should have seen the right initial cookie.");
     25    }
     26  }
     27  ok(seenCookie, "Should have seen the cookie.");
     28 
     29  faviconPromise = waitForLinkAvailable(browser);
     30  BrowserTestUtils.startLoadingURIString(browser, testPath);
     31  await BrowserTestUtils.browserLoaded(browser);
     32  await faviconPromise;
     33  cookies = Services.cookies.getCookiesFromHost(
     34    "example.com",
     35    browser.contentPrincipal.originAttributes
     36  );
     37  seenCookie = false;
     38  for (let cookie of cookies) {
     39    if (cookie.name == "faviconCookie") {
     40      seenCookie = true;
     41      is(cookie.value, "1", "Should have seen the cached cookie.");
     42    }
     43  }
     44  ok(seenCookie, "Should have seen the cookie.");
     45 
     46  // Reset the cookie so if this test is run again it will still pass.
     47  await fetch(resetPath);
     48 
     49  BrowserTestUtils.removeTab(tab);
     50 });