tor-browser

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

browser_rules_font-family-parsing.js (1710B)


      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 parsed font-family property value shown in the rules
      7 // pane is correct.
      8 
      9 const TEST_URI = `
     10  <style type="text/css">
     11    #id1 {
     12      font-family: georgia, arial, sans-serif;
     13    }
     14    #id2 {
     15      font-family: georgia,arial,sans-serif;
     16    }
     17    #id3 {
     18      font-family: georgia ,arial ,sans-serif;
     19    }
     20    #id4 {
     21      font-family: georgia , arial , sans-serif;
     22    }
     23    #id4 {
     24      font-family:   arial,  georgia,   sans-serif  ;
     25    }
     26    #id5 {
     27      font-family: helvetica !important;
     28    }
     29  </style>
     30  <div id="id1">1</div>
     31  <div id="id2">2</div>
     32  <div id="id3">3</div>
     33  <div id="id4">4</div>
     34  <div id="id5">5</div>
     35 `;
     36 
     37 const TESTS = [
     38  { selector: "#id1", expectedTextContent: "georgia, arial, sans-serif" },
     39  { selector: "#id2", expectedTextContent: "georgia,arial,sans-serif" },
     40  { selector: "#id3", expectedTextContent: "georgia ,arial ,sans-serif" },
     41  { selector: "#id4", expectedTextContent: "arial, georgia, sans-serif" },
     42  { selector: "#id5", expectedTextContent: "helvetica !important" },
     43 ];
     44 
     45 add_task(async function () {
     46  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     47  const { inspector, view } = await openRuleView();
     48 
     49  for (const { selector, expectedTextContent } of TESTS) {
     50    await selectNode(selector, inspector);
     51    info("Looking for font-family property value in selector " + selector);
     52 
     53    const prop = getRuleViewProperty(view, selector, "font-family").valueSpan;
     54    is(
     55      prop.textContent,
     56      expectedTextContent,
     57      "The font-family property value is correct"
     58    );
     59  }
     60 });