tor-browser

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

browser_fontinspector_expand-css-code.js (1247B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that the font-face css rule code is collapsed by default, and can be expanded.
      7 
      8 const TEST_URI = URL_ROOT + "doc_browser_fontinspector.html";
      9 
     10 add_task(async function () {
     11  const { view, inspector } = await openFontInspectorForURL(TEST_URI);
     12  const viewDoc = view.document;
     13  await selectNode("div", inspector);
     14 
     15  await expandFontsAccordion(viewDoc);
     16  info("Checking that the css font-face rule is collapsed by default");
     17  const fontEl = getAllFontsEls(viewDoc)[1];
     18  const codeEl = fontEl.querySelector(".font-css-code");
     19  is(codeEl.textContent, "@font-face {}", "The font-face rule is collapsed");
     20 
     21  info("Expanding the rule by clicking on the expander icon");
     22  const onExpanded = BrowserTestUtils.waitForCondition(() => {
     23    return (
     24      codeEl.textContent ===
     25      `@font-face {\n  font-family: bar;\n  src: url("bad/font/name.ttf"), url("ostrich-regular.ttf") format("truetype");\n}`
     26    );
     27  }, "Waiting for the font-face rule 1");
     28 
     29  const expander = fontEl.querySelector(".font-css-code .theme-twisty");
     30  expander.click();
     31  await onExpanded;
     32 
     33  ok(true, "Font-face rule is now expanded");
     34 });