tor-browser

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

browser_markup_links_02.js (1637B)


      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 attributes are linkified correctly when attributes are updated
      7 // and created.
      8 
      9 const TEST_URL = URL_ROOT + "doc_markup_links.html";
     10 
     11 add_task(async function () {
     12  const { inspector } = await openInspectorForURL(TEST_URL);
     13 
     14  info("Adding a contextmenu attribute to the body node");
     15  await addNewAttributes("body", 'contextmenu="menu1"', inspector);
     16 
     17  info("Checking for links in the new attribute");
     18  let { editor } = await getContainerForSelector("body", inspector);
     19  let linkEls = editor.attrElements
     20    .get("contextmenu")
     21    .querySelectorAll(".link");
     22  is(linkEls.length, 1, "There is one link in the contextmenu attribute");
     23  is(linkEls[0].dataset.type, "idref", "The link has the right type");
     24  is(linkEls[0].textContent, "menu1", "The link has the right value");
     25 
     26  info("Editing the contextmenu attribute on the body node");
     27  const nodeMutated = inspector.once("markupmutation");
     28  const attr = editor.attrElements
     29    .get("contextmenu")
     30    .querySelector(".editable");
     31  setEditableFieldValue(attr, 'contextmenu="menu2"', inspector);
     32  await nodeMutated;
     33 
     34  info("Checking for links in the updated attribute");
     35  ({ editor } = await getContainerForSelector("body", inspector));
     36  linkEls = editor.attrElements.get("contextmenu").querySelectorAll(".link");
     37  is(linkEls.length, 1, "There is one link in the contextmenu attribute");
     38  is(linkEls[0].dataset.type, "idref", "The link has the right type");
     39  is(linkEls[0].textContent, "menu2", "The link has the right value");
     40 });