tor-browser

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

common.js (6018B)


      1 setup({explicit_done:true});
      2 onload = function() {
      3    setupIframe();
      4 
      5    var tests = [
      6    {input:"1", q:"1px"},
      7    {input:"+1", q:"1px"},
      8    {input:"-1", q:"-1px"},
      9    {input:"1.5", q:"1.5px"},
     10    {input:"+1.5", q:"1.5px"},
     11    {input:"-1.5", q:"-1.5px"},
     12    {input:"\\31 "},
     13    {input:"+\\31 "},
     14    {input:"-\\31 "},
     15    {input:"\\31 .5"},
     16    {input:"+\\31 .5"},
     17    {input:"-\\31 .5"},
     18    {input:"1\\31 "},
     19    {input:"+1\\31 "},
     20    {input:"-1\\31 "},
     21    {input:"1\\31 .5"},
     22    {input:"+1\\31 .5"},
     23    {input:"-1\\31 .5"},
     24    {input:"a"},
     25    {input:"A"},
     26    {input:"1a"},
     27    {input:"+1a"},
     28    {input:"-1a"},
     29    {input:"+1A"},
     30    {input:"-1A"},
     31    {input:"+a"},
     32    {input:"-a"},
     33    {input:"+A"},
     34    {input:"-A"},
     35    {input:"@a"},
     36    {input:"@1"},
     37    {input:"@1a"},
     38    {input:'"a"'},
     39    {input:'"1"'},
     40    {input:'"1a"'},
     41    {input:"url(1)"},
     42    {input:"url('1')"},
     43    {input:"#1"},
     44    {input:"#01"},
     45    {input:"#001"},
     46    {input:"#0001"},
     47    {input:"#00001"},
     48    {input:"#000001"},
     49    {input:"+/**/1"},
     50    {input:"-/**/1"},
     51    {input:"calc(1)"},
     52    {input:"calc(2 * 2px)", q:"4px", s:"4px"},
     53    {input:"1px 2", q:"1px 2px", shorthand:true},
     54    {input:"1 2px", q:"1px 2px", shorthand:true},
     55    {input:"1px calc(2)", shorthand:true},
     56    {input:"calc(1) 2px", shorthand:true},
     57    {input:"1 +2", q:"1px 2px", shorthand:true},
     58    {input:"1 -2", q:"1px -2px", shorthand:true},
     59    ];
     60 
     61    var props = [
     62    {prop:'background-position', check:'background-position', check_also:[]},
     63    {prop:'border-spacing', check:'border-spacing', check_also:[]},
     64    {prop:'border-top-width', check:'border-top-width'},
     65    {prop:'border-right-width', check:'border-right-width'},
     66    {prop:'border-bottom-width', check:'border-bottom-width'},
     67    {prop:'border-left-width', check:'border-left-width'},
     68    {prop:'border-width', check:'border-top-width', check_also:['border-right-width', 'border-bottom-width', 'border-left-width']},
     69    {prop:'bottom', check:'bottom'},
     70    {prop:'clip', check:'clip'},
     71    {prop:'font-size', check:'font-size'},
     72    {prop:'height', check:'height'},
     73    {prop:'left', check:'left'},
     74    {prop:'letter-spacing', check:'letter-spacing'},
     75    {prop:'margin-right', check:'margin-right'},
     76    {prop:'margin-left', check:'margin-left'},
     77    {prop:'margin-top', check:'margin-top'},
     78    {prop:'margin-bottom', check:'margin-bottom'},
     79    {prop:'margin', check:'margin-top', check_also:['margin-right', 'margin-bottom', 'margin-left']},
     80    {prop:'max-height', check:'max-height'},
     81    {prop:'max-width', check:'max-width'},
     82    {prop:'min-height', check:'min-height'},
     83    {prop:'min-width', check:'min-width'},
     84    {prop:'padding-top', check:'padding-top'},
     85    {prop:'padding-right', check:'padding-right'},
     86    {prop:'padding-bottom', check:'padding-bottom'},
     87    {prop:'padding-left', check:'padding-left'},
     88    {prop:'padding', check:'padding-top', check_also:['padding-right', 'padding-bottom', 'padding-left']},
     89    {prop:'right', check:'right'},
     90    {prop:'text-indent', check:'text-indent'},
     91    {prop:'top', check:'top'},
     92    {prop:'vertical-align', check:'vertical-align'},
     93    {prop:'width', check:'width'},
     94    {prop:'word-spacing', check:'word-spacing'},
     95    ];
     96    var style_template = '#test{border-style:solid;position:relative;{prop}:{test};}' +
     97                         '#ref{border-style:solid;position:relative;{prop}:{ref};}';
     98 
     99    tests.forEach(function(t) {
    100        for (var i in props) {
    101            if (t.shorthand && !(props[i].check_also)) {
    102                continue;
    103            }
    104            test(function() {
    105                win.style.textContent = style_template.replace('{test}', t.input)
    106                            .replace('{ref}', quirks ? t.q : t.s).replace(/\{prop\}/g, props[i].prop)
    107                            .replace(/clip:[^;]+/g, function(match) {
    108                                return 'clip:rect(auto, auto, auto, ' + match.substr(5) + ')';
    109                            });
    110                assert_equals(win.getComputedStyle(win.test).getPropertyValue(props[i].check),
    111                              win.getComputedStyle(win.ref).getPropertyValue(props[i].check),
    112                              props[i].prop);
    113                if (t.shorthand && props[i].check_also) {
    114                    for (var j in props[i].check_also) {
    115                        assert_equals(win.getComputedStyle(win.test).getPropertyValue(props[i].check_also[j]),
    116                                      win.getComputedStyle(win.ref).getPropertyValue(props[i].check_also[j]),
    117                                      props[i].prop + ', checking ' + props[i].check_also[j]);
    118                    }
    119                }
    120            }, props[i].prop + ": " + t.input);
    121 
    122        }
    123    });
    124 
    125    if (quirks) {
    126        var other_tests = [
    127        {input:'background:1 1', prop:'background-position'},
    128        {input:'border-top:red solid 1', prop:'border-top-width'},
    129        {input:'border-right:red solid 1', prop:'border-right-width'},
    130        {input:'border-bottom:red solid 1', prop:'border-bottom-width'},
    131        {input:'border-left:red solid 1', prop:'border-left-width'},
    132        {input:'border:red solid 1', prop:'border-top-width'},
    133        {input:'font:normal normal normal 40 sans-serif', prop:'font-size'},
    134        {input:'outline:red solid 1', prop:'outline-width'},
    135        {input:'outline-width:1', prop:'outline-width'},
    136        ];
    137 
    138        var other_template = "#test{position:relative;outline-style:solid;{test}}" +
    139                             "#ref{outline-style:solid}";
    140 
    141        other_tests.forEach(function(t) {
    142            test(function() {
    143                win.style.textContent = other_template.replace('{test}', t.input);
    144                assert_equals(win.getComputedStyle(win.test).getPropertyValue(t.prop),
    145                              win.getComputedStyle(win.ref).getPropertyValue(t.prop),
    146                              'quirk was supported');
    147            }, 'Excluded property '+t.input);
    148        });
    149    }
    150 
    151    done();
    152 }