tor-browser

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

test_compute_data_with_start_struct.html (3163B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for correct handling of aStartStruct parameter to nsRuleNode::Compute*Data</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script type="text/javascript" src="property_database.js"></script>
      7  <style type="text/css" id="stylesheet"></style>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=216456">Mozilla Bug 216456</a>
     12 <p id="display">
     13  <span id="base"></span>
     14  <span id="test"></span>
     15 </p>
     16 <div id="content" style="display: none">
     17  
     18 </div>
     19 <pre id="test">
     20 <script class="testbody" type="text/javascript">
     21 
     22 /**
     23 * The purpose of this test was to test that in the old style system
     24 * the nsRuleNode::Compute*Data functions were written correctly.
     25 * In particular, in these functions, when the specified value of a
     26 * property had unit eCSSUnit_Null, touching the computed data is
     27 * forbidden. This is because we sometimes would stop walking up the
     28 * rule tree when we find computed data for an initial subsequence of
     29 * our rules (i.e., an ancestor rule node) that we can use as a starting
     30 * point (aStartStruct) for the computation for the current rule node.
     31 *
     32 * However, we don't cache style structs in the rule tree in the current
     33 * style system code, and property cascading no longer relies on hand
     34 * written functions, so this particular failure mode isn't as likely to
     35 * happen.
     36 */
     37 
     38 var gStyleSheet = document.getElementById("stylesheet").sheet;
     39 var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#base, #test {}", gStyleSheet.cssRules.length)];
     40 var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#test {}", gStyleSheet.cssRules.length)];
     41 
     42 var gBase = getComputedStyle(document.getElementById("base"), "");
     43 var gTest = getComputedStyle(document.getElementById("test"), "");
     44 
     45 function test_property(prop, lower_set, higher_set) {
     46  var info = gCSSProperties[prop];
     47  if (info.subproperties || info.logical)
     48    return;
     49 
     50  gRule1.style.setProperty(prop, info[lower_set][0]);
     51  gRule2.style.setProperty(prop, info[higher_set][0]);
     52 
     53  if ("prerequisites" in info) {
     54    for (var prereq in info.prerequisites) {
     55      gRule2.style.setProperty(prereq, info.prerequisites[prereq], "");
     56    }
     57  }
     58 
     59  gBase.getPropertyValue(prop);
     60  var higher_set_val = gTest.getPropertyValue(prop);
     61  gRule2.style.setProperty(prop, info[lower_set][0], "");
     62  var lower_set_val = gTest.getPropertyValue(prop);
     63  isnot(higher_set_val, lower_set_val, "initial and other values of " + prop + " are different");
     64 
     65  gRule2.style.removeProperty(prop);
     66  is(gTest.getPropertyValue(prop), lower_set_val, prop + " is not touched when its value comes from aStartStruct");
     67 
     68  gRule1.style.removeProperty(prop);
     69  if ("prerequisites" in info) {
     70    for (var prereq in info.prerequisites) {
     71      gRule2.style.removeProperty(prereq);
     72    }
     73  }
     74 }
     75 
     76 function round(lower_set, higher_set) {
     77  for (var prop in gCSSProperties)
     78    test_property(prop, lower_set, higher_set);
     79 }
     80 
     81 round("other_values", "initial_values");
     82 round("initial_values", "other_values");
     83 
     84 </script>
     85 </pre>
     86 </body>
     87 </html>