summaryrefslogtreecommitdiffstats
path: root/layout/reftests/canvas/ctm-singular-sanity.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /layout/reftests/canvas/ctm-singular-sanity.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/reftests/canvas/ctm-singular-sanity.html')
-rw-r--r--layout/reftests/canvas/ctm-singular-sanity.html60
1 files changed, 60 insertions, 0 deletions
diff --git a/layout/reftests/canvas/ctm-singular-sanity.html b/layout/reftests/canvas/ctm-singular-sanity.html
new file mode 100644
index 0000000000..48617d7628
--- /dev/null
+++ b/layout/reftests/canvas/ctm-singular-sanity.html
@@ -0,0 +1,60 @@
+<html>
+<head>
+ <script type="text/javascript">
+function assert(cond, msg) {
+ if (!cond) {
+ throw msg;
+ }
+}
+
+assert.equal = function(m1, m2, msg) {
+ assert(
+ m1.is2D &&
+ m2.is2D &&
+ m1.a === m2.a &&
+ m1.b === m2.b &&
+ m1.c === m2.c &&
+ m1.d === m2.d &&
+ m1.e === m2.e &&
+ m1.f === m2.f,
+ msg
+ );
+};
+
+window.onload = function() {
+ try {
+ var ctx = document.getElementById("c1").getContext("2d");
+
+ var singular = new DOMMatrix([0, 0, 0, 0, 0, 0]);
+ ctx.setTransform(singular);
+ assert.equal(
+ ctx.getTransform(),
+ singular,
+ "Expected setting transform to a singular matrix to work"
+ );
+ var inv = ctx.getTransform().invertSelf();
+ assert(
+ isNaN(inv.a) && isNaN(inv.b) && isNaN(inv.c) && isNaN(inv.d),
+ "Expected to get back matrix of NaN's from inverse transform"
+ );
+
+ var m = new DOMMatrix([1, 2, 3, 4, 5, 6]);
+ ctx.setTransform(m);
+ ctx.setTransform(singular.invertSelf());
+ assert.equal(
+ ctx.getTransform(),
+ m,
+ "Setting transform to an inverse singular matrix is a no-op"
+ );
+ } catch (e) {
+ document.body.innerHTML = "FAIL: " + e.toString();
+ return;
+ }
+ document.body.innerHTML = "Pass";
+};
+ </script>
+</head>
+<body>
+ <div><canvas id="c1" width="300" height="300"></canvas></div>
+</body>
+</html>