tor-browser

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

browser_rules_add-property-commented.js (1864B)


      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 commented properties can be added and are disabled.
      7 
      8 const TEST_URI = "<div id='testid'></div>";
      9 
     10 add_task(async function () {
     11  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     12  const { inspector, view } = await openRuleView();
     13  await selectNode("#testid", inspector);
     14  await testCreateNewSetOfCommentedAndUncommentedProperties(view);
     15 });
     16 
     17 async function testCreateNewSetOfCommentedAndUncommentedProperties(view) {
     18  info("Test creating a new set of commented and uncommented properties");
     19 
     20  info("Focusing a new property name in the rule-view");
     21  const ruleEditor = getRuleViewRuleEditor(view, 0);
     22  const editor = await focusEditableField(view, ruleEditor.closeBrace);
     23  is(
     24    inplaceEditor(ruleEditor.newPropSpan),
     25    editor,
     26    "The new property editor has focus"
     27  );
     28 
     29  info(
     30    "Entering a commented property/value pair into the property name editor"
     31  );
     32  const input = editor.input;
     33  input.value = `color: blue;
     34                 /* background-color: yellow; */
     35                 width: 200px;
     36                 height: 100px;
     37                 /* padding-bottom: 1px; */`;
     38 
     39  info("Pressing return to commit and focus the new value field");
     40  const onModifications = view.once("ruleview-changed");
     41  EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow);
     42  await onModifications;
     43 
     44  const textProps = ruleEditor.rule.textProps;
     45  ok(textProps[0].enabled, "The 'color' property is enabled.");
     46  ok(!textProps[1].enabled, "The 'background-color' property is disabled.");
     47  ok(textProps[2].enabled, "The 'width' property is enabled.");
     48  ok(textProps[3].enabled, "The 'height' property is enabled.");
     49  ok(!textProps[4].enabled, "The 'padding-bottom' property is disabled.");
     50 }