tor-browser

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

test_style_struct_copy_constructors.html (3076B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 -->
      5 <head>
      6  <title>Test for style struct copy constructors</title>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <script type="text/javascript" src="property_database.js"></script>
      9  <style type="text/css" id="stylesheet"></style>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <p id="display"><span id="one"></span><span id="two"></span><span id="parent"><span id="child"></span></span></p>
     14 <div id="content" style="display: none">
     15 
     16 <div id="testnode"><span id="element"></span></div>
     17 
     18  
     19 </div>
     20 <pre id="test">
     21 <script class="testbody" type="text/javascript">
     22 
     23 /** Test for style struct copy constructors */
     24 
     25 /**
     26 * XXX Why doesn't putting a bug in the nsStyleFont copy-constructor for
     27 * font-weight (initializing to normal) trigger a failure of this test?
     28 * It works for leaving -moz-image-region uninitialized (both halves),
     29 * overwriting text-decoration (only the first half, since it's not
     30 * inherited), and leaving visibility uninitialized (only the second
     31 * half; passes the first half ok).
     32 */
     33 
     34 var gElementOne = document.getElementById("one");
     35 var gElementTwo = document.getElementById("two");
     36 var gElementParent = document.getElementById("parent");
     37 var gElementChild = document.getElementById("child");
     38 var gStyleSheet = document.getElementById("stylesheet").sheet;
     39 var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#one, #two, #parent {}", gStyleSheet.cssRules.length)];
     40 var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#two, #child {}", gStyleSheet.cssRules.length)];
     41 
     42 /** Test using aStartStruct */
     43 
     44 for (var prop in gCSSProperties) {
     45  var info = gCSSProperties[prop];
     46  if (!("subproperties" in info)) {
     47    gRule1.style.setProperty(prop, info.other_values[0], "");
     48    gRule2.style.setProperty(prop, info.other_values[0], "");
     49  }
     50 }
     51 
     52 for (var prop in gCSSProperties) {
     53  var info = gCSSProperties[prop];
     54  if (!("subproperties" in info)) {
     55    gRule2.style.removeProperty(prop);
     56 
     57    var one = getComputedStyle(gElementOne, "").getPropertyValue(prop);
     58    var two = getComputedStyle(gElementTwo, "").getPropertyValue(prop);
     59    is(two, one,
     60       "property '" + prop + "' was copy-constructed correctly (aStartStruct)");
     61 
     62    gRule2.style.setProperty(prop, info.other_values[0], "");
     63  }
     64 }
     65 
     66 /** Test using inheritance */
     67 
     68 // TODO(bug 1887221): Zoom right now doesn't apply to explicitly inherited
     69 // values, so remove it to get consistent results.
     70 gRule1.style.removeProperty("zoom");
     71 gRule2.style.removeProperty("zoom");
     72 
     73 for (var prop in gCSSProperties) {
     74  var info = gCSSProperties[prop];
     75  if (info.inherited && !("subproperties" in info)) {
     76    gRule2.style.removeProperty(prop);
     77 
     78    var parent = getComputedStyle(gElementParent, "").getPropertyValue(prop);
     79    var child = getComputedStyle(gElementChild, "").getPropertyValue(prop);
     80 
     81    is(child, parent,
     82       "property '" + prop + "' was copy-constructed correctly (inheritance)");
     83 
     84    gRule2.style.setProperty(prop, info.other_values[0], "");
     85  }
     86 }
     87 
     88 </script>
     89 </pre>
     90 </body>
     91 </html>