DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (a81015259a98)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
  <title>Test for style struct copy constructors</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="property_database.js"></script>
  <style type="text/css" id="stylesheet"></style>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"><span id="one"></span><span id="two"></span><span id="parent"><span id="child"></span></span></p>
<div id="content" style="display: none">

<div id="testnode"><span id="element"></span></div>

  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for style struct copy constructors **/

/**
 * XXX Why doesn't putting a bug in the nsStyleFont copy-constructor for
 * font-weight (initializing to normal) trigger a failure of this test?
 * It works for leaving -moz-image-region uninitialized (both halves),
 * overwriting text-decoration (only the first half, since it's not
 * inherited), and leaving visibility uninitialized (only the second
 * half; passes the first half ok).
 */

var gElementOne = document.getElementById("one");
var gElementTwo = document.getElementById("two");
var gElementParent = document.getElementById("parent");
var gElementChild = document.getElementById("child");
var gStyleSheet = document.getElementById("stylesheet").sheet;
var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#one, #two, #parent {}", gStyleSheet.cssRules.length)];
var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#two, #child {}", gStyleSheet.cssRules.length)];

/** Test using aStartStruct **/

for (var prop in gCSSProperties) {
  var info = gCSSProperties[prop];
  if (!("subproperties" in info)) {
    gRule1.style.setProperty(prop, info.other_values[0], "");
    gRule2.style.setProperty(prop, info.other_values[0], "");
  }
}

for (var prop in gCSSProperties) {
  var info = gCSSProperties[prop];
  if (!("subproperties" in info)) {
    gRule2.style.removeProperty(prop);

    var one = getComputedStyle(gElementOne, "").getPropertyValue(prop);
    var two = getComputedStyle(gElementTwo, "").getPropertyValue(prop);
    is(two, one,
       "property '" + prop + "' was copy-constructed correctly (aStartStruct)");

    gRule2.style.setProperty(prop, info.other_values[0], "");
  }
}

/** Test using inheritance **/
for (var prop in gCSSProperties) {
  var info = gCSSProperties[prop];
  if (info.inherited && !("subproperties" in info)) {
    gRule2.style.removeProperty(prop);

    var parent = getComputedStyle(gElementParent, "").getPropertyValue(prop);
    var child = getComputedStyle(gElementChild, "").getPropertyValue(prop);

    is(child, parent,
       "property '" + prop + "' was copy-constructed correctly (inheritance)");

    gRule2.style.setProperty(prop, info.other_values[0], "");
  }
}

for (var prop in gCSSProperties) {
  var info = gCSSProperties[prop];
  if (!("subproperties" in info)) {
    gRule1.style.removeProperty(prop);
    gRule2.style.removeProperty(prop);
  }
}

</script>
</pre>
</body>
</html>