1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

LibWeb: Add DOMMatrix string constructor and set matrix value

This commit is contained in:
Bastiaan van der Plaat 2024-01-06 18:05:21 +01:00 committed by Andreas Kling
parent 903d3c92c8
commit be7538961b
15 changed files with 336 additions and 120 deletions

View file

@ -40,5 +40,29 @@
// 10. Creating a DOMMatrix with fromFloat64Array wrong amount
testPart(() => DOMMatrix.fromFloat64Array(new Float64Array([10, 20, 30, 40])));
// 11. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('translate(10px, 10px)'));
// 12. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('scale(10) translate(10px, 10px)'));
// 13. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('scale(2)'));
// 14. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('rotate(20deg) translate(10px, 10px)'));
// 15. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('translate(2)'));
// 16. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('rotate(20)'));
// 17. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('rotate(20px)'));
// 18. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('matrix(1.0, 2.0deg, 3.0, 4.0, 5.0, 6.0)'));
});
</script>

View file

@ -0,0 +1,32 @@
<script src="../include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
try {
println(`${testCounter}. ${JSON.stringify(part())}`);
} catch (e) {
println(`${testCounter}. Exception: ${e.name}`);
}
testCounter++;
}
// 1. DOMMatrix set matrix value empty
testPart(() => new DOMMatrix().setMatrixValue(''));
// 2. DOMMatrix set matrix value
testPart(() => new DOMMatrix().setMatrixValue('translate(10px, 10px)'));
// 3. DOMMatrix set matrix value
testPart(() => new DOMMatrix().setMatrixValue('rotate(10deg) translate(10px, 10px)'));
// 4. DOMMatrix set matrix value
testPart(() => new DOMMatrix().setMatrixValue('scale(0.2) rotate(10deg)'));
// 5. DOMMatrix set matrix value wrong
testPart(() => new DOMMatrix().setMatrixValue('scale(2deg)'));
// 6. DOMMatrix set matrix value wrong
testPart(() => new DOMMatrix().setMatrixValue('translate(40%)'));
});
</script>