mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 12:41:59 +03: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
Notes:
sideshowbarker
2024-07-16 21:30:46 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/fe66aeb225 Pull-request: https://github.com/SerenityOS/serenity/pull/23228 Reviewed-by: https://github.com/AtkinsSJ
@ -4,3 +4,4 @@
|
||||
4. {"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}
|
||||
7. Exception: TypeError
|
||||
|
@ -3,7 +3,12 @@
|
||||
test(() => {
|
||||
let testCounter = 1;
|
||||
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
|
||||
@ -33,5 +38,11 @@
|
||||
const matrix = new DOMMatrix([10, 20, 30, 40, 50, 60]);
|
||||
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>
|
||||
|
@ -41,7 +41,7 @@ DOMPointReadOnly::~DOMPointReadOnly() = default;
|
||||
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.
|
||||
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.
|
||||
return matrix_object->transform_point(*this);
|
||||
|
Loading…
Reference in New Issue
Block a user