tor-browser

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

sanitizer-get.tentative.html (1654B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="./support/util.js"></script>
      7 </head>
      8 <body>
      9 <script>
     10 
     11 const TEST_CASES = [
     12  [
     13    ["b", "a"],
     14    ["a", "b"]
     15  ],
     16  [
     17    ["c", "b", "a"],
     18    ["a", "b", "c"]
     19  ],
     20  [
     21    [{name: "b", namespace: null}, {name: "a", namespace: null}],
     22    [{name: "a", namespace: null}, {name: "b", namespace: null}]
     23  ],
     24  [
     25    [{name: "_", namespace: "a"}, {name: "_", namespace: null}],
     26    [{name: "_", namespace: null}, {name: "_", namespace: "a"}]
     27  ],
     28  [
     29    [{name: "_", namespace: "b"}, {name: "_", namespace: "a"}],
     30    [{name: "_", namespace: "a"}, {name: "_", namespace: "b"}]
     31  ],
     32  [
     33    [{name: "a", namespace: "b"}, {name: "z", namespace: "a"}, {name: "b", namespace: "b"}],
     34    [{name: "z", namespace: "a"}, {name: "a", namespace: "b"}, {name: "b", namespace: "b"}],
     35  ]
     36 ];
     37 
     38 for (const key of ["attributes", "removeAttributes", "elements", "removeElements", "replaceWithChildrenElements"]) {
     39  test(() => {
     40    for (const [input, expected] of TEST_CASES) {
     41      let s = new Sanitizer({
     42        [key]: input
     43      });
     44      assert_config(s.get(), {
     45        [key]: expected
     46      });
     47    }
     48  }, `Sorting of ${key}`);
     49 }
     50 
     51 for (const key of ["attributes", "removeAttributes"]) {
     52  test(() => {
     53      for (const [input, expected] of TEST_CASES) {
     54        let s = new Sanitizer({
     55          elements: [{name: "_", [key]: input}]
     56        });
     57        assert_config(s.get(), {
     58          elements: [{name: "_", [key]: expected}]
     59        });
     60      }
     61  }, `Sorting of element's ${key}`);
     62 }
     63 
     64 </script>
     65 </body>
     66 </html>