tor-browser

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

browser_rules_add-property-cancel_03.js (1293B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Tests adding a new property and escapes the property name editor with a
      7 // value.
      8 
      9 const TEST_URI = `
     10  <style type='text/css'>
     11    div {
     12      background-color: blue;
     13    }
     14  </style>
     15  <div>Test node</div>
     16 `;
     17 
     18 add_task(async function () {
     19  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     20  const { inspector, view } = await openRuleView();
     21  await selectNode("div", inspector);
     22 
     23  // Add a property to the element's style declaration, add some text,
     24  // then press escape.
     25 
     26  const elementRuleEditor = getRuleViewRuleEditor(view, 1);
     27  const editor = await focusNewRuleViewProperty(elementRuleEditor);
     28 
     29  is(
     30    inplaceEditor(elementRuleEditor.newPropSpan),
     31    editor,
     32    "Next focused editor should be the new property editor."
     33  );
     34 
     35  EventUtils.sendString("background", view.styleWindow);
     36 
     37  const onBlur = once(editor.input, "blur");
     38  EventUtils.synthesizeKey("KEY_Escape");
     39  await onBlur;
     40 
     41  is(
     42    elementRuleEditor.rule.textProps.length,
     43    1,
     44    "Should have canceled creating a new text property."
     45  );
     46  is(
     47    view.styleDocument.activeElement,
     48    view.styleDocument.body,
     49    "Correct element has focus"
     50  );
     51 });