| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| description("The test to ensure that modifying the result of getTransform doesn't affect the context."); |
| |
| function shouldHaveMatrixEquality(matrixName, expected) { |
| shouldEvaluateTo(matrixName + ".a", expected[0]); |
| shouldEvaluateTo(matrixName + ".b", expected[1]); |
| shouldEvaluateTo(matrixName + ".c", expected[2]); |
| shouldEvaluateTo(matrixName + ".d", expected[3]); |
| shouldEvaluateTo(matrixName + ".e", expected[4]); |
| shouldEvaluateTo(matrixName + ".f", expected[5]); |
| } |
| |
| var ctx1 = document.createElement("canvas").getContext("2d"); |
| var copiedTransform = ctx1.getTransform(); |
| |
| ctx1.setTransform(1, 2, 3, 4, 5, 6); |
| shouldHaveMatrixEquality("copiedTransform", [1, 0, 0, 1, 0, 0]); |
| |
| copiedTransform = copiedTransform.translate(5, 6); |
| var newTransform = ctx1.getTransform(); |
| shouldHaveMatrixEquality("newTransform", [1, 2, 3, 4, 5, 6]); |
| |
| ctx1.setTransform(copiedTransform); |
| var modifiedTransform = ctx1.getTransform(); |
| shouldHaveMatrixEquality("modifiedTransform", [1, 0, 0, 1, 5, 6]); |
| |
| var ctx2 = document.createElement("canvas").getContext("2d"); |
| ctx2.setTransform(1, 0, 0, 1, 5, 6); |
| |
| var ctx1Transform = ctx1.getTransform(); |
| var ctx2Transform = ctx2.getTransform(); |
| shouldBe("ctx1Transform.a", "ctx2Transform.a"); |
| shouldBe("ctx1Transform.b", "ctx2Transform.b"); |
| shouldBe("ctx1Transform.c", "ctx2Transform.c"); |
| shouldBe("ctx1Transform.d", "ctx2Transform.d"); |
| shouldBe("ctx1Transform.e", "ctx2Transform.e"); |
| shouldBe("ctx1Transform.f", "ctx2Transform.f"); |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |
| |