tor-browser

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

browser_rules_edit-property-remove_01.js (1984B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests removing a property by clearing the property name and pressing the
      7 // return key, and checks if the focus is moved to the appropriate editable
      8 // field.
      9 
     10 const TEST_URI = `
     11  <style type='text/css'>
     12  #testid {
     13    background-color: #00F;
     14    color: #00F;
     15  }
     16  </style>
     17  <div id='testid'>Styled Node</div>
     18 `;
     19 
     20 add_task(async function () {
     21  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     22  const { inspector, view } = await openRuleView();
     23  await selectNode("#testid", inspector);
     24 
     25  info("Getting the first property in the #testid rule");
     26  const rule = getRuleViewRuleEditor(view, 1).rule;
     27  let prop = rule.textProps[0];
     28 
     29  info("Deleting the name of that property to remove the property");
     30  await removeProperty(view, prop, false);
     31 
     32  let newValue = await getRulePropertyValue(0, 0, "background-color");
     33  is(newValue, "", "background-color should have been unset.");
     34 
     35  info("Getting the new first property in the rule");
     36  prop = rule.textProps[0];
     37 
     38  let editor = inplaceEditor(view.styleDocument.activeElement);
     39  is(
     40    inplaceEditor(prop.editor.nameSpan),
     41    editor,
     42    "Focus should have moved to the next property name"
     43  );
     44 
     45  info("Deleting the name of that property to remove the property");
     46  view.styleDocument.activeElement.blur();
     47  await removeProperty(view, prop, false);
     48 
     49  newValue = await getRulePropertyValue(0, 0, "color");
     50  is(newValue, "", "color should have been unset.");
     51 
     52  editor = inplaceEditor(view.styleDocument.activeElement);
     53  is(
     54    inplaceEditor(rule.editor.newPropSpan),
     55    editor,
     56    "Focus should have moved to the new property span"
     57  );
     58  is(rule.textProps.length, 0, "All properties should have been removed.");
     59  is(
     60    rule.editor.propertyList.children.length,
     61    1,
     62    "Should have the new property span."
     63  );
     64 
     65  view.styleDocument.activeElement.blur();
     66 });