chromium/third_party/blink/web_tests/fast/dom/geometry-interfaces-dom-matrix-multiply.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./resources/geometry-interfaces-test-helpers.js"></script>
<script>
test(function() {
  var matrix = new DOMMatrix();
  matrix.a = 1;
  matrix.b = 2;
  matrix.c = 3;
  matrix.d = 4;
  matrix.e = 5;
  matrix.f = 6;
  assert_2d_matrix_equals(matrix, [1, 2, 3, 4, 5, 6]);
  var other = new DOMMatrix();
  other.m11 = 6;
  other.m21 = 5;
  other.m31 = 4;
  other.m33 = 3;
  other.m41 = 2;
  other.m43 = 1;
  assert_3d_matrix_equals(other, [6, 0, 0, 0, 5, 1, 0, 0, 4, 0, 3, 0, 2, 0, 1, 1]);
  var result = matrix.multiply(other);
  assert_3d_matrix_equals(result, [6, 12, 0, 0, 8, 14, 0, 0, 4, 8, 3, 0, 7, 10, 1, 1]);
  matrix.multiplySelf(other);
  assert_false(matrix.is2D);
  assert_false(matrix.isIdentity);
  assert_array_equals(matrix.toFloat64Array(), result.toFloat64Array());
  assert_throws_js(TypeError, () => { matrix.multiplySelf({a: 2, m11: 3}) });
}, "DOMMatrix.multiply(other) and DOMMatrix.multiplySelf(other)");

test(function() {
  var matrix = new DOMMatrix();
  matrix.a = 1;
  matrix.b = 2;
  matrix.c = 3;
  matrix.d = 4;
  matrix.e = 5;
  matrix.f = 6;
  assert_2d_matrix_equals(matrix, [1, 2, 3, 4, 5, 6]);
  var other = new DOMMatrix();
  other.m11 = 6;
  other.m21 = 5;
  other.m31 = 4;
  other.m33 = 3;
  other.m41 = 2;
  other.m43 = 1;
  assert_3d_matrix_equals(other, [6, 0, 0, 0, 5, 1, 0, 0, 4, 0, 3, 0, 2, 0, 1, 1]);
  var result = matrix.preMultiplySelf(other);
  assert_3d_matrix_equals(result, [16, 2, 0, 0, 38, 4, 0, 0, 4, 0, 3, 0, 62, 6, 1, 1]);
  assert_array_equals(matrix.toFloat64Array(), result.toFloat64Array());
  assert_throws_js(TypeError, () => { matrix.preMultiplySelf({b: 3, m12: 2}) });
}, "DOMMatrix.preMultiplySelf(other)");
</script>