summaryrefslogtreecommitdiffstats
path: root/devtools/client/application/test/browser/browser_application_panel_manifest-open-json.js
blob: 7869502d4b6cbd72f256f0203b19775a11b976ca (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/**
 * Check that the application panel fetches a manifest when in the Manifest Page
 */

add_task(async function () {
  info("Test that manifest page has a link that opens the manifest JSON file");
  const url = URL_ROOT_SSL + "resources/manifest/load-ok-manifest-link.html";
  const manifestUrl = URL_ROOT_SSL + "resources/manifest/manifest.json";

  await enableApplicationPanel();
  const { panel, tab } = await openNewTabAndApplicationPanel(url);
  const doc = panel.panelWin.document;

  selectPage(panel, "manifest");

  info("Waiting for the manifest JSON link");
  await waitUntil(() => doc.querySelector(".js-manifest-json-link") !== null);
  ok(true, "Link to JSON is displayed");

  info("Click on link and wait till the JSON is opened in a new tab");
  // click on the link and wait for the new tab to open
  const onTabLoaded = BrowserTestUtils.waitForNewTab(
    gBrowser,
    `${manifestUrl}`
  );
  const link = doc.querySelector(".js-manifest-json-link");
  link.click();
  const jsonTab = await onTabLoaded;
  ok(jsonTab, "The manifest JSON was opened in a new tab");

  // close the tabs
  info("Closing the page tab.");
  await BrowserTestUtils.removeTab(tab);
  info("Closing the manifest JSON tab.");
  await BrowserTestUtils.removeTab(jsonTab);
});

add_task(async function () {
  info(
    "Test that manifest page does not show a link for manifests embedded in a data url"
  );
  const url = URL_ROOT_SSL + "resources/manifest/load-ok.html";

  await enableApplicationPanel();
  const { panel, tab } = await openNewTabAndApplicationPanel(url);
  const doc = panel.panelWin.document;

  selectPage(panel, "manifest");

  info("Waiting for the manifest to load");
  await waitUntil(() => doc.querySelector(".js-manifest") !== null);
  ok(true, "Manifest loaded successfully");
  is(
    doc.querySelector(".js-manifest-json-link"),
    null,
    "No JSON link is shown"
  );

  // close tab
  info("Closing the tab");
  await BrowserTestUtils.removeTab(tab);
});