tor-browser

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

test_escapeCSSComment.js (874B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const {
      7  escapeCSSComment,
      8  unescapeCSSComment,
      9 } = require("resource://devtools/shared/css/parsing-utils.js");
     10 
     11 const TEST_DATA = [
     12  {
     13    input: "simple",
     14    expected: "simple",
     15  },
     16  {
     17    input: "/* comment */",
     18    expected: "/\\* comment *\\/",
     19  },
     20  {
     21    input: "/* two *//* comments */",
     22    expected: "/\\* two *\\//\\* comments *\\/",
     23  },
     24  {
     25    input: "/* nested /\\* comment *\\/ */",
     26    expected: "/\\* nested /\\\\* comment *\\\\/ *\\/",
     27  },
     28 ];
     29 
     30 function run_test() {
     31  let i = 0;
     32  for (const test of TEST_DATA) {
     33    ++i;
     34    info("Test #" + i);
     35 
     36    const escaped = escapeCSSComment(test.input);
     37    equal(escaped, test.expected);
     38    const unescaped = unescapeCSSComment(escaped);
     39    equal(unescaped, test.input);
     40  }
     41 }