Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

Fix font-dependent mouse offset test

Noz Wu30594c4fdea2
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs
index 8d1c9da48..647cc61d9 100644
--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs
+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/computed_style.rs
@@ -9892,8 +9892,9 @@ fn mouse_event_offsets_follow_retargeted_shadow_targets() {
'html, body { padding: 0; margin: 0; } ' +
'my-host { display: block; width: 180px; height: 80px; margin: 10px 20px; padding: 10px; }';
document.documentElement.firstChild.appendChild(pageStyle);
- // Keep the span non-atomic while fixing its line-box top independently of
- // whichever default font the host has installed.
+ // Keep the span non-atomic while fixing the shared line-box top used by
+ // MouseEvent offsets. The span's own fragment top still depends on font
+ // metrics, so compare it only across equivalent light/shadow trees below.
const shadowStyle =
'#container { width: 160px; height: 60px; padding: 10px; } ' +
'#target { line-height: 20px; vertical-align: top; margin-left: 5px; }';
@@ -9927,6 +9928,7 @@ fn mouse_event_offsets_follow_retargeted_shadow_targets() {
light.innerHTML =
'<style>' + shadowStyle + '</style><div id="container"><span id="target">Click</span></div>';
const lightTarget = light.querySelector('#target');
+ const lightTargetOffsetTop = lightTarget.offsetTop;
const lightContainer = light.querySelector('#container');
const lightLogs = attachLoggers([lightTarget, lightContainer, light, document.body], 'light-down');
const lightEvent = new MouseEvent('light-down', {
@@ -9949,7 +9951,6 @@ fn mouse_event_offsets_follow_retargeted_shadow_targets() {
light.offsetLeft,
light.offsetTop,
lightTarget.offsetLeft,
- lightTarget.offsetTop,
Object.hasOwn(lightEvent, 'offsetX'),
Object.hasOwn(lightEvent, 'offsetY'),
Object.hasOwn(MouseEvent.prototype, 'offsetX'),
@@ -9978,7 +9979,7 @@ fn mouse_event_offsets_follow_retargeted_shadow_targets() {
}));
const closedResult = [
closedTarget.offsetLeft,
- closedTarget.offsetTop,
+ closedTarget.offsetTop === lightTargetOffsetTop,
closedLogs.join(',')
].join('|');
@@ -10018,9 +10019,9 @@ fn mouse_event_offsets_follow_retargeted_shadow_targets() {
assert_eq!(
result,
concat!(
- "20|10|45|30|false|false|true|true|get offsetX|0|true|true|true|TypeError|",
+ "20|10|45|false|false|true|true|get offsetX|0|true|true|true|TypeError|",
"span:span:21:17,div:span:21:17,my-host:span:21:17,body:span:21:17|",
- "45|30|",
+ "45|true|",
"span:span:21:17,div:span:21:17,#shadow-root:span:21:17,",
"my-host:my-host:31:27,body:my-host:31:27|",
"45|30|",