tor-browser

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

browser_rules_add-property-invalid-identifier.js (1032B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test adding properties that are invalid identifiers.
      7 
      8 const TEST_URI = "<div id='testid'>Styled Node</div>";
      9 const TEST_DATA = [
     10  { name: "1", value: "100" },
     11  { name: "-1", value: "100" },
     12  { name: "1a", value: "100" },
     13  { name: "-11a", value: "100" },
     14 ];
     15 
     16 add_task(async function () {
     17  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
     18  const { inspector, view } = await openRuleView();
     19  await selectNode("#testid", inspector);
     20 
     21  for (const { name, value } of TEST_DATA) {
     22    info(`Test creating a new property ${name}: ${value}`);
     23    const declaration = await addProperty(view, 0, name, value);
     24 
     25    is(declaration.name, name, "Property name should have been changed.");
     26    is(declaration.value, value, "Property value should have been changed.");
     27    is(
     28      declaration.editor.isValid(),
     29      false,
     30      "The declaration should be invalid."
     31    );
     32  }
     33 });