tor-browser

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

browser_rules_non_ascii.js (1225B)


      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 rule view can open when there are non-ASCII characters in
      7 // the style sheet.  Regression test for bug 1390455.
      8 
      9 // Use a few 4-byte UTF-8 sequences to make it so the rule column
     10 // would be wrong when we had the bug.
     11 const SHEET_TEXT = "/*🆒🆒🆒🆒🆒🆒🆒🆒🆒🆒🆒🆒🆒🆒🆒*/#q{color:orange}";
     12 const HTML = `<style type="text/css">\n${SHEET_TEXT}
     13              </style><div id="q">Styled Node</div>`;
     14 const TEST_URI = "data:text/html;charset=utf-8," + encodeURIComponent(HTML);
     15 
     16 add_task(async function () {
     17  await addTab(TEST_URI);
     18 
     19  const { inspector, view } = await openRuleView();
     20  await selectNode("#q", inspector);
     21 
     22  const elementStyle = view._elementStyle;
     23 
     24  const expected = [{ name: "color", overridden: false }];
     25 
     26  const rule = elementStyle.rules[1];
     27 
     28  for (let i = 0; i < expected.length; ++i) {
     29    const prop = rule.textProps[i];
     30    is(prop.name, expected[i].name, `Got expected property name ${prop.name}`);
     31    is(
     32      prop.overridden,
     33      expected[i].overridden,
     34      `Got expected overridden value ${prop.overridden}`
     35    );
     36  }
     37 });