mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
Tests/LibWeb: Add tests for DOMRect construction
This commit is contained in:
parent
fe66aeb225
commit
b03c94c26e
Notes:
sideshowbarker
2024-07-17 06:45:52 +09:00
Author: https://github.com/tcl3
Commit: b03c94c26e
Pull-request: https://github.com/SerenityOS/serenity/pull/23228
Reviewed-by: https://github.com/AtkinsSJ
2 changed files with 42 additions and 0 deletions
10
Tests/LibWeb/Text/expected/geometry/domrect-create.txt
Normal file
10
Tests/LibWeb/Text/expected/geometry/domrect-create.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
Testing DOMRect:
|
||||
1. {"x":0,"y":0,"width":0,"height":0,"top":0,"right":0,"bottom":0,"left":0}
|
||||
2. {"x":10,"y":20,"width":30,"height":40,"top":20,"right":40,"bottom":60,"left":10}
|
||||
3. {"x":-10,"y":-20,"width":30,"height":40,"top":-20,"right":20,"bottom":20,"left":-10}
|
||||
4. {"x":10,"y":20,"width":30,"height":40,"top":20,"right":40,"bottom":60,"left":10}
|
||||
Testing DOMRectReadOnly:
|
||||
1. {"x":0,"y":0,"width":0,"height":0,"top":0,"right":0,"bottom":0,"left":0}
|
||||
2. {"x":10,"y":20,"width":30,"height":40,"top":20,"right":40,"bottom":60,"left":10}
|
||||
3. {"x":-10,"y":-20,"width":30,"height":40,"top":-20,"right":20,"bottom":20,"left":-10}
|
||||
4. {"x":10,"y":20,"width":30,"height":40,"top":20,"right":40,"bottom":60,"left":10}
|
32
Tests/LibWeb/Text/input/geometry/domrect-create.html
Normal file
32
Tests/LibWeb/Text/input/geometry/domrect-create.html
Normal 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++;
|
||||
}
|
||||
|
||||
for (const Rect of [DOMRect, DOMRectReadOnly]) {
|
||||
println(`Testing ${Rect.name}:`);
|
||||
|
||||
// 1. Creating a DOMRect with no arguments
|
||||
testPart(() => new Rect());
|
||||
|
||||
// 2. Creating a DOMRect with positive x, y, width and height
|
||||
testPart(() => new Rect(10, 20, 30, 40));
|
||||
|
||||
// 3. Creating a DOMRect with negative x and y values
|
||||
testPart(() => new Rect(-10, -20, 30, 40));
|
||||
|
||||
// 4. Creating a DOMRect with DOMRect.fromRect()
|
||||
testPart(() => Rect.fromRect({ x: 10, y: 20, width: 30, height: 40 }));
|
||||
|
||||
testCounter = 1;
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue