Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / geometry-interfaces-dom-rect.html
blobf02fb4435d5c0fa5dc3ae2953d71cb0dcee3b1e3
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Geometry Interfaces: DOMRect</title>
5 <script src="../../resources/js-test.js"></script>
6 </head>
7 <body>
8 <script>
10 debug("# DOMRect()");
11 var rect = new DOMRect();
12 shouldBe("rect.x", "0");
13 shouldBe("rect.y", "0");
14 shouldBe("rect.width", "0");
15 shouldBe("rect.height", "0");
16 shouldBe("rect.top", "0");
17 shouldBe("rect.right", "0");
18 shouldBe("rect.bottom", "0");
19 shouldBe("rect.left", "0");
20 shouldBe("rect.top", "rect.y");
21 shouldBe("rect.right", "rect.x + rect.width");
22 shouldBe("rect.bottom", "rect.y + rect.height");
23 shouldBe("rect.left", "rect.x");
24 debug("");
26 debug("# DOMRect(10)");
27 rect = new DOMRect(10);
28 shouldBe("rect.x", "10");
29 shouldBe("rect.y", "0");
30 shouldBe("rect.width", "0");
31 shouldBe("rect.height", "0");
32 shouldBe("rect.top", "0");
33 shouldBe("rect.right", "10");
34 shouldBe("rect.bottom", "0");
35 shouldBe("rect.left", "10");
36 shouldBe("rect.top", "rect.y");
37 shouldBe("rect.right", "rect.x + rect.width");
38 shouldBe("rect.bottom", "rect.y + rect.height");
39 shouldBe("rect.left", "rect.x");
40 debug("");
42 debug("# DOMRect(10, 20)");
43 rect = new DOMRect(10, 20);
44 shouldBe("rect.x", "10");
45 shouldBe("rect.y", "20");
46 shouldBe("rect.width", "0");
47 shouldBe("rect.height", "0");
48 shouldBe("rect.top", "20");
49 shouldBe("rect.right", "10");
50 shouldBe("rect.bottom", "20");
51 shouldBe("rect.left", "10");
52 shouldBe("rect.top", "rect.y");
53 shouldBe("rect.right", "rect.x + rect.width");
54 shouldBe("rect.bottom", "rect.y + rect.height");
55 shouldBe("rect.left", "rect.x");
56 debug("");
58 debug("# DOMRect(10, 20, 80)");
59 rect = new DOMRect(10, 20, 80);
60 shouldBe("rect.x", "10");
61 shouldBe("rect.y", "20");
62 shouldBe("rect.width", "80");
63 shouldBe("rect.height", "0");
64 shouldBe("rect.top", "20");
65 shouldBe("rect.right", "90");
66 shouldBe("rect.bottom", "20");
67 shouldBe("rect.left", "10");
68 shouldBe("rect.top", "rect.y");
69 shouldBe("rect.right", "rect.x + rect.width");
70 shouldBe("rect.bottom", "rect.y + rect.height");
71 shouldBe("rect.left", "rect.x");
72 debug("");
74 debug("# DOMRect(10, 20, 80, 50)");
75 rect = new DOMRect(10, 20, 80, 50);
76 shouldBe("rect.x", "10");
77 shouldBe("rect.y", "20");
78 shouldBe("rect.width", "80");
79 shouldBe("rect.height", "50");
80 shouldBe("rect.top", "20");
81 shouldBe("rect.right", "90");
82 shouldBe("rect.bottom", "70");
83 shouldBe("rect.left", "10");
84 shouldBe("rect.top", "rect.y");
85 shouldBe("rect.right", "rect.x + rect.width");
86 shouldBe("rect.bottom", "rect.y + rect.height");
87 shouldBe("rect.left", "rect.x");
88 debug("");
90 debug("# DOMRect setter");
91 rect.x = 30;
92 shouldBe("rect.x", "30");
93 shouldBe("rect.left", "30");
94 shouldBe("rect.width", "80");
95 shouldBe("rect.right", "110");
96 rect.y = -10;
97 shouldBe("rect.y", "-10");
98 shouldBe("rect.top", "-10");
99 shouldBe("rect.height", "50");
100 shouldBe("rect.bottom", "40");
101 rect.width = 20;
102 shouldBe("rect.x", "30");
103 shouldBe("rect.left", "30");
104 shouldBe("rect.width", "20");
105 shouldBe("rect.right", "50");
106 rect.height = 40;
107 shouldBe("rect.y", "-10");
108 shouldBe("rect.top", "-10");
109 shouldBe("rect.height", "40");
110 shouldBe("rect.bottom", "30");
111 debug("");
113 debug("# DOMRect(10, 20, -80, -50) negative width and height");
114 rect = new DOMRect(10, 20, -80, -50);
115 shouldBe("rect.x", "10");
116 shouldBe("rect.y", "20");
117 shouldBe("rect.width", "-80");
118 shouldBe("rect.height", "-50");
119 shouldBe("rect.top", "-30");
120 shouldBe("rect.right", "10");
121 shouldBe("rect.bottom", "20");
122 shouldBe("rect.left", "-70");
123 shouldBe("rect.top", "rect.y + rect.height");
124 shouldBe("rect.right", "rect.x");
125 shouldBe("rect.bottom", "rect.y");
126 shouldBe("rect.left", "rect.x + rect.width");
127 debug("");
129 debug("# DOMRectReadOnly(10, 20, 80, 50)");
130 rect = new DOMRectReadOnly(10, 20, 80, 50);
131 shouldBe("rect.x", "10");
132 shouldBe("rect.y", "20");
133 shouldBe("rect.width", "80");
134 shouldBe("rect.height", "50");
135 shouldBe("rect.top", "20");
136 shouldBe("rect.right", "90");
137 shouldBe("rect.bottom", "70");
138 shouldBe("rect.left", "10");
139 shouldBe("rect.top", "rect.y");
140 shouldBe("rect.right", "rect.x + rect.width");
141 shouldBe("rect.bottom", "rect.y + rect.height");
142 shouldBe("rect.left", "rect.x");
143 debug("");
145 debug("# DOMRectReadOnly readonly test");
146 rect.x = 40;
147 rect.y = 90;
148 rect.width = 200;
149 rect.height = 200;
150 shouldBe("rect.x", "10");
151 shouldBe("rect.y", "20");
152 shouldBe("rect.width", "80");
153 shouldBe("rect.height", "50");
154 shouldBe("rect.top", "20");
155 shouldBe("rect.right", "90");
156 shouldBe("rect.bottom", "70");
157 shouldBe("rect.left", "10");
158 shouldBe("rect.top", "rect.y");
159 shouldBe("rect.right", "rect.x + rect.width");
160 shouldBe("rect.bottom", "rect.y + rect.height");
161 shouldBe("rect.left", "rect.x");
162 debug("");
164 </script>
165 </body>
166 </html>