Files
firefox/testing/web-platform/tests/css/geometry/DOMPoint-001.html
T
Blake Kaplan 8273cba1c2 Bug 1186265 - Partially update DOMPoint, DOMQuad, DOMRect, DOMMatrix. r=bz
Some notes: this does not fully bring us to compliance to the current spec.
Instead, these are the fixes that I needed to make in order to make
css/geometry/interfaces.html pass with the DOMPoint changes in the previous
patches. I don't fully understand why that patch caused the test to fail the
way it did, but it ended up being easier to fix our code than understand why
the harness was falling over.

The DOMQuad::QuadBounds class was the source of some confusion for me. Now
that DOMRectReadOnly is a concrete class with members, I wanted to avoid
wasting them. However, the spec is unclear as to whether a DOMQuad's bound's
should be live -- that is because DOMQuad exposes DOMPoint, we can set its
points after retrieving a QuadBounds object. Our current code is live, setting
the points changes the QuadBounds. Chromium's current behavior is to never
update the QuadBounds object. I've left our behavior untouched in this patch
(and waste 4 doubles per QuadBounds object), but I am intending to file a bug
to understand what the intent of the spec is. I wonder if the author intended
the points to be DOMPointReadOnly instead. If so, we could simplify the
DOMRectReadOnly code and get rid of the virtual getters, which would be nice.

I also wasn't thrilled to put the DOMMatrix setters on the DOMMatrixReadOnly
class, but for brevity and simplicity of implementation, I've made them
public. I briefly considered making the setters protected on the ReadOnly
version of the class, but I'm not convinced that having to explicitly make
them public on the derived class is worth the extra copies of the names.

MozReview-Commit-ID: CjdW4Nbnc6A
2018-03-29 16:19:31 -07:00

88 lines
3.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Geometry Interfaces: DOMPoint and DOMPointReadOnly interface tests</title>
<link rel="author" title="Dirk Schulze" href="mailto:[email protected]" />
<link rel="help" href="http://www.w3.org/TR/geometry-1/#DOMPoint">
<link rel="help" href="http://www.w3.org/TR/geometry-1/#dictdef-dompointinit">
<link rel="help" href="http://www.w3.org/TR/geometry-1/#dom-dompoint-dompoint">
<link rel="help" href="http://www.w3.org/TR/geometry-1/#dom-dompointreadonly-dompoint-x">
<link rel="help" href="http://www.w3.org/TR/geometry-1/#dom-dompointreadonly-dompoint-y">
<link rel="help" href="http://www.w3.org/TR/geometry-1/#dom-dompointreadonly-dompoint-z">
<link rel="help" href="http://www.w3.org/TR/geometry-1/#dom-dompointreadonly-dompoint-w">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Test DOMPoint and DOMPointReadOnly interfaces</p>
<div id="log"></div>
<script>
test(function() {
checkDOMPoint(new DOMPoint(), {x:0, y:0, z:0, w:1});
},'testConstructor0');
test(function() {
checkDOMPoint(new DOMPoint(1), {x:1, y:0, z:0, w:1});
},'testConstructor1');
test(function() {
checkDOMPoint(new DOMPoint(1, 2), {x:1, y:2, z:0, w:1});
},'testConstructor2');
test(function() {
checkDOMPoint(new DOMPoint(1, 2, 3), {x:1, y:2, z:3, w:1});
},'testConstructor3');
test(function() {
checkDOMPoint(new DOMPoint(1, 2, 3, 4), {x:1, y:2, z:3, w:4});
},'testConstructor4');
test(function() {
checkDOMPoint(new DOMPoint(1, 2, 3, 4, 5), {x:1, y:2, z:3, w:4});
},'testConstructor5');
test(function() {
checkDOMPoint(new DOMPoint({}), {x:NaN, y:0, z:0, w:1});
},'testConstructorDictionary0');
test(function() {
checkDOMPoint(new DOMPoint({x:1}), {x:NaN, y:0, z:0, w:1});
},'testConstructorDictionary1');
test(function() {
checkDOMPoint(new DOMPoint({x:1, y:2}), {x:NaN, y:0, z:0, w:1});
},'testConstructorDictionary2');
test(function() {
checkDOMPoint(new DOMPoint(1, undefined), {x:1, y:0, z:0, w:1});
},'testConstructor2undefined');
test(function() {
checkDOMPoint(new DOMPoint("a", "b"), {x:NaN, y:NaN, z:0, w:1});
},'testConstructorUndefined1');
test(function() {
checkDOMPoint(new DOMPoint({x:"a", y:"b"}), {x:NaN, y:0, z:0, w:1});
},'testConstructorUndefined2');
test(function() {
checkDOMPoint(new DOMPointReadOnly(), {x:0, y:0, z:0, w:1});
},'DOMPointReadOnly constructor with no values');
test(function() {
checkDOMPoint(new DOMPointReadOnly(1, 2, 3, 4), {x:1, y:2, z:3, w:4});
},'DOMPointReadOnly constructor with 4 values');
test(function() {
var p = new DOMPoint(0, 0, 0, 1);
p.x = undefined;
p.y = undefined;
p.z = undefined;
p.w = undefined;
checkDOMPoint(p, {x:NaN, y:NaN, z:NaN, w:NaN});
},'testAttributesUndefined');
test(function() {
var p = new DOMPoint(0, 0, 0, 1);
p.x = NaN;
p.y = Number.POSITIVE_INFINITY;
p.z = Number.NEGATIVE_INFINITY;
p.w = Infinity;
checkDOMPoint(p, {x:NaN, y:Infinity, z:-Infinity, w:Infinity});
},'testAttributesNaNInfinity');
function checkDOMPoint(p, exp) {
assert_equals(p.x, exp.x, "Expected value for x is " + exp.x);
assert_equals(p.y, exp.y, "Expected value for y is " + exp.y);
assert_equals(p.z, exp.z, "Expected value for z is " + exp.z);
assert_equals(p.w, exp.w, "Expected value for w is " + exp.w);
}
</script>
</body>
</html>