tor-browser

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

browser_markup_void_elements_html.js (2084B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test void element display in the markupview.
      7 const TEST_URL = URL_ROOT + "doc_markup_void_elements.html";
      8 
      9 add_task(async function () {
     10  const { inspector } = await openInspectorForURL(TEST_URL);
     11  const { win } = inspector.markup;
     12 
     13  info("check non-void element closing tag is displayed");
     14  const { editor } = await getContainerForSelector("h1", inspector);
     15  ok(
     16    !editor.elt.classList.contains("void-element"),
     17    "h1 element does not have void-element class"
     18  );
     19  Assert.notStrictEqual(
     20    !editor.elt.querySelector(".close").style.display,
     21    "none",
     22    "h1 element tag is not hidden"
     23  );
     24 
     25  info("check void element closing tag is hidden in HTML document");
     26  let container = await getContainerForSelector("img", inspector);
     27  ok(
     28    container.editor.elt.classList.contains("void-element"),
     29    "img element has the expected class"
     30  );
     31  let closeElement = container.editor.elt.querySelector(".close");
     32  let computedStyle = win.getComputedStyle(closeElement);
     33  Assert.strictEqual(
     34    computedStyle.display,
     35    "none",
     36    "img closing tag is hidden"
     37  );
     38 
     39  info("check void element with pseudo element");
     40  const hrNodeFront = await getNodeFront("hr.before", inspector);
     41  container = getContainerForNodeFront(hrNodeFront, inspector);
     42  ok(
     43    container.editor.elt.classList.contains("void-element"),
     44    "hr element has the expected class"
     45  );
     46  closeElement = container.editor.elt.querySelector(".close");
     47  computedStyle = win.getComputedStyle(closeElement);
     48  Assert.strictEqual(computedStyle.display, "none", "hr closing tag is hidden");
     49 
     50  info("check expanded void element closing tag is not hidden");
     51  await inspector.markup.expandNode(hrNodeFront);
     52  await waitForMultipleChildrenUpdates(inspector);
     53  ok(container.expanded, "hr container is expanded");
     54  computedStyle = win.getComputedStyle(closeElement);
     55  Assert.strictEqual(
     56    computedStyle.display,
     57    "none",
     58    "hr closing tag is not hidden anymore"
     59  );
     60 });