tor-browser

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

browser_rules_add-property-cancel_01.js (1445B)


      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 new empty property name editor.
      7 
      8 const TEST_URI = `
      9  <style type="text/css">
     10    #testid {
     11      background-color: blue;
     12    }
     13    .testclass {
     14      background-color: green;
     15    }
     16  </style>
     17  <div id='testid' class='testclass'>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  const elementRuleEditor = getRuleViewRuleEditor(view, 0);
     26  const editor = await focusNewRuleViewProperty(elementRuleEditor);
     27  is(
     28    inplaceEditor(elementRuleEditor.newPropSpan),
     29    editor,
     30    "The new property editor got focused"
     31  );
     32 
     33  info("Escape the new property editor");
     34  const onBlur = once(editor.input, "blur");
     35  EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow);
     36  await onBlur;
     37 
     38  info("Checking the state of cancelling a new property name editor");
     39  is(
     40    elementRuleEditor.rule.textProps.length,
     41    0,
     42    "Should have cancelled creating a new text property."
     43  );
     44  ok(
     45    !elementRuleEditor.propertyList.hasChildNodes(),
     46    "Should not have any properties."
     47  );
     48 
     49  is(
     50    view.styleDocument.activeElement,
     51    view.styleDocument.body,
     52    "Correct element has focus"
     53  );
     54 });