tor-browser

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

browser_application_panel_manifest-open-json.js (2111B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Check that the application panel fetches a manifest when in the Manifest Page
      8 */
      9 
     10 add_task(async function () {
     11  info("Test that manifest page has a link that opens the manifest JSON file");
     12  const url = URL_ROOT_SSL + "resources/manifest/load-ok-manifest-link.html";
     13  const manifestUrl = URL_ROOT_SSL + "resources/manifest/manifest.json";
     14 
     15  await enableApplicationPanel();
     16  const { panel, tab } = await openNewTabAndApplicationPanel(url);
     17  const doc = panel.panelWin.document;
     18 
     19  selectPage(panel, "manifest");
     20 
     21  info("Waiting for the manifest JSON link");
     22  await waitUntil(() => doc.querySelector(".js-manifest-json-link") !== null);
     23  ok(true, "Link to JSON is displayed");
     24 
     25  info("Click on link and wait till the JSON is opened in a new tab");
     26  // click on the link and wait for the new tab to open
     27  const onTabLoaded = BrowserTestUtils.waitForNewTab(
     28    gBrowser,
     29    `${manifestUrl}`
     30  );
     31  const link = doc.querySelector(".js-manifest-json-link");
     32  link.click();
     33  const jsonTab = await onTabLoaded;
     34  ok(jsonTab, "The manifest JSON was opened in a new tab");
     35 
     36  // close the tabs
     37  info("Closing the page tab.");
     38  await BrowserTestUtils.removeTab(tab);
     39  info("Closing the manifest JSON tab.");
     40  await BrowserTestUtils.removeTab(jsonTab);
     41 });
     42 
     43 add_task(async function () {
     44  info(
     45    "Test that manifest page does not show a link for manifests embedded in a data url"
     46  );
     47  const url = URL_ROOT_SSL + "resources/manifest/load-ok.html";
     48 
     49  await enableApplicationPanel();
     50  const { panel, tab } = await openNewTabAndApplicationPanel(url);
     51  const doc = panel.panelWin.document;
     52 
     53  selectPage(panel, "manifest");
     54 
     55  info("Waiting for the manifest to load");
     56  await waitUntil(() => doc.querySelector(".js-manifest") !== null);
     57  ok(true, "Manifest loaded successfully");
     58  is(
     59    doc.querySelector(".js-manifest-json-link"),
     60    null,
     61    "No JSON link is shown"
     62  );
     63 
     64  // close tab
     65  info("Closing the tab");
     66  await BrowserTestUtils.removeTab(tab);
     67 });