layout/style/test/test_style_struct_copy_constructors.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/test/test_style_struct_copy_constructors.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +-->
     1.8 +<head>
     1.9 +  <title>Test for style struct copy constructors</title>
    1.10 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.11 +  <script type="text/javascript" src="property_database.js"></script>
    1.12 +  <style type="text/css" id="stylesheet"></style>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<p id="display"><span id="one"></span><span id="two"></span><span id="parent"><span id="child"></span></span></p>
    1.17 +<div id="content" style="display: none">
    1.18 +
    1.19 +<div id="testnode"><span id="element"></span></div>
    1.20 +
    1.21 +  
    1.22 +</div>
    1.23 +<pre id="test">
    1.24 +<script class="testbody" type="text/javascript">
    1.25 +
    1.26 +/** Test for style struct copy constructors **/
    1.27 +
    1.28 +/**
    1.29 + * XXX Why doesn't putting a bug in the nsStyleFont copy-constructor for
    1.30 + * font-weight (initializing to normal) trigger a failure of this test?
    1.31 + * It works for leaving -moz-image-region uninitialized (both halves),
    1.32 + * overwriting text-decoration (only the first half, since it's not
    1.33 + * inherited), and leaving visibility uninitialized (only the second
    1.34 + * half; passes the first half ok).
    1.35 + */
    1.36 +
    1.37 +var gElementOne = document.getElementById("one");
    1.38 +var gElementTwo = document.getElementById("two");
    1.39 +var gElementParent = document.getElementById("parent");
    1.40 +var gElementChild = document.getElementById("child");
    1.41 +var gStyleSheet = document.getElementById("stylesheet").sheet;
    1.42 +var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#one, #two, #parent {}", gStyleSheet.cssRules.length)];
    1.43 +var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#two, #child {}", gStyleSheet.cssRules.length)];
    1.44 +
    1.45 +/** Test using aStartStruct **/
    1.46 +
    1.47 +for (var prop in gCSSProperties) {
    1.48 +  var info = gCSSProperties[prop];
    1.49 +  if (!("subproperties" in info)) {
    1.50 +    gRule1.style.setProperty(prop, info.other_values[0], "");
    1.51 +    gRule2.style.setProperty(prop, info.other_values[0], "");
    1.52 +  }
    1.53 +}
    1.54 +
    1.55 +for (var prop in gCSSProperties) {
    1.56 +  var info = gCSSProperties[prop];
    1.57 +  if (!("subproperties" in info)) {
    1.58 +    gRule2.style.removeProperty(prop);
    1.59 +
    1.60 +    var one = getComputedStyle(gElementOne, "").getPropertyValue(prop);
    1.61 +    var two = getComputedStyle(gElementTwo, "").getPropertyValue(prop);
    1.62 +    is(two, one,
    1.63 +       "property '" + prop + "' was copy-constructed correctly (aStartStruct)");
    1.64 +
    1.65 +    gRule2.style.setProperty(prop, info.other_values[0], "");
    1.66 +  }
    1.67 +}
    1.68 +
    1.69 +/** Test using inheritance **/
    1.70 +for (var prop in gCSSProperties) {
    1.71 +  var info = gCSSProperties[prop];
    1.72 +  if (info.inherited && !("subproperties" in info)) {
    1.73 +    gRule2.style.removeProperty(prop);
    1.74 +
    1.75 +    var parent = getComputedStyle(gElementParent, "").getPropertyValue(prop);
    1.76 +    var child = getComputedStyle(gElementChild, "").getPropertyValue(prop);
    1.77 +
    1.78 +    is(child, parent,
    1.79 +       "property '" + prop + "' was copy-constructed correctly (inheritance)");
    1.80 +
    1.81 +    gRule2.style.setProperty(prop, info.other_values[0], "");
    1.82 +  }
    1.83 +}
    1.84 +
    1.85 +for (var prop in gCSSProperties) {
    1.86 +  var info = gCSSProperties[prop];
    1.87 +  if (!("subproperties" in info)) {
    1.88 +    gRule1.style.removeProperty(prop);
    1.89 +    gRule2.style.removeProperty(prop);
    1.90 +  }
    1.91 +}
    1.92 +
    1.93 +</script>
    1.94 +</pre>
    1.95 +</body>
    1.96 +</html>

mercurial