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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
<!DOCTYPE html>
<html>
<head>
<title>Geometry Interfaces: DOMRect</title>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
debug("# DOMRect()");
var rect = new DOMRect();
shouldBe("rect.x", "0");
shouldBe("rect.y", "0");
shouldBe("rect.width", "0");
shouldBe("rect.height", "0");
shouldBe("rect.top", "0");
shouldBe("rect.right", "0");
shouldBe("rect.bottom", "0");
shouldBe("rect.left", "0");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
debug("# DOMRect(10)");
rect = new DOMRect(10);
shouldBe("rect.x", "10");
shouldBe("rect.y", "0");
shouldBe("rect.width", "0");
shouldBe("rect.height", "0");
shouldBe("rect.top", "0");
shouldBe("rect.right", "10");
shouldBe("rect.bottom", "0");
shouldBe("rect.left", "10");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
debug("# DOMRect(10, 20)");
rect = new DOMRect(10, 20);
shouldBe("rect.x", "10");
shouldBe("rect.y", "20");
shouldBe("rect.width", "0");
shouldBe("rect.height", "0");
shouldBe("rect.top", "20");
shouldBe("rect.right", "10");
shouldBe("rect.bottom", "20");
shouldBe("rect.left", "10");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
debug("# DOMRect(10, 20, 80)");
rect = new DOMRect(10, 20, 80);
shouldBe("rect.x", "10");
shouldBe("rect.y", "20");
shouldBe("rect.width", "80");
shouldBe("rect.height", "0");
shouldBe("rect.top", "20");
shouldBe("rect.right", "90");
shouldBe("rect.bottom", "20");
shouldBe("rect.left", "10");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
debug("# DOMRect(10, 20, 80, 50)");
rect = new DOMRect(10, 20, 80, 50);
shouldBe("rect.x", "10");
shouldBe("rect.y", "20");
shouldBe("rect.width", "80");
shouldBe("rect.height", "50");
shouldBe("rect.top", "20");
shouldBe("rect.right", "90");
shouldBe("rect.bottom", "70");
shouldBe("rect.left", "10");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
debug("# DOMRect setter");
rect.x = 30;
shouldBe("rect.x", "30");
shouldBe("rect.left", "30");
shouldBe("rect.width", "80");
shouldBe("rect.right", "110");
rect.y = -10;
shouldBe("rect.y", "-10");
shouldBe("rect.top", "-10");
shouldBe("rect.height", "50");
shouldBe("rect.bottom", "40");
rect.width = 20;
shouldBe("rect.x", "30");
shouldBe("rect.left", "30");
shouldBe("rect.width", "20");
shouldBe("rect.right", "50");
rect.height = 40;
shouldBe("rect.y", "-10");
shouldBe("rect.top", "-10");
shouldBe("rect.height", "40");
shouldBe("rect.bottom", "30");
debug("");
debug("# DOMRect(10, 20, -80, -50) negative width and height");
rect = new DOMRect(10, 20, -80, -50);
shouldBe("rect.x", "10");
shouldBe("rect.y", "20");
shouldBe("rect.width", "-80");
shouldBe("rect.height", "-50");
shouldBe("rect.top", "-30");
shouldBe("rect.right", "10");
shouldBe("rect.bottom", "20");
shouldBe("rect.left", "-70");
shouldBe("rect.top", "rect.y + rect.height");
shouldBe("rect.right", "rect.x");
shouldBe("rect.bottom", "rect.y");
shouldBe("rect.left", "rect.x + rect.width");
debug("");
debug("# DOMRectReadOnly(10, 20, 80, 50)");
rect = new DOMRectReadOnly(10, 20, 80, 50);
shouldBe("rect.x", "10");
shouldBe("rect.y", "20");
shouldBe("rect.width", "80");
shouldBe("rect.height", "50");
shouldBe("rect.top", "20");
shouldBe("rect.right", "90");
shouldBe("rect.bottom", "70");
shouldBe("rect.left", "10");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
debug("# DOMRectReadOnly readonly test");
rect.x = 40;
rect.y = 90;
rect.width = 200;
rect.height = 200;
shouldBe("rect.x", "10");
shouldBe("rect.y", "20");
shouldBe("rect.width", "80");
shouldBe("rect.height", "50");
shouldBe("rect.top", "20");
shouldBe("rect.right", "90");
shouldBe("rect.bottom", "70");
shouldBe("rect.left", "10");
shouldBe("rect.top", "rect.y");
shouldBe("rect.right", "rect.x + rect.width");
shouldBe("rect.bottom", "rect.y + rect.height");
shouldBe("rect.left", "rect.x");
debug("");
</script>
</body>
</html>
|