layout/style/test/test_style_struct_copy_constructors.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 -->
     5 <head>
     6   <title>Test for style struct copy constructors</title>
     7   <script type="text/javascript" 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">
    16 <div id="testnode"><span id="element"></span></div>
    19 </div>
    20 <pre id="test">
    21 <script class="testbody" type="text/javascript">
    23 /** Test for style struct copy constructors **/
    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  */
    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)];
    42 /** Test using aStartStruct **/
    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 }
    52 for (var prop in gCSSProperties) {
    53   var info = gCSSProperties[prop];
    54   if (!("subproperties" in info)) {
    55     gRule2.style.removeProperty(prop);
    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)");
    62     gRule2.style.setProperty(prop, info.other_values[0], "");
    63   }
    64 }
    66 /** Test using inheritance **/
    67 for (var prop in gCSSProperties) {
    68   var info = gCSSProperties[prop];
    69   if (info.inherited && !("subproperties" in info)) {
    70     gRule2.style.removeProperty(prop);
    72     var parent = getComputedStyle(gElementParent, "").getPropertyValue(prop);
    73     var child = getComputedStyle(gElementChild, "").getPropertyValue(prop);
    75     is(child, parent,
    76        "property '" + prop + "' was copy-constructed correctly (inheritance)");
    78     gRule2.style.setProperty(prop, info.other_values[0], "");
    79   }
    80 }
    82 for (var prop in gCSSProperties) {
    83   var info = gCSSProperties[prop];
    84   if (!("subproperties" in info)) {
    85     gRule1.style.removeProperty(prop);
    86     gRule2.style.removeProperty(prop);
    87   }
    88 }
    90 </script>
    91 </pre>
    92 </body>
    93 </html>

mercurial