tor-browser

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

browser_rules_mark_overridden_02.js (1286B)


      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 for short hand
      7 // properties and the computed list properties
      8 
      9 const TEST_URI = `
     10  <style type='text/css'>
     11  #testid {
     12    margin-left: 1px;
     13  }
     14  .testclass {
     15    margin: 2px;
     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  await testMarkOverridden(inspector, view);
     26 });
     27 
     28 function testMarkOverridden(inspector, view) {
     29  const elementStyle = view._elementStyle;
     30 
     31  const classRule = elementStyle.rules[2];
     32  const classProp = classRule.textProps[0];
     33  ok(
     34    !classProp.overridden,
     35    "Class prop shouldn't be overridden, some props are still being used."
     36  );
     37 
     38  for (const computed of classProp.computed) {
     39    if (computed.name.indexOf("margin-left") == 0) {
     40      ok(computed.overridden, "margin-left props should be overridden.");
     41    } else {
     42      ok(
     43        !computed.overridden,
     44        "Non-margin-left props should not be overridden."
     45      );
     46    }
     47  }
     48 }