tor-browser

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

test_priority_preservation.html (5396B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for property priority preservation</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      7 </head>
      8 <body>
      9 <p id="display"></p>
     10 <div id="content" style="display: none">
     11  
     12 </div>
     13 <pre id="test">
     14 <script type="application/javascript">
     15 
     16 /**
     17 * Test that priorities are preserved correctly when setProperty is
     18 * called, and during declaration block expansion/compression when other
     19 * properties are manipulated.
     20 */
     21 
     22 var div = document.getElementById("content");
     23 var s = div.style;
     24 
     25 s.setProperty("text-decoration", "underline", "");
     26 is(s.getPropertyValue("text-decoration"), "underline",
     27   "text-decoration stored");
     28 is(s.getPropertyPriority("text-decoration"), "",
     29   "text-decoration priority stored");
     30 s.setProperty("z-index", "7", "important");
     31 is(s.getPropertyValue("z-index"), "7",
     32   "z-index stored");
     33 is(s.getPropertyPriority("z-index"), "important",
     34   "z-index priority stored");
     35 s.setProperty("z-index", "3", "");
     36 is(s.getPropertyValue("z-index"), "3",
     37   "z-index overridden by setting non-important");
     38 is(s.getPropertyPriority("z-index"), "",
     39   "z-index priority overridden by setting non-important");
     40 is(s.getPropertyValue("text-decoration"), "underline",
     41   "text-decoration still stored");
     42 is(s.getPropertyPriority("text-decoration"), "",
     43   "text-decoration priority still stored");
     44 s.setProperty("text-decoration", "overline", "");
     45 is(s.getPropertyValue("text-decoration"), "overline",
     46   "text-decoration stored");
     47 is(s.getPropertyPriority("text-decoration"), "",
     48   "text-decoration priority stored");
     49 is(s.getPropertyValue("z-index"), "3",
     50   "z-index still stored");
     51 is(s.getPropertyPriority("z-index"), "",
     52   "z-index priority still stored");
     53 s.setProperty("text-decoration", "line-through", "important");
     54 is(s.getPropertyValue("text-decoration"), "line-through",
     55   "text-decoration stored at new priority");
     56 is(s.getPropertyPriority("text-decoration"), "important",
     57   "text-decoration priority overridden");
     58 is(s.getPropertyValue("z-index"), "3",
     59   "z-index still stored");
     60 is(s.getPropertyPriority("z-index"), "",
     61   "z-index priority still stored");
     62 
     63  // also test setting a shorthand
     64 s.setProperty("font", "italic bold 12px/30px serif", "important");
     65 is(s.getPropertyValue("font-style"), "italic", "font-style stored");
     66 is(s.getPropertyPriority("font-style"), "important",
     67   "font-style priority stored");
     68 is(s.getPropertyValue("font-weight"), "bold", "font-weight stored");
     69 is(s.getPropertyPriority("font-weight"), "important",
     70   "font-weight priority stored");
     71 is(s.getPropertyValue("font-size"), "12px", "font-size stored");
     72 is(s.getPropertyPriority("font-size"), "important",
     73   "font-size priority stored");
     74 is(s.getPropertyValue("line-height"), "30px", "line-height stored");
     75 is(s.getPropertyPriority("line-height"), "important",
     76   "line-height priority stored");
     77 is(s.getPropertyValue("font-family"), "serif", "font-family stored");
     78 is(s.getPropertyPriority("font-family"), "important",
     79   "font-family priority stored");
     80 
     81 is(s.getPropertyValue("text-decoration"), "line-through",
     82   "text-decoration still stored");
     83 is(s.getPropertyPriority("text-decoration"), "important",
     84   "text-decoration priority still stored");
     85 is(s.getPropertyValue("z-index"), "3",
     86   "z-index still stored");
     87 is(s.getPropertyPriority("z-index"), "",
     88   "z-index priority still stored");
     89 
     90  // and overriding one element of that shorthand with some longhand
     91  // test omitting the third argument to setProperty too (bug 655478)
     92 s.setProperty("font-style", "normal");
     93 
     94 is(s.getPropertyValue("font-style"), "normal", "font-style overridden");
     95 is(s.getPropertyPriority("font-style"), "", "font-style priority overridden");
     96 
     97 is(s.getPropertyValue("font-weight"), "bold", "font-weight unchanged");
     98 is(s.getPropertyPriority("font-weight"), "important",
     99   "font-weight priority unchanged");
    100 is(s.getPropertyValue("font-size"), "12px", "font-size unchanged");
    101 is(s.getPropertyPriority("font-size"), "important",
    102   "font-size priority unchanged");
    103 is(s.getPropertyValue("line-height"), "30px", "line-height unchanged");
    104 is(s.getPropertyPriority("line-height"), "important",
    105   "line-height priority unchanged");
    106 is(s.getPropertyValue("font-family"), "serif", "font-family unchanged");
    107 is(s.getPropertyPriority("font-family"), "important",
    108   "font-family priority unchanged");
    109 
    110 is(s.getPropertyValue("text-decoration"), "line-through",
    111   "text-decoration still stored");
    112 is(s.getPropertyPriority("text-decoration"), "important",
    113   "text-decoration priority still stored");
    114 is(s.getPropertyValue("z-index"), "3",
    115   "z-index still stored");
    116 is(s.getPropertyPriority("z-index"), "",
    117   "z-index priority still stored");
    118 
    119 s.setProperty("border-radius", "2em", "");
    120 is(s.getPropertyValue("border-radius"), "2em",
    121   "border-radius serialization 1")
    122 
    123 s.setProperty("border-top-left-radius", "3em 4em", "");
    124 is(s.getPropertyValue("border-radius"),
    125   "3em 2em 2em / 4em 2em 2em",
    126   "border-radius serialization 2");
    127 
    128 s.setProperty("border-radius", "2em / 3em", "");
    129 is(s.getPropertyValue("border-radius"),
    130   "2em / 3em",
    131   "border-radius serialization 3")
    132 
    133 s.setProperty("border-top-left-radius", "4em", "");
    134 is(s.getPropertyValue("border-radius"),
    135   "4em 2em 2em / 4em 3em 3em",
    136   "border-radius serialization 3");
    137 
    138 </script>
    139 </pre>
    140 </body>
    141 </html>