6
<title>Test for nsStyleStruct copy constructors</title>
7
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
8
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9
<script type="text/javascript" src="property_database.js"></script>
10
<style type="text/css" id="stylesheet"></style>
11
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
14
<p id="display"><span id="one"></span><span id="two"></span><span id="parent"><span id="child"></span></span></p>
15
<div id="content" style="display: none">
17
<div id="testnode"><span id="element"></span></div>
22
<script class="testbody" type="text/javascript">
24
/** Test for nsStyleStruct copy constructors **/
27
* XXX Why doesn't putting a bug in the nsStyleFont copy-constructor for
28
* font-weight (initializing to normal) trigger a failure of this test?
29
* It works for leaving -moz-image-region uninitialized (both halves),
30
* overwriting text-decoration (only the first half, since it's not
31
* inherited), and leaving visibility uninitialized (only the second
32
* half; passes the first half ok).
35
var gElementOne = document.getElementById("one");
36
var gElementTwo = document.getElementById("two");
37
var gElementParent = document.getElementById("parent");
38
var gElementChild = document.getElementById("child");
39
var gStyleSheet = document.getElementById("stylesheet").sheet;
40
var gRule1 = gStyleSheet.cssRules[gStyleSheet.insertRule("#one, #two, #parent {}", gStyleSheet.cssRules.length)];
41
var gRule2 = gStyleSheet.cssRules[gStyleSheet.insertRule("#two, #child {}", gStyleSheet.cssRules.length)];
43
/** Test using aStartStruct **/
45
for (var prop in gCSSProperties) {
46
var info = gCSSProperties[prop];
47
if (!("subproperties" in info)) {
48
gRule1.style.setProperty(prop, info.other_values[0], "");
49
gRule2.style.setProperty(prop, info.other_values[0], "");
53
for (var prop in gCSSProperties) {
54
var info = gCSSProperties[prop];
55
if (!("subproperties" in info)) {
56
gRule2.style.removeProperty(prop);
58
var one = getComputedStyle(gElementOne, "").getPropertyValue(prop);
59
var two = getComputedStyle(gElementTwo, "").getPropertyValue(prop);
61
"property '" + prop + "' was copy-constructed correctly (aStartStruct)");
63
gRule2.style.setProperty(prop, info.other_values[0], "");
67
/** Test using inheritance **/
68
for (var prop in gCSSProperties) {
69
var info = gCSSProperties[prop];
70
if (info.inherited && !("subproperties" in info)) {
71
gRule2.style.removeProperty(prop);
73
var parent = getComputedStyle(gElementParent, "").getPropertyValue(prop);
74
var child = getComputedStyle(gElementChild, "").getPropertyValue(prop);
77
"property '" + prop + "' was copy-constructed correctly (inheritance)");
79
gRule2.style.setProperty(prop, info.other_values[0], "");
83
for (var prop in gCSSProperties) {
84
var info = gCSSProperties[prop];
85
if (!("subproperties" in info)) {
86
gRule1.style.removeProperty(prop);
87
gRule2.style.removeProperty(prop);