Skip to content

Commit fc08728

Browse files
authored
fix: revert utilites (#7209)
* revert utilites * fix tests * update hammerhead and add a test
1 parent 76e8e9f commit fc08728

File tree

6 files changed

+70
-4
lines changed

6 files changed

+70
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "testcafe",
33
"description": "Automated browser testing for the modern web development stack.",
44
"license": "MIT",
5-
"version": "1.20.1-rc.1",
5+
"version": "1.20.1-rc.2",
66
"author": {
77
"name": "Developer Express Inc.",
88
"url": "https://www.devexpress.com/"
@@ -137,7 +137,7 @@
137137
"source-map-support": "^0.5.16",
138138
"strip-bom": "^2.0.0",
139139
"testcafe-browser-tools": "2.0.23",
140-
"testcafe-hammerhead": "24.6.0",
140+
"testcafe-hammerhead": "24.7.2",
141141
"testcafe-legacy-api": "5.1.4",
142142
"testcafe-reporter-dashboard": "1.0.0-rc.3",
143143
"testcafe-reporter-json": "^2.1.0",

src/client/core/utils/position.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,53 @@ export function containsOffset (el: HTMLElement, offsetX?: number, offsetY?: num
127127
(typeof offsetY === 'undefined' || offsetY >= 0 && maxY >= offsetY);
128128
}
129129

130+
export function getEventAbsoluteCoordinates (ev: MouseEvent): AxisValues<number> {
131+
const el = ev.target || ev.srcElement;
132+
const pageCoordinates = getEventPageCoordinates(ev);
133+
const curDocument = domUtils.findDocument(el);
134+
let xOffset = 0;
135+
let yOffset = 0;
136+
137+
if (domUtils.isElementInIframe(curDocument.documentElement)) {
138+
const currentIframe = domUtils.getIframeByElement(curDocument);
139+
140+
if (currentIframe) {
141+
const iframeOffset = getOffsetPosition(currentIframe);
142+
const iframeBorders = styleUtils.getBordersWidth(currentIframe);
143+
144+
xOffset = iframeOffset.left + iframeBorders.left;
145+
yOffset = iframeOffset.top + iframeBorders.top;
146+
}
147+
}
148+
149+
return new AxisValues(pageCoordinates.x + xOffset, pageCoordinates.y + yOffset);
150+
}
151+
152+
export function getEventPageCoordinates (ev: MouseEvent): AxisValues<number> {
153+
const curCoordObject = /^touch/.test(ev.type) && (ev as unknown as TouchEvent).targetTouches ? (ev as unknown as TouchEvent).targetTouches[0] || (ev as unknown as TouchEvent).changedTouches[0] : ev;
154+
155+
const bothPageCoordinatesAreZero = curCoordObject.pageX === 0 && curCoordObject.pageY === 0;
156+
const notBothClientCoordinatesAreZero = curCoordObject.clientX !== 0 || curCoordObject.clientY !== 0;
157+
158+
if ((curCoordObject.pageX === null || bothPageCoordinatesAreZero && notBothClientCoordinatesAreZero) &&
159+
curCoordObject.clientX !== null) {
160+
const currentDocument = domUtils.findDocument(ev.target || ev.srcElement);
161+
const html = currentDocument.documentElement;
162+
const body = currentDocument.body;
163+
164+
return new AxisValues<number>(
165+
Math.round(curCoordObject.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) -
166+
(html.clientLeft || 0)),
167+
Math.round(curCoordObject.clientY + (html && html.scrollTop || body && body.scrollTop || 0) -
168+
(html.clientTop || 0))
169+
);
170+
}
171+
return new AxisValues<number>(
172+
Math.round(curCoordObject.pageX),
173+
Math.round(curCoordObject.pageY)
174+
);
175+
}
176+
130177
export function getIframePointRelativeToParentFrame (pos: AxisValues<number>, iframeWin: Window): AxisValues<number> {
131178
const iframe = domUtils.findIframeByWindow(iframeWin);
132179
const iframeOffset = getOffsetPosition(iframe);

test/client/fixtures/automation/click-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,9 +1161,11 @@ $(document).ready(function () {
11611161
.then(function () {
11621162
ok($area.data('clicked'), 'area element was clicked');
11631163
notOk($img.data('clicked'), 'img element was not clicked');
1164+
11641165
startNext();
11651166
});
1166-
}, TEST_RESULT_TIMEOUT);
1167+
// This test under Firefox MacOS takes a little more time.
1168+
}, TEST_RESULT_TIMEOUT + 200);
11671169
});
11681170

11691171
module('touch devices test');

test/client/fixtures/core/page-unload-barrier-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $(document).ready(function () {
7979
const iframeDocument = iframe.contentDocument;
8080
const link = iframeDocument.createElement('a');
8181

82-
link.href = '/xhr-test/750';
82+
link.href = '/xhr-test/650';
8383
link.textContent = 'link';
8484
iframeDocument.body.appendChild(link);
8585

test/functional/fixtures/api/es-next/request-hooks/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ describe('Request Hooks', () => {
2626
expect(testReport.errs[0]).contains('Error in the "respond" method');
2727
});
2828
});
29+
30+
it('Should not raise an error if response has 500 status code (GH-7213)', () => {
31+
return runTests('./testcafe-fixtures/request-mock/500-status-code.js', null, { only: 'chrome' });
32+
});
2933
});
3034

3135
describe('RequestLogger', () => {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { RequestMock } from 'testcafe';
2+
3+
fixture `Fixture`;
4+
5+
test
6+
.requestHooks(
7+
RequestMock()
8+
.onRequestTo(/d/)
9+
.respond('', 500)
10+
)
11+
('should pass', async t => {
12+
await t.expect(true).ok();
13+
});

0 commit comments

Comments
 (0)