OLD | NEW |
(Empty) | |
| 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> |
| 9 |
| 10 debug("# DOMQuad()"); |
| 11 var quad = new DOMQuad(); |
| 12 shouldBe("quad.p1.x", "0"); |
| 13 shouldBe("quad.p1.y", "0"); |
| 14 shouldBe("quad.p2.x", "0"); |
| 15 shouldBe("quad.p2.y", "0"); |
| 16 shouldBe("quad.p3.x", "0"); |
| 17 shouldBe("quad.p3.y", "0"); |
| 18 shouldBe("quad.p4.x", "0"); |
| 19 shouldBe("quad.p4.y", "0"); |
| 20 shouldBe("quad.bounds.x", "0"); |
| 21 shouldBe("quad.bounds.y", "0"); |
| 22 shouldBe("quad.bounds.width", "0"); |
| 23 shouldBe("quad.bounds.height", "0"); |
| 24 debug(""); |
| 25 |
| 26 debug("# DOMQuad({ x : 10, y : 10, width : 20, height : 30 }) - DOMRectInit"); |
| 27 quad = new DOMQuad({ x : 10, y : 10, width : 20, height : 30 }); |
| 28 shouldBe("quad.p1.x", "10"); |
| 29 shouldBe("quad.p1.y", "10"); |
| 30 shouldBe("quad.p2.x", "30"); |
| 31 shouldBe("quad.p2.y", "10"); |
| 32 shouldBe("quad.p3.x", "30"); |
| 33 shouldBe("quad.p3.y", "40"); |
| 34 shouldBe("quad.p4.x", "10"); |
| 35 shouldBe("quad.p4.y", "40"); |
| 36 shouldBe("quad.bounds.x", "10"); |
| 37 shouldBe("quad.bounds.y", "10"); |
| 38 shouldBe("quad.bounds.width", "20"); |
| 39 shouldBe("quad.bounds.height", "30"); |
| 40 debug(""); |
| 41 |
| 42 debug("# DOMQuad(new DOMRectReadOnly(10, 10, 20, 30)) - DOMRectReadOnly"); |
| 43 quad = new DOMQuad(new DOMRectReadOnly(10, 10, 20, 30)); |
| 44 shouldBe("quad.p1.x", "10"); |
| 45 shouldBe("quad.p1.y", "10"); |
| 46 shouldBe("quad.p2.x", "30"); |
| 47 shouldBe("quad.p2.y", "10"); |
| 48 shouldBe("quad.p3.x", "30"); |
| 49 shouldBe("quad.p3.y", "40"); |
| 50 shouldBe("quad.p4.x", "10"); |
| 51 shouldBe("quad.p4.y", "40"); |
| 52 shouldBe("quad.bounds.x", "10"); |
| 53 shouldBe("quad.bounds.y", "10"); |
| 54 shouldBe("quad.bounds.width", "20"); |
| 55 shouldBe("quad.bounds.height", "30"); |
| 56 debug(""); |
| 57 |
| 58 debug("# DOMQuad(new DOMRect(10, 10, 20, 30)) - DOMRect"); |
| 59 quad = new DOMQuad(new DOMRect(10, 10, 20, 30)); |
| 60 shouldBe("quad.p1.x", "10"); |
| 61 shouldBe("quad.p1.y", "10"); |
| 62 shouldBe("quad.p2.x", "30"); |
| 63 shouldBe("quad.p2.y", "10"); |
| 64 shouldBe("quad.p3.x", "30"); |
| 65 shouldBe("quad.p3.y", "40"); |
| 66 shouldBe("quad.p4.x", "10"); |
| 67 shouldBe("quad.p4.y", "40"); |
| 68 shouldBe("quad.bounds.x", "10"); |
| 69 shouldBe("quad.bounds.y", "10"); |
| 70 shouldBe("quad.bounds.width", "20"); |
| 71 shouldBe("quad.bounds.height", "30"); |
| 72 debug(""); |
| 73 |
| 74 debug("# DOMQuad(p1, p2) - DOMPointInit"); |
| 75 quad = new DOMQuad( |
| 76 { x : 10, y : 10 }, |
| 77 { x : 30, y : 10 } |
| 78 ); |
| 79 shouldBe("quad.p1.x", "10"); |
| 80 shouldBe("quad.p1.y", "10"); |
| 81 shouldBe("quad.p2.x", "30"); |
| 82 shouldBe("quad.p2.y", "10"); |
| 83 shouldBe("quad.p3.x", "0"); |
| 84 shouldBe("quad.p3.y", "0"); |
| 85 shouldBe("quad.p4.x", "0"); |
| 86 shouldBe("quad.p4.y", "0"); |
| 87 shouldBe("quad.bounds.x", "0"); |
| 88 shouldBe("quad.bounds.y", "0"); |
| 89 shouldBe("quad.bounds.width", "30"); |
| 90 shouldBe("quad.bounds.height", "10"); |
| 91 debug(""); |
| 92 |
| 93 debug("# DOMQuad(p1, p2, p3) - DOMPointInit"); |
| 94 quad = new DOMQuad( |
| 95 { x : 10, y : 10 }, |
| 96 { x : 30, y : 10 }, |
| 97 { x : 40, y : 40 } |
| 98 ); |
| 99 shouldBe("quad.p1.x", "10"); |
| 100 shouldBe("quad.p1.y", "10"); |
| 101 shouldBe("quad.p2.x", "30"); |
| 102 shouldBe("quad.p2.y", "10"); |
| 103 shouldBe("quad.p3.x", "40"); |
| 104 shouldBe("quad.p3.y", "40"); |
| 105 shouldBe("quad.p4.x", "0"); |
| 106 shouldBe("quad.p4.y", "0"); |
| 107 shouldBe("quad.bounds.x", "0"); |
| 108 shouldBe("quad.bounds.y", "0"); |
| 109 shouldBe("quad.bounds.width", "40"); |
| 110 shouldBe("quad.bounds.height", "40"); |
| 111 debug(""); |
| 112 |
| 113 debug("# DOMQuad(p1, p2, p3, p4) - DOMPointInit"); |
| 114 quad = new DOMQuad( |
| 115 { x : 10, y : 10 }, |
| 116 { x : 30, y : 10 }, |
| 117 { x : 40, y : 40 }, |
| 118 { x : 20, y : 50 } |
| 119 ); |
| 120 shouldBe("quad.p1.x", "10"); |
| 121 shouldBe("quad.p1.y", "10"); |
| 122 shouldBe("quad.p2.x", "30"); |
| 123 shouldBe("quad.p2.y", "10"); |
| 124 shouldBe("quad.p3.x", "40"); |
| 125 shouldBe("quad.p3.y", "40"); |
| 126 shouldBe("quad.p4.x", "20"); |
| 127 shouldBe("quad.p4.y", "50"); |
| 128 shouldBe("quad.bounds.x", "10"); |
| 129 shouldBe("quad.bounds.y", "10"); |
| 130 shouldBe("quad.bounds.width", "30"); |
| 131 shouldBe("quad.bounds.height", "40"); |
| 132 debug(""); |
| 133 |
| 134 debug("# DOMQuad(p1, p2, p3, p4) - DOMPointInit/DOMPoint"); |
| 135 quad = new DOMQuad( |
| 136 { x : 10, y : 10 }, |
| 137 new DOMPoint(30, 10), |
| 138 { x : 40, y : 40 }, |
| 139 new DOMPoint(20, 50) |
| 140 ); |
| 141 shouldBe("quad.p1.x", "10"); |
| 142 shouldBe("quad.p1.y", "10"); |
| 143 shouldBe("quad.p2.x", "30"); |
| 144 shouldBe("quad.p2.y", "10"); |
| 145 shouldBe("quad.p3.x", "40"); |
| 146 shouldBe("quad.p3.y", "40"); |
| 147 shouldBe("quad.p4.x", "20"); |
| 148 shouldBe("quad.p4.y", "50"); |
| 149 shouldBe("quad.bounds.x", "10"); |
| 150 shouldBe("quad.bounds.y", "10"); |
| 151 shouldBe("quad.bounds.width", "30"); |
| 152 shouldBe("quad.bounds.height", "40"); |
| 153 debug(""); |
| 154 |
| 155 debug("# DOMQuad.pX is readonly."); |
| 156 quad.p1 = new DOMPoint(0, 0); |
| 157 quad.p2 = new DOMPoint(20, 90); |
| 158 quad.p3 = new DOMPoint(80, 70); |
| 159 quad.p4 = new DOMPoint(40, 50); |
| 160 shouldBe("quad.p1.x", "10"); |
| 161 shouldBe("quad.p1.y", "10"); |
| 162 shouldBe("quad.p2.x", "30"); |
| 163 shouldBe("quad.p2.y", "10"); |
| 164 shouldBe("quad.p3.x", "40"); |
| 165 shouldBe("quad.p3.y", "40"); |
| 166 shouldBe("quad.p4.x", "20"); |
| 167 shouldBe("quad.p4.y", "50"); |
| 168 shouldBe("quad.bounds.x", "10"); |
| 169 shouldBe("quad.bounds.y", "10"); |
| 170 shouldBe("quad.bounds.width", "30"); |
| 171 shouldBe("quad.bounds.height", "40"); |
| 172 debug(""); |
| 173 |
| 174 debug("# DOMQuad.pX.Attr is not readonly."); |
| 175 quad.p1.x = 0; |
| 176 quad.p1.y = 0; |
| 177 quad.p2.x = 20; |
| 178 quad.p2.y = 90; |
| 179 quad.p3.x = 80; |
| 180 quad.p3.y = 70; |
| 181 quad.p4.x = 40; |
| 182 quad.p4.y = 50; |
| 183 shouldBe("quad.p1.x", "0"); |
| 184 shouldBe("quad.p1.y", "0"); |
| 185 shouldBe("quad.p2.x", "20"); |
| 186 shouldBe("quad.p2.y", "90"); |
| 187 shouldBe("quad.p3.x", "80"); |
| 188 shouldBe("quad.p3.y", "70"); |
| 189 shouldBe("quad.p4.x", "40"); |
| 190 shouldBe("quad.p4.y", "50"); |
| 191 shouldBe("quad.bounds.x", "0"); |
| 192 shouldBe("quad.bounds.y", "0"); |
| 193 shouldBe("quad.bounds.width", "80"); |
| 194 shouldBe("quad.bounds.height", "90"); |
| 195 debug(""); |
| 196 |
| 197 debug("# DOMQuad.bounds must be updated automatically."); |
| 198 var bounds = quad.bounds; |
| 199 quad.p1.x = 10; |
| 200 quad.p3.x = 100; |
| 201 shouldBe("bounds.x", "10"); |
| 202 shouldBe("bounds.width", "90"); |
| 203 shouldBe("quad.bounds.x", "10"); |
| 204 shouldBe("quad.bounds.width", "90"); |
| 205 shouldBeTrue("quad.bounds == bounds"); |
| 206 debug(""); |
| 207 |
| 208 </script> |
| 209 </body> |
| 210 </html> |
OLD | NEW |