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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
<html>
<body>
<div id=t></div>
<div id=console></div>
<script>
function print(message, color)
{
var paragraph = document.createElement("div");
paragraph.appendChild(document.createTextNode(message));
paragraph.style.fontFamily = "monospace";
if (color)
paragraph.style.color = color;
document.getElementById("console").appendChild(paragraph);
}
function run(a)
{
print(a);
try {
eval(a);
} catch(e) {
print(e);
}
}
function shouldBe(a, b)
{
var evalA;
try {
evalA = eval(a);
} catch(e) {
evalA = e;
}
if (evalA == b)
print("PASS: " + a + " should be " + b + " and is.", "green");
else
print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
}
if (window.testRunner)
testRunner.dumpAsText();
var t = document.getElementById('t');
run("t.style.backgroundPositionX = '5%';");
shouldBe("t.style.backgroundPosition", "");
shouldBe("t.style.backgroundPositionX", "5%");
shouldBe("t.style.backgroundPositionY", "");
shouldBe("t.style.cssText", "background-position-x: 5%;");
shouldBe("t.getAttribute('style')", "background-position-x: 5%;");
run("t.style.backgroundPositionY = '5%';");
shouldBe("t.style.backgroundPosition", "5% 5%");
shouldBe("t.style.backgroundPositionX", "5%");
shouldBe("t.style.backgroundPositionY", "5%");
shouldBe("t.style.cssText", "background-position: 5% 5%;");
shouldBe("t.getAttribute('style')", "background-position: 5% 5%;");
run("t.style.backgroundPosition = '10% 10%';");
shouldBe("t.style.backgroundPosition", "10% 10%");
shouldBe("t.style.backgroundPositionX", "10%");
shouldBe("t.style.backgroundPositionY", "10%");
shouldBe("t.style.cssText", "background-position: 10% 10%;");
shouldBe("t.getAttribute('style')", "background-position: 10% 10%;");
run("t.style.backgroundPositionX = '20%';");
shouldBe("t.style.backgroundPosition", "20% 10%");
shouldBe("t.style.backgroundPositionX", "20%");
shouldBe("t.style.backgroundPositionY", "10%");
shouldBe("t.style.cssText", "background-position: 20% 10%;");
shouldBe("t.getAttribute('style')", "background-position: 20% 10%;");
run("t.style.backgroundPositionY = '20%';");
shouldBe("t.style.backgroundPosition", "20% 20%");
shouldBe("t.style.backgroundPositionX", "20%");
shouldBe("t.style.backgroundPositionY", "20%");
shouldBe("t.style.cssText", "background-position: 20% 20%;");
shouldBe("t.getAttribute('style')", "background-position: 20% 20%;");
run("t.setAttribute('style', 'background-position: 30% 30%');");
shouldBe("t.style.backgroundPosition", "30% 30%");
shouldBe("t.style.backgroundPositionX", "30%");
shouldBe("t.style.backgroundPositionY", "30%");
shouldBe("t.style.cssText", "background-position: 30% 30%;");
shouldBe("t.getAttribute('style')", "background-position: 30% 30%");
run("t.style.backgroundPositionX = '20%';");
shouldBe("t.style.backgroundPosition", "20% 30%");
shouldBe("t.style.backgroundPositionX", "20%");
shouldBe("t.style.backgroundPositionY", "30%");
shouldBe("t.style.cssText", "background-position: 20% 30%;");
shouldBe("t.getAttribute('style')", "background-position: 20% 30%;");
run("t.style.backgroundPositionY = '20%';");
shouldBe("t.style.backgroundPosition", "20% 20%");
shouldBe("t.style.backgroundPositionX", "20%");
shouldBe("t.style.backgroundPositionY", "20%");
shouldBe("t.style.cssText", "background-position: 20% 20%;");
shouldBe("t.getAttribute('style')", "background-position: 20% 20%;");
run("t.setAttribute('style', 'background-position: 60% 60% !important;');");
shouldBe("t.style.backgroundPosition", "60% 60%");
shouldBe("t.style.backgroundPositionX", "60%");
shouldBe("t.style.backgroundPositionY", "60%");
shouldBe("t.style.cssText", "background-position: 60% 60% !important;");
run("t.setAttribute('style', 'background-position: 10px 15px, 20px 25px, 30px 35px');");
shouldBe("t.style.backgroundPosition", "10px 15px, 20px 25px, 30px 35px");
shouldBe("t.style.backgroundPositionX", "10px, 20px, 30px");
shouldBe("t.style.backgroundPositionY", "15px, 25px, 35px");
shouldBe("t.style.cssText", "background-position: 10px 15px, 20px 25px, 30px 35px;");
run("t.setAttribute('style', 'background: url(about:blank) 80% 80%;');");
run("t.style.backgroundPositionY = '50px'");
print("style.cssText =");
print(t.style.cssText);
</script>
|