tor-browser

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

css-test-helper.js (1613B)


      1 var svg_ns = "http://www.w3.org/2000/svg";
      2 var url_prefix = location.protocol + "//" + location.hostname + ":" +
      3                 location.port + "/common/security-features/subresource/";
      4 
      5 var svg_test_properties = [
      6  'fill',
      7  'stroke',
      8  'filter',
      9  'clip-path',
     10  'marker-start',
     11  'marker-mid',
     12  'marker-end',
     13  'mask',
     14  'mask-image',
     15 ];
     16 
     17 // Parameters:
     18 //     testProperties: An array of test properties.
     19 //     testDescription: A test description
     20 //     testFunction: A function call which sets up the expect result and runs
     21 //                   the actual test
     22 function runSvgTests(testProperties, testDescription, testFunction) {
     23  for (const property of testProperties) {
     24    let current = {
     25      id: token(),
     26      property: property,
     27    };
     28 
     29    promise_test(t => {
     30      testFunction(current);
     31      return timeoutPromise(t, 800)
     32        .then(() => {
     33            let check_url = url_prefix + "svg.py" + "?id=" + current.id +
     34                            "&report-headers";
     35            return requestViaFetch(check_url);
     36          })
     37        .then(message => {
     38            assert_own_property(message, "headers");
     39            assert_own_property(message, "referrer");
     40            assert_equals(message.referrer, current.expected);
     41          });
     42      },
     43      testDescription + " " + property);
     44  }
     45 }
     46 
     47 function createSvg() {
     48  let svg = document.createElementNS(svg_ns, 'svg');
     49  svg.setAttribute('width', '400');
     50  svg.setAttribute('height', '400');
     51  let path = document.createElementNS(svg_ns, 'path');
     52  path.setAttribute('d', 'M 50,5 95,100 5,100 z');
     53  svg.appendChild(path);
     54  return svg;
     55 }