Automatic update from web-platform-tests Merge checkDOMMatrix into checkMatrix This patch removes the checkDOMMatrix() and replaces it with checkMatrix(). Both helpers were almost the same thing, so keeping one is enough. Tests only. No runtime behavior change. Bug: 441818586 Change-Id: I075bb7187b64c0ce3f2f75a5fddece30da742f2b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6897068 Reviewed-by: Jinho Bang <zino@chromium.org> Commit-Queue: Philip Rogers <pdr@chromium.org> Reviewed-by: Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1508432} -- wpt-commits: 2f6c5497ac9da9832bf1e5ac27819bc47f119f98 wpt-pr: 54595
74 lines
2.3 KiB
HTML
74 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<link rel="help" href="https://drafts.fxtf.org/geometry-1/#DOMMatrix">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="support/dommatrix-test-util.js"></script>
|
|
<p>Test DOMMatrix.inverse()/invertSelf() for invertible matrices</p>
|
|
<script>
|
|
test(function() {
|
|
var m = new DOMMatrix();
|
|
assert_true(m.isIdentity);
|
|
var m1 = m.inverse();
|
|
assert_true(m1.isIdentity);
|
|
checkMatrix(m, m1);
|
|
m.invertSelf();
|
|
checkMatrix(m, m1);
|
|
}, "identity");
|
|
|
|
test(function() {
|
|
var m = new DOMMatrix().translate(10, -20.5);
|
|
var m1 = m.inverse();
|
|
checkMatrix(m1, new DOMMatrix().translate(-10, 20.5));
|
|
// Check with 'new DOMMatrix()' instead of identity() because the latter is
|
|
// a 3d identity matrix.
|
|
checkMatrix(m1.multiply(m), new DOMMatrix());
|
|
m.invertSelf();
|
|
checkMatrix(m, m1);
|
|
}, "translate");
|
|
|
|
test(function() {
|
|
var m = new DOMMatrix().translate(10, -20.5, 30.5);
|
|
var m1 = m.inverse();
|
|
checkMatrix(m1, new DOMMatrix().translate(-10, 20.5, -30.5));
|
|
checkMatrix(m1.multiply(m), identity());
|
|
m.invertSelf();
|
|
checkMatrix(m, m1);
|
|
}, "translate3d");
|
|
|
|
test(function() {
|
|
var m = new DOMMatrix().scale(4, -0.5);
|
|
var m1 = m.inverse();
|
|
checkMatrix(m1, new DOMMatrix().scale(0.25, -2.0));
|
|
checkMatrix(m1.multiply(m), new DOMMatrix());
|
|
m.invertSelf();
|
|
checkMatrix(m, m1);
|
|
}, "scale");
|
|
|
|
test(function() {
|
|
var m = new DOMMatrix().scale(4, -0.5, 2);
|
|
var m1 = m.inverse();
|
|
checkMatrix(m1, new DOMMatrix().scale(0.25, -2.0, 0.5));
|
|
checkMatrix(m1.multiply(m), identity());
|
|
m.invertSelf();
|
|
checkMatrix(m, m1);
|
|
}, "scale3d");
|
|
|
|
test(function() {
|
|
var m = new DOMMatrix().rotateAxisAngle(0, 0, 1, -30)
|
|
.scale(10, -0.5, 2.5)
|
|
.rotateAxisAngle(0, 1, 0, 10)
|
|
.translate(10, -20.5, 30.5)
|
|
.rotateAxisAngle(1, 0, 0, 20);
|
|
var expected = new DOMMatrix().rotateAxisAngle(1, 0, 0, -20)
|
|
.translate(-10, 20.5, -30.5)
|
|
.rotateAxisAngle(0, 1, 0, -10)
|
|
.scale(0.1, -2.0, 0.4)
|
|
.rotateAxisAngle(0, 0, 1, 30);
|
|
var m1 = m.inverse();
|
|
var epsilon = 1e-6;
|
|
checkMatrix(m1, expected, {epsilon});
|
|
m.invertSelf();
|
|
checkMatrix(m, expected, {epsilon});
|
|
}, "complex");
|
|
</script>
|