From 26d4431dc660a861797b5330de62d4681a98ddf4 Mon Sep 17 00:00:00 2001 From: "adil.rakhaliyev" Date: Wed, 2 Dec 2026 20:16:32 +0500 Subject: [PATCH 1/2] fix: check offsets of an image map area against its coords Firefox 161 returns an empty rect from getBoundingClientRect() for , so containsOffset() rejected any offset, the expected element was dropped, and the Firefox image-map correction never ran (T299665). Use the rectangle hammerhead computes from the area's coords, which the click point already uses. --- src/client/core/utils/position.ts | 19 +++++++++++--- test/client/fixtures/automation/click-test.js | 26 +++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/client/core/utils/position.ts b/src/client/core/utils/position.ts index 717092d4aa8..8d52a9a8d93 100644 --- a/src/client/core/utils/position.ts +++ b/src/client/core/utils/position.ts @@ -118,12 +118,25 @@ export function getIframeClientCoordinates (iframe: HTMLIFrameElement): Boundary iframeRectangleLeft); } -export function containsOffset (el: HTMLElement, offsetX?: number, offsetY?: number): boolean { +function getMaxOffset (el: HTMLElement): AxisValuesData { + if (domUtils.isMapElement(el)) { + const { width, height } = getElementRectangle(el); + + return { x: width, y: height }; + } + const dimensions = getClientDimensions(el); const width = Math.max(el.scrollWidth, dimensions.width); const height = Math.max(el.scrollHeight, dimensions.height); - const maxX = dimensions.scrollbar.right + dimensions.border.left + dimensions.border.right + width; - const maxY = dimensions.scrollbar.bottom + dimensions.border.top + dimensions.border.bottom + height; + + return { + x: dimensions.scrollbar.right + dimensions.border.left + dimensions.border.right + width, + y: dimensions.scrollbar.bottom + dimensions.border.top + dimensions.border.bottom + height, + }; +} + +export function containsOffset (el: HTMLElement, offsetX?: number, offsetY?: number): boolean { + const { x: maxX, y: maxY } = getMaxOffset(el); return (typeof offsetX === 'undefined' || offsetX >= 0 && maxX >= offsetX) && (typeof offsetY === 'undefined' || offsetY >= 0 && maxY >= offsetY); diff --git a/test/client/fixtures/automation/click-test.js b/test/client/fixtures/automation/click-test.js index dbbc96f4e72..4b7119cdd07 100644 --- a/test/client/fixtures/automation/click-test.js +++ b/test/client/fixtures/automation/click-test.js @@ -3,8 +3,9 @@ const browserUtils = hammerhead.utils.browser; const featureDetection = hammerhead.utils.featureDetection; const Promise = hammerhead.Promise; -const testCafeCore = window.getTestCafeModule('testCafeCore'); -const styleUtils = testCafeCore.styleUtils; +const testCafeCore = window.getTestCafeModule('testCafeCore'); +const styleUtils = testCafeCore.styleUtils; +const positionUtils = testCafeCore.positionUtils; const testCafeAutomation = window.getTestCafeModule('testCafeAutomation'); const getOffsetOptions = testCafeAutomation.getOffsetOptions; @@ -1183,6 +1184,27 @@ $(document).ready(function () { }, TEST_RESULT_TIMEOUT + 200); }); + test('Offsets of an image map area should be checked against its coords', function () { + const $map = $('') + .appendTo('body') + .addClass(TEST_ELEMENT_CLASS); + + const $area = $('').appendTo($map); + + $('') + .css({ + width: '200px', + height: '200px', + }) + .appendTo('body') + .addClass(TEST_ELEMENT_CLASS); + + ok(positionUtils.containsOffset($area[0], 10, 10)); + ok(positionUtils.containsOffset($area[0], 50, 100)); + notOk(positionUtils.containsOffset($area[0], 60, 10)); + notOk(positionUtils.containsOffset($area[0], 10, 110)); + }); + module('touch devices test'); if (featureDetection.isTouchDevice) { asyncTest('touch event on click', function () { From 582f4c6f2d33ad0a4161117721f0f6011760d7f4 Mon Sep 17 00:00:00 2001 From: "adil.rakhaliyev" Date: Thu, 3 Dec 2026 17:09:20 +0500 Subject: [PATCH 2/2] fix: limit the image map area offset check to Firefox --- src/client/core/utils/position.ts | 12 +++++++++++- test/client/fixtures/automation/click-test.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/core/utils/position.ts b/src/client/core/utils/position.ts index 8d52a9a8d93..d7f33838a08 100644 --- a/src/client/core/utils/position.ts +++ b/src/client/core/utils/position.ts @@ -118,8 +118,18 @@ export function getIframeClientCoordinates (iframe: HTMLIFrameElement): Boundary iframeRectangleLeft); } +function isImageMapArea (el: HTMLElement): boolean { + if (domUtils.getTagName(el) !== 'area') + return false; + + const map = domUtils.closest(el, 'map'); + const container = map && domUtils.getMapContainer(map); + + return !!container && domUtils.isImgElement(container); +} + function getMaxOffset (el: HTMLElement): AxisValuesData { - if (domUtils.isMapElement(el)) { + if (hammerhead.utils.browser.isFirefox && isImageMapArea(el)) { const { width, height } = getElementRectangle(el); return { x: width, y: height }; diff --git a/test/client/fixtures/automation/click-test.js b/test/client/fixtures/automation/click-test.js index 4b7119cdd07..7ebc8461420 100644 --- a/test/client/fixtures/automation/click-test.js +++ b/test/client/fixtures/automation/click-test.js @@ -1184,7 +1184,7 @@ $(document).ready(function () { }, TEST_RESULT_TIMEOUT + 200); }); - test('Offsets of an image map area should be checked against its coords', function () { + (browserUtils.isFirefox ? test : QUnit.skip)('Offsets of an image map area should be checked against its coords', function () { const $map = $('') .appendTo('body') .addClass(TEST_ELEMENT_CLASS);