tor-browser

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

browser_webchannel-page-favicon-data.js (1577B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const FRONTEND_URL =
      8  "https://example.com/browser/devtools/client/performance-new/test/browser/webchannel-favicons.html";
      9 const TEST_FAVICON =
     10  "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRFAP//GVwvJQAAAA5JREFUeJxjZGBgJAUBAAHIABFDZFrTAAAAAElFTkSuQmCC";
     11 
     12 const PAGE_URL = "https://profiler.firefox.com";
     13 const FAVICON_URL = "https://profiler.firefox.com/favicon.ico";
     14 
     15 ChromeUtils.defineESModuleGetters(this, {
     16  PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs",
     17  PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
     18 });
     19 
     20 add_setup(() => {
     21  registerCleanupFunction(async () => {
     22    PlacesUtils.favicons.expireAllFavicons();
     23    await PlacesUtils.history.clear();
     24  });
     25 });
     26 
     27 add_task(async function test() {
     28  info("Test the WebChannel mechanism works for getting the page favicon data");
     29 
     30  await PlacesTestUtils.addVisits(PAGE_URL);
     31  await PlacesUtils.favicons.setFaviconForPage(
     32    Services.io.newURI(PAGE_URL),
     33    Services.io.newURI(FAVICON_URL),
     34    Services.io.newURI(TEST_FAVICON)
     35  );
     36 
     37  await BrowserTestUtils.withNewTab(
     38    {
     39      gBrowser,
     40      url: FRONTEND_URL,
     41    },
     42    async () => {
     43      await waitForTabTitle("Favicons received");
     44      ok(true, "The favicons are successfully retrieved by the WebChannel.");
     45    }
     46  );
     47 });