tor-browser

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

test_getCSSVariables.js (1281B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 */
      5 
      6 "use strict";
      7 
      8 // Test whether getCSSVariables function of utils.js works correctly or not.
      9 
     10 const {
     11  getCSSVariables,
     12 } = require("resource://devtools/client/inspector/rules/utils/utils.js");
     13 
     14 add_task(() => {
     15  info("Normal usage");
     16  Assert.deepEqual(
     17    getCSSVariables("var(--color)"),
     18    ["--color"],
     19    "Found --color variable in var(--color)"
     20  );
     21 
     22  info("Variable with fallback");
     23  Assert.deepEqual(
     24    getCSSVariables("var(--color, red)"),
     25    ["--color"],
     26    "Found --color variable in var(--color)"
     27  );
     28 
     29  info("Nested variables");
     30  Assert.deepEqual(
     31    getCSSVariables("var(--color1, var(--color2, blue))"),
     32    ["--color1", "--color2"],
     33    "Found --color1 and --color2 variables in var(--color1, var(--color2, blue))"
     34  );
     35 
     36  info("Invalid variable");
     37  Assert.deepEqual(
     38    getCSSVariables("--color", "--color"),
     39    [],
     40    "Did not find variables in --color"
     41  );
     42 
     43  info("Variable with whitespace");
     44  Assert.deepEqual(
     45    getCSSVariables("var( --color )", "--color"),
     46    ["--color"],
     47    "Found --color variable in var( --color )"
     48  );
     49 });