tor-browser

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

browser_markup_links_03.js (1612B)


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