mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibWeb: Validate arguments when creating DOMPoint from matrix transform
Previously, it was possible to create a DOMPoint from a matrix transform with inconsistent arguments. A TypeError is now thrown in this case.
This commit is contained in:
parent
c5d1ec4dea
commit
fe66aeb225
3 changed files with 14 additions and 2 deletions
|
@ -4,3 +4,4 @@
|
||||||
4. {"x":750,"y":1060,"z":0,"w":1}
|
4. {"x":750,"y":1060,"z":0,"w":1}
|
||||||
5. {"x":750,"y":1060,"z":0,"w":1}
|
5. {"x":750,"y":1060,"z":0,"w":1}
|
||||||
6. {"x":750,"y":1060,"z":0,"w":1}
|
6. {"x":750,"y":1060,"z":0,"w":1}
|
||||||
|
7. Exception: TypeError
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
test(() => {
|
test(() => {
|
||||||
let testCounter = 1;
|
let testCounter = 1;
|
||||||
function testPart(part) {
|
function testPart(part) {
|
||||||
println(`${testCounter++}. ${JSON.stringify(part())}`);
|
try {
|
||||||
|
println(`${testCounter}. ${JSON.stringify(part())}`);
|
||||||
|
} catch (e) {
|
||||||
|
println(`${testCounter}. Exception: ${e.name}`);
|
||||||
|
}
|
||||||
|
testCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Creating a DOMPoint
|
// 1. Creating a DOMPoint
|
||||||
|
@ -33,5 +38,11 @@
|
||||||
const matrix = new DOMMatrix([10, 20, 30, 40, 50, 60]);
|
const matrix = new DOMMatrix([10, 20, 30, 40, 50, 60]);
|
||||||
return matrix.transformPoint({x: 10, y: 20});
|
return matrix.transformPoint({x: 10, y: 20});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 7. Transforming a point using a matrixTransform with an invalid DOMMatrixInit
|
||||||
|
testPart(function () {
|
||||||
|
const point = new DOMPoint(10, 20);
|
||||||
|
return point.matrixTransform({ is2D: true, m33: 1.0000001 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -41,7 +41,7 @@ DOMPointReadOnly::~DOMPointReadOnly() = default;
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> DOMPointReadOnly::matrix_transform(DOMMatrixInit& matrix) const
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMPoint>> DOMPointReadOnly::matrix_transform(DOMMatrixInit& matrix) const
|
||||||
{
|
{
|
||||||
// 1. Let matrixObject be the result of invoking create a DOMMatrix from the dictionary matrix.
|
// 1. Let matrixObject be the result of invoking create a DOMMatrix from the dictionary matrix.
|
||||||
auto matrix_object = TRY(DOMMatrix::create_from_dom_matrix_2d_init(realm(), matrix));
|
auto matrix_object = TRY(DOMMatrix::create_from_dom_matrix_init(realm(), matrix));
|
||||||
|
|
||||||
// 2. Return the result of invoking transform a point with a matrix, given the current point and matrixObject. The current point does not get modified.
|
// 2. Return the result of invoking transform a point with a matrix, given the current point and matrixObject. The current point does not get modified.
|
||||||
return matrix_object->transform_point(*this);
|
return matrix_object->transform_point(*this);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue