blob: 93247638fd6d100d07bf4169b717a535ecd38d76 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(() => {
var quad = new DOMQuad();
assert_equals(quad.__proto__, DOMQuad.prototype);
var toJSONDescriptor = Object.getOwnPropertyDescriptor(DOMQuad.prototype, "toJSON");
assert_own_property(toJSONDescriptor, "value");
assert_true(toJSONDescriptor.enumerable);
assert_true(toJSONDescriptor.configurable);
assert_true(toJSONDescriptor.writable);
}, "DOMQuad has a toJSON function");
function check(jsonObject, quad)
{
assert_equals(jsonObject.p1.x, quad.p1.x, "Expected value for p1.x is " + quad.p1.x);
assert_equals(jsonObject.p1.y, quad.p1.y, "Expected value for p1.y is " + quad.p1.y);
assert_equals(jsonObject.p1.z, quad.p1.z, "Expected value for p1.z is " + quad.p1.z);
assert_equals(jsonObject.p1.w, quad.p1.w, "Expected value for p1.w is " + quad.p1.w);
assert_equals(jsonObject.p2.x, quad.p2.x, "Expected value for p2.x is " + quad.p2.x);
assert_equals(jsonObject.p2.y, quad.p2.y, "Expected value for p2.y is " + quad.p2.y);
assert_equals(jsonObject.p2.z, quad.p2.z, "Expected value for p2.z is " + quad.p2.z);
assert_equals(jsonObject.p2.w, quad.p2.w, "Expected value for p2.w is " + quad.p2.w);
assert_equals(jsonObject.p3.x, quad.p3.x, "Expected value for p3.x is " + quad.p3.x);
assert_equals(jsonObject.p3.y, quad.p3.y, "Expected value for p3.y is " + quad.p3.y);
assert_equals(jsonObject.p3.z, quad.p3.z, "Expected value for p3.z is " + quad.p3.z);
assert_equals(jsonObject.p3.w, quad.p3.w, "Expected value for p3.w is " + quad.p3.w);
assert_equals(jsonObject.p4.x, quad.p4.x, "Expected value for p4.x is " + quad.p4.x);
assert_equals(jsonObject.p4.y, quad.p4.y, "Expected value for p4.y is " + quad.p4.y);
assert_equals(jsonObject.p4.z, quad.p4.z, "Expected value for p4.z is " + quad.p4.z);
assert_equals(jsonObject.p4.w, quad.p4.w, "Expected value for p4.w is " + quad.p4.w);
}
test(() => {
var quad = new DOMQuad();
jsonObject = quad.toJSON();
check(jsonObject, quad);
}, "The values of all the points in a DOMQuad are serialized to JSON.");
test(() => {
var quad = new DOMQuad();
parsedJSONObject = JSON.parse(JSON.stringify(quad))
check(parsedJSONObject, quad);
}, "The values of all the points in a DOMQuad are preserved through a round-trip through JSON.stringify and JSON.parse");
</script>
</body>
</html>