blob: 89f353b36e577ab1bb0a8a69762aaf2af6e97587 [file] [log] [blame]
<!doctype html>
<meta charset="utf-8">
<title>Geometry Interfaces: DOMPoint</title>
<link rel="help" href="https://drafts.fxtf.org/geometry/#DOMPoint">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./resources/geometry-interfaces-test-helpers.js"></script>
<script>
'use strict';
test(() => {
var point = new DOMPoint(2, 3);
assert_dom_point_equals(point, [2, 3, 0, 1]);
}, 'DOMPoint constructor with x, y parameters');
test(() => {
var point = new DOMPoint(5, 7, 9);
assert_dom_point_equals(point, [5, 7, 9, 1]);
}, 'DOMPoint constructor with x, y, z parameters');
test(() => {
var point = new DOMPoint(8, 2, 1, 6);
assert_dom_point_equals(point, [8, 2, 1, 6]);
}, 'DOMPoint constructor with x, y, z, w parameters');
test(() => {
var point = new DOMPoint();
assert_dom_point_equals(point, [0, 0, 0, 1]);
}, 'DOMPoint constructor without parameter');
test(() => {
var point = new DOMPoint();
point.x = 10;
point.y = 20;
point.z = 30;
point.w = 40;
assert_dom_point_equals(point, [10, 20, 30, 40]);
}, 'DOMPoint setter');
test(() => {
var point = new DOMPoint(1, 2, 3, 4);
assert_object_equals(point.toJSON(), {x: 1, y: 2, z: 3, w: 4});
}, 'DOMPoint toJSON');
test(() => {
var point = DOMPoint.fromPoint({x: 1, y: 2, z: 3, w: 4});
assert_dom_point_equals(point, [1, 2, 3, 4]);
}, 'DOMPoint.fromPoint({x: 1, y: 2, z: 3, w: 4}) should create a DOMPoint');
test(() => {
var point = DOMPoint.fromPoint();
assert_dom_point_equals(point, [0, 0, 0, 1]);
}, 'DOMPoint.fromPoint() should create a DOMPoint');
test(() => {
var point1 = DOMPoint.fromPoint();
var point2 = DOMPoint.fromPoint();
assert_false(point1 == point2);
assert_true(point1.x == point2.x);
assert_true(point1.y == point2.y);
assert_true(point1.z == point2.z);
assert_true(point1.w == point2.w);
}, 'DOMPoint.fromPoint() should create a new DOMPoint');
</script>