tor-browser

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

browser_rules_mark_overridden_04.js (1619B)


      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 rule view marks overridden rules correctly if a property gets
      7 // disabled
      8 
      9 const TEST_URI = `
     10  <style type='text/css'>
     11  #testid {
     12    background-color: blue;
     13  }
     14  .testclass {
     15    background-color: green;
     16  }
     17  </style>
     18  <div id='testid' class='testclass'>Styled Node</div>
     19 `;
     20 
     21 add_task(async function () {
     22  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     23  const { inspector, view } = await openRuleView();
     24  await selectNode("#testid", inspector);
     25 
     26  const idProp = getTextProperty(view, 1, { "background-color": "blue" });
     27  const classProp = getTextProperty(view, 2, { "background-color": "green" });
     28 
     29  ok(classProp.overridden, "Class prop is overridden at first.");
     30  ok(
     31    classProp.editor.filterProperty,
     32    "filter button is rendered for class prop"
     33  );
     34  is(
     35    classProp.editor.filterProperty.hidden,
     36    false,
     37    "filter button isn't hidden"
     38  );
     39 
     40  await togglePropStatus(view, idProp);
     41  ok(
     42    !classProp.overridden,
     43    "Class prop should not be overridden after id prop was disabled."
     44  );
     45  is(
     46    classProp.editor.filterProperty.hidden,
     47    true,
     48    "filter button is hidden for class prop after id prop was disabled"
     49  );
     50 
     51  await togglePropStatus(view, idProp);
     52  ok(
     53    classProp.overridden,
     54    "Class prop is overridden again after id prop was re-enabled."
     55  );
     56  is(
     57    classProp.editor.filterProperty.hidden,
     58    false,
     59    "filter button isn't hidden for class prop after id prop was re-enabled"
     60  );
     61 });