tor-browser

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

browser_rules_edit-property_08.js (2027B)


      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 renaming a property works.
      7 
      8 const TEST_URI = `
      9  <style type="text/css">
     10  #testid {
     11    color: #FFF;
     12  }
     13  </style>
     14  <div style='color: red' id='testid'>Styled Node</div>
     15 `;
     16 
     17 add_task(async function () {
     18  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     19  const { inspector, view } = await openRuleView();
     20  await selectNode("#testid", inspector);
     21 
     22  info("Get the color property editor");
     23  const ruleEditor = getRuleViewRuleEditor(view, 0);
     24  const propEditor = ruleEditor.rule.textProps[0].editor;
     25  is(ruleEditor.rule.textProps[0].name, "color");
     26 
     27  info("Focus the property name field");
     28  await focusEditableField(ruleEditor.ruleView, propEditor.nameSpan, 32, 1);
     29 
     30  info("Rename the property to background-color");
     31  // Expect 3 events: the value editor being focused, the ruleview-changed event
     32  // which signals that the new value has been previewed (fires once when the
     33  // value gets focused), and the markupmutation event since we're modifying an
     34  // inline style.
     35  const onValueFocus = once(ruleEditor.element, "focus", true);
     36  let onRuleViewChanged = ruleEditor.ruleView.once("ruleview-changed");
     37  const onMutation = inspector.once("markupmutation");
     38  EventUtils.sendString("background-color:", ruleEditor.doc.defaultView);
     39  await onValueFocus;
     40  await onRuleViewChanged;
     41  await onMutation;
     42 
     43  is(ruleEditor.rule.textProps[0].name, "background-color");
     44  await waitForComputedStyleProperty(
     45    "#testid",
     46    null,
     47    "background-color",
     48    "rgb(255, 0, 0)"
     49  );
     50 
     51  is(
     52    await getComputedStyleProperty("#testid", null, "color"),
     53    "rgb(255, 255, 255)",
     54    "color is white"
     55  );
     56 
     57  // The value field is still focused. Blur it now and wait for the
     58  // ruleview-changed event to avoid pending requests.
     59  onRuleViewChanged = view.once("ruleview-changed");
     60  EventUtils.synthesizeKey("KEY_Escape");
     61  await onRuleViewChanged;
     62 });