Index: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-point.html |
diff --git a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-point.html b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-point.html |
index 3c531b9a3c38e1ec505568fc9bca0c706fa8de96..a50e4d329c636f59827c0af9f824f155ad19f980 100644 |
--- a/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-point.html |
+++ b/third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-point.html |
@@ -1,114 +1,143 @@ |
<!DOCTYPE html> |
-<html> |
-<head> |
-<title>Geometry Interfaces: DOMPoint</title> |
-<script src="../../resources/js-test.js"></script> |
-</head> |
-<body> |
+<title>Geometry Interfaces: DOMPoint tests</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
<script> |
-debug("# DOMPoint(2, 3)"); |
-var point = new DOMPoint(2, 3); |
-shouldBe("point.x", "2"); |
-shouldBe("point.y", "3"); |
-shouldBe("point.z", "0"); |
-shouldBe("point.w", "1"); |
-debug(""); |
- |
-debug("# DOMPoint(5, 7, 9)"); |
-point = new DOMPoint(5, 7, 9); |
-shouldBe("point.x", "5"); |
-shouldBe("point.y", "7"); |
-shouldBe("point.z", "9"); |
-shouldBe("point.w", "1"); |
-debug(""); |
- |
-debug("# DOMPoint(8, 2, 1, 6)"); |
-point = new DOMPoint(5, 7, 9); |
-point = new DOMPoint(8, 2, 1, 6); |
-shouldBe("point.x", "8"); |
-shouldBe("point.y", "2"); |
-shouldBe("point.z", "1"); |
-shouldBe("point.w", "6"); |
-debug(""); |
- |
-debug("# DOMPoint({ x : 2 })"); |
-point = new DOMPoint({ x : 2 }); |
-shouldBe("point.x", "2"); |
-shouldBe("point.y", "0"); |
-shouldBe("point.z", "0"); |
-shouldBe("point.w", "1"); |
-debug(""); |
- |
-debug("# DOMPoint({ y : 2 })"); |
-point = new DOMPoint({ y : 2 }); |
-shouldBe("point.x", "0"); |
-shouldBe("point.y", "2"); |
-shouldBe("point.z", "0"); |
-shouldBe("point.w", "1"); |
-debug(""); |
- |
-debug("# DOMPoint({ z : 2 })"); |
-point = new DOMPoint({ z : 2 }); |
-shouldBe("point.x", "0"); |
-shouldBe("point.y", "0"); |
-shouldBe("point.z", "2"); |
-shouldBe("point.w", "1"); |
-debug(""); |
- |
-debug("# DOMPoint({ w : 2 })"); |
-point = new DOMPoint({ w : 2 }); |
-shouldBe("point.x", "0"); |
-shouldBe("point.y", "0"); |
-shouldBe("point.z", "0"); |
-shouldBe("point.w", "2"); |
-debug(""); |
- |
-debug("# DOMPoint({ x : 2, y : 3, z : 4, w : 5 })"); |
-point = new DOMPoint({ x : 2, y : 3, z : 4, w : 5 }); |
-shouldBe("point.x", "2"); |
-shouldBe("point.y", "3"); |
-shouldBe("point.z", "4"); |
-shouldBe("point.w", "5"); |
-debug(""); |
- |
-debug("# DOMPoint()"); |
-point = new DOMPoint(); |
-shouldBe("point.x", "0"); |
-shouldBe("point.y", "0"); |
-shouldBe("point.z", "0"); |
-shouldBe("point.w", "1"); |
-debug(""); |
- |
-debug("# DOMPoint setter"); |
-point.x = 10; |
-shouldBe("point.x", "10"); |
-point.y = 20; |
-shouldBe("point.y", "20"); |
-point.z = 30; |
-shouldBe("point.z", "30"); |
-point.w = 40; |
-shouldBe("point.w", "40"); |
-debug(""); |
- |
-debug("# DOMPointReadOnly(10, 20, 30, 40)"); |
-point = new DOMPointReadOnly(10, 20, 30, 40); |
-shouldBe("point.x", "10"); |
-shouldBe("point.y", "20"); |
-shouldBe("point.z", "30"); |
-shouldBe("point.w", "40"); |
-debug(""); |
- |
-debug("# DOMPointReadOnly readonly test"); |
-point.x = 100; |
-shouldBe("point.x", "10"); |
-point.y = 100; |
-shouldBe("point.y", "20"); |
-point.z = 100; |
-shouldBe("point.z", "30"); |
-point.w = 100; |
-shouldBe("point.w", "40"); |
+function assert_dom_point_equals(dom_point, expected) { |
+ assert_equals(dom_point.x, expected.x, 'x'); |
+ assert_equals(dom_point.y, expected.y, 'y'); |
+ assert_equals(dom_point.z, expected.z, 'z'); |
+ assert_equals(dom_point.w, expected.w, 'w'); |
+} |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(); |
+ assert_dom_point_equals(dom_point_read_only, { x: 0, y: 0, z: 0, w: 1 }); |
+ var dom_point = new DOMPoint(); |
+ assert_dom_point_equals(dom_point, { x: 0, y: 0, z: 0, w: 1 }); |
+}, 'new DOMPoint/DOMPointReadOnly()'); |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(1); |
+ assert_dom_point_equals(dom_point_read_only, { x: 1, y: 0, z: 0, w: 1 }); |
+ var dom_point = new DOMPoint(1); |
+ assert_dom_point_equals(dom_point, { x: 1, y: 0, z: 0, w: 1 }); |
+}, 'new DOMPoint/DOMPointReadOnly(1)'); |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(1, 2); |
+ assert_dom_point_equals(dom_point_read_only, { x: 1, y: 2, z: 0, w: 1 }); |
+ var dom_point = new DOMPoint(1, 2); |
+ assert_dom_point_equals(dom_point, { x: 1, y: 2, z: 0, w: 1 }); |
+}, 'new DOMPoint/DOMPointReadOnly(1, 2)'); |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(1, 2, 3); |
+ assert_dom_point_equals(dom_point_read_only, { x: 1, y: 2, z: 3, w: 1 }); |
+ var dom_point = new DOMPoint(1, 2, 3); |
+ assert_dom_point_equals(dom_point, { x: 1, y: 2, z: 3, w: 1 }); |
+}, 'new DOMPoint/DOMPointReadOnly(1, 2, 3)'); |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(1, 2, 3, 4); |
+ assert_dom_point_equals(dom_point_read_only, { x: 1, y: 2, z: 3, w: 4 }); |
+ var dom_point = new DOMPoint(1, 2, 3, 4); |
+ assert_dom_point_equals(dom_point, { x: 1, y: 2, z: 3, w: 4 }); |
+}, 'new DOMPoint/DOMPointReadOnly(1, 2, 3, 4)'); |
+ |
+test(() => { |
+ var dom_point_read_only = |
+ new DOMPointReadOnly(undefined, undefined, undefined, undefined); |
+ assert_dom_point_equals(dom_point_read_only, { x: 0, y: 0, z: 0, w: 1 }); |
+ var dom_point = new DOMPoint(undefined, undefined, undefined, undefined); |
+ assert_dom_point_equals(dom_point, { x: 0, y: 0, z: 0, w: 1 }); |
+}, 'If constructor takes undefined as parameter, should set default value.'); |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(null, null, null, null); |
+ assert_dom_point_equals(dom_point_read_only, { x: 0, y: 0, z: 0, w: 0 }); |
+ var dom_point = new DOMPoint(null, null, null, null); |
+ assert_dom_point_equals(dom_point, { x: 0, y: 0, z: 0, w: 0 }); |
+}, 'The "null" is the same to 0.'); |
+ |
+test(() => { |
+ var dom_point_read_only = |
+ new DOMPointReadOnly(function() {}, {}, new Object(), 'string'); |
+ assert_dom_point_equals(dom_point_read_only, { x: NaN, y: NaN, z: NaN, w: NaN }); |
+ var dom_point = new DOMPoint(function() {}, {}, new Object(), 'string'); |
+ assert_dom_point_equals(dom_point, { x: NaN, y: NaN, z: NaN, w: NaN }); |
+}, 'If constructor takes function/object as parameter, should set "NaN".'); |
+ |
+test(() => { |
+ var dom_point_read_only = |
+ new DOMPointReadOnly(function() {}, {}, new Object(), 'string'); |
+ assert_dom_point_equals( |
+ dom_point_read_only, { x: NaN, y: NaN, z: NaN, w: NaN }); |
+ var dom_point = new DOMPoint(function() {}, {}, new Object(), 'string'); |
+ assert_dom_point_equals(dom_point, { x: NaN, y: NaN, z: NaN, w: NaN }); |
+}, 'new DOMPoint/DOMPointReadOnly([], [10], ["string"], [10, 20])'); |
+ |
+test(() => { |
+ var dom_point_read_only = new DOMPointReadOnly(1, 2, 3, 4); |
+ dom_point_read_only.x = 4; |
+ dom_point_read_only.y = 3; |
+ dom_point_read_only.z = 2; |
+ dom_point_read_only.w = 1; |
+ assert_dom_point_equals(dom_point_read_only, { x: 1, y: 2, z: 3, w: 4 }); |
+}, 'DOMPointReadOnly does not have setter'); |
+ |
+test(() => { |
+ var dom_point = new DOMPoint(1, 2, 3, 4); |
+ dom_point.x = 10.5; |
+ dom_point.y = 20.7; |
+ dom_point.z = 30; |
+ dom_point.w = 40; |
+ assert_dom_point_equals(dom_point, { x: 10.5, y: 20.7, z: 30, w: 40 }); |
+}, 'DOMPoint setter test (number)'); |
+ |
+test(() => { |
+ var dom_point = new DOMPoint(1, 2, 3, 4); |
+ dom_point.x = undefined; |
+ dom_point.y = null; |
+ dom_point.z = undefined; |
+ dom_point.w = null; |
+ assert_dom_point_equals(dom_point, { x: NaN, y: 0, z: NaN, w: 0 }); |
+}, 'DOMPoint setter test (undefined/null)'); |
+ |
+test(() => { |
+ var dom_point = new DOMPoint(1, 2, 3, 4); |
+ dom_point.x = function() {}; |
+ dom_point.y = {}; |
+ dom_point.z = 'string'; |
+ dom_point.w = new Object(); |
+ assert_dom_point_equals(dom_point, { x: NaN, y: NaN, z: NaN, w: NaN }); |
+}, 'DOMPoint setter test (function/object)'); |
+ |
+test(() => { |
+ var dom_point = new DOMPoint(1, 2, 3, 4); |
+ dom_point.x = []; |
+ dom_point.y = [10]; |
+ dom_point.z = ['string']; |
+ dom_point.w = [10, 20]; |
+ assert_dom_point_equals(dom_point, { x: 0, y: 10, z: NaN, w: NaN }); |
+}, 'DOMPoint setter test (array)'); |
+ |
+test(() => { |
+ const dom_point_read_only_getter = |
+ Object.getOwnPropertyDescriptor(DOMPointReadOnly.prototype, 'x').get; |
+ dom_point_read_only_getter.call(new DOMPoint()); |
+ dom_point_read_only_getter.call(new DOMPointReadOnly()); |
+ assert_throws(null, () => dom_point_read_only_getter.call({})); |
+ assert_throws(null, () => dom_point_read_only_getter.call({ x: 10 })); |
+ |
+ const dom_point_setter = |
+ Object.getOwnPropertyDescriptor(DOMPoint.prototype, 'y').set; |
+ var dom_point = new DOMPoint(); |
+ dom_point_setter.call(dom_point, 10); |
+ assert_dom_point_equals(dom_point, { x: 0, y: 10, z: 0, w: 1 }); |
+ assert_throws(null, () => dom_point_setter.call({}, 10)); |
+ assert_throws(null, () => dom_point_setter.call({ y: 10 }, 20)); |
+}, 'Test for exception when binding object is not DOMPoint/DOMPointReadOnly'); |
</script> |
-</body> |
-</html> |