tor-browser

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

variable-substitution-shorthands.html (7628B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <title>Test shorthand variable substitution</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7 
      8    <meta rel="author" title="Kevin Babbitt">
      9    <meta rel="author" title="Greg Whitworth">
     10    <link rel="author" title="Microsoft Corporation" href="http://microsoft.com" />
     11    <link rel="help" href="http://www.w3.org/TR/css-variables-1/#variables-in-shorthands">
     12 
     13    <style>
     14        #target7parent > #target7 {
     15            margin: var(--invalid); /* invalid at compute time */
     16        }
     17 
     18        #target7 {
     19            margin: 77px;
     20        }
     21    </style>
     22 </head>
     23 <body>
     24 
     25 <div id="target1" style="--prop: 8px; margin: var(--prop); margin-top: 10px"></div>
     26 <div id="target2" style="--prop: 8px; margin: var(--prop) !important; margin-top: 10px"></div>
     27 <div id="target3" style="--prop: 8px; margin-top: 10px !important; margin: var(--prop);"></div>
     28 <div id="target4" style="--prop: 3px 5px 7px 11px; margin: var(--prop);"></div>
     29 <div id="target5" style="--border1: 5px solid rgb(0, 0, 0); --border2: 3px dotted red; border-left: var(--border2); border: var(--border1);"></div>
     30 <div id="target6" style="--border1: 5px solid rgb(0, 0, 0); --border2: 3px dotted red; border: var(--border1); border-left: var(--border2);"></div>
     31 <div id="target7parent">
     32    <div id="target7"></div>
     33 </div>
     34 <div id="target8" style="transition: opacity var(--duration); --duration: 2s"></div>
     35 <div id="target9" style="border-style: dashed; --border1: 5px solid rgb(0, 0, 0); --border2: 3px dotted red; --width: 1px; border-left: var(--border1); border-width: var(--width);"></div>
     36 <script type="text/javascript">
     37    "use strict";
     38    // Set a value via CSSOM to test precedence over markup values
     39    document.getElementById("target9").style.borderLeft = "var(--border2)";
     40 </script>
     41 
     42 <script type="text/javascript">
     43    "use strict";
     44 
     45    var testcases = [
     46        { element: "target1",   propertyName: "margin-left",    expectedPropertyValue: "8px" },
     47        { element: "target1",   propertyName: "margin-top",     expectedPropertyValue: "10px" },
     48        { element: "target1",   propertyName: "margin-right",   expectedPropertyValue: "8px" },
     49        { element: "target1",   propertyName: "margin-bottom",  expectedPropertyValue: "8px" },
     50 
     51        { element: "target2",   propertyName: "margin-left",    expectedPropertyValue: "8px" },
     52        { element: "target2",   propertyName: "margin-top",     expectedPropertyValue: "8px" },
     53        { element: "target2",   propertyName: "margin-right",   expectedPropertyValue: "8px" },
     54        { element: "target2",   propertyName: "margin-bottom",  expectedPropertyValue: "8px" },
     55 
     56        { element: "target3",   propertyName: "margin-left",    expectedPropertyValue: "8px" },
     57        { element: "target3",   propertyName: "margin-top",     expectedPropertyValue: "10px" },
     58        { element: "target3",   propertyName: "margin-right",   expectedPropertyValue: "8px" },
     59        { element: "target3",   propertyName: "margin-bottom",  expectedPropertyValue: "8px" },
     60 
     61        { element: "target4",   propertyName: "margin-left",    expectedPropertyValue: "11px" },
     62        { element: "target4",   propertyName: "margin-top",     expectedPropertyValue: "3px" },
     63        { element: "target4",   propertyName: "margin-right",   expectedPropertyValue: "5px" },
     64        { element: "target4",   propertyName: "margin-bottom",  expectedPropertyValue: "7px" },
     65 
     66        { element: "target5",   propertyName: "border-top-width",       expectedPropertyValue: "5px" },
     67        { element: "target5",   propertyName: "border-top-style",       expectedPropertyValue: "solid" },
     68        { element: "target5",   propertyName: "border-top-color",       expectedPropertyValue: "rgb(0, 0, 0)" },
     69        { element: "target5",   propertyName: "border-right-width",     expectedPropertyValue: "5px" },
     70        { element: "target5",   propertyName: "border-right-style",     expectedPropertyValue: "solid" },
     71        { element: "target5",   propertyName: "border-right-color",     expectedPropertyValue: "rgb(0, 0, 0)" },
     72        { element: "target5",   propertyName: "border-bottom-width",    expectedPropertyValue: "5px" },
     73        { element: "target5",   propertyName: "border-bottom-style",    expectedPropertyValue: "solid" },
     74        { element: "target5",   propertyName: "border-bottom-color",    expectedPropertyValue: "rgb(0, 0, 0)" },
     75        { element: "target5",   propertyName: "border-left-width",      expectedPropertyValue: "5px" },
     76        { element: "target5",   propertyName: "border-left-style",      expectedPropertyValue: "solid" },
     77        { element: "target5",   propertyName: "border-left-color",      expectedPropertyValue: "rgb(0, 0, 0)" },
     78 
     79        { element: "target6",   propertyName: "border-top-width",       expectedPropertyValue: "5px" },
     80        { element: "target6",   propertyName: "border-top-style",       expectedPropertyValue: "solid" },
     81        { element: "target6",   propertyName: "border-top-color",       expectedPropertyValue: "rgb(0, 0, 0)" },
     82        { element: "target6",   propertyName: "border-right-width",     expectedPropertyValue: "5px" },
     83        { element: "target6",   propertyName: "border-right-style",     expectedPropertyValue: "solid" },
     84        { element: "target6",   propertyName: "border-right-color",     expectedPropertyValue: "rgb(0, 0, 0)" },
     85        { element: "target6",   propertyName: "border-bottom-width",    expectedPropertyValue: "5px" },
     86        { element: "target6",   propertyName: "border-bottom-style",    expectedPropertyValue: "solid" },
     87        { element: "target6",   propertyName: "border-bottom-color",    expectedPropertyValue: "rgb(0, 0, 0)" },
     88        { element: "target6",   propertyName: "border-left-width",      expectedPropertyValue: "3px" },
     89        { element: "target6",   propertyName: "border-left-style",      expectedPropertyValue: "dotted" },
     90        { element: "target6",   propertyName: "border-left-color",      expectedPropertyValue: "rgb(255, 0, 0)" },
     91 
     92        { element: "target7",   propertyName: "margin-left",    expectedPropertyValue: "0px" },
     93        { element: "target7",   propertyName: "margin-top",     expectedPropertyValue: "0px" },
     94        { element: "target7",   propertyName: "margin-right",   expectedPropertyValue: "0px" },
     95        { element: "target7",   propertyName: "margin-bottom",  expectedPropertyValue: "0px" },
     96 
     97        { element: "target8",   propertyName: "transition-duration",    expectedPropertyValue: "2s" },
     98 
     99        { element: "target9",   propertyName: "border-left-width",      expectedPropertyValue: "3px" },
    100        { element: "target9",   propertyName: "border-left-style",      expectedPropertyValue: "dotted" },
    101        { element: "target9",   propertyName: "border-left-color",      expectedPropertyValue: "rgb(255, 0, 0)" },
    102        { element: "target9",   propertyName: "border-top-width",       expectedPropertyValue: "1px" },
    103        { element: "target9",   propertyName: "border-right-width",     expectedPropertyValue: "1px" },
    104        { element: "target9",   propertyName: "border-bottom-width",    expectedPropertyValue: "1px" },
    105    ];
    106 
    107    testcases.forEach(function (testcase) {
    108        test( function () {
    109            var div = document.getElementById(testcase.element);
    110            var actualPropertyValue = window.getComputedStyle(div).getPropertyValue(testcase.propertyName);
    111            assert_equals(actualPropertyValue, testcase.expectedPropertyValue);
    112        }, testcase.element + " " + testcase.propertyName);
    113    });
    114 </script>
    115 
    116 </body>
    117 </html>