Skip to content

Truly independent web browser

LibWeb: Import CSSMatrixComponent copy tests

Andreas Kling17c6572bade7
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent-toMatrix-returns-new-matrix.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent-toMatrix-returns-new-matrix.txt
new file mode 100644
index 00000000000..b269c814275
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent-toMatrix-returns-new-matrix.txt
@@ -0,0 +1,9 @@
+Harness status: OK
+
+Found 4 tests
+
+4 Fail
+Fail Mutating the result of toMatrix() on a 2D CSSMatrixComponent does not change the component
+Fail Mutating the result of toMatrix() on a 3D CSSMatrixComponent does not change the component
+Fail Calling a self-mutating method on the result of toMatrix() on a 3D CSSMatrixComponent does not change the component
+Fail Mutating the result of toMatrix() on a 3D CSSMatrixComponent does not change an enclosing CSSTransformValue
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent-toMatrix-returns-new-matrix.html b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent-toMatrix-returns-new-matrix.html
new file mode 100644
index 00000000000..a6c68fa3e44
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-typed-om/stylevalue-subclasses/cssMatrixComponent-toMatrix-returns-new-matrix.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSSMatrixComponent.toMatrix() returns a new DOMMatrix</title>
+<link rel="help" href="https://drafts.css-houdini.org/css-typed-om-1/#dom-csstransformcomponent-tomatrix">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+'use strict';
+
+test(() => {
+ const component = new CSSMatrixComponent(new DOMMatrixReadOnly([1, 2, 3, 4, 5, 6]));
+ const matrix = component.toMatrix();
+ assert_not_equals(matrix, component.matrix);
+ assert_not_equals(matrix, component.toMatrix());
+ matrix.m41 = 100;
+ assert_equals(component.matrix.m41, 5);
+ assert_equals(component.toMatrix().m41, 5);
+ assert_equals(component.toString(), 'matrix(1, 2, 3, 4, 5, 6)');
+}, 'Mutating the result of toMatrix() on a 2D CSSMatrixComponent does not change the component');
+
+test(() => {
+ const component = new CSSMatrixComponent(new DOMMatrixReadOnly([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 6, 7, 1]));
+ const matrix = component.toMatrix();
+ assert_not_equals(matrix, component.matrix);
+ assert_not_equals(matrix, component.toMatrix());
+ matrix.m41 = 100;
+ assert_equals(component.matrix.m41, 5);
+ assert_equals(component.toMatrix().m41, 5);
+ assert_equals(component.toString(), 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 6, 7, 1)');
+}, 'Mutating the result of toMatrix() on a 3D CSSMatrixComponent does not change the component');
+
+test(() => {
+ const component = new CSSMatrixComponent(new DOMMatrixReadOnly([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 6, 7, 1]));
+ component.toMatrix().translateSelf(10, 20, 30);
+ assert_equals(component.toString(), 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 6, 7, 1)');
+}, 'Calling a self-mutating method on the result of toMatrix() on a 3D CSSMatrixComponent does not change the component');
+
+test(() => {
+ const component = new CSSMatrixComponent(new DOMMatrixReadOnly([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 5, 6, 7, 1]));
+ const transform = new CSSTransformValue([component]);
+ component.toMatrix().m42 = 100;
+ assert_equals(transform.toMatrix().m42, 6);
+}, 'Mutating the result of toMatrix() on a 3D CSSMatrixComponent does not change an enclosing CSSTransformValue');
+</script>