mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02:00
When constructing MouseEvent, PointerEvent, DragEvent, or WheelEvent from JavaScript, pageX/pageY and offsetX/offsetY were left at 0 instead of being initialized from clientX/clientY. Per the CSSOM View spec, pageX should be clientX + scrollX (which is 0 for a newly constructed event with no associated window), and offsetX should be clientX minus the target's bounding rect origin (which is 0 for an event with no target). So both should default to clientX.
26 lines
993 B
HTML
26 lines
993 B
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
// Constructed MouseEvent should initialize pageX/pageY and offsetX/offsetY from clientX/clientY.
|
|
let e = new MouseEvent("click", { clientX: 10.5, clientY: 20.5, screenX: 30.5, screenY: 40.5 });
|
|
|
|
println(`screenX: ${e.screenX}`);
|
|
println(`screenY: ${e.screenY}`);
|
|
println(`clientX: ${e.clientX}`);
|
|
println(`clientY: ${e.clientY}`);
|
|
println(`pageX: ${e.pageX}`);
|
|
println(`pageY: ${e.pageY}`);
|
|
println(`offsetX: ${e.offsetX}`);
|
|
println(`offsetY: ${e.offsetY}`);
|
|
|
|
// PointerEvent should behave the same way.
|
|
let pe = new PointerEvent("pointerdown", { clientX: 5.25, clientY: 15.75 });
|
|
|
|
println(`PointerEvent pageX: ${pe.pageX}`);
|
|
println(`PointerEvent pageY: ${pe.pageY}`);
|
|
println(`PointerEvent offsetX: ${pe.offsetX}`);
|
|
println(`PointerEvent offsetY: ${pe.offsetY}`);
|
|
});
|
|
</script>
|