tor-browser

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

browser_markup_links_05.js (2603B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests that the contextual menu items shown when clicking on links in
      7 // attributes actually do the right things.
      8 
      9 const TEST_URL = URL_ROOT_SSL + "doc_markup_links.html";
     10 
     11 add_task(async function () {
     12  const { inspector } = await openInspectorForURL(TEST_URL);
     13 
     14  info("Select a node with a URI attribute");
     15  await selectNode("video", inspector);
     16 
     17  info("Set the popupNode to the node that contains the uri");
     18  let { editor } = await getContainerForSelector("video", inspector);
     19  openContextMenuAndGetAllItems(inspector, {
     20    target: editor.attrElements.get("poster").querySelector(".link"),
     21  });
     22 
     23  info("Follow the link and wait for the new tab to open");
     24  const onTabOpened = once(gBrowser.tabContainer, "TabOpen");
     25  inspector.markup.contextMenu._onFollowLink();
     26  const { target: tab } = await onTabOpened;
     27  await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
     28 
     29  ok(true, "A new tab opened");
     30  is(
     31    tab.linkedBrowser.currentURI.spec,
     32    URL_ROOT_SSL + "doc_markup_tooltip.png",
     33    "The URL for the new tab is correct"
     34  );
     35  gBrowser.removeTab(tab);
     36 
     37  info("Select a node with a IDREF attribute");
     38  await selectNode("label", inspector);
     39 
     40  info("Set the popupNode to the node that contains the ref");
     41  ({ editor } = await getContainerForSelector("label", inspector));
     42  openContextMenuAndGetAllItems(inspector, {
     43    target: editor.attrElements.get("for").querySelector(".link"),
     44  });
     45 
     46  info("Follow the link and wait for the new node to be selected");
     47  const onSelection = inspector.selection.once("new-node-front");
     48  inspector.markup.contextMenu._onFollowLink();
     49  await onSelection;
     50 
     51  ok(true, "A new node was selected");
     52  is(inspector.selection.nodeFront.id, "name", "The right node was selected");
     53 
     54  info("Select a node with an invalid IDREF attribute");
     55  await selectNode("output", inspector);
     56 
     57  info("Set the popupNode to the node that contains the ref");
     58  ({ editor } = await getContainerForSelector("output", inspector));
     59  openContextMenuAndGetAllItems(inspector, {
     60    target: editor.attrElements.get("for").querySelectorAll(".link")[2],
     61  });
     62 
     63  info("Try to follow the link and check that no new node were selected");
     64  const onFailed = inspector.markup.once("idref-attribute-link-failed");
     65  inspector.markup.contextMenu._onFollowLink();
     66  await onFailed;
     67 
     68  ok(true, "The node selection failed");
     69  is(
     70    inspector.selection.nodeFront.tagName.toLowerCase(),
     71    "output",
     72    "The <output> node is still selected"
     73  );
     74 });