summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html')
-rw-r--r--testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html76
1 files changed, 76 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html b/testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html
new file mode 100644
index 0000000000..d5bef624d2
--- /dev/null
+++ b/testing/web-platform/tests/css/geometry/DOMMatrix-invert-invertible.html
@@ -0,0 +1,76 @@
+<!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);
+ // Use checkMatrix() instead of checkDOMMatrix() because checkMatrix() has
+ // a default epsilon = Number.MIN_VALUE which can at least pass
+ // assert_approx_equal(0, -0, epsilon).
+ 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>