testcafe 1.18.3 → 1.18.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/automations/click/create-mouse-click-strategy.js +59 -0
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/shared-adapter-initializer.js +15 -1
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/utils/dom-utils.js +94 -3
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/utils/position-utils.js +38 -7
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/utils/style-utils.js +8 -15
- package/lib/client/automation/index.js +1699 -1380
- package/lib/client/automation/index.min.js +1 -1
- package/lib/client/core/index.js +33 -4
- package/lib/client/core/index.min.js +1 -1
- package/lib/client/core/scroll/index.js +2 -2
- package/lib/client/core/utils/shared/position.js +2 -2
- package/lib/client/driver/index.js +143 -94
- package/lib/client/driver/index.min.js +1 -1
- package/lib/client/proxyless/index.js +5 -3
- package/lib/shared/actions/action-executor.js +4 -4
- package/lib/shared/actions/automations/click/index.js +53 -0
- package/lib/shared/actions/automations/click/mouse-click-strategy-base.js +21 -0
- package/lib/shared/actions/automations/move.js +4 -4
- package/lib/shared/actions/automations/visible-element-automation.js +162 -0
- package/lib/shared/actions/get-element.js +68 -0
- package/lib/shared/actions/utils/is-window-iframe.js +8 -0
- package/lib/shared/actions/utils/offsets.js +33 -0
- package/lib/shared/actions/utils/screen-point-to-client.js +15 -0
- package/package.json +3 -3
|
@@ -30,7 +30,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
30
30
|
if (underTopShadowUIElement === void 0) { underTopShadowUIElement = false; }
|
|
31
31
|
return testCafeUI.hide(underTopShadowUIElement)
|
|
32
32
|
.then(function () {
|
|
33
|
-
var topElement = positionUtils.getElementFromPoint(point
|
|
33
|
+
var topElement = positionUtils.getElementFromPoint(point);
|
|
34
34
|
return testCafeUI.show(underTopShadowUIElement)
|
|
35
35
|
.then(function () { return topElement; });
|
|
36
36
|
});
|
|
@@ -103,58 +103,75 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
var lastHoveredElement = null;
|
|
107
|
+
var lastHoveredElementHolder = {
|
|
108
|
+
get: function () {
|
|
109
|
+
return lastHoveredElement;
|
|
110
|
+
},
|
|
111
|
+
set: function (element) {
|
|
112
|
+
lastHoveredElement = element;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var AxisValues = /** @class */ (function () {
|
|
117
|
+
function AxisValues(x, y) {
|
|
118
|
+
this.x = x;
|
|
119
|
+
this.y = y;
|
|
113
120
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
AxisValues.create = function (a) {
|
|
122
|
+
if ('left' in a)
|
|
123
|
+
return new AxisValues(a.left, a.top);
|
|
124
|
+
else if ('right' in a)
|
|
125
|
+
return new AxisValues(a.right, a.bottom);
|
|
126
|
+
return new AxisValues(a.x, a.y);
|
|
117
127
|
};
|
|
118
|
-
|
|
128
|
+
AxisValues.prototype.add = function (p) {
|
|
129
|
+
this.x += p.x;
|
|
130
|
+
this.y += p.y;
|
|
131
|
+
return this;
|
|
119
132
|
};
|
|
120
|
-
|
|
133
|
+
AxisValues.prototype.sub = function (p) {
|
|
134
|
+
this.x -= p.x;
|
|
135
|
+
this.y -= p.y;
|
|
136
|
+
return this;
|
|
121
137
|
};
|
|
122
|
-
|
|
138
|
+
AxisValues.prototype.round = function (fn) {
|
|
139
|
+
if (fn === void 0) { fn = Math.round; }
|
|
140
|
+
this.x = fn(this.x);
|
|
141
|
+
this.y = fn(this.y);
|
|
142
|
+
return this;
|
|
123
143
|
};
|
|
124
|
-
|
|
144
|
+
AxisValues.prototype.eql = function (p) {
|
|
145
|
+
return this.x === p.x && this.y === p.y;
|
|
125
146
|
};
|
|
126
|
-
|
|
147
|
+
AxisValues.prototype.mul = function (n) {
|
|
148
|
+
this.x *= n;
|
|
149
|
+
this.y *= n;
|
|
150
|
+
return this;
|
|
127
151
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// raises an exception when we try to compare it with the current element
|
|
131
|
-
var prevElementInDocument = prevElement && testCafeCore.domUtils.isElementInDocument(prevElement);
|
|
132
|
-
var prevElementInRemovedIframe = prevElement && testCafeCore.domUtils.isElementInIframe(prevElement) &&
|
|
133
|
-
!testCafeCore.domUtils.getIframeByElement(prevElement);
|
|
134
|
-
if (!prevElementInDocument || prevElementInRemovedIframe)
|
|
135
|
-
prevElement = null;
|
|
136
|
-
var elementChanged = currentElement !== prevElement;
|
|
137
|
-
var commonAncestor = elementChanged ? testCafeCore.domUtils.getCommonAncestor(currentElement, prevElement) : null;
|
|
138
|
-
this.setup();
|
|
139
|
-
if (elementChanged && !!prevElement)
|
|
140
|
-
this.leaveElement(currentElement, prevElement, commonAncestor, options);
|
|
141
|
-
if (browserUtils.isIE)
|
|
142
|
-
this.move(currentElement, options);
|
|
143
|
-
if (elementChanged && testCafeCore.domUtils.isElementInDocument(currentElement))
|
|
144
|
-
this.enterElement(currentElement, prevElement, commonAncestor, options);
|
|
145
|
-
if (!browserUtils.isIE)
|
|
146
|
-
this.move(currentElement, options);
|
|
147
|
-
this.dragAndDrop(dragElement, currentElement, prevElement, options, dragDataStore);
|
|
148
|
-
this.teardown(currentElement, options, prevElement);
|
|
149
|
-
var dragAndDropMode = this.dragAndDropMode;
|
|
150
|
-
var dropAllowed = this.dropAllowed;
|
|
151
|
-
this.dragAndDropMode = false;
|
|
152
|
-
this.dropAllowed = false;
|
|
153
|
-
return { dragAndDropMode: dragAndDropMode, dropAllowed: dropAllowed };
|
|
152
|
+
AxisValues.prototype.distance = function (p) {
|
|
153
|
+
return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
|
154
154
|
};
|
|
155
|
-
return
|
|
155
|
+
return AxisValues;
|
|
156
156
|
}());
|
|
157
157
|
|
|
158
|
+
function getDevicePoint(clientPoint) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
return __generator(this, function (_a) {
|
|
161
|
+
if (!clientPoint)
|
|
162
|
+
return [2 /*return*/, null];
|
|
163
|
+
return [2 /*return*/, adapter.PromiseCtor.resolve(adapter.position.getWindowPosition())
|
|
164
|
+
.then(function (windowPosition) {
|
|
165
|
+
var screenLeft = windowPosition.x;
|
|
166
|
+
var screenTop = windowPosition.y;
|
|
167
|
+
var x = screenLeft + clientPoint.x;
|
|
168
|
+
var y = screenTop + clientPoint.y;
|
|
169
|
+
return new AxisValues(x, y);
|
|
170
|
+
})];
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
158
175
|
var eventSimulator = hammerhead__default.eventSandbox.eventSimulator;
|
|
159
176
|
var extend = hammerhead__default.utils.extend;
|
|
160
177
|
var nativeMethods = hammerhead__default.nativeMethods;
|
|
@@ -206,6 +223,98 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
206
223
|
return DragAndDropBehavior;
|
|
207
224
|
}());
|
|
208
225
|
|
|
226
|
+
var positionUtils$1 = testCafeCore__default.positionUtils, domUtils = testCafeCore__default.domUtils, eventUtils = testCafeCore__default.eventUtils;
|
|
227
|
+
function ensureMouseEventAfterScroll(currentElement, element, wasScrolled) {
|
|
228
|
+
return __awaiter(this, void 0, hammerhead__default.Promise, function () {
|
|
229
|
+
var elementUnderCursorContainsTarget, prevElement, commonAncestor, clientPosition, devicePoint, options;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
elementUnderCursorContainsTarget = !!currentElement && domUtils.contains(element, currentElement);
|
|
234
|
+
if (!elementUnderCursorContainsTarget || !wasScrolled)
|
|
235
|
+
return [2 /*return*/];
|
|
236
|
+
prevElement = lastHoveredElementHolder.get();
|
|
237
|
+
commonAncestor = domUtils.getCommonAncestor(currentElement, prevElement);
|
|
238
|
+
return [4 /*yield*/, positionUtils$1.getClientPosition(currentElement)];
|
|
239
|
+
case 1:
|
|
240
|
+
clientPosition = _a.sent();
|
|
241
|
+
return [4 /*yield*/, getDevicePoint(clientPosition)];
|
|
242
|
+
case 2:
|
|
243
|
+
devicePoint = _a.sent();
|
|
244
|
+
if (!devicePoint)
|
|
245
|
+
return [2 /*return*/];
|
|
246
|
+
options = {
|
|
247
|
+
clientX: clientPosition.x,
|
|
248
|
+
clientY: clientPosition.y,
|
|
249
|
+
screenX: devicePoint.x,
|
|
250
|
+
screenY: devicePoint.y,
|
|
251
|
+
ctrl: false,
|
|
252
|
+
alt: false,
|
|
253
|
+
shift: false,
|
|
254
|
+
meta: false,
|
|
255
|
+
buttons: eventUtils.BUTTONS_PARAMETER.leftButton,
|
|
256
|
+
};
|
|
257
|
+
MoveBehaviour.leaveElement(currentElement, prevElement, commonAncestor, options);
|
|
258
|
+
MoveBehaviour.enterElement(currentElement, prevElement, commonAncestor, options);
|
|
259
|
+
lastHoveredElementHolder.set(currentElement);
|
|
260
|
+
return [2 /*return*/];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
var browserUtils = hammerhead__default.utils.browser;
|
|
267
|
+
var MoveEventSequenceBase = /** @class */ (function () {
|
|
268
|
+
function MoveEventSequenceBase(_a) {
|
|
269
|
+
var moveEvent = _a.moveEvent;
|
|
270
|
+
this.dragAndDropMode = false;
|
|
271
|
+
this.dropAllowed = false;
|
|
272
|
+
this.moveEvent = moveEvent;
|
|
273
|
+
}
|
|
274
|
+
MoveEventSequenceBase.prototype.setup = function () {
|
|
275
|
+
this.dragAndDropMode = false;
|
|
276
|
+
this.dropAllowed = false;
|
|
277
|
+
};
|
|
278
|
+
MoveEventSequenceBase.prototype.leaveElement = function ( /* currentElement, prevElement, commonAncestor, options */) {
|
|
279
|
+
};
|
|
280
|
+
MoveEventSequenceBase.prototype.move = function ( /* element, options */) {
|
|
281
|
+
};
|
|
282
|
+
MoveEventSequenceBase.prototype.enterElement = function ( /* currentElement, prevElement, commonAncestor, options */) {
|
|
283
|
+
};
|
|
284
|
+
MoveEventSequenceBase.prototype.dragAndDrop = function ( /* dragElement, currentElement, prevElement, options, dragDataStore */) {
|
|
285
|
+
};
|
|
286
|
+
MoveEventSequenceBase.prototype.teardown = function ( /* currentElement, eventOptions, prevElement */) {
|
|
287
|
+
};
|
|
288
|
+
MoveEventSequenceBase.prototype.run = function (currentElement, prevElement, options, dragElement, dragDataStore) {
|
|
289
|
+
// NOTE: if last hovered element was in an iframe that has been removed, IE
|
|
290
|
+
// raises an exception when we try to compare it with the current element
|
|
291
|
+
var prevElementInDocument = prevElement && testCafeCore.domUtils.isElementInDocument(prevElement);
|
|
292
|
+
var prevElementInRemovedIframe = prevElement && testCafeCore.domUtils.isElementInIframe(prevElement) &&
|
|
293
|
+
!testCafeCore.domUtils.getIframeByElement(prevElement);
|
|
294
|
+
if (!prevElementInDocument || prevElementInRemovedIframe)
|
|
295
|
+
prevElement = null;
|
|
296
|
+
var elementChanged = currentElement !== prevElement;
|
|
297
|
+
var commonAncestor = elementChanged ? testCafeCore.domUtils.getCommonAncestor(currentElement, prevElement) : null;
|
|
298
|
+
this.setup();
|
|
299
|
+
if (elementChanged && !!prevElement)
|
|
300
|
+
this.leaveElement(currentElement, prevElement, commonAncestor, options);
|
|
301
|
+
if (browserUtils.isIE)
|
|
302
|
+
this.move(currentElement, options);
|
|
303
|
+
if (elementChanged && testCafeCore.domUtils.isElementInDocument(currentElement))
|
|
304
|
+
this.enterElement(currentElement, prevElement, commonAncestor, options);
|
|
305
|
+
if (!browserUtils.isIE)
|
|
306
|
+
this.move(currentElement, options);
|
|
307
|
+
this.dragAndDrop(dragElement, currentElement, prevElement, options, dragDataStore);
|
|
308
|
+
this.teardown(currentElement, options, prevElement);
|
|
309
|
+
var dragAndDropMode = this.dragAndDropMode;
|
|
310
|
+
var dropAllowed = this.dropAllowed;
|
|
311
|
+
this.dragAndDropMode = false;
|
|
312
|
+
this.dropAllowed = false;
|
|
313
|
+
return { dragAndDropMode: dragAndDropMode, dropAllowed: dropAllowed };
|
|
314
|
+
};
|
|
315
|
+
return MoveEventSequenceBase;
|
|
316
|
+
}());
|
|
317
|
+
|
|
209
318
|
var eventSimulator$1 = hammerhead__default.eventSandbox.eventSimulator;
|
|
210
319
|
var TOUCH_MOVE_EVENT_NAME = 'touchmove';
|
|
211
320
|
var MoveEventSequence = /** @class */ (function (_super) {
|
|
@@ -294,70 +403,600 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
294
403
|
return new DragAndDropFirstMoveEventSequence(options);
|
|
295
404
|
}
|
|
296
405
|
|
|
297
|
-
var
|
|
298
|
-
var
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
406
|
+
var Promise = hammerhead__default.Promise;
|
|
407
|
+
var messageSandbox = hammerhead__default.eventSandbox.message;
|
|
408
|
+
function sendRequestToFrame(msg, responseCmd, receiverWindow) {
|
|
409
|
+
return new Promise(function (resolve) {
|
|
410
|
+
function onMessage(e) {
|
|
411
|
+
if (e.message.cmd === responseCmd) {
|
|
412
|
+
messageSandbox.off(messageSandbox.SERVICE_MSG_RECEIVED_EVENT, onMessage);
|
|
413
|
+
resolve(e.message);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
messageSandbox.on(messageSandbox.SERVICE_MSG_RECEIVED_EVENT, onMessage);
|
|
417
|
+
messageSandbox.sendServiceMsg(msg, receiverWindow);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
308
420
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
var
|
|
314
|
-
var
|
|
315
|
-
var
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
};
|
|
331
|
-
var DispatchEventAutomation = /** @class */ (function () {
|
|
332
|
-
function DispatchEventAutomation(element, eventName, options) {
|
|
333
|
-
this.element = element;
|
|
334
|
-
this.eventName = eventName;
|
|
335
|
-
this.options = options;
|
|
421
|
+
function isIframeWindow(window) {
|
|
422
|
+
return window.top !== window;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
var Promise$1 = hammerhead__default.Promise;
|
|
426
|
+
var nativeMethods$1 = hammerhead__default.nativeMethods;
|
|
427
|
+
var browserUtils$1 = hammerhead__default.utils.browser;
|
|
428
|
+
var focusBlurSandbox = hammerhead__default.eventSandbox.focusBlur;
|
|
429
|
+
var contentEditable = testCafeCore__default.contentEditable;
|
|
430
|
+
var textSelection = testCafeCore__default.textSelection;
|
|
431
|
+
var domUtils$1 = testCafeCore__default.domUtils;
|
|
432
|
+
var styleUtils = testCafeCore__default.styleUtils;
|
|
433
|
+
var messageSandbox$1 = hammerhead__default.eventSandbox.message;
|
|
434
|
+
var GET_IFRAME_REQUEST_CMD = 'automation|iframe|request';
|
|
435
|
+
var GET_IFRAME_RESPONSE_CMD = 'automation|iframe|response';
|
|
436
|
+
messageSandbox$1.on(messageSandbox$1.SERVICE_MSG_RECEIVED_EVENT, function (e) {
|
|
437
|
+
if (e.message.cmd === GET_IFRAME_REQUEST_CMD) {
|
|
438
|
+
var iframeElement = domUtils$1.findIframeByWindow(e.source);
|
|
439
|
+
focusBlurSandbox.focus(iframeElement, function () {
|
|
440
|
+
messageSandbox$1.sendServiceMsg({ cmd: GET_IFRAME_RESPONSE_CMD }, e.source);
|
|
441
|
+
}, false);
|
|
336
442
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (Ctor) {
|
|
348
|
-
var event_1 = new Ctor(this.eventName, this.options);
|
|
349
|
-
this.element.dispatchEvent(event_1);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
DispatchEventAutomation._getEventCtorByEventType = function (eventName, eventConstructor) {
|
|
353
|
-
if (eventConstructor && typeof DispatchEventAutomation._getEventCtorFromWindow(eventConstructor) === 'function') {
|
|
354
|
-
var Ctor = DispatchEventAutomation._getEventCtorFromNativeMethods(eventConstructor);
|
|
355
|
-
if (Ctor && typeof Ctor === 'function')
|
|
356
|
-
return Ctor;
|
|
443
|
+
});
|
|
444
|
+
function setCaretPosition(element, caretPos) {
|
|
445
|
+
var isTextEditable = domUtils$1.isTextEditableElement(element);
|
|
446
|
+
var isContentEditable = domUtils$1.isContentEditableElement(element);
|
|
447
|
+
if (isTextEditable || isContentEditable) {
|
|
448
|
+
if (isContentEditable && isNaN(parseInt(caretPos, 10)))
|
|
449
|
+
textSelection.setCursorToLastVisiblePosition(element);
|
|
450
|
+
else {
|
|
451
|
+
var position = isNaN(parseInt(caretPos, 10)) ? domUtils$1.getElementValue(element).length : caretPos;
|
|
452
|
+
textSelection.select(element, position, position);
|
|
357
453
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
// NOTE: if focus is called for a non-contentEditable element (like 'img' or 'button') inside
|
|
457
|
+
// a contentEditable parent, we should try to set the right window selection. Generally, we can't
|
|
458
|
+
// set the right window selection object because after the selection setup, the window.getSelection
|
|
459
|
+
// method returns a different object, which depends on the browser.
|
|
460
|
+
var contentEditableParent = contentEditable.findContentEditableParent(element);
|
|
461
|
+
if (contentEditableParent)
|
|
462
|
+
textSelection.setCursorToLastVisiblePosition(contentEditable.findContentEditableParent(contentEditableParent));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function focusAndSetSelection(element, simulateFocus, caretPos) {
|
|
466
|
+
var _this = this;
|
|
467
|
+
return new Promise$1(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
468
|
+
var activeElement, isTextEditable, labelWithForAttr, isElementFocusable, shouldFocusByRelatedElement, isContentEditable, elementForFocus, focusWithSilentMode, focusForMouseEvent, preventScrolling, curDocument, curActiveElement, isActiveElementBody, focusableParent, elementChildOfActiveElement;
|
|
469
|
+
return __generator(this, function (_a) {
|
|
470
|
+
switch (_a.label) {
|
|
471
|
+
case 0:
|
|
472
|
+
if (!isIframeWindow(window)) return [3 /*break*/, 2];
|
|
473
|
+
return [4 /*yield*/, sendRequestToFrame({ cmd: GET_IFRAME_REQUEST_CMD }, GET_IFRAME_RESPONSE_CMD, window.parent)];
|
|
474
|
+
case 1:
|
|
475
|
+
_a.sent();
|
|
476
|
+
_a.label = 2;
|
|
477
|
+
case 2:
|
|
478
|
+
activeElement = domUtils$1.getActiveElement();
|
|
479
|
+
isTextEditable = domUtils$1.isTextEditableElement(element);
|
|
480
|
+
labelWithForAttr = domUtils$1.closest(element, 'label[for]');
|
|
481
|
+
isElementFocusable = domUtils$1.isElementFocusable(element);
|
|
482
|
+
shouldFocusByRelatedElement = !isElementFocusable && labelWithForAttr;
|
|
483
|
+
isContentEditable = domUtils$1.isContentEditableElement(element);
|
|
484
|
+
elementForFocus = isContentEditable ? contentEditable.findContentEditableParent(element) : element;
|
|
485
|
+
// NOTE: in WebKit, if selection was never set in an input element, the focus method selects all the
|
|
486
|
+
// text in this element. So, we should call select before focus to set the caret to the first symbol.
|
|
487
|
+
if (simulateFocus && browserUtils$1.isWebKit && isTextEditable)
|
|
488
|
+
textSelection.select(element, 0, 0);
|
|
489
|
+
// NOTE: we should call focus for the element related with a 'label' that has the 'for' attribute
|
|
490
|
+
if (shouldFocusByRelatedElement) {
|
|
491
|
+
if (simulateFocus)
|
|
492
|
+
focusByLabel(labelWithForAttr);
|
|
493
|
+
resolve();
|
|
494
|
+
return [2 /*return*/];
|
|
495
|
+
}
|
|
496
|
+
focusWithSilentMode = !simulateFocus;
|
|
497
|
+
focusForMouseEvent = true;
|
|
498
|
+
preventScrolling = false;
|
|
499
|
+
if (!isElementFocusable && !isContentEditable) {
|
|
500
|
+
curDocument = domUtils$1.findDocument(elementForFocus);
|
|
501
|
+
curActiveElement = nativeMethods$1.documentActiveElementGetter.call(curDocument);
|
|
502
|
+
isActiveElementBody = domUtils$1.isBodyElement(curActiveElement);
|
|
503
|
+
focusableParent = domUtils$1.isBodyElement(elementForFocus) ?
|
|
504
|
+
elementForFocus : domUtils$1.getFocusableParent(elementForFocus);
|
|
505
|
+
elementChildOfActiveElement = curActiveElement && !isActiveElementBody &&
|
|
506
|
+
domUtils$1.containsElement(curActiveElement, elementForFocus);
|
|
507
|
+
if (elementChildOfActiveElement || isActiveElementBody && domUtils$1.isBodyElement(focusableParent)) {
|
|
508
|
+
resolve();
|
|
509
|
+
return [2 /*return*/];
|
|
510
|
+
}
|
|
511
|
+
elementForFocus = focusableParent || curDocument.body;
|
|
512
|
+
preventScrolling = true;
|
|
513
|
+
}
|
|
514
|
+
focusBlurSandbox.focus(elementForFocus, function () {
|
|
515
|
+
// NOTE: if a different element was focused in the focus event handler, we should not set selection
|
|
516
|
+
if (simulateFocus && !isContentEditable && element !== domUtils$1.getActiveElement()) {
|
|
517
|
+
resolve();
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
setCaretPosition(element, caretPos);
|
|
521
|
+
// NOTE: we can't avoid the element being focused because the setSelection method leads to focusing.
|
|
522
|
+
// So, we just focus the previous active element without handlers if we don't need focus here
|
|
523
|
+
if (!simulateFocus && domUtils$1.getActiveElement() !== activeElement)
|
|
524
|
+
focusBlurSandbox.focus(activeElement, resolve, true, true);
|
|
525
|
+
else
|
|
526
|
+
resolve();
|
|
527
|
+
}, focusWithSilentMode, focusForMouseEvent, false, preventScrolling);
|
|
528
|
+
return [2 /*return*/];
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}); });
|
|
532
|
+
}
|
|
533
|
+
function getElementBoundToLabel(element) {
|
|
534
|
+
var labelWithForAttr = domUtils$1.closest(element, 'label[for]');
|
|
535
|
+
var control = labelWithForAttr && (labelWithForAttr.control || document.getElementById(labelWithForAttr.htmlFor));
|
|
536
|
+
var isControlVisible = control && styleUtils.isElementVisible(control);
|
|
537
|
+
return isControlVisible ? control : null;
|
|
538
|
+
}
|
|
539
|
+
function focusByLabel(label) {
|
|
540
|
+
if (domUtils$1.isElementFocusable(label))
|
|
541
|
+
focusBlurSandbox.focus(label, testCafeCore__default.noop, false, true);
|
|
542
|
+
else
|
|
543
|
+
focusByRelatedElement(label);
|
|
544
|
+
}
|
|
545
|
+
function focusByRelatedElement(element) {
|
|
546
|
+
var elementForFocus = getElementBoundToLabel(element);
|
|
547
|
+
if (!elementForFocus || domUtils$1.getActiveElement() === elementForFocus)
|
|
548
|
+
return;
|
|
549
|
+
focusBlurSandbox.focus(elementForFocus, testCafeCore__default.noop, false, true);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
var Promise$2 = hammerhead__default.Promise;
|
|
553
|
+
var nativeMethods$2 = hammerhead__default.nativeMethods;
|
|
554
|
+
function nextTick () {
|
|
555
|
+
return new Promise$2(function (resolve) { return nativeMethods$2.setTimeout.call(window, resolve, 0); });
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
var browserUtils$2 = hammerhead__default.utils.browser;
|
|
559
|
+
var eventSimulator$3 = hammerhead__default.eventSandbox.eventSimulator;
|
|
560
|
+
var listeners = hammerhead__default.eventSandbox.listeners;
|
|
561
|
+
var nativeMethods$3 = hammerhead__default.nativeMethods;
|
|
562
|
+
var domUtils$2 = testCafeCore__default.domUtils;
|
|
563
|
+
var styleUtils$1 = testCafeCore__default.styleUtils;
|
|
564
|
+
var selectElementUI = testCafeUI.selectElement;
|
|
565
|
+
var ElementClickCommand = /** @class */ (function () {
|
|
566
|
+
function ElementClickCommand(eventState, eventArgs) {
|
|
567
|
+
this.eventState = eventState;
|
|
568
|
+
this.eventArgs = eventArgs;
|
|
569
|
+
}
|
|
570
|
+
ElementClickCommand.prototype.run = function () {
|
|
571
|
+
if (this.eventState.clickElement)
|
|
572
|
+
eventSimulator$3.click(this.eventState.clickElement, this.eventArgs.options);
|
|
573
|
+
if (!domUtils$2.isElementFocusable(this.eventArgs.element))
|
|
574
|
+
focusByRelatedElement(this.eventArgs.element);
|
|
575
|
+
};
|
|
576
|
+
return ElementClickCommand;
|
|
577
|
+
}());
|
|
578
|
+
var LabelElementClickCommand = /** @class */ (function (_super) {
|
|
579
|
+
__extends(LabelElementClickCommand, _super);
|
|
580
|
+
function LabelElementClickCommand(eventState, eventArgs) {
|
|
581
|
+
var _this = _super.call(this, eventState, eventArgs) || this;
|
|
582
|
+
_this.label = _this.eventArgs.element;
|
|
583
|
+
_this.input = getElementBoundToLabel(_this.eventArgs.element);
|
|
584
|
+
return _this;
|
|
585
|
+
}
|
|
586
|
+
LabelElementClickCommand.prototype.run = function () {
|
|
587
|
+
var _this = this;
|
|
588
|
+
var focusRaised = false;
|
|
589
|
+
var ensureFocusRaised = function (e) {
|
|
590
|
+
focusRaised = nativeMethods$3.eventTargetGetter.call(e) === _this.input;
|
|
591
|
+
};
|
|
592
|
+
listeners.addInternalEventBeforeListener(window, ['focus'], ensureFocusRaised);
|
|
593
|
+
_super.prototype.run.call(this);
|
|
594
|
+
listeners.removeInternalEventBeforeListener(window, ['focus'], ensureFocusRaised);
|
|
595
|
+
if (domUtils$2.isElementFocusable(this.label) && !focusRaised)
|
|
596
|
+
this._ensureBoundElementFocusRaised();
|
|
597
|
+
};
|
|
598
|
+
LabelElementClickCommand.prototype._ensureBoundElementFocusRaised = function () {
|
|
599
|
+
eventSimulator$3.focus(this.input);
|
|
600
|
+
};
|
|
601
|
+
return LabelElementClickCommand;
|
|
602
|
+
}(ElementClickCommand));
|
|
603
|
+
var SelectElementClickCommand = /** @class */ (function (_super) {
|
|
604
|
+
__extends(SelectElementClickCommand, _super);
|
|
605
|
+
function SelectElementClickCommand(eventState, eventArgs) {
|
|
606
|
+
return _super.call(this, eventState, eventArgs) || this;
|
|
607
|
+
}
|
|
608
|
+
SelectElementClickCommand.prototype.run = function () {
|
|
609
|
+
_super.prototype.run.call(this);
|
|
610
|
+
this._toggleSelectOptionList();
|
|
611
|
+
};
|
|
612
|
+
SelectElementClickCommand.prototype._toggleSelectOptionList = function () {
|
|
613
|
+
// NOTE: Emulating the click event on the 'select' element doesn't expand the
|
|
614
|
+
// dropdown with options (except chrome), therefore we should emulate it.
|
|
615
|
+
var element = this.eventArgs.element;
|
|
616
|
+
var isSelectWithDropDown = styleUtils$1.getSelectElementSize(element) === 1;
|
|
617
|
+
if (isSelectWithDropDown && this.eventState.simulateDefaultBehavior !== false) {
|
|
618
|
+
if (selectElementUI.isOptionListExpanded(element))
|
|
619
|
+
selectElementUI.collapseOptionList();
|
|
620
|
+
else
|
|
621
|
+
selectElementUI.expandOptionList(element);
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
return SelectElementClickCommand;
|
|
625
|
+
}(ElementClickCommand));
|
|
626
|
+
var OptionElementClickCommand = /** @class */ (function (_super) {
|
|
627
|
+
__extends(OptionElementClickCommand, _super);
|
|
628
|
+
function OptionElementClickCommand(eventState, eventArgs) {
|
|
629
|
+
return _super.call(this, eventState, eventArgs) || this;
|
|
630
|
+
}
|
|
631
|
+
OptionElementClickCommand.prototype.run = function () {
|
|
632
|
+
return this.eventArgs.element;
|
|
633
|
+
};
|
|
634
|
+
return OptionElementClickCommand;
|
|
635
|
+
}(ElementClickCommand));
|
|
636
|
+
var LabelledCheckboxElementClickCommand = /** @class */ (function (_super) {
|
|
637
|
+
__extends(LabelledCheckboxElementClickCommand, _super);
|
|
638
|
+
function LabelledCheckboxElementClickCommand(eventState, eventArgs) {
|
|
639
|
+
var _this = _super.call(this, eventState, eventArgs) || this;
|
|
640
|
+
_this.checkbox = _this.input;
|
|
641
|
+
return _this;
|
|
642
|
+
}
|
|
643
|
+
LabelledCheckboxElementClickCommand.prototype.run = function () {
|
|
644
|
+
var changed = false;
|
|
645
|
+
var onChange = function () {
|
|
646
|
+
changed = true;
|
|
647
|
+
};
|
|
648
|
+
listeners.addInternalEventBeforeListener(window, ['change'], onChange);
|
|
649
|
+
_super.prototype.run.call(this);
|
|
650
|
+
listeners.removeInternalEventBeforeListener(window, ['change'], onChange);
|
|
651
|
+
if (browserUtils$2.isChrome && !changed)
|
|
652
|
+
this._ensureCheckboxStateChanged();
|
|
653
|
+
};
|
|
654
|
+
LabelledCheckboxElementClickCommand.prototype._ensureCheckboxStateChanged = function () {
|
|
655
|
+
this.checkbox.checked = !this.checkbox.checked;
|
|
656
|
+
eventSimulator$3.change(this.checkbox);
|
|
657
|
+
};
|
|
658
|
+
return LabelledCheckboxElementClickCommand;
|
|
659
|
+
}(LabelElementClickCommand));
|
|
660
|
+
function createClickCommand (eventState, eventArgs) {
|
|
661
|
+
var elementBoundToLabel = getElementBoundToLabel(eventArgs.element);
|
|
662
|
+
var isSelectElement = domUtils$2.isSelectElement(eventArgs.element);
|
|
663
|
+
var isOptionElement = domUtils$2.isOptionElement(eventArgs.element);
|
|
664
|
+
var isLabelElement = domUtils$2.isLabelElement(eventArgs.element) && elementBoundToLabel;
|
|
665
|
+
var isLabelledCheckbox = elementBoundToLabel && domUtils$2.isCheckboxElement(elementBoundToLabel);
|
|
666
|
+
if (isSelectElement)
|
|
667
|
+
return new SelectElementClickCommand(eventState, eventArgs);
|
|
668
|
+
if (isOptionElement)
|
|
669
|
+
return new OptionElementClickCommand(eventState, eventArgs);
|
|
670
|
+
if (isLabelledCheckbox)
|
|
671
|
+
return new LabelledCheckboxElementClickCommand(eventState, eventArgs);
|
|
672
|
+
if (isLabelElement)
|
|
673
|
+
return new LabelElementClickCommand(eventState, eventArgs);
|
|
674
|
+
return new ElementClickCommand(eventState, eventArgs);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
var MouseClickStrategyBase = /** @class */ (function () {
|
|
678
|
+
function MouseClickStrategyBase() {
|
|
679
|
+
}
|
|
680
|
+
return MouseClickStrategyBase;
|
|
681
|
+
}());
|
|
682
|
+
var MouseClickStrategyEmpty = /** @class */ (function (_super) {
|
|
683
|
+
__extends(MouseClickStrategyEmpty, _super);
|
|
684
|
+
function MouseClickStrategyEmpty() {
|
|
685
|
+
return _super.call(this) || this;
|
|
686
|
+
}
|
|
687
|
+
MouseClickStrategyEmpty.prototype.mousedown = function () {
|
|
688
|
+
throw new Error('not implemented');
|
|
689
|
+
};
|
|
690
|
+
MouseClickStrategyEmpty.prototype.mouseup = function () {
|
|
691
|
+
throw new Error('not implemented');
|
|
692
|
+
};
|
|
693
|
+
return MouseClickStrategyEmpty;
|
|
694
|
+
}(MouseClickStrategyBase));
|
|
695
|
+
|
|
696
|
+
// @ts-ignore
|
|
697
|
+
var Promise$3 = hammerhead__default.Promise;
|
|
698
|
+
var browserUtils$3 = hammerhead__default.utils.browser;
|
|
699
|
+
var featureDetection = hammerhead__default.utils.featureDetection;
|
|
700
|
+
var eventSimulator$4 = hammerhead__default.eventSandbox.eventSimulator;
|
|
701
|
+
var listeners$1 = hammerhead__default.eventSandbox.listeners;
|
|
702
|
+
var domUtils$3 = testCafeCore__default.domUtils;
|
|
703
|
+
var eventUtils$1 = testCafeCore__default.eventUtils;
|
|
704
|
+
var arrayUtils = testCafeCore__default.arrayUtils;
|
|
705
|
+
function _getElementForClick(mouseDownElement, topElement, mouseDownElementParentNodes) {
|
|
706
|
+
var topElementParentNodes = domUtils$3.getParents(topElement);
|
|
707
|
+
var areElementsSame = domUtils$3.isTheSameNode(topElement, mouseDownElement);
|
|
708
|
+
// NOTE: Mozilla Firefox always skips click, if an element under cursor has been changed after mousedown.
|
|
709
|
+
if (browserUtils$3.isFirefox)
|
|
710
|
+
return areElementsSame ? mouseDownElement : null;
|
|
711
|
+
if (!areElementsSame) {
|
|
712
|
+
// @ts-ignore
|
|
713
|
+
if (mouseDownElement.contains(topElement) && !domUtils$3.isEditableFormElement(topElement))
|
|
714
|
+
return mouseDownElement;
|
|
715
|
+
// @ts-ignore
|
|
716
|
+
if (topElement.contains(mouseDownElement))
|
|
717
|
+
return topElement;
|
|
718
|
+
// NOTE: If elements are not in the parent-child relationships,
|
|
719
|
+
// non-ff browsers raise the `click` event for their common parent.
|
|
720
|
+
return arrayUtils.getCommonElement(topElementParentNodes, mouseDownElementParentNodes);
|
|
721
|
+
}
|
|
722
|
+
// NOTE: In case the target element and the top element are the same,
|
|
723
|
+
// non-FF browsers are dispatching the `click` event if the target
|
|
724
|
+
// element hasn't changed its position in the DOM after mousedown.
|
|
725
|
+
return arrayUtils.equals(mouseDownElementParentNodes, topElementParentNodes) ? mouseDownElement : null;
|
|
726
|
+
}
|
|
727
|
+
var MouseClickStrategy = /** @class */ (function (_super) {
|
|
728
|
+
__extends(MouseClickStrategy, _super);
|
|
729
|
+
function MouseClickStrategy(element, caretPos) {
|
|
730
|
+
var _this = _super.call(this) || this;
|
|
731
|
+
_this.element = element;
|
|
732
|
+
_this.caretPos = caretPos;
|
|
733
|
+
_this.targetElementParentNodes = [];
|
|
734
|
+
_this.activeElementBeforeMouseDown = null;
|
|
735
|
+
_this.mouseDownElement = null;
|
|
736
|
+
_this.eventState = {
|
|
737
|
+
mousedownPrevented: false,
|
|
738
|
+
blurRaised: false,
|
|
739
|
+
simulateDefaultBehavior: true,
|
|
740
|
+
clickElement: null,
|
|
741
|
+
touchStartCancelled: false,
|
|
742
|
+
touchEndCancelled: false,
|
|
743
|
+
};
|
|
744
|
+
return _this;
|
|
745
|
+
}
|
|
746
|
+
MouseClickStrategy.prototype.mousedown = function (eventArgs) {
|
|
747
|
+
var _this = this;
|
|
748
|
+
this.targetElementParentNodes = domUtils$3.getParents(eventArgs.element);
|
|
749
|
+
this.mouseDownElement = eventArgs.element;
|
|
750
|
+
this._raiseTouchEvents(eventArgs);
|
|
751
|
+
var activeElement = domUtils$3.getActiveElement();
|
|
752
|
+
this.activeElementBeforeMouseDown = activeElement;
|
|
753
|
+
// NOTE: In WebKit and IE, the mousedown event opens the select element's dropdown;
|
|
754
|
+
// therefore, we should prevent mousedown and hide the dropdown (B236416).
|
|
755
|
+
var needCloseSelectDropDown = (browserUtils$3.isWebKit || browserUtils$3.isIE) &&
|
|
756
|
+
domUtils$3.isSelectElement(this.mouseDownElement);
|
|
757
|
+
if (needCloseSelectDropDown)
|
|
758
|
+
this._bindMousedownHandler();
|
|
759
|
+
this._bindBlurHandler(activeElement);
|
|
760
|
+
if (!this._isTouchEventWasCancelled())
|
|
761
|
+
this.eventState.simulateDefaultBehavior = eventSimulator$4.mousedown(eventArgs.element, eventArgs.options);
|
|
762
|
+
if (this.eventState.simulateDefaultBehavior === false)
|
|
763
|
+
this.eventState.simulateDefaultBehavior = needCloseSelectDropDown && !this.eventState.mousedownPrevented;
|
|
764
|
+
return this._ensureActiveElementBlur(activeElement)
|
|
765
|
+
.then(function () { return _this._focus(eventArgs); });
|
|
766
|
+
};
|
|
767
|
+
MouseClickStrategy.prototype.mouseup = function (element, eventArgs) {
|
|
768
|
+
eventArgs.element = element;
|
|
769
|
+
this.eventState.clickElement = _getElementForClick(this.mouseDownElement, element, this.targetElementParentNodes);
|
|
770
|
+
var timeStamp = {};
|
|
771
|
+
var getTimeStamp = function (e) {
|
|
772
|
+
timeStamp = e.timeStamp;
|
|
773
|
+
listeners$1.removeInternalEventBeforeListener(window, ['mouseup'], getTimeStamp);
|
|
774
|
+
};
|
|
775
|
+
if (!browserUtils$3.isIE)
|
|
776
|
+
listeners$1.addInternalEventBeforeListener(window, ['mouseup'], getTimeStamp);
|
|
777
|
+
if (!this._isTouchEventWasCancelled())
|
|
778
|
+
eventSimulator$4.mouseup(element, eventArgs.options);
|
|
779
|
+
if (eventArgs.options)
|
|
780
|
+
eventArgs.options.timeStamp = timeStamp;
|
|
781
|
+
return this._click(eventArgs);
|
|
782
|
+
};
|
|
783
|
+
MouseClickStrategy.prototype._click = function (eventArgs) {
|
|
784
|
+
return __awaiter(this, void 0, hammerhead__default.Promise, function () {
|
|
785
|
+
var clickCommand;
|
|
786
|
+
return __generator(this, function (_a) {
|
|
787
|
+
clickCommand = createClickCommand(this.eventState, eventArgs);
|
|
788
|
+
if (!this._isTouchEventWasCancelled())
|
|
789
|
+
clickCommand.run();
|
|
790
|
+
return [2 /*return*/, eventArgs];
|
|
791
|
+
});
|
|
792
|
+
});
|
|
793
|
+
};
|
|
794
|
+
// NOTE:
|
|
795
|
+
// If `touchstart`, `touchmove`, or `touchend` are canceled, we should not dispatch any mouse event
|
|
796
|
+
// that would be a consequential result of the prevented touch event
|
|
797
|
+
MouseClickStrategy.prototype._isTouchEventWasCancelled = function () {
|
|
798
|
+
return this.eventState.touchStartCancelled || this.eventState.touchEndCancelled;
|
|
799
|
+
};
|
|
800
|
+
MouseClickStrategy.prototype._bindMousedownHandler = function () {
|
|
801
|
+
var _this = this;
|
|
802
|
+
var onmousedown = function (e) {
|
|
803
|
+
_this.eventState.mousedownPrevented = e.defaultPrevented;
|
|
804
|
+
eventUtils$1.preventDefault(e);
|
|
805
|
+
eventUtils$1.unbind(_this.element, 'mousedown', onmousedown);
|
|
806
|
+
};
|
|
807
|
+
eventUtils$1.bind(this.element, 'mousedown', onmousedown);
|
|
808
|
+
};
|
|
809
|
+
MouseClickStrategy.prototype._bindBlurHandler = function (element) {
|
|
810
|
+
var _this = this;
|
|
811
|
+
var onblur = function () {
|
|
812
|
+
_this.eventState.blurRaised = true;
|
|
813
|
+
eventUtils$1.unbind(element, 'blur', onblur, true);
|
|
814
|
+
};
|
|
815
|
+
eventUtils$1.bind(element, 'blur', onblur, true);
|
|
816
|
+
};
|
|
817
|
+
MouseClickStrategy.prototype._ensureActiveElementBlur = function (element) {
|
|
818
|
+
var _this = this;
|
|
819
|
+
// NOTE: In some cases, mousedown may lead to active element change (browsers raise blur).
|
|
820
|
+
// We simulate the blur event if the active element was changed after the mousedown, and
|
|
821
|
+
// the blur event does not get raised automatically (B239273, B253520)
|
|
822
|
+
return new Promise$3(function (resolve) {
|
|
823
|
+
var simulateBlur = domUtils$3.getActiveElement() !== element && !_this.eventState.blurRaised;
|
|
824
|
+
if (!simulateBlur) {
|
|
825
|
+
resolve();
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (browserUtils$3.isIE && browserUtils$3.version < 12) {
|
|
829
|
+
// NOTE: In whatever way an element is blurred from the client script, the
|
|
830
|
+
// blur event is raised asynchronously in IE (in MSEdge focus/blur is sync)
|
|
831
|
+
nextTick()
|
|
832
|
+
.then(function () {
|
|
833
|
+
if (!_this.eventState.blurRaised)
|
|
834
|
+
eventSimulator$4.blur(element);
|
|
835
|
+
resolve();
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
eventSimulator$4.blur(element);
|
|
840
|
+
resolve();
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
};
|
|
844
|
+
MouseClickStrategy.prototype._focus = function (eventArgs) {
|
|
845
|
+
if (this.eventState.simulateDefaultBehavior === false)
|
|
846
|
+
return Promise$3.resolve();
|
|
847
|
+
// NOTE: If a target element is a contentEditable element, we need to call focusAndSetSelection directly for
|
|
848
|
+
// this element. Otherwise, if the element obtained by elementFromPoint is a child of the contentEditable
|
|
849
|
+
// element, a selection position may be calculated incorrectly (by using the caretPos option).
|
|
850
|
+
var elementForFocus = domUtils$3.isContentEditableElement(this.element) ? this.element : eventArgs.element;
|
|
851
|
+
// NOTE: IE doesn't perform focus if active element has been changed while executing mousedown
|
|
852
|
+
var simulateFocus = !browserUtils$3.isIE || this.activeElementBeforeMouseDown === domUtils$3.getActiveElement();
|
|
853
|
+
return focusAndSetSelection(elementForFocus, simulateFocus, this.caretPos);
|
|
854
|
+
};
|
|
855
|
+
MouseClickStrategy.prototype._raiseTouchEvents = function (eventArgs) {
|
|
856
|
+
if (featureDetection.isTouchDevice) {
|
|
857
|
+
this.eventState.touchStartCancelled = !eventSimulator$4.touchstart(eventArgs.element, eventArgs.options);
|
|
858
|
+
this.eventState.touchEndCancelled = !eventSimulator$4.touchend(eventArgs.element, eventArgs.options);
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
return MouseClickStrategy;
|
|
862
|
+
}(MouseClickStrategyBase));
|
|
863
|
+
function createMouseClickStrategy(element, caretPos) {
|
|
864
|
+
return new MouseClickStrategy(element, caretPos);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
var Cursor = /** @class */ (function () {
|
|
868
|
+
function Cursor(activeWin, ui) {
|
|
869
|
+
this._ui = ui;
|
|
870
|
+
// NOTE: the default position should be outside of the page (GH-794)
|
|
871
|
+
this._x = -1;
|
|
872
|
+
this._y = -1;
|
|
873
|
+
this._activeWindow = activeWin;
|
|
874
|
+
}
|
|
875
|
+
Cursor.prototype._ensureActiveWindow = function (win) {
|
|
876
|
+
if (this._activeWindow === win || this._activeWindow === win.parent)
|
|
877
|
+
return;
|
|
878
|
+
if (this._activeWindow.parent !== win)
|
|
879
|
+
this._activeWindow = win;
|
|
880
|
+
};
|
|
881
|
+
Cursor.prototype.isActive = function (currWin) {
|
|
882
|
+
this._ensureActiveWindow(currWin);
|
|
883
|
+
return this._activeWindow === currWin;
|
|
884
|
+
};
|
|
885
|
+
Cursor.prototype.setActiveWindow = function (win) {
|
|
886
|
+
this._activeWindow = win;
|
|
887
|
+
};
|
|
888
|
+
Cursor.prototype.getActiveWindow = function (currWin) {
|
|
889
|
+
this._ensureActiveWindow(currWin);
|
|
890
|
+
return this._activeWindow;
|
|
891
|
+
};
|
|
892
|
+
Cursor.prototype.getPosition = function () {
|
|
893
|
+
return new AxisValues(this._x, this._y);
|
|
894
|
+
};
|
|
895
|
+
Cursor.prototype.move = function (point) {
|
|
896
|
+
this._x = point.x;
|
|
897
|
+
this._y = point.y;
|
|
898
|
+
return this._ui.move(point);
|
|
899
|
+
};
|
|
900
|
+
Cursor.prototype.hide = function () {
|
|
901
|
+
if (this._ui.hide)
|
|
902
|
+
return this._ui.hide();
|
|
903
|
+
return adapter.PromiseCtor.resolve();
|
|
904
|
+
};
|
|
905
|
+
Cursor.prototype.show = function () {
|
|
906
|
+
if (this._ui.show)
|
|
907
|
+
return this._ui.show();
|
|
908
|
+
return adapter.PromiseCtor.resolve();
|
|
909
|
+
};
|
|
910
|
+
Cursor.prototype.leftButtonDown = function () {
|
|
911
|
+
return this._ui.leftButtonDown();
|
|
912
|
+
};
|
|
913
|
+
Cursor.prototype.rightButtonDown = function () {
|
|
914
|
+
return this._ui.rightButtonDown();
|
|
915
|
+
};
|
|
916
|
+
Cursor.prototype.buttonUp = function () {
|
|
917
|
+
return this._ui.buttonUp();
|
|
918
|
+
};
|
|
919
|
+
return Cursor;
|
|
920
|
+
}());
|
|
921
|
+
|
|
922
|
+
var cursorUI = !isIframeWindow(window) ? testCafeUI.cursorUI : testCafeUI.iframeCursorUI;
|
|
923
|
+
var cursor = new Cursor(window.top, cursorUI);
|
|
924
|
+
|
|
925
|
+
var nativeMethods$4 = hammerhead__default.nativeMethods, Promise$4 = hammerhead__default.Promise, _a = hammerhead__default.utils, browser = _a.browser, featureDetection$1 = _a.featureDetection, extend$1 = _a.extend;
|
|
926
|
+
var dom = testCafeCore__default.domUtils, position = testCafeCore__default.positionUtils, ScrollAutomation = testCafeCore__default.ScrollAutomation, style = testCafeCore__default.styleUtils, event = testCafeCore__default.eventUtils;
|
|
927
|
+
initializeAdapter({
|
|
928
|
+
PromiseCtor: Promise$4,
|
|
929
|
+
nativeMethods: nativeMethods$4,
|
|
930
|
+
scroll: function (el, scrollOptions) { return new ScrollAutomation(el, scrollOptions).run(); },
|
|
931
|
+
getElementExceptUI: getElementFromPoint,
|
|
932
|
+
dom: dom, position: position, style: style, event: event, browser: browser, featureDetection: featureDetection$1,
|
|
933
|
+
utils: { extend: extend$1 },
|
|
934
|
+
createEventSequence: createEventSequence,
|
|
935
|
+
sendRequestToFrame: testCafeCore__default.sendRequestToFrame,
|
|
936
|
+
ensureMouseEventAfterScroll: ensureMouseEventAfterScroll,
|
|
937
|
+
automations: {
|
|
938
|
+
click: {
|
|
939
|
+
createMouseClickStrategy: createMouseClickStrategy,
|
|
940
|
+
},
|
|
941
|
+
_ensureWindowAndCursorForLegacyTests: function (automation) {
|
|
942
|
+
automation.window = automation.window || window;
|
|
943
|
+
automation.cursor = cursor;
|
|
944
|
+
},
|
|
945
|
+
},
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
var nativeMethods$5 = hammerhead__default.nativeMethods;
|
|
949
|
+
var MOUSE_EVENT_NAME_RE = /^((mouse\w+)|((dbl)?click)|(contextmenu))$/;
|
|
950
|
+
var DRAG_EVENT_NAME_RE = /^((drag\w*)|(drop))$/;
|
|
951
|
+
var KEY_EVENT_NAME_RE = /^key\w+$/;
|
|
952
|
+
var INPUT_EVENT_NAME_RE = /^(before)?input$/;
|
|
953
|
+
var FOCUS_EVENT_NAME_RE = /^(blur|(focus(in|out)?))$/;
|
|
954
|
+
var POINTER_EVENT_NAME_RE = /^pointer\w+/;
|
|
955
|
+
var DEFAULT_MOUSE_EVENT_DETAIL_PROP_VALUE = {
|
|
956
|
+
click: 1,
|
|
957
|
+
dblclick: 2,
|
|
958
|
+
mousedown: 1,
|
|
959
|
+
mouseup: 1,
|
|
960
|
+
};
|
|
961
|
+
// NOTE: default e.buttons for left button pressed
|
|
962
|
+
var DEFAULT_BUTTONS_PARAMETER = 1;
|
|
963
|
+
var EVENT_CTORS = {
|
|
964
|
+
MouseEvent: 'MouseEvent',
|
|
965
|
+
PointerEvent: 'PointerEvent',
|
|
966
|
+
KeyboardEvent: 'KeyboardEvent',
|
|
967
|
+
InputEvent: 'InputEvent',
|
|
968
|
+
FocusEvent: 'FocusEvent',
|
|
969
|
+
};
|
|
970
|
+
var DispatchEventAutomation = /** @class */ (function () {
|
|
971
|
+
function DispatchEventAutomation(element, eventName, options) {
|
|
972
|
+
this.element = element;
|
|
973
|
+
this.eventName = eventName;
|
|
974
|
+
this.options = options;
|
|
975
|
+
}
|
|
976
|
+
DispatchEventAutomation.prototype.run = function () {
|
|
977
|
+
var _a = this.options, bubbles = _a.bubbles, cancelable = _a.cancelable, detail = _a.detail, view = _a.view, buttons = _a.buttons;
|
|
978
|
+
bubbles = bubbles !== false;
|
|
979
|
+
cancelable = cancelable !== false;
|
|
980
|
+
detail = detail || DEFAULT_MOUSE_EVENT_DETAIL_PROP_VALUE[this.eventName];
|
|
981
|
+
view = window;
|
|
982
|
+
buttons = buttons === void 0 ? DEFAULT_BUTTONS_PARAMETER : buttons;
|
|
983
|
+
// eslint-disable-next-line no-restricted-globals
|
|
984
|
+
Object.assign(this.options, { bubbles: bubbles, cancelable: cancelable, detail: detail, view: view, buttons: buttons });
|
|
985
|
+
var Ctor = DispatchEventAutomation._getEventCtorByEventType(this.eventName, this.options.eventConstructor);
|
|
986
|
+
if (Ctor) {
|
|
987
|
+
var event_1 = new Ctor(this.eventName, this.options);
|
|
988
|
+
this.element.dispatchEvent(event_1);
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
DispatchEventAutomation._getEventCtorByEventType = function (eventName, eventConstructor) {
|
|
992
|
+
if (eventConstructor && typeof DispatchEventAutomation._getEventCtorFromWindow(eventConstructor) === 'function') {
|
|
993
|
+
var Ctor = DispatchEventAutomation._getEventCtorFromNativeMethods(eventConstructor);
|
|
994
|
+
if (Ctor && typeof Ctor === 'function')
|
|
995
|
+
return Ctor;
|
|
996
|
+
}
|
|
997
|
+
if (MOUSE_EVENT_NAME_RE.test(eventName))
|
|
998
|
+
return DispatchEventAutomation._getEventCtorFromNativeMethods(EVENT_CTORS.MouseEvent);
|
|
999
|
+
if (DRAG_EVENT_NAME_RE.test(eventName))
|
|
361
1000
|
return DispatchEventAutomation._getEventCtorFromNativeMethods(EVENT_CTORS.MouseEvent);
|
|
362
1001
|
if (POINTER_EVENT_NAME_RE.test(eventName))
|
|
363
1002
|
return DispatchEventAutomation._getEventCtorFromNativeMethods(EVENT_CTORS.PointerEvent);
|
|
@@ -370,7 +1009,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
370
1009
|
return DispatchEventAutomation._getEventCtorFromNativeMethods('CustomEvent');
|
|
371
1010
|
};
|
|
372
1011
|
DispatchEventAutomation._getEventCtorFromNativeMethods = function (eventCtor) {
|
|
373
|
-
var ctor = nativeMethods$
|
|
1012
|
+
var ctor = nativeMethods$5['Window' + eventCtor] || DispatchEventAutomation._getEventCtorFromWindow(eventCtor);
|
|
374
1013
|
return ctor;
|
|
375
1014
|
};
|
|
376
1015
|
DispatchEventAutomation._getEventCtorFromWindow = function (eventCtor) {
|
|
@@ -380,35 +1019,37 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
380
1019
|
return DispatchEventAutomation;
|
|
381
1020
|
}());
|
|
382
1021
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
1022
|
+
function getAutomationPoint(element, offset) {
|
|
1023
|
+
return adapter.PromiseCtor.resolve(adapter.dom.isDocumentElement(element))
|
|
1024
|
+
.then(function (isDocEl) {
|
|
1025
|
+
if (isDocEl)
|
|
1026
|
+
return new AxisValues(0, 0);
|
|
1027
|
+
var roundFn = adapter.browser.isFirefox ? Math.ceil : Math.round;
|
|
1028
|
+
return adapter.PromiseCtor.resolve(adapter.position.getOffsetPosition(element, roundFn))
|
|
1029
|
+
.then(function (elementOffset) { return AxisValues.create(elementOffset); });
|
|
1030
|
+
})
|
|
1031
|
+
.then(function (point) { return point.add(offset); });
|
|
393
1032
|
}
|
|
394
1033
|
|
|
395
1034
|
function convertToClient(element, point) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
1035
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1036
|
+
var elementScroll, hasScroll;
|
|
1037
|
+
return __generator(this, function (_a) {
|
|
1038
|
+
switch (_a.label) {
|
|
1039
|
+
case 0: return [4 /*yield*/, adapter.style.getElementScroll(element)];
|
|
1040
|
+
case 1:
|
|
1041
|
+
elementScroll = _a.sent();
|
|
1042
|
+
return [4 /*yield*/, adapter.style.hasScroll(element)];
|
|
1043
|
+
case 2:
|
|
1044
|
+
hasScroll = _a.sent();
|
|
1045
|
+
if (!/html/i.test(element.tagName) && hasScroll) {
|
|
1046
|
+
point.x -= elementScroll.left;
|
|
1047
|
+
point.y -= elementScroll.top;
|
|
1048
|
+
}
|
|
1049
|
+
return [2 /*return*/, adapter.position.offsetToClientCoords(point)];
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
});
|
|
412
1053
|
}
|
|
413
1054
|
|
|
414
1055
|
function calcOffset(size) {
|
|
@@ -416,104 +1057,108 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
416
1057
|
return offset < 1 ? 0 : Math.round(offset);
|
|
417
1058
|
}
|
|
418
1059
|
function getDefaultAutomationOffsets(element) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
1060
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1061
|
+
var rect, offsetX, offsetY;
|
|
1062
|
+
return __generator(this, function (_a) {
|
|
1063
|
+
switch (_a.label) {
|
|
1064
|
+
case 0: return [4 /*yield*/, adapter.position.getElementRectangle(element)];
|
|
1065
|
+
case 1:
|
|
1066
|
+
rect = _a.sent();
|
|
1067
|
+
offsetX = calcOffset(rect.width);
|
|
1068
|
+
offsetY = calcOffset(rect.height);
|
|
1069
|
+
return [2 /*return*/, { offsetX: offsetX, offsetY: offsetY }];
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
423
1073
|
}
|
|
424
1074
|
function getOffsetOptions(element, offsetX, offsetY) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
1075
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1076
|
+
var defaultOffsets, dimensions, width, height, maxX, maxY;
|
|
1077
|
+
return __generator(this, function (_a) {
|
|
1078
|
+
switch (_a.label) {
|
|
1079
|
+
case 0: return [4 /*yield*/, getDefaultAutomationOffsets(element)];
|
|
1080
|
+
case 1:
|
|
1081
|
+
defaultOffsets = _a.sent();
|
|
1082
|
+
offsetX = typeof offsetX === 'number' ? Math.round(offsetX) : defaultOffsets.offsetX;
|
|
1083
|
+
offsetY = typeof offsetY === 'number' ? Math.round(offsetY) : defaultOffsets.offsetY;
|
|
1084
|
+
if (offsetX > 0 && offsetY > 0)
|
|
1085
|
+
return [2 /*return*/, { offsetX: offsetX, offsetY: offsetY }];
|
|
1086
|
+
return [4 /*yield*/, adapter.position.getClientDimensions(element)];
|
|
1087
|
+
case 2:
|
|
1088
|
+
dimensions = _a.sent();
|
|
1089
|
+
width = Math.round(Math.max(element.scrollWidth, dimensions.width));
|
|
1090
|
+
height = Math.round(Math.max(element.scrollHeight, dimensions.height));
|
|
1091
|
+
maxX = dimensions.scrollbar.right + dimensions.border.left + dimensions.border.right + width;
|
|
1092
|
+
maxY = dimensions.scrollbar.bottom + dimensions.border.top + dimensions.border.bottom + height;
|
|
1093
|
+
return [2 /*return*/, {
|
|
1094
|
+
offsetX: offsetX < 0 ? maxX + offsetX : offsetX,
|
|
1095
|
+
offsetY: offsetY < 0 ? maxY + offsetY : offsetY,
|
|
1096
|
+
}];
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
439
1100
|
}
|
|
440
1101
|
|
|
441
|
-
function isIframeWindow(window) {
|
|
442
|
-
return window.
|
|
1102
|
+
function isIframeWindow$1(window) {
|
|
1103
|
+
return !window.parent || window.parent !== window;
|
|
443
1104
|
}
|
|
444
1105
|
|
|
445
|
-
var browserUtils$2 = hammerhead__default.utils.browser;
|
|
446
|
-
var Promise$1 = hammerhead__default.Promise;
|
|
447
|
-
var nativeMethods$3 = hammerhead__default.nativeMethods;
|
|
448
|
-
var positionUtils$1 = testCafeCore__default.positionUtils;
|
|
449
|
-
var domUtils = testCafeCore__default.domUtils;
|
|
450
|
-
function fromPoint(point /*: AxisValuesData<number>*/, underTopShadowUIElement) {
|
|
451
|
-
var topElement = null;
|
|
452
|
-
return testCafeUI.hide(underTopShadowUIElement)
|
|
453
|
-
.then(function () {
|
|
454
|
-
topElement = positionUtils$1.getElementFromPoint(point.x, point.y);
|
|
455
|
-
return testCafeUI.show(underTopShadowUIElement);
|
|
456
|
-
})
|
|
457
|
-
.then(function () { return topElement; });
|
|
458
|
-
}
|
|
459
1106
|
function ensureImageMap(imgElement, areaElement) {
|
|
460
|
-
|
|
461
|
-
|
|
1107
|
+
return adapter.PromiseCtor.resolve(adapter.dom.closest(areaElement, 'map'))
|
|
1108
|
+
.then(function (mapElement) {
|
|
1109
|
+
return mapElement && mapElement.name === adapter.dom.getImgMapName(imgElement) ? areaElement : imgElement;
|
|
1110
|
+
});
|
|
462
1111
|
}
|
|
463
|
-
function findElementOrNonEmptyChildFromPoint(
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
1112
|
+
function findElementOrNonEmptyChildFromPoint(point, element) {
|
|
1113
|
+
return adapter.PromiseCtor.resolve(adapter.position.getElementFromPoint(point))
|
|
1114
|
+
.then(function (topElement) {
|
|
1115
|
+
return adapter.PromiseCtor.resolve(adapter.dom.containsElement(element, topElement))
|
|
1116
|
+
.then(function (containsEl) { return containsEl && adapter.dom.getNodeText(topElement); })
|
|
1117
|
+
.then(function (isNonEmptyChild) { return isNonEmptyChild || topElement && adapter.dom.isNodeEqual(topElement, element) ? topElement : null; });
|
|
1118
|
+
});
|
|
470
1119
|
}
|
|
471
1120
|
function correctTopElementByExpectedElement(topElement, expectedElement) {
|
|
472
|
-
|
|
473
|
-
if (!expectedElementDefined || !topElement || topElement === expectedElement)
|
|
1121
|
+
if (!expectedElement || !topElement || adapter.dom.isNodeEqual(topElement, expectedElement))
|
|
474
1122
|
return topElement;
|
|
475
|
-
var isTREFElement =
|
|
1123
|
+
var isTREFElement = adapter.dom.getTagName(expectedElement) === 'tref';
|
|
476
1124
|
// NOTE: 'document.elementFromPoint' can't find these types of elements
|
|
477
1125
|
if (isTREFElement)
|
|
478
1126
|
return expectedElement;
|
|
479
1127
|
// NOTE: T299665 - Incorrect click automation for images with an associated map element in Firefox
|
|
480
1128
|
// All browsers return the <area> element from document.getElementFromPoint, but
|
|
481
1129
|
// Firefox returns the <img> element. We should accomplish this for Firefox as well.
|
|
482
|
-
var isImageMapArea =
|
|
483
|
-
if (
|
|
1130
|
+
var isImageMapArea = adapter.dom.getTagName(expectedElement) === 'area' && adapter.dom.isImgElement(topElement);
|
|
1131
|
+
if (adapter.browser.isFirefox && isImageMapArea)
|
|
484
1132
|
return ensureImageMap(topElement, expectedElement);
|
|
485
1133
|
// NOTE: try to find a multi-line link by its rectangle (T163678)
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
1134
|
+
return adapter.PromiseCtor.resolve(adapter.dom.closest(expectedElement, 'a'))
|
|
1135
|
+
.then(function (anchor) { return !!anchor; })
|
|
1136
|
+
.then(function (isLinkOrChildExpected) {
|
|
1137
|
+
if (!isLinkOrChildExpected)
|
|
1138
|
+
return false;
|
|
1139
|
+
return adapter.PromiseCtor.resolve(adapter.dom.containsElement(expectedElement, topElement))
|
|
1140
|
+
.then(function (containsElement) { return containsElement && adapter.dom.getNodeText(topElement); })
|
|
1141
|
+
.then(function (isTopElementChildOfLink) { return !isTopElementChildOfLink && adapter.dom.getNodeText(expectedElement); });
|
|
1142
|
+
})
|
|
1143
|
+
.then(function (shouldSearchForMultilineLink) {
|
|
1144
|
+
if (!shouldSearchForMultilineLink)
|
|
1145
|
+
return topElement;
|
|
1146
|
+
return adapter.PromiseCtor.resolve(adapter.position.getClientDimensions(expectedElement))
|
|
1147
|
+
.then(function (linkRect) { return findElementOrNonEmptyChildFromPoint({ x: linkRect.right - 1, y: linkRect.top + 1 }, expectedElement)
|
|
1148
|
+
.then(function (el) { return el || findElementOrNonEmptyChildFromPoint({ x: linkRect.left + 1, y: linkRect.bottom - 1 }, expectedElement); })
|
|
1149
|
+
.then(function (el) { return el || topElement; }); });
|
|
1150
|
+
});
|
|
499
1151
|
}
|
|
500
|
-
function getElementFromPoint$1(point
|
|
501
|
-
return
|
|
1152
|
+
function getElementFromPoint$1(point, win, expectedEl) {
|
|
1153
|
+
return adapter.getElementExceptUI(point)
|
|
502
1154
|
.then(function (topElement) {
|
|
503
|
-
var foundElement = topElement;
|
|
504
1155
|
// NOTE: when trying to get an element by elementFromPoint in iframe and the target
|
|
505
1156
|
// element is under any of shadow-ui elements, you will get null (only in IE).
|
|
506
1157
|
// In this case, you should hide a top window's shadow-ui root to obtain an element.
|
|
507
|
-
var resChain =
|
|
508
|
-
if (!
|
|
509
|
-
resChain = resChain
|
|
510
|
-
|
|
511
|
-
.then(function (element) {
|
|
512
|
-
foundElement = element;
|
|
513
|
-
return element;
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
return resChain.then(function (element) { return correctTopElementByExpectedElement(element, expectedElement); });
|
|
1158
|
+
var resChain = adapter.PromiseCtor.resolve(topElement);
|
|
1159
|
+
if (!topElement && isIframeWindow$1(win) && point.x > 0 && point.y > 0)
|
|
1160
|
+
resChain = resChain.then(function () { return adapter.getElementExceptUI(point, true); });
|
|
1161
|
+
return resChain.then(function (element) { return correctTopElementByExpectedElement(element, expectedEl); });
|
|
517
1162
|
});
|
|
518
1163
|
}
|
|
519
1164
|
|
|
@@ -566,6 +1211,15 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
566
1211
|
return AutomationSettings;
|
|
567
1212
|
}());
|
|
568
1213
|
|
|
1214
|
+
function delay(ms) {
|
|
1215
|
+
var setTimeout = adapter.nativeMethods.setTimeout;
|
|
1216
|
+
return new adapter.PromiseCtor(function (resolve) { return setTimeout(resolve, ms); });
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
function nextTick$1() {
|
|
1220
|
+
return delay(0);
|
|
1221
|
+
}
|
|
1222
|
+
|
|
569
1223
|
// -------------------------------------------------------------
|
|
570
1224
|
// WARNING: this file is used by both the client and the server.
|
|
571
1225
|
// Do not use any browser or node-specific API!
|
|
@@ -1405,206 +2059,26 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1405
2059
|
return [
|
|
1406
2060
|
{ name: 'timeout', type: positiveIntegerOption },
|
|
1407
2061
|
{ name: 'allowUnawaitedPromise', type: booleanOption },
|
|
1408
|
-
];
|
|
1409
|
-
};
|
|
1410
|
-
return AssertionOptions;
|
|
1411
|
-
}(Assignable));
|
|
1412
|
-
// Press
|
|
1413
|
-
var PressOptions = /** @class */ (function (_super) {
|
|
1414
|
-
__extends(PressOptions, _super);
|
|
1415
|
-
function PressOptions(obj, validate) {
|
|
1416
|
-
var _this = _super.call(this) || this;
|
|
1417
|
-
_this.confidential = void 0;
|
|
1418
|
-
_this._assignFrom(obj, validate);
|
|
1419
|
-
return _this;
|
|
1420
|
-
}
|
|
1421
|
-
PressOptions.prototype._getAssignableProperties = function () {
|
|
1422
|
-
return _super.prototype._getAssignableProperties.call(this).concat([
|
|
1423
|
-
{ name: 'confidential', type: booleanOption },
|
|
1424
|
-
]);
|
|
1425
|
-
};
|
|
1426
|
-
return PressOptions;
|
|
1427
|
-
}(ActionOptions));
|
|
1428
|
-
|
|
1429
|
-
var AxisValues = /** @class */ (function () {
|
|
1430
|
-
function AxisValues(x, y) {
|
|
1431
|
-
this.x = x;
|
|
1432
|
-
this.y = y;
|
|
1433
|
-
}
|
|
1434
|
-
AxisValues.create = function (a) {
|
|
1435
|
-
if ('left' in a)
|
|
1436
|
-
return new AxisValues(a.left, a.top);
|
|
1437
|
-
else if ('right' in a)
|
|
1438
|
-
return new AxisValues(a.right, a.bottom);
|
|
1439
|
-
return new AxisValues(a.x, a.y);
|
|
1440
|
-
};
|
|
1441
|
-
AxisValues.prototype.add = function (p) {
|
|
1442
|
-
this.x += p.x;
|
|
1443
|
-
this.y += p.y;
|
|
1444
|
-
return this;
|
|
1445
|
-
};
|
|
1446
|
-
AxisValues.prototype.sub = function (p) {
|
|
1447
|
-
this.x -= p.x;
|
|
1448
|
-
this.y -= p.y;
|
|
1449
|
-
return this;
|
|
1450
|
-
};
|
|
1451
|
-
AxisValues.prototype.round = function (fn) {
|
|
1452
|
-
if (fn === void 0) { fn = Math.round; }
|
|
1453
|
-
this.x = fn(this.x);
|
|
1454
|
-
this.y = fn(this.y);
|
|
1455
|
-
return this;
|
|
1456
|
-
};
|
|
1457
|
-
AxisValues.prototype.eql = function (p) {
|
|
1458
|
-
return this.x === p.x && this.y === p.y;
|
|
1459
|
-
};
|
|
1460
|
-
AxisValues.prototype.mul = function (n) {
|
|
1461
|
-
this.x *= n;
|
|
1462
|
-
this.y *= n;
|
|
1463
|
-
return this;
|
|
1464
|
-
};
|
|
1465
|
-
AxisValues.prototype.distance = function (p) {
|
|
1466
|
-
return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
|
1467
|
-
};
|
|
1468
|
-
return AxisValues;
|
|
1469
|
-
}());
|
|
1470
|
-
|
|
1471
|
-
var Cursor = /** @class */ (function () {
|
|
1472
|
-
function Cursor(activeWin, ui) {
|
|
1473
|
-
this._ui = ui;
|
|
1474
|
-
// NOTE: the default position should be outside of the page (GH-794)
|
|
1475
|
-
this._x = -1;
|
|
1476
|
-
this._y = -1;
|
|
1477
|
-
this._activeWindow = activeWin;
|
|
1478
|
-
}
|
|
1479
|
-
Cursor.prototype._ensureActiveWindow = function (win) {
|
|
1480
|
-
if (this._activeWindow === win || this._activeWindow === win.parent)
|
|
1481
|
-
return;
|
|
1482
|
-
if (this._activeWindow.parent !== win)
|
|
1483
|
-
this._activeWindow = win;
|
|
1484
|
-
};
|
|
1485
|
-
Cursor.prototype.isActive = function (currWin) {
|
|
1486
|
-
this._ensureActiveWindow(currWin);
|
|
1487
|
-
return this._activeWindow === currWin;
|
|
1488
|
-
};
|
|
1489
|
-
Cursor.prototype.setActiveWindow = function (win) {
|
|
1490
|
-
this._activeWindow = win;
|
|
1491
|
-
};
|
|
1492
|
-
Cursor.prototype.getActiveWindow = function (currWin) {
|
|
1493
|
-
this._ensureActiveWindow(currWin);
|
|
1494
|
-
return this._activeWindow;
|
|
1495
|
-
};
|
|
1496
|
-
Cursor.prototype.getPosition = function () {
|
|
1497
|
-
return new AxisValues(this._x, this._y);
|
|
1498
|
-
};
|
|
1499
|
-
Cursor.prototype.move = function (point) {
|
|
1500
|
-
this._x = point.x;
|
|
1501
|
-
this._y = point.y;
|
|
1502
|
-
return this._ui.move(point);
|
|
1503
|
-
};
|
|
1504
|
-
Cursor.prototype.hide = function () {
|
|
1505
|
-
if (this._ui.hide)
|
|
1506
|
-
return this._ui.hide();
|
|
1507
|
-
return adapter.PromiseCtor.resolve();
|
|
1508
|
-
};
|
|
1509
|
-
Cursor.prototype.show = function () {
|
|
1510
|
-
if (this._ui.show)
|
|
1511
|
-
return this._ui.show();
|
|
1512
|
-
return adapter.PromiseCtor.resolve();
|
|
1513
|
-
};
|
|
1514
|
-
Cursor.prototype.leftButtonDown = function () {
|
|
1515
|
-
return this._ui.leftButtonDown();
|
|
1516
|
-
};
|
|
1517
|
-
Cursor.prototype.rightButtonDown = function () {
|
|
1518
|
-
return this._ui.rightButtonDown();
|
|
1519
|
-
};
|
|
1520
|
-
Cursor.prototype.buttonUp = function () {
|
|
1521
|
-
return this._ui.buttonUp();
|
|
2062
|
+
];
|
|
1522
2063
|
};
|
|
1523
|
-
return
|
|
1524
|
-
}());
|
|
1525
|
-
|
|
1526
|
-
var
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
var equationYIntercept = startLine.x * (startLine.y - endLine.y) / (endLine.x - startLine.x) + startLine.y;
|
|
1534
|
-
return Math.round(equationSlope * x + equationYIntercept);
|
|
1535
|
-
}
|
|
1536
|
-
function getLineXByYCoord(startLine, endLine, y) {
|
|
1537
|
-
if (endLine.y - startLine.y === 0)
|
|
1538
|
-
return 0;
|
|
1539
|
-
var equationSlope = (endLine.x - startLine.x) / (endLine.y - startLine.y);
|
|
1540
|
-
var equationXIntercept = startLine.y * (startLine.x - endLine.x) / (endLine.y - startLine.y) + startLine.x;
|
|
1541
|
-
return Math.round(equationSlope * y + equationXIntercept);
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
function findIntersectionHorizontal(startLinePoint, endLinePoint, rectSide) {
|
|
1545
|
-
var intersectionX = getLineXByYCoord(startLinePoint, endLinePoint, rectSide.top);
|
|
1546
|
-
var haveIntersectionInBounds = intersectionX && intersectionX >= rectSide.left && intersectionX <= rectSide.right;
|
|
1547
|
-
return haveIntersectionInBounds ? new AxisValues(intersectionX, rectSide.top) : null;
|
|
1548
|
-
}
|
|
1549
|
-
function findIntersectionVertical(startLinePoint, endLinePoint, rectSide) {
|
|
1550
|
-
var intersectionY = getLineYByXCoord(startLinePoint, endLinePoint, rectSide.left);
|
|
1551
|
-
var haveIntersectionInBounds = intersectionY && intersectionY >= rectSide.top && intersectionY <= rectSide.bottom;
|
|
1552
|
-
return haveIntersectionInBounds ? new AxisValues(rectSide.left, intersectionY) : null;
|
|
1553
|
-
}
|
|
1554
|
-
function getLineRectIntersection (startLine, endLine, rect) {
|
|
1555
|
-
var res = [];
|
|
1556
|
-
var rectLines = [
|
|
1557
|
-
{ left: rect.left, top: rect.top, right: rect.left, bottom: rect.bottom, isHorizontal: false },
|
|
1558
|
-
{ left: rect.right, top: rect.top, right: rect.right, bottom: rect.bottom, isHorizontal: false },
|
|
1559
|
-
{ left: rect.left, top: rect.top, right: rect.right, bottom: rect.top, isHorizontal: true },
|
|
1560
|
-
{ left: rect.left, top: rect.bottom, right: rect.right, bottom: rect.bottom, isHorizontal: true },
|
|
1561
|
-
];
|
|
1562
|
-
for (var _i = 0, rectLines_1 = rectLines; _i < rectLines_1.length; _i++) {
|
|
1563
|
-
var rectLine = rectLines_1[_i];
|
|
1564
|
-
var intersection = rectLine.isHorizontal
|
|
1565
|
-
? findIntersectionHorizontal(startLine, endLine, rectLine)
|
|
1566
|
-
: findIntersectionVertical(startLine, endLine, rectLine);
|
|
1567
|
-
if (intersection)
|
|
1568
|
-
res.push(intersection);
|
|
2064
|
+
return AssertionOptions;
|
|
2065
|
+
}(Assignable));
|
|
2066
|
+
// Press
|
|
2067
|
+
var PressOptions = /** @class */ (function (_super) {
|
|
2068
|
+
__extends(PressOptions, _super);
|
|
2069
|
+
function PressOptions(obj, validate) {
|
|
2070
|
+
var _this = _super.call(this) || this;
|
|
2071
|
+
_this.confidential = void 0;
|
|
2072
|
+
_this._assignFrom(obj, validate);
|
|
2073
|
+
return _this;
|
|
1569
2074
|
}
|
|
1570
|
-
|
|
1571
|
-
return
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
return
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
var lastHoveredElement = null;
|
|
1579
|
-
var lastHoveredElementHolder = {
|
|
1580
|
-
get: function () {
|
|
1581
|
-
return lastHoveredElement;
|
|
1582
|
-
},
|
|
1583
|
-
set: function (element) {
|
|
1584
|
-
lastHoveredElement = element;
|
|
1585
|
-
},
|
|
1586
|
-
};
|
|
1587
|
-
|
|
1588
|
-
function delay(ms) {
|
|
1589
|
-
var setTimeout = adapter.nativeMethods.setTimeout;
|
|
1590
|
-
return new adapter.PromiseCtor(function (resolve) { return setTimeout(resolve, ms); });
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
function nextTick() {
|
|
1594
|
-
return delay(0);
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
function getAutomationPoint$1(element, offset) {
|
|
1598
|
-
return adapter.PromiseCtor.resolve(adapter.dom.isDocumentElement(element))
|
|
1599
|
-
.then(function (isDocEl) {
|
|
1600
|
-
if (isDocEl)
|
|
1601
|
-
return new AxisValues(0, 0);
|
|
1602
|
-
var roundFn = adapter.browser.isFirefox ? Math.ceil : Math.round;
|
|
1603
|
-
return adapter.PromiseCtor.resolve(adapter.position.getOffsetPosition(element, roundFn))
|
|
1604
|
-
.then(function (elementOffset) { return AxisValues.create(elementOffset); });
|
|
1605
|
-
})
|
|
1606
|
-
.then(function (point) { return point.add(offset); });
|
|
1607
|
-
}
|
|
2075
|
+
PressOptions.prototype._getAssignableProperties = function () {
|
|
2076
|
+
return _super.prototype._getAssignableProperties.call(this).concat([
|
|
2077
|
+
{ name: 'confidential', type: booleanOption },
|
|
2078
|
+
]);
|
|
2079
|
+
};
|
|
2080
|
+
return PressOptions;
|
|
2081
|
+
}(ActionOptions));
|
|
1608
2082
|
|
|
1609
2083
|
function whilst(condition, iterator) {
|
|
1610
2084
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1622,27 +2096,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1622
2096
|
});
|
|
1623
2097
|
}
|
|
1624
2098
|
|
|
1625
|
-
function getDevicePoint$1(clientPoint) {
|
|
1626
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1627
|
-
return __generator(this, function (_a) {
|
|
1628
|
-
if (!clientPoint)
|
|
1629
|
-
return [2 /*return*/, null];
|
|
1630
|
-
return [2 /*return*/, adapter.PromiseCtor.resolve(adapter.position.getWindowPosition())
|
|
1631
|
-
.then(function (windowPosition) {
|
|
1632
|
-
var screenLeft = windowPosition.x;
|
|
1633
|
-
var screenTop = windowPosition.y;
|
|
1634
|
-
var x = screenLeft + clientPoint.x;
|
|
1635
|
-
var y = screenTop + clientPoint.y;
|
|
1636
|
-
return new AxisValues(x, y);
|
|
1637
|
-
})];
|
|
1638
|
-
});
|
|
1639
|
-
});
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
2099
|
var MOVE_REQUEST_CMD = 'automation|move|request';
|
|
1643
2100
|
var MOVE_RESPONSE_CMD = 'automation|move|response';
|
|
1644
2101
|
var MoveAutomation = /** @class */ (function () {
|
|
1645
|
-
function MoveAutomation(el, offset, win, cursor
|
|
2102
|
+
function MoveAutomation(el, offset, moveOptions, win, cursor) {
|
|
1646
2103
|
this.touchMode = adapter.featureDetection.isTouchDevice;
|
|
1647
2104
|
this.moveEvent = this.touchMode ? 'touchmove' : 'mousemove';
|
|
1648
2105
|
this.automationSettings = new AutomationSettings(moveOptions.speed);
|
|
@@ -1658,7 +2115,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1658
2115
|
this.speed = moveOptions.speed;
|
|
1659
2116
|
this.firstMovingStepOccured = false;
|
|
1660
2117
|
}
|
|
1661
|
-
MoveAutomation.create = function (el, win, cursor
|
|
2118
|
+
MoveAutomation.create = function (el, moveOptions, win, cursor) {
|
|
1662
2119
|
return __awaiter(this, void 0, void 0, function () {
|
|
1663
2120
|
var _a, element, offset;
|
|
1664
2121
|
return __generator(this, function (_b) {
|
|
@@ -1666,7 +2123,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1666
2123
|
case 0: return [4 /*yield*/, MoveAutomation.getTarget(el, win, new AxisValues(moveOptions.offsetX, moveOptions.offsetY))];
|
|
1667
2124
|
case 1:
|
|
1668
2125
|
_a = _b.sent(), element = _a.element, offset = _a.offset;
|
|
1669
|
-
return [2 /*return*/, new MoveAutomation(element, offset, win, cursor
|
|
2126
|
+
return [2 /*return*/, new MoveAutomation(element, offset, moveOptions, win, cursor)];
|
|
1670
2127
|
}
|
|
1671
2128
|
});
|
|
1672
2129
|
});
|
|
@@ -1678,7 +2135,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1678
2135
|
.then(function (containsOffset) {
|
|
1679
2136
|
if (!containsOffset) {
|
|
1680
2137
|
return Promise$f.all([
|
|
1681
|
-
getAutomationPoint
|
|
2138
|
+
getAutomationPoint(element, offset),
|
|
1682
2139
|
adapter.dom.getDocumentElement(window),
|
|
1683
2140
|
])
|
|
1684
2141
|
.then(function (_a) {
|
|
@@ -1711,7 +2168,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1711
2168
|
MoveAutomation.prototype._getEventSequenceOptions = function (currPosition) {
|
|
1712
2169
|
var _this = this;
|
|
1713
2170
|
var button = adapter.event.BUTTONS_PARAMETER.noButton;
|
|
1714
|
-
return getDevicePoint
|
|
2171
|
+
return getDevicePoint(currPosition)
|
|
1715
2172
|
.then(function (devicePoint) {
|
|
1716
2173
|
var eventOptions = {
|
|
1717
2174
|
clientX: currPosition.x,
|
|
@@ -1764,7 +2221,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1764
2221
|
return null;
|
|
1765
2222
|
return _this._emulateEvents(currentElement, currPosition);
|
|
1766
2223
|
})
|
|
1767
|
-
.then(nextTick);
|
|
2224
|
+
.then(nextTick$1);
|
|
1768
2225
|
};
|
|
1769
2226
|
MoveAutomation.prototype._getCorrectedTopElement = function (topElement) {
|
|
1770
2227
|
return topElement;
|
|
@@ -1874,152 +2331,121 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1874
2331
|
return MoveAutomation;
|
|
1875
2332
|
}());
|
|
1876
2333
|
|
|
1877
|
-
var
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
var iframePoint = new AxisValues(e.message.endX, e.message.endY);
|
|
1886
|
-
var iframeWin = e.source;
|
|
1887
|
-
var iframe = domUtils$1.findIframeByWindow(iframeWin);
|
|
1888
|
-
var iframeBorders = styleUtils.getBordersWidth(iframe);
|
|
1889
|
-
var iframePadding = styleUtils.getElementPadding(iframe);
|
|
1890
|
-
var iframeRectangle = positionUtils$2.getIframeClientCoordinates(iframe);
|
|
1891
|
-
var iframePointRelativeToParent = positionUtils$2.getIframePointRelativeToParentFrame(iframePoint, iframeWin);
|
|
1892
|
-
var cursorPosition = cursor.getPosition();
|
|
1893
|
-
var intersectionPoint = positionUtils$2.isInRectangle(cursorPosition, iframeRectangle) ? cursorPosition :
|
|
1894
|
-
getLineRectIntersection(cursorPosition, iframePointRelativeToParent, iframeRectangle);
|
|
1895
|
-
var intersectionRelatedToIframe = {
|
|
1896
|
-
x: intersectionPoint.x - iframeRectangle.left,
|
|
1897
|
-
y: intersectionPoint.y - iframeRectangle.top,
|
|
1898
|
-
};
|
|
1899
|
-
var moveOptions = new MoveOptions({
|
|
1900
|
-
modifiers: e.message.modifiers,
|
|
1901
|
-
offsetX: intersectionRelatedToIframe.x + iframeBorders.left + iframePadding.left,
|
|
1902
|
-
offsetY: intersectionRelatedToIframe.y + iframeBorders.top + iframePadding.top,
|
|
1903
|
-
speed: e.message.speed,
|
|
1904
|
-
// NOTE: we should not perform scrolling because the active window was
|
|
1905
|
-
// already scrolled to the target element before the request (GH-847)
|
|
1906
|
-
skipScrolling: true,
|
|
1907
|
-
}, false);
|
|
1908
|
-
var responseMsg = {
|
|
1909
|
-
cmd: MOVE_RESPONSE_CMD$1,
|
|
1910
|
-
x: intersectionRelatedToIframe.x,
|
|
1911
|
-
y: intersectionRelatedToIframe.y,
|
|
2334
|
+
var EventEmitter = /** @class */ (function () {
|
|
2335
|
+
function EventEmitter() {
|
|
2336
|
+
this._eventsListeners = {};
|
|
2337
|
+
}
|
|
2338
|
+
EventEmitter.prototype.on = function (evt, listener) {
|
|
2339
|
+
if (!this._eventsListeners[evt])
|
|
2340
|
+
this._eventsListeners[evt] = [];
|
|
2341
|
+
this._eventsListeners[evt].push(listener);
|
|
1912
2342
|
};
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2343
|
+
EventEmitter.prototype.once = function (evt, listener) {
|
|
2344
|
+
var _this = this;
|
|
2345
|
+
this.on(evt, function () {
|
|
2346
|
+
var args = [];
|
|
2347
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2348
|
+
args[_i] = arguments[_i];
|
|
2349
|
+
}
|
|
2350
|
+
_this.off(evt, listener);
|
|
2351
|
+
return listener.apply(void 0, args);
|
|
1922
2352
|
});
|
|
1923
|
-
}
|
|
1924
|
-
else
|
|
1925
|
-
messageSandbox.sendServiceMsg(responseMsg, iframeWin);
|
|
1926
|
-
}
|
|
1927
|
-
function onMoveOutRequest(e) {
|
|
1928
|
-
var parentWin = e.source;
|
|
1929
|
-
var iframeRectangle = {
|
|
1930
|
-
left: e.message.left,
|
|
1931
|
-
right: e.message.right,
|
|
1932
|
-
top: e.message.top,
|
|
1933
|
-
bottom: e.message.bottom,
|
|
1934
2353
|
};
|
|
1935
|
-
|
|
1936
|
-
var
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
if (
|
|
1942
|
-
|
|
1943
|
-
|
|
2354
|
+
EventEmitter.prototype.off = function (evt, listener) {
|
|
2355
|
+
var listeners = this._eventsListeners[evt];
|
|
2356
|
+
if (listeners)
|
|
2357
|
+
this._eventsListeners[evt] = adapter.nativeMethods.arrayFilter.call(listeners, function (item) { return item !== listener; });
|
|
2358
|
+
};
|
|
2359
|
+
EventEmitter.prototype.offAll = function (evt) {
|
|
2360
|
+
if (evt)
|
|
2361
|
+
this._eventsListeners[evt] = [];
|
|
2362
|
+
else
|
|
2363
|
+
this._eventsListeners = {};
|
|
2364
|
+
};
|
|
2365
|
+
EventEmitter.prototype.emit = function (evt) {
|
|
2366
|
+
var args = [];
|
|
2367
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2368
|
+
args[_i - 1] = arguments[_i];
|
|
1944
2369
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
}
|
|
1962
|
-
var moveOptions = new MoveOptions({
|
|
1963
|
-
modifiers: e.message.modifiers,
|
|
1964
|
-
offsetX: intersectionPoint.x - iframeRectangle.left,
|
|
1965
|
-
offsetY: intersectionPoint.y - iframeRectangle.top,
|
|
1966
|
-
speed: e.message.speed,
|
|
1967
|
-
// NOTE: we should not perform scrolling because the active window was
|
|
1968
|
-
// already scrolled to the target element before the request (GH-847)
|
|
1969
|
-
skipScrolling: true,
|
|
1970
|
-
}, false);
|
|
1971
|
-
MoveAutomation.create(document.documentElement, window, cursor, moveOptions)
|
|
1972
|
-
.then(function (moveAutomation) {
|
|
1973
|
-
return moveAutomation.run();
|
|
1974
|
-
})
|
|
1975
|
-
.then(function () {
|
|
1976
|
-
var responseMsg = {
|
|
1977
|
-
cmd: MOVE_RESPONSE_CMD$1,
|
|
1978
|
-
x: intersectionPoint.x,
|
|
1979
|
-
y: intersectionPoint.y,
|
|
1980
|
-
};
|
|
1981
|
-
cursor.setActiveWindow(parentWin);
|
|
1982
|
-
messageSandbox.sendServiceMsg(responseMsg, parentWin);
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
// Setup cross-iframe interaction
|
|
1986
|
-
messageSandbox.on(messageSandbox.SERVICE_MSG_RECEIVED_EVENT, function (e) {
|
|
1987
|
-
if (e.message.cmd === MOVE_REQUEST_CMD$1) {
|
|
1988
|
-
if (e.source.parent === window)
|
|
1989
|
-
onMoveToIframeRequest(e);
|
|
1990
|
-
else {
|
|
1991
|
-
hammerhead__default.on(hammerhead__default.EVENTS.beforeUnload, function () { return messageSandbox.sendServiceMsg({ cmd: MOVE_RESPONSE_CMD$1 }, e.source); });
|
|
1992
|
-
onMoveOutRequest(e);
|
|
2370
|
+
var listeners = this._eventsListeners[evt];
|
|
2371
|
+
if (!listeners)
|
|
2372
|
+
return;
|
|
2373
|
+
for (var i = 0; i < listeners.length; i++) {
|
|
2374
|
+
try {
|
|
2375
|
+
listeners[i].apply(this, args);
|
|
2376
|
+
}
|
|
2377
|
+
catch (e) {
|
|
2378
|
+
// Hack for IE: after document.write calling IFrameSandbox event handlers
|
|
2379
|
+
// rises 'Can't execute code from a freed script' exception because document has been
|
|
2380
|
+
// recreated
|
|
2381
|
+
if (e.message && e.message.indexOf('freed script') > -1)
|
|
2382
|
+
this.off(evt, listeners[i]);
|
|
2383
|
+
else
|
|
2384
|
+
throw e;
|
|
2385
|
+
}
|
|
1993
2386
|
}
|
|
1994
|
-
}
|
|
1995
|
-
|
|
2387
|
+
};
|
|
2388
|
+
return EventEmitter;
|
|
2389
|
+
}());
|
|
1996
2390
|
|
|
1997
|
-
var extend$1 = hammerhead__default.utils.extend;
|
|
1998
2391
|
var ElementState = /** @class */ (function () {
|
|
1999
2392
|
function ElementState(_a) {
|
|
2000
|
-
var _b = _a.element, element = _b === void 0 ? null : _b, _c = _a.clientPoint, clientPoint = _c === void 0 ? null : _c, _d = _a.screenPoint, screenPoint = _d === void 0 ? null : _d, _e = _a.isTarget, isTarget = _e === void 0 ? false : _e, _f = _a.inMoving, inMoving = _f === void 0 ? false : _f;
|
|
2393
|
+
var _b = _a.element, element = _b === void 0 ? null : _b, _c = _a.clientPoint, clientPoint = _c === void 0 ? null : _c, _d = _a.screenPoint, screenPoint = _d === void 0 ? null : _d, _e = _a.isTarget, isTarget = _e === void 0 ? false : _e, _f = _a.inMoving, inMoving = _f === void 0 ? false : _f, _g = _a.devicePoint, devicePoint = _g === void 0 ? null : _g;
|
|
2001
2394
|
this.element = element;
|
|
2002
2395
|
this.clientPoint = clientPoint;
|
|
2003
2396
|
this.screenPoint = screenPoint;
|
|
2397
|
+
this.devicePoint = devicePoint;
|
|
2004
2398
|
this.isTarget = isTarget;
|
|
2005
2399
|
this.inMoving = inMoving;
|
|
2006
|
-
this.devicePoint = getDevicePoint(clientPoint);
|
|
2007
2400
|
}
|
|
2401
|
+
ElementState.create = function (_a) {
|
|
2402
|
+
var element = _a.element, clientPoint = _a.clientPoint, screenPoint = _a.screenPoint, isTarget = _a.isTarget, inMoving = _a.inMoving;
|
|
2403
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2404
|
+
var devicePoint, state;
|
|
2405
|
+
return __generator(this, function (_b) {
|
|
2406
|
+
switch (_b.label) {
|
|
2407
|
+
case 0:
|
|
2408
|
+
devicePoint = null;
|
|
2409
|
+
if (!clientPoint) return [3 /*break*/, 2];
|
|
2410
|
+
return [4 /*yield*/, getDevicePoint(clientPoint)];
|
|
2411
|
+
case 1:
|
|
2412
|
+
devicePoint = _b.sent();
|
|
2413
|
+
_b.label = 2;
|
|
2414
|
+
case 2:
|
|
2415
|
+
state = new ElementState({ element: element, clientPoint: clientPoint, screenPoint: screenPoint, isTarget: isTarget, inMoving: inMoving, devicePoint: devicePoint });
|
|
2416
|
+
return [2 /*return*/, state];
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
});
|
|
2420
|
+
};
|
|
2008
2421
|
return ElementState;
|
|
2009
2422
|
}());
|
|
2010
2423
|
var VisibleElementAutomation = /** @class */ (function (_super) {
|
|
2011
2424
|
__extends(VisibleElementAutomation, _super);
|
|
2012
|
-
function VisibleElementAutomation(element, offsetOptions) {
|
|
2425
|
+
function VisibleElementAutomation(element, offsetOptions, win, cursor) {
|
|
2013
2426
|
var _this = _super.call(this) || this;
|
|
2014
2427
|
_this.TARGET_ELEMENT_FOUND_EVENT = 'automation|target-element-found-event';
|
|
2015
2428
|
_this.element = element;
|
|
2016
2429
|
_this.options = offsetOptions;
|
|
2017
|
-
_this.automationSettings = new AutomationSettings(offsetOptions.speed);
|
|
2430
|
+
_this.automationSettings = new AutomationSettings(offsetOptions.speed || 1);
|
|
2431
|
+
_this.window = win;
|
|
2432
|
+
_this.cursor = cursor;
|
|
2433
|
+
// NOTE: only for legacy API
|
|
2434
|
+
adapter.automations._ensureWindowAndCursorForLegacyTests(_this);
|
|
2018
2435
|
return _this;
|
|
2019
2436
|
}
|
|
2020
2437
|
VisibleElementAutomation.prototype._getElementForEvent = function (eventArgs) {
|
|
2021
|
-
|
|
2022
|
-
|
|
2438
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2439
|
+
var expectedElement;
|
|
2440
|
+
return __generator(this, function (_a) {
|
|
2441
|
+
switch (_a.label) {
|
|
2442
|
+
case 0: return [4 /*yield*/, adapter.position.containsOffset(this.element, this.options.offsetX, this.options.offsetY)];
|
|
2443
|
+
case 1:
|
|
2444
|
+
expectedElement = (_a.sent()) ? this.element : null;
|
|
2445
|
+
return [2 /*return*/, getElementFromPoint$1(eventArgs.point, this.window, expectedElement)];
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
});
|
|
2023
2449
|
};
|
|
2024
2450
|
VisibleElementAutomation.prototype._moveToElement = function () {
|
|
2025
2451
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -2028,97 +2454,112 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2028
2454
|
return __generator(this, function (_a) {
|
|
2029
2455
|
switch (_a.label) {
|
|
2030
2456
|
case 0:
|
|
2031
|
-
moveOptions = new MoveOptions(extend
|
|
2032
|
-
return [4 /*yield*/, MoveAutomation.create(this.element, window, cursor
|
|
2457
|
+
moveOptions = new MoveOptions(adapter.utils.extend({ skipScrolling: true }, this.options), false);
|
|
2458
|
+
return [4 /*yield*/, MoveAutomation.create(this.element, moveOptions, this.window, this.cursor)];
|
|
2033
2459
|
case 1:
|
|
2034
2460
|
moveAutomation = _a.sent();
|
|
2035
2461
|
return [2 /*return*/, moveAutomation
|
|
2036
2462
|
.run()
|
|
2037
|
-
.then(function () { return
|
|
2463
|
+
.then(function () { return delay(_this.automationSettings.mouseActionStepDelay); })];
|
|
2038
2464
|
}
|
|
2039
2465
|
});
|
|
2040
2466
|
});
|
|
2041
2467
|
};
|
|
2042
2468
|
VisibleElementAutomation.prototype._scrollToElement = function () {
|
|
2043
2469
|
var _this = this;
|
|
2044
|
-
var scrollOptions = new ScrollOptions(this.options);
|
|
2045
|
-
var scrollAutomation = new testCafeCore.ScrollAutomation(this.element, scrollOptions);
|
|
2046
2470
|
var wasScrolled = false;
|
|
2047
|
-
|
|
2048
|
-
|
|
2471
|
+
var scrollOptions = new ScrollOptions(this.options, false);
|
|
2472
|
+
return adapter.scroll(this.element, scrollOptions)
|
|
2049
2473
|
.then(function (scrollWasPerformed) {
|
|
2050
2474
|
wasScrolled = scrollWasPerformed;
|
|
2051
|
-
return
|
|
2475
|
+
return delay(_this.automationSettings.mouseActionStepDelay);
|
|
2052
2476
|
})
|
|
2053
|
-
.then(function () { return getElementFromPoint$1(cursor.getPosition()); })
|
|
2477
|
+
.then(function () { return getElementFromPoint$1(_this.cursor.getPosition(), _this.window); })
|
|
2054
2478
|
.then(function (currentElement) {
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
var prevElement = lastHoveredElementHolder.get();
|
|
2059
|
-
var commonAncestor = testCafeCore.domUtils.getCommonAncestor(currentElement, prevElement);
|
|
2060
|
-
var clientPosition = testCafeCore.positionUtils.getClientPosition(currentElement);
|
|
2061
|
-
var devicePoint = getDevicePoint({ x: clientPosition.x, y: clientPosition.y });
|
|
2062
|
-
var options = {
|
|
2063
|
-
clientX: clientPosition.x,
|
|
2064
|
-
clientY: clientPosition.y,
|
|
2065
|
-
screenX: devicePoint.x,
|
|
2066
|
-
screenY: devicePoint.y,
|
|
2067
|
-
ctrl: false,
|
|
2068
|
-
alt: false,
|
|
2069
|
-
shift: false,
|
|
2070
|
-
meta: false,
|
|
2071
|
-
buttons: testCafeCore.eventUtils.BUTTONS_PARAMETER.leftButton,
|
|
2072
|
-
};
|
|
2073
|
-
MoveBehaviour.leaveElement(currentElement, prevElement, commonAncestor, options);
|
|
2074
|
-
MoveBehaviour.enterElement(currentElement, prevElement, commonAncestor, options);
|
|
2075
|
-
lastHoveredElementHolder.set(currentElement);
|
|
2479
|
+
return adapter.ensureMouseEventAfterScroll(currentElement, _this.element, wasScrolled);
|
|
2480
|
+
})
|
|
2481
|
+
.then(function () {
|
|
2076
2482
|
return wasScrolled;
|
|
2077
2483
|
});
|
|
2078
2484
|
};
|
|
2079
2485
|
VisibleElementAutomation.prototype._getElementOffset = function () {
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2486
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2487
|
+
var defaultOffsets, _a, offsetX, offsetY;
|
|
2488
|
+
return __generator(this, function (_b) {
|
|
2489
|
+
switch (_b.label) {
|
|
2490
|
+
case 0: return [4 /*yield*/, getOffsetOptions(this.element)];
|
|
2491
|
+
case 1:
|
|
2492
|
+
defaultOffsets = _b.sent();
|
|
2493
|
+
_a = this.options, offsetX = _a.offsetX, offsetY = _a.offsetY;
|
|
2494
|
+
offsetX = offsetX || offsetX === 0 ? offsetX : defaultOffsets.offsetX;
|
|
2495
|
+
offsetY = offsetY || offsetY === 0 ? offsetY : defaultOffsets.offsetY;
|
|
2496
|
+
return [2 /*return*/, { offsetX: offsetX, offsetY: offsetY }];
|
|
2497
|
+
}
|
|
2498
|
+
});
|
|
2499
|
+
});
|
|
2085
2500
|
};
|
|
2086
2501
|
VisibleElementAutomation.prototype._wrapAction = function (action) {
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2502
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2503
|
+
var _a, x, y, screenPointBeforeAction, clientPositionBeforeAction, screenPointAfterAction, clientPositionAfterAction, clientPoint, expectedElement, element, isTarget, offsetPositionChanged, clientPositionChanged, targetElementIsMoving;
|
|
2504
|
+
return __generator(this, function (_b) {
|
|
2505
|
+
switch (_b.label) {
|
|
2506
|
+
case 0: return [4 /*yield*/, this._getElementOffset()];
|
|
2507
|
+
case 1:
|
|
2508
|
+
_a = _b.sent(), x = _a.offsetX, y = _a.offsetY;
|
|
2509
|
+
return [4 /*yield*/, getAutomationPoint(this.element, { x: x, y: y })];
|
|
2510
|
+
case 2:
|
|
2511
|
+
screenPointBeforeAction = _b.sent();
|
|
2512
|
+
return [4 /*yield*/, adapter.position.getClientPosition(this.element)];
|
|
2513
|
+
case 3:
|
|
2514
|
+
clientPositionBeforeAction = _b.sent();
|
|
2515
|
+
return [4 /*yield*/, action()];
|
|
2516
|
+
case 4:
|
|
2517
|
+
_b.sent();
|
|
2518
|
+
return [4 /*yield*/, getAutomationPoint(this.element, { x: x, y: y })];
|
|
2519
|
+
case 5:
|
|
2520
|
+
screenPointAfterAction = _b.sent();
|
|
2521
|
+
return [4 /*yield*/, adapter.position.getClientPosition(this.element)];
|
|
2522
|
+
case 6:
|
|
2523
|
+
clientPositionAfterAction = _b.sent();
|
|
2524
|
+
return [4 /*yield*/, convertToClient(this.element, screenPointAfterAction)];
|
|
2525
|
+
case 7:
|
|
2526
|
+
clientPoint = _b.sent();
|
|
2527
|
+
return [4 /*yield*/, adapter.position.containsOffset(this.element, x, y)];
|
|
2528
|
+
case 8:
|
|
2529
|
+
expectedElement = (_b.sent()) ? this.element : null;
|
|
2530
|
+
return [4 /*yield*/, getElementFromPoint$1(clientPoint, this.window, expectedElement)];
|
|
2531
|
+
case 9:
|
|
2532
|
+
element = _b.sent();
|
|
2533
|
+
if (!element) {
|
|
2534
|
+
return [2 /*return*/, ElementState.create({
|
|
2535
|
+
element: null,
|
|
2536
|
+
clientPoint: null,
|
|
2537
|
+
screenPoint: null,
|
|
2538
|
+
isTarget: false,
|
|
2539
|
+
inMoving: false,
|
|
2540
|
+
})];
|
|
2541
|
+
}
|
|
2542
|
+
isTarget = !expectedElement || element === expectedElement || element === this.element;
|
|
2543
|
+
if (!!isTarget) return [3 /*break*/, 11];
|
|
2544
|
+
return [4 /*yield*/, this._contains(this.element, element)];
|
|
2545
|
+
case 10:
|
|
2546
|
+
// NOTE: perform an operation with searching in dom only if necessary
|
|
2547
|
+
isTarget = _b.sent();
|
|
2548
|
+
_b.label = 11;
|
|
2549
|
+
case 11:
|
|
2550
|
+
offsetPositionChanged = screenPointBeforeAction.x !== screenPointAfterAction.x ||
|
|
2551
|
+
screenPointBeforeAction.y !== screenPointAfterAction.y;
|
|
2552
|
+
clientPositionChanged = clientPositionBeforeAction.x !== clientPositionAfterAction.x ||
|
|
2553
|
+
clientPositionBeforeAction.y !== clientPositionAfterAction.y;
|
|
2554
|
+
targetElementIsMoving = offsetPositionChanged && clientPositionChanged;
|
|
2555
|
+
return [2 /*return*/, ElementState.create({
|
|
2556
|
+
element: element,
|
|
2557
|
+
clientPoint: clientPoint,
|
|
2558
|
+
screenPoint: screenPointAfterAction,
|
|
2559
|
+
isTarget: isTarget,
|
|
2560
|
+
inMoving: targetElementIsMoving,
|
|
2561
|
+
})];
|
|
2105
2562
|
}
|
|
2106
|
-
var offsetPositionChanged = screenPointBeforeAction.x !== screenPointAfterAction.x ||
|
|
2107
|
-
screenPointBeforeAction.y !== screenPointAfterAction.y;
|
|
2108
|
-
var clientPositionChanged = clientPositionBeforeAction.x !== clientPositionAfterAction.x ||
|
|
2109
|
-
clientPositionBeforeAction.y !== clientPositionAfterAction.y;
|
|
2110
|
-
// NOTE: We consider the element moved if its offset position and client position
|
|
2111
|
-
// are changed both. If only client position was changed it means the page was
|
|
2112
|
-
// scrolled and the element keeps its position on the page. If only offset position was
|
|
2113
|
-
// changed it means the element is fixed on the page (it can be implemented via script).
|
|
2114
|
-
var targetElementIsMoving = offsetPositionChanged && clientPositionChanged;
|
|
2115
|
-
return new ElementState({
|
|
2116
|
-
element: element,
|
|
2117
|
-
clientPoint: clientPoint,
|
|
2118
|
-
screenPoint: screenPointAfterAction,
|
|
2119
|
-
isTarget: isTarget,
|
|
2120
|
-
inMoving: targetElementIsMoving,
|
|
2121
|
-
});
|
|
2122
2563
|
});
|
|
2123
2564
|
});
|
|
2124
2565
|
};
|
|
@@ -2131,6 +2572,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2131
2572
|
};
|
|
2132
2573
|
VisibleElementAutomation.prototype._ensureElement = function (useStrictElementCheck, skipCheckAfterMoving, skipMoving) {
|
|
2133
2574
|
var _this = this;
|
|
2575
|
+
if (skipCheckAfterMoving === void 0) { skipCheckAfterMoving = false; }
|
|
2576
|
+
if (skipMoving === void 0) { skipMoving = false; }
|
|
2134
2577
|
return this
|
|
2135
2578
|
._wrapAction(function () { return _this._scrollToElement(); })
|
|
2136
2579
|
.then(function (state) { return VisibleElementAutomation._checkElementState(state, useStrictElementCheck); })
|
|
@@ -2143,551 +2586,320 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2143
2586
|
return state;
|
|
2144
2587
|
})
|
|
2145
2588
|
.then(function (state) {
|
|
2146
|
-
_this.emit(_this.TARGET_ELEMENT_FOUND_EVENT, { element: state.element });
|
|
2589
|
+
_this.emit(_this.TARGET_ELEMENT_FOUND_EVENT, { element: (state === null || state === void 0 ? void 0 : state.element) || null });
|
|
2147
2590
|
return {
|
|
2148
|
-
element: state.element,
|
|
2149
|
-
clientPoint: state.clientPoint,
|
|
2150
|
-
screenPoint: state.screenPoint,
|
|
2151
|
-
devicePoint: state.devicePoint,
|
|
2591
|
+
element: (state === null || state === void 0 ? void 0 : state.element) || null,
|
|
2592
|
+
clientPoint: (state === null || state === void 0 ? void 0 : state.clientPoint) || null,
|
|
2593
|
+
screenPoint: (state === null || state === void 0 ? void 0 : state.screenPoint) || null,
|
|
2594
|
+
devicePoint: (state === null || state === void 0 ? void 0 : state.devicePoint) || null,
|
|
2152
2595
|
};
|
|
2153
2596
|
});
|
|
2154
2597
|
};
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
'topRight': [el.scrollWidth, 0],
|
|
2168
|
-
'topLeft': [0, 0],
|
|
2169
|
-
'bottomRight': [el.scrollWidth, el.scrollHeight],
|
|
2170
|
-
'bottomLeft': [0, el.scrollHeight],
|
|
2171
|
-
'center': [centerX, centerY],
|
|
2172
|
-
};
|
|
2173
|
-
return positions[position];
|
|
2174
|
-
}
|
|
2175
|
-
var SetScrollAutomation = /** @class */ (function (_super) {
|
|
2176
|
-
__extends(SetScrollAutomation, _super);
|
|
2177
|
-
function SetScrollAutomation(element, _a, offsetOptions) {
|
|
2178
|
-
var _b;
|
|
2179
|
-
var x = _a.x, y = _a.y, position = _a.position, byX = _a.byX, byY = _a.byY;
|
|
2180
|
-
var _this = _super.call(this, element, offsetOptions) || this;
|
|
2181
|
-
if (position)
|
|
2182
|
-
_b = calculatePosition(element, position), x = _b[0], y = _b[1];
|
|
2183
|
-
_this.scrollLeft = typeof x === 'number' ? x : element.scrollLeft;
|
|
2184
|
-
_this.scrollTop = typeof y === 'number' ? y : element.scrollTop;
|
|
2185
|
-
if (byX)
|
|
2186
|
-
_this.scrollLeft += byX;
|
|
2187
|
-
if (byY)
|
|
2188
|
-
_this.scrollTop += byY;
|
|
2189
|
-
return _this;
|
|
2190
|
-
}
|
|
2191
|
-
SetScrollAutomation.prototype.run = function (useStrictElementCheck) {
|
|
2192
|
-
var _this = this;
|
|
2193
|
-
var promise = Promise$2.resolve();
|
|
2194
|
-
if (this.element !== document.scrollingElement && this.element !== document.documentElement)
|
|
2195
|
-
promise = this._ensureElement(useStrictElementCheck, true, true);
|
|
2196
|
-
return promise
|
|
2197
|
-
.then(function () {
|
|
2198
|
-
_this.element.scrollLeft = _this.scrollLeft;
|
|
2199
|
-
_this.element.scrollTop = _this.scrollTop;
|
|
2200
|
-
});
|
|
2201
|
-
};
|
|
2202
|
-
return SetScrollAutomation;
|
|
2203
|
-
}(VisibleElementAutomation));
|
|
2204
|
-
|
|
2205
|
-
var ScrollIntoViewAutomation = /** @class */ (function (_super) {
|
|
2206
|
-
__extends(ScrollIntoViewAutomation, _super);
|
|
2207
|
-
function ScrollIntoViewAutomation(element, offsetOptions) {
|
|
2208
|
-
return _super.call(this, element, offsetOptions) || this;
|
|
2209
|
-
}
|
|
2210
|
-
ScrollIntoViewAutomation.prototype.run = function (useStrictElementCheck) {
|
|
2211
|
-
return this._ensureElement(useStrictElementCheck, true, true);
|
|
2212
|
-
};
|
|
2213
|
-
return ScrollIntoViewAutomation;
|
|
2214
|
-
}(VisibleElementAutomation));
|
|
2215
|
-
|
|
2216
|
-
var Promise$3 = hammerhead__default.Promise;
|
|
2217
|
-
var messageSandbox$1 = hammerhead__default.eventSandbox.message;
|
|
2218
|
-
function sendRequestToFrame(msg, responseCmd, receiverWindow) {
|
|
2219
|
-
return new Promise$3(function (resolve) {
|
|
2220
|
-
function onMessage(e) {
|
|
2221
|
-
if (e.message.cmd === responseCmd) {
|
|
2222
|
-
messageSandbox$1.off(messageSandbox$1.SERVICE_MSG_RECEIVED_EVENT, onMessage);
|
|
2223
|
-
resolve(e.message);
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
messageSandbox$1.on(messageSandbox$1.SERVICE_MSG_RECEIVED_EVENT, onMessage);
|
|
2227
|
-
messageSandbox$1.sendServiceMsg(msg, receiverWindow);
|
|
2228
|
-
});
|
|
2229
|
-
}
|
|
2230
|
-
|
|
2231
|
-
var Promise$4 = hammerhead__default.Promise;
|
|
2232
|
-
var nativeMethods$4 = hammerhead__default.nativeMethods;
|
|
2233
|
-
var browserUtils$3 = hammerhead__default.utils.browser;
|
|
2234
|
-
var focusBlurSandbox = hammerhead__default.eventSandbox.focusBlur;
|
|
2235
|
-
var contentEditable = testCafeCore__default.contentEditable;
|
|
2236
|
-
var textSelection = testCafeCore__default.textSelection;
|
|
2237
|
-
var domUtils$2 = testCafeCore__default.domUtils;
|
|
2238
|
-
var styleUtils$1 = testCafeCore__default.styleUtils;
|
|
2239
|
-
var messageSandbox$2 = hammerhead__default.eventSandbox.message;
|
|
2240
|
-
var GET_IFRAME_REQUEST_CMD = 'automation|iframe|request';
|
|
2241
|
-
var GET_IFRAME_RESPONSE_CMD = 'automation|iframe|response';
|
|
2242
|
-
messageSandbox$2.on(messageSandbox$2.SERVICE_MSG_RECEIVED_EVENT, function (e) {
|
|
2243
|
-
if (e.message.cmd === GET_IFRAME_REQUEST_CMD) {
|
|
2244
|
-
var iframeElement = domUtils$2.findIframeByWindow(e.source);
|
|
2245
|
-
focusBlurSandbox.focus(iframeElement, function () {
|
|
2246
|
-
messageSandbox$2.sendServiceMsg({ cmd: GET_IFRAME_RESPONSE_CMD }, e.source);
|
|
2247
|
-
}, false);
|
|
2248
|
-
}
|
|
2249
|
-
});
|
|
2250
|
-
function setCaretPosition(element, caretPos) {
|
|
2251
|
-
var isTextEditable = domUtils$2.isTextEditableElement(element);
|
|
2252
|
-
var isContentEditable = domUtils$2.isContentEditableElement(element);
|
|
2253
|
-
if (isTextEditable || isContentEditable) {
|
|
2254
|
-
if (isContentEditable && isNaN(parseInt(caretPos, 10)))
|
|
2255
|
-
textSelection.setCursorToLastVisiblePosition(element);
|
|
2256
|
-
else {
|
|
2257
|
-
var position = isNaN(parseInt(caretPos, 10)) ? domUtils$2.getElementValue(element).length : caretPos;
|
|
2258
|
-
textSelection.select(element, position, position);
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
else {
|
|
2262
|
-
// NOTE: if focus is called for a non-contentEditable element (like 'img' or 'button') inside
|
|
2263
|
-
// a contentEditable parent, we should try to set the right window selection. Generally, we can't
|
|
2264
|
-
// set the right window selection object because after the selection setup, the window.getSelection
|
|
2265
|
-
// method returns a different object, which depends on the browser.
|
|
2266
|
-
var contentEditableParent = contentEditable.findContentEditableParent(element);
|
|
2267
|
-
if (contentEditableParent)
|
|
2268
|
-
textSelection.setCursorToLastVisiblePosition(contentEditable.findContentEditableParent(contentEditableParent));
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
function focusAndSetSelection(element, simulateFocus, caretPos) {
|
|
2272
|
-
var _this = this;
|
|
2273
|
-
return new Promise$4(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
2274
|
-
var activeElement, isTextEditable, labelWithForAttr, isElementFocusable, shouldFocusByRelatedElement, isContentEditable, elementForFocus, focusWithSilentMode, focusForMouseEvent, preventScrolling, curDocument, curActiveElement, isActiveElementBody, focusableParent, elementChildOfActiveElement;
|
|
2275
|
-
return __generator(this, function (_a) {
|
|
2276
|
-
switch (_a.label) {
|
|
2277
|
-
case 0:
|
|
2278
|
-
if (!isIframeWindow(window)) return [3 /*break*/, 2];
|
|
2279
|
-
return [4 /*yield*/, sendRequestToFrame({ cmd: GET_IFRAME_REQUEST_CMD }, GET_IFRAME_RESPONSE_CMD, window.parent)];
|
|
2280
|
-
case 1:
|
|
2281
|
-
_a.sent();
|
|
2282
|
-
_a.label = 2;
|
|
2283
|
-
case 2:
|
|
2284
|
-
activeElement = domUtils$2.getActiveElement();
|
|
2285
|
-
isTextEditable = domUtils$2.isTextEditableElement(element);
|
|
2286
|
-
labelWithForAttr = domUtils$2.closest(element, 'label[for]');
|
|
2287
|
-
isElementFocusable = domUtils$2.isElementFocusable(element);
|
|
2288
|
-
shouldFocusByRelatedElement = !isElementFocusable && labelWithForAttr;
|
|
2289
|
-
isContentEditable = domUtils$2.isContentEditableElement(element);
|
|
2290
|
-
elementForFocus = isContentEditable ? contentEditable.findContentEditableParent(element) : element;
|
|
2291
|
-
// NOTE: in WebKit, if selection was never set in an input element, the focus method selects all the
|
|
2292
|
-
// text in this element. So, we should call select before focus to set the caret to the first symbol.
|
|
2293
|
-
if (simulateFocus && browserUtils$3.isWebKit && isTextEditable)
|
|
2294
|
-
textSelection.select(element, 0, 0);
|
|
2295
|
-
// NOTE: we should call focus for the element related with a 'label' that has the 'for' attribute
|
|
2296
|
-
if (shouldFocusByRelatedElement) {
|
|
2297
|
-
if (simulateFocus)
|
|
2298
|
-
focusByLabel(labelWithForAttr);
|
|
2299
|
-
resolve();
|
|
2300
|
-
return [2 /*return*/];
|
|
2301
|
-
}
|
|
2302
|
-
focusWithSilentMode = !simulateFocus;
|
|
2303
|
-
focusForMouseEvent = true;
|
|
2304
|
-
preventScrolling = false;
|
|
2305
|
-
if (!isElementFocusable && !isContentEditable) {
|
|
2306
|
-
curDocument = domUtils$2.findDocument(elementForFocus);
|
|
2307
|
-
curActiveElement = nativeMethods$4.documentActiveElementGetter.call(curDocument);
|
|
2308
|
-
isActiveElementBody = domUtils$2.isBodyElement(curActiveElement);
|
|
2309
|
-
focusableParent = domUtils$2.isBodyElement(elementForFocus) ?
|
|
2310
|
-
elementForFocus : domUtils$2.getFocusableParent(elementForFocus);
|
|
2311
|
-
elementChildOfActiveElement = curActiveElement && !isActiveElementBody &&
|
|
2312
|
-
domUtils$2.containsElement(curActiveElement, elementForFocus);
|
|
2313
|
-
if (elementChildOfActiveElement || isActiveElementBody && domUtils$2.isBodyElement(focusableParent)) {
|
|
2314
|
-
resolve();
|
|
2315
|
-
return [2 /*return*/];
|
|
2316
|
-
}
|
|
2317
|
-
elementForFocus = focusableParent || curDocument.body;
|
|
2318
|
-
preventScrolling = true;
|
|
2319
|
-
}
|
|
2320
|
-
focusBlurSandbox.focus(elementForFocus, function () {
|
|
2321
|
-
// NOTE: if a different element was focused in the focus event handler, we should not set selection
|
|
2322
|
-
if (simulateFocus && !isContentEditable && element !== domUtils$2.getActiveElement()) {
|
|
2323
|
-
resolve();
|
|
2324
|
-
return;
|
|
2598
|
+
VisibleElementAutomation.prototype._contains = function (parent, child) {
|
|
2599
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2600
|
+
var parents, _i, parents_1, el;
|
|
2601
|
+
return __generator(this, function (_a) {
|
|
2602
|
+
switch (_a.label) {
|
|
2603
|
+
case 0: return [4 /*yield*/, adapter.dom.getParents(child)];
|
|
2604
|
+
case 1:
|
|
2605
|
+
parents = _a.sent();
|
|
2606
|
+
for (_i = 0, parents_1 = parents; _i < parents_1.length; _i++) {
|
|
2607
|
+
el = parents_1[_i];
|
|
2608
|
+
if (el === parent)
|
|
2609
|
+
return [2 /*return*/, true];
|
|
2325
2610
|
}
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
focusBlurSandbox.focus(activeElement, resolve, true, true);
|
|
2331
|
-
else
|
|
2332
|
-
resolve();
|
|
2333
|
-
}, focusWithSilentMode, focusForMouseEvent, false, preventScrolling);
|
|
2334
|
-
return [2 /*return*/];
|
|
2335
|
-
}
|
|
2336
|
-
});
|
|
2337
|
-
}); });
|
|
2338
|
-
}
|
|
2339
|
-
function getElementBoundToLabel(element) {
|
|
2340
|
-
var labelWithForAttr = domUtils$2.closest(element, 'label[for]');
|
|
2341
|
-
var control = labelWithForAttr && (labelWithForAttr.control || document.getElementById(labelWithForAttr.htmlFor));
|
|
2342
|
-
var isControlVisible = control && styleUtils$1.isElementVisible(control);
|
|
2343
|
-
return isControlVisible ? control : null;
|
|
2344
|
-
}
|
|
2345
|
-
function focusByLabel(label) {
|
|
2346
|
-
if (domUtils$2.isElementFocusable(label))
|
|
2347
|
-
focusBlurSandbox.focus(label, testCafeCore__default.noop, false, true);
|
|
2348
|
-
else
|
|
2349
|
-
focusByRelatedElement(label);
|
|
2350
|
-
}
|
|
2351
|
-
function focusByRelatedElement(element) {
|
|
2352
|
-
var elementForFocus = getElementBoundToLabel(element);
|
|
2353
|
-
if (!elementForFocus || domUtils$2.getActiveElement() === elementForFocus)
|
|
2354
|
-
return;
|
|
2355
|
-
focusBlurSandbox.focus(elementForFocus, testCafeCore__default.noop, false, true);
|
|
2356
|
-
}
|
|
2357
|
-
|
|
2358
|
-
var Promise$5 = hammerhead__default.Promise;
|
|
2359
|
-
var nativeMethods$5 = hammerhead__default.nativeMethods;
|
|
2360
|
-
function nextTick$1 () {
|
|
2361
|
-
return new Promise$5(function (resolve) { return nativeMethods$5.setTimeout.call(window, resolve, 0); });
|
|
2362
|
-
}
|
|
2363
|
-
|
|
2364
|
-
var browserUtils$4 = hammerhead__default.utils.browser;
|
|
2365
|
-
var eventSimulator$4 = hammerhead__default.eventSandbox.eventSimulator;
|
|
2366
|
-
var listeners = hammerhead__default.eventSandbox.listeners;
|
|
2367
|
-
var nativeMethods$6 = hammerhead__default.nativeMethods;
|
|
2368
|
-
var domUtils$3 = testCafeCore__default.domUtils;
|
|
2369
|
-
var styleUtils$2 = testCafeCore__default.styleUtils;
|
|
2370
|
-
var selectElementUI = testCafeUI.selectElement;
|
|
2371
|
-
var ElementClickCommand = /** @class */ (function () {
|
|
2372
|
-
function ElementClickCommand(eventState, eventArgs) {
|
|
2373
|
-
this.eventState = eventState;
|
|
2374
|
-
this.eventArgs = eventArgs;
|
|
2375
|
-
}
|
|
2376
|
-
ElementClickCommand.prototype.run = function () {
|
|
2377
|
-
if (this.eventState.clickElement)
|
|
2378
|
-
eventSimulator$4.click(this.eventState.clickElement, this.eventArgs.options);
|
|
2379
|
-
if (!domUtils$3.isElementFocusable(this.eventArgs.element))
|
|
2380
|
-
focusByRelatedElement(this.eventArgs.element);
|
|
2381
|
-
};
|
|
2382
|
-
return ElementClickCommand;
|
|
2383
|
-
}());
|
|
2384
|
-
var LabelElementClickCommand = /** @class */ (function (_super) {
|
|
2385
|
-
__extends(LabelElementClickCommand, _super);
|
|
2386
|
-
function LabelElementClickCommand(eventState, eventArgs) {
|
|
2387
|
-
var _this = _super.call(this, eventState, eventArgs) || this;
|
|
2388
|
-
_this.label = _this.eventArgs.element;
|
|
2389
|
-
_this.input = getElementBoundToLabel(_this.eventArgs.element);
|
|
2390
|
-
return _this;
|
|
2391
|
-
}
|
|
2392
|
-
LabelElementClickCommand.prototype.run = function () {
|
|
2393
|
-
var _this = this;
|
|
2394
|
-
var focusRaised = false;
|
|
2395
|
-
var ensureFocusRaised = function (e) {
|
|
2396
|
-
focusRaised = nativeMethods$6.eventTargetGetter.call(e) === _this.input;
|
|
2397
|
-
};
|
|
2398
|
-
listeners.addInternalEventBeforeListener(window, ['focus'], ensureFocusRaised);
|
|
2399
|
-
_super.prototype.run.call(this);
|
|
2400
|
-
listeners.removeInternalEventBeforeListener(window, ['focus'], ensureFocusRaised);
|
|
2401
|
-
if (domUtils$3.isElementFocusable(this.label) && !focusRaised)
|
|
2402
|
-
this._ensureBoundElementFocusRaised();
|
|
2403
|
-
};
|
|
2404
|
-
LabelElementClickCommand.prototype._ensureBoundElementFocusRaised = function () {
|
|
2405
|
-
eventSimulator$4.focus(this.input);
|
|
2406
|
-
};
|
|
2407
|
-
return LabelElementClickCommand;
|
|
2408
|
-
}(ElementClickCommand));
|
|
2409
|
-
var SelectElementClickCommand = /** @class */ (function (_super) {
|
|
2410
|
-
__extends(SelectElementClickCommand, _super);
|
|
2411
|
-
function SelectElementClickCommand(eventState, eventArgs) {
|
|
2412
|
-
return _super.call(this, eventState, eventArgs) || this;
|
|
2413
|
-
}
|
|
2414
|
-
SelectElementClickCommand.prototype.run = function () {
|
|
2415
|
-
_super.prototype.run.call(this);
|
|
2416
|
-
this._toggleSelectOptionList();
|
|
2417
|
-
};
|
|
2418
|
-
SelectElementClickCommand.prototype._toggleSelectOptionList = function () {
|
|
2419
|
-
// NOTE: Emulating the click event on the 'select' element doesn't expand the
|
|
2420
|
-
// dropdown with options (except chrome), therefore we should emulate it.
|
|
2421
|
-
var element = this.eventArgs.element;
|
|
2422
|
-
var isSelectWithDropDown = styleUtils$2.getSelectElementSize(element) === 1;
|
|
2423
|
-
if (isSelectWithDropDown && this.eventState.simulateDefaultBehavior !== false) {
|
|
2424
|
-
if (selectElementUI.isOptionListExpanded(element))
|
|
2425
|
-
selectElementUI.collapseOptionList();
|
|
2426
|
-
else
|
|
2427
|
-
selectElementUI.expandOptionList(element);
|
|
2428
|
-
}
|
|
2429
|
-
};
|
|
2430
|
-
return SelectElementClickCommand;
|
|
2431
|
-
}(ElementClickCommand));
|
|
2432
|
-
var OptionElementClickCommand = /** @class */ (function (_super) {
|
|
2433
|
-
__extends(OptionElementClickCommand, _super);
|
|
2434
|
-
function OptionElementClickCommand(eventState, eventArgs) {
|
|
2435
|
-
return _super.call(this, eventState, eventArgs) || this;
|
|
2436
|
-
}
|
|
2437
|
-
OptionElementClickCommand.prototype.run = function () {
|
|
2438
|
-
return this.eventArgs.element;
|
|
2611
|
+
return [2 /*return*/, false];
|
|
2612
|
+
}
|
|
2613
|
+
});
|
|
2614
|
+
});
|
|
2439
2615
|
};
|
|
2440
|
-
return
|
|
2441
|
-
}(
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2616
|
+
return VisibleElementAutomation;
|
|
2617
|
+
}(EventEmitter));
|
|
2618
|
+
|
|
2619
|
+
var Promise$5 = hammerhead__default.Promise;
|
|
2620
|
+
function calculatePosition(el, position) {
|
|
2621
|
+
var centerX = Math.floor(el.scrollWidth / 2 - el.clientWidth / 2);
|
|
2622
|
+
var centerY = Math.floor(el.scrollHeight / 2 - el.clientHeight / 2);
|
|
2623
|
+
var positions = {
|
|
2624
|
+
'top': [centerX, 0],
|
|
2625
|
+
'right': [el.scrollWidth, centerY],
|
|
2626
|
+
'bottom': [centerX, el.scrollHeight],
|
|
2627
|
+
'left': [0, centerY],
|
|
2628
|
+
'topRight': [el.scrollWidth, 0],
|
|
2629
|
+
'topLeft': [0, 0],
|
|
2630
|
+
'bottomRight': [el.scrollWidth, el.scrollHeight],
|
|
2631
|
+
'bottomLeft': [0, el.scrollHeight],
|
|
2632
|
+
'center': [centerX, centerY],
|
|
2633
|
+
};
|
|
2634
|
+
return positions[position];
|
|
2635
|
+
}
|
|
2636
|
+
var SetScrollAutomation = /** @class */ (function (_super) {
|
|
2637
|
+
__extends(SetScrollAutomation, _super);
|
|
2638
|
+
function SetScrollAutomation(element, _a, offsetOptions) {
|
|
2639
|
+
var _b;
|
|
2640
|
+
var x = _a.x, y = _a.y, position = _a.position, byX = _a.byX, byY = _a.byY;
|
|
2641
|
+
var _this = _super.call(this, element, offsetOptions, window, cursor) || this;
|
|
2642
|
+
if (position)
|
|
2643
|
+
_b = calculatePosition(element, position), x = _b[0], y = _b[1];
|
|
2644
|
+
_this.scrollLeft = typeof x === 'number' ? x : element.scrollLeft;
|
|
2645
|
+
_this.scrollTop = typeof y === 'number' ? y : element.scrollTop;
|
|
2646
|
+
if (byX)
|
|
2647
|
+
_this.scrollLeft += byX;
|
|
2648
|
+
if (byY)
|
|
2649
|
+
_this.scrollTop += byY;
|
|
2447
2650
|
return _this;
|
|
2448
2651
|
}
|
|
2449
|
-
|
|
2450
|
-
var
|
|
2451
|
-
var
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2652
|
+
SetScrollAutomation.prototype.run = function (useStrictElementCheck) {
|
|
2653
|
+
var _this = this;
|
|
2654
|
+
var promise = Promise$5.resolve();
|
|
2655
|
+
if (this.element !== document.scrollingElement && this.element !== document.documentElement)
|
|
2656
|
+
promise = this._ensureElement(useStrictElementCheck, true, true);
|
|
2657
|
+
return promise
|
|
2658
|
+
.then(function () {
|
|
2659
|
+
_this.element.scrollLeft = _this.scrollLeft;
|
|
2660
|
+
_this.element.scrollTop = _this.scrollTop;
|
|
2661
|
+
});
|
|
2459
2662
|
};
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2663
|
+
return SetScrollAutomation;
|
|
2664
|
+
}(VisibleElementAutomation));
|
|
2665
|
+
|
|
2666
|
+
var ScrollIntoViewAutomation = /** @class */ (function (_super) {
|
|
2667
|
+
__extends(ScrollIntoViewAutomation, _super);
|
|
2668
|
+
function ScrollIntoViewAutomation(element, offsetOptions) {
|
|
2669
|
+
return _super.call(this, element, offsetOptions, window, cursor) || this;
|
|
2670
|
+
}
|
|
2671
|
+
ScrollIntoViewAutomation.prototype.run = function (useStrictElementCheck) {
|
|
2672
|
+
return this._ensureElement(useStrictElementCheck, true, true);
|
|
2463
2673
|
};
|
|
2464
|
-
return
|
|
2465
|
-
}(
|
|
2466
|
-
function createClickCommand (eventState, eventArgs) {
|
|
2467
|
-
var elementBoundToLabel = getElementBoundToLabel(eventArgs.element);
|
|
2468
|
-
var isSelectElement = domUtils$3.isSelectElement(eventArgs.element);
|
|
2469
|
-
var isOptionElement = domUtils$3.isOptionElement(eventArgs.element);
|
|
2470
|
-
var isLabelElement = domUtils$3.isLabelElement(eventArgs.element) && elementBoundToLabel;
|
|
2471
|
-
var isLabelledCheckbox = elementBoundToLabel && domUtils$3.isCheckboxElement(elementBoundToLabel);
|
|
2472
|
-
if (isSelectElement)
|
|
2473
|
-
return new SelectElementClickCommand(eventState, eventArgs);
|
|
2474
|
-
if (isOptionElement)
|
|
2475
|
-
return new OptionElementClickCommand(eventState, eventArgs);
|
|
2476
|
-
if (isLabelledCheckbox)
|
|
2477
|
-
return new LabelledCheckboxElementClickCommand(eventState, eventArgs);
|
|
2478
|
-
if (isLabelElement)
|
|
2479
|
-
return new LabelElementClickCommand(eventState, eventArgs);
|
|
2480
|
-
return new ElementClickCommand(eventState, eventArgs);
|
|
2481
|
-
}
|
|
2674
|
+
return ScrollIntoViewAutomation;
|
|
2675
|
+
}(VisibleElementAutomation));
|
|
2482
2676
|
|
|
2483
|
-
var Promise$6 = hammerhead__default.Promise;
|
|
2484
|
-
var extend$2 = hammerhead__default.utils.extend;
|
|
2485
|
-
var browserUtils$5 = hammerhead__default.utils.browser;
|
|
2486
|
-
var featureDetection$1 = hammerhead__default.utils.featureDetection;
|
|
2487
|
-
var eventSimulator$5 = hammerhead__default.eventSandbox.eventSimulator;
|
|
2488
|
-
var listeners$1 = hammerhead__default.eventSandbox.listeners;
|
|
2489
|
-
var domUtils$4 = testCafeCore__default.domUtils;
|
|
2490
|
-
var eventUtils = testCafeCore__default.eventUtils;
|
|
2491
|
-
var arrayUtils = testCafeCore__default.arrayUtils;
|
|
2492
|
-
var delay$1 = testCafeCore__default.delay;
|
|
2493
2677
|
var ClickAutomation = /** @class */ (function (_super) {
|
|
2494
2678
|
__extends(ClickAutomation, _super);
|
|
2495
|
-
function ClickAutomation(element, clickOptions) {
|
|
2496
|
-
var _this = _super.call(this, element, clickOptions) || this;
|
|
2679
|
+
function ClickAutomation(element, clickOptions, win, cursor) {
|
|
2680
|
+
var _this = _super.call(this, element, clickOptions, win, cursor) || this;
|
|
2497
2681
|
_this.modifiers = clickOptions.modifiers;
|
|
2498
|
-
_this.
|
|
2499
|
-
_this.targetElementParentNodes = [];
|
|
2500
|
-
_this.activeElementBeforeMouseDown = null;
|
|
2501
|
-
_this.mouseDownElement = null;
|
|
2502
|
-
_this.eventState = {
|
|
2503
|
-
mousedownPrevented: false,
|
|
2504
|
-
blurRaised: false,
|
|
2505
|
-
simulateDefaultBehavior: true,
|
|
2506
|
-
clickElement: null,
|
|
2507
|
-
touchStartCancelled: false,
|
|
2508
|
-
touchEndCancelled: false,
|
|
2509
|
-
};
|
|
2682
|
+
_this.strategy = adapter.automations.click.createMouseClickStrategy(_this.element, clickOptions.caretPos);
|
|
2510
2683
|
return _this;
|
|
2511
2684
|
}
|
|
2512
|
-
ClickAutomation.prototype._bindMousedownHandler = function () {
|
|
2513
|
-
var _this = this;
|
|
2514
|
-
var onmousedown = function (e) {
|
|
2515
|
-
_this.eventState.mousedownPrevented = e.defaultPrevented;
|
|
2516
|
-
eventUtils.preventDefault(e);
|
|
2517
|
-
eventUtils.unbind(_this.element, 'mousedown', onmousedown);
|
|
2518
|
-
};
|
|
2519
|
-
eventUtils.bind(this.element, 'mousedown', onmousedown);
|
|
2520
|
-
};
|
|
2521
|
-
ClickAutomation.prototype._bindBlurHandler = function (element) {
|
|
2522
|
-
var _this = this;
|
|
2523
|
-
var onblur = function () {
|
|
2524
|
-
_this.eventState.blurRaised = true;
|
|
2525
|
-
eventUtils.unbind(element, 'blur', onblur, true);
|
|
2526
|
-
};
|
|
2527
|
-
eventUtils.bind(element, 'blur', onblur, true);
|
|
2528
|
-
};
|
|
2529
|
-
// NOTE:
|
|
2530
|
-
// If `touchstart`, `touchmove`, or `touchend` are canceled, we should not dispatch any mouse event
|
|
2531
|
-
// that would be a consequential result of the prevented touch event
|
|
2532
|
-
ClickAutomation.prototype._isTouchEventWasCancelled = function () {
|
|
2533
|
-
return this.eventState.touchStartCancelled || this.eventState.touchEndCancelled;
|
|
2534
|
-
};
|
|
2535
|
-
ClickAutomation.prototype._raiseTouchEvents = function (eventArgs) {
|
|
2536
|
-
if (featureDetection$1.isTouchDevice) {
|
|
2537
|
-
this.eventState.touchStartCancelled = !eventSimulator$5.touchstart(eventArgs.element, eventArgs.options);
|
|
2538
|
-
this.eventState.touchEndCancelled = !eventSimulator$5.touchend(eventArgs.element, eventArgs.options);
|
|
2539
|
-
}
|
|
2540
|
-
};
|
|
2541
2685
|
ClickAutomation.prototype._mousedown = function (eventArgs) {
|
|
2542
|
-
|
|
2543
|
-
this.targetElementParentNodes = domUtils$4.getParents(eventArgs.element);
|
|
2544
|
-
this.mouseDownElement = eventArgs.element;
|
|
2545
|
-
return cursor
|
|
2546
|
-
.leftButtonDown()
|
|
2547
|
-
.then(function () {
|
|
2548
|
-
_this._raiseTouchEvents(eventArgs);
|
|
2549
|
-
var activeElement = domUtils$4.getActiveElement();
|
|
2550
|
-
_this.activeElementBeforeMouseDown = activeElement;
|
|
2551
|
-
// NOTE: In WebKit and IE, the mousedown event opens the select element's dropdown;
|
|
2552
|
-
// therefore, we should prevent mousedown and hide the dropdown (B236416).
|
|
2553
|
-
var needCloseSelectDropDown = (browserUtils$5.isWebKit || browserUtils$5.isIE) &&
|
|
2554
|
-
domUtils$4.isSelectElement(_this.mouseDownElement);
|
|
2555
|
-
if (needCloseSelectDropDown)
|
|
2556
|
-
_this._bindMousedownHandler();
|
|
2557
|
-
_this._bindBlurHandler(activeElement);
|
|
2558
|
-
if (!_this._isTouchEventWasCancelled())
|
|
2559
|
-
_this.eventState.simulateDefaultBehavior = eventSimulator$5.mousedown(eventArgs.element, eventArgs.options);
|
|
2560
|
-
if (_this.eventState.simulateDefaultBehavior === false)
|
|
2561
|
-
_this.eventState.simulateDefaultBehavior = needCloseSelectDropDown && !_this.eventState.mousedownPrevented;
|
|
2562
|
-
return _this._ensureActiveElementBlur(activeElement);
|
|
2563
|
-
})
|
|
2564
|
-
.then(function () { return _this._focus(eventArgs); });
|
|
2565
|
-
};
|
|
2566
|
-
ClickAutomation.prototype._ensureActiveElementBlur = function (element) {
|
|
2567
|
-
var _this = this;
|
|
2568
|
-
// NOTE: In some cases, mousedown may lead to active element change (browsers raise blur).
|
|
2569
|
-
// We simulate the blur event if the active element was changed after the mousedown, and
|
|
2570
|
-
// the blur event does not get raised automatically (B239273, B253520)
|
|
2571
|
-
return new Promise$6(function (resolve) {
|
|
2572
|
-
var simulateBlur = domUtils$4.getActiveElement() !== element && !_this.eventState.blurRaised;
|
|
2573
|
-
if (!simulateBlur) {
|
|
2574
|
-
resolve();
|
|
2575
|
-
return;
|
|
2576
|
-
}
|
|
2577
|
-
if (browserUtils$5.isIE && browserUtils$5.version < 12) {
|
|
2578
|
-
// NOTE: In whatever way an element is blurred from the client script, the
|
|
2579
|
-
// blur event is raised asynchronously in IE (in MSEdge focus/blur is sync)
|
|
2580
|
-
nextTick$1()
|
|
2581
|
-
.then(function () {
|
|
2582
|
-
if (!_this.eventState.blurRaised)
|
|
2583
|
-
eventSimulator$5.blur(element);
|
|
2584
|
-
resolve();
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
|
-
else {
|
|
2588
|
-
eventSimulator$5.blur(element);
|
|
2589
|
-
resolve();
|
|
2590
|
-
}
|
|
2591
|
-
});
|
|
2592
|
-
};
|
|
2593
|
-
ClickAutomation.prototype._focus = function (eventArgs) {
|
|
2594
|
-
if (this.eventState.simulateDefaultBehavior === false)
|
|
2595
|
-
return Promise$6.resolve();
|
|
2596
|
-
// NOTE: If a target element is a contentEditable element, we need to call focusAndSetSelection directly for
|
|
2597
|
-
// this element. Otherwise, if the element obtained by elementFromPoint is a child of the contentEditable
|
|
2598
|
-
// element, a selection position may be calculated incorrectly (by using the caretPos option).
|
|
2599
|
-
var elementForFocus = domUtils$4.isContentEditableElement(this.element) ? this.element : eventArgs.element;
|
|
2600
|
-
// NOTE: IE doesn't perform focus if active element has been changed while executing mousedown
|
|
2601
|
-
var simulateFocus = !browserUtils$5.isIE || this.activeElementBeforeMouseDown === domUtils$4.getActiveElement();
|
|
2602
|
-
return focusAndSetSelection(elementForFocus, simulateFocus, this.caretPos);
|
|
2686
|
+
return this.strategy.mousedown(eventArgs);
|
|
2603
2687
|
};
|
|
2604
|
-
ClickAutomation.
|
|
2605
|
-
|
|
2606
|
-
var areElementsSame = domUtils$4.isTheSameNode(topElement, mouseDownElement);
|
|
2607
|
-
// NOTE: Mozilla Firefox always skips click, if an element under cursor has been changed after mousedown.
|
|
2608
|
-
if (browserUtils$5.isFirefox)
|
|
2609
|
-
return areElementsSame ? mouseDownElement : null;
|
|
2610
|
-
if (!areElementsSame) {
|
|
2611
|
-
if (mouseDownElement.contains(topElement) && !domUtils$4.isEditableFormElement(topElement))
|
|
2612
|
-
return mouseDownElement;
|
|
2613
|
-
if (topElement.contains(mouseDownElement))
|
|
2614
|
-
return topElement;
|
|
2615
|
-
// NOTE: If elements are not in the parent-child relationships,
|
|
2616
|
-
// non-ff browsers raise the `click` event for their common parent.
|
|
2617
|
-
return arrayUtils.getCommonElement(topElementParentNodes, mouseDownElementParentNodes);
|
|
2618
|
-
}
|
|
2619
|
-
// NOTE: In case the target element and the top element are the same,
|
|
2620
|
-
// non-FF browsers are dispatching the `click` event if the target
|
|
2621
|
-
// element hasn't changed its position in the DOM after mousedown.
|
|
2622
|
-
return arrayUtils.equals(mouseDownElementParentNodes, topElementParentNodes) ? mouseDownElement : null;
|
|
2688
|
+
ClickAutomation.prototype._mouseup = function (element, eventArgs) {
|
|
2689
|
+
return this.strategy.mouseup(element, eventArgs);
|
|
2623
2690
|
};
|
|
2624
|
-
ClickAutomation.prototype.
|
|
2691
|
+
ClickAutomation.prototype.run = function (useStrictElementCheck) {
|
|
2625
2692
|
var _this = this;
|
|
2626
|
-
|
|
2627
|
-
|
|
2693
|
+
var eventArgs;
|
|
2694
|
+
return this
|
|
2695
|
+
._ensureElement(useStrictElementCheck)
|
|
2696
|
+
.then(function (_a) {
|
|
2697
|
+
var element = _a.element, clientPoint = _a.clientPoint, screenPoint = _a.screenPoint, devicePoint = _a.devicePoint;
|
|
2698
|
+
eventArgs = {
|
|
2699
|
+
point: clientPoint,
|
|
2700
|
+
screenPoint: screenPoint,
|
|
2701
|
+
element: element,
|
|
2702
|
+
options: adapter.utils.extend({
|
|
2703
|
+
clientX: clientPoint === null || clientPoint === void 0 ? void 0 : clientPoint.x,
|
|
2704
|
+
clientY: clientPoint === null || clientPoint === void 0 ? void 0 : clientPoint.y,
|
|
2705
|
+
screenX: devicePoint === null || devicePoint === void 0 ? void 0 : devicePoint.x,
|
|
2706
|
+
screenY: devicePoint === null || devicePoint === void 0 ? void 0 : devicePoint.y,
|
|
2707
|
+
}, _this.modifiers),
|
|
2708
|
+
};
|
|
2709
|
+
// NOTE: we should raise mouseup event with 'mouseActionStepDelay' after we trigger
|
|
2710
|
+
// mousedown event regardless of how long mousedown event handlers were executing
|
|
2711
|
+
return Promise$f.all([delay(_this.automationSettings.mouseActionStepDelay), _this.cursor
|
|
2712
|
+
.leftButtonDown()
|
|
2713
|
+
.then(function () { return _this._mousedown(eventArgs); }),
|
|
2714
|
+
]);
|
|
2715
|
+
})
|
|
2716
|
+
.then(function () { return _this.cursor.buttonUp(); })
|
|
2628
2717
|
.then(function () { return _this._getElementForEvent(eventArgs); })
|
|
2629
2718
|
.then(function (element) {
|
|
2630
|
-
|
|
2631
|
-
_this.eventState.clickElement = ClickAutomation._getElementForClick(_this.mouseDownElement, element, _this.targetElementParentNodes);
|
|
2632
|
-
var timeStamp = {};
|
|
2633
|
-
var getTimeStamp = function (e) {
|
|
2634
|
-
timeStamp = e.timeStamp;
|
|
2635
|
-
listeners$1.removeInternalEventBeforeListener(window, ['mouseup'], getTimeStamp);
|
|
2636
|
-
};
|
|
2637
|
-
if (!browserUtils$5.isIE)
|
|
2638
|
-
listeners$1.addInternalEventBeforeListener(window, ['mouseup'], getTimeStamp);
|
|
2639
|
-
if (!_this._isTouchEventWasCancelled())
|
|
2640
|
-
eventSimulator$5.mouseup(element, eventArgs.options);
|
|
2641
|
-
return { timeStamp: timeStamp };
|
|
2719
|
+
return element ? _this._mouseup(element, eventArgs) : null;
|
|
2642
2720
|
});
|
|
2643
2721
|
};
|
|
2644
|
-
ClickAutomation
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2722
|
+
return ClickAutomation;
|
|
2723
|
+
}(VisibleElementAutomation));
|
|
2724
|
+
|
|
2725
|
+
function getLineYByXCoord(startLine, endLine, x) {
|
|
2726
|
+
if (endLine.x === startLine.x)
|
|
2727
|
+
return 0;
|
|
2728
|
+
var equationSlope = (endLine.y - startLine.y) / (endLine.x - startLine.x);
|
|
2729
|
+
var equationYIntercept = startLine.x * (startLine.y - endLine.y) / (endLine.x - startLine.x) + startLine.y;
|
|
2730
|
+
return Math.round(equationSlope * x + equationYIntercept);
|
|
2731
|
+
}
|
|
2732
|
+
function getLineXByYCoord(startLine, endLine, y) {
|
|
2733
|
+
if (endLine.y - startLine.y === 0)
|
|
2734
|
+
return 0;
|
|
2735
|
+
var equationSlope = (endLine.x - startLine.x) / (endLine.y - startLine.y);
|
|
2736
|
+
var equationXIntercept = startLine.y * (startLine.x - endLine.x) / (endLine.y - startLine.y) + startLine.x;
|
|
2737
|
+
return Math.round(equationSlope * y + equationXIntercept);
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2740
|
+
function findIntersectionHorizontal(startLinePoint, endLinePoint, rectSide) {
|
|
2741
|
+
var intersectionX = getLineXByYCoord(startLinePoint, endLinePoint, rectSide.top);
|
|
2742
|
+
var haveIntersectionInBounds = intersectionX && intersectionX >= rectSide.left && intersectionX <= rectSide.right;
|
|
2743
|
+
return haveIntersectionInBounds ? new AxisValues(intersectionX, rectSide.top) : null;
|
|
2744
|
+
}
|
|
2745
|
+
function findIntersectionVertical(startLinePoint, endLinePoint, rectSide) {
|
|
2746
|
+
var intersectionY = getLineYByXCoord(startLinePoint, endLinePoint, rectSide.left);
|
|
2747
|
+
var haveIntersectionInBounds = intersectionY && intersectionY >= rectSide.top && intersectionY <= rectSide.bottom;
|
|
2748
|
+
return haveIntersectionInBounds ? new AxisValues(rectSide.left, intersectionY) : null;
|
|
2749
|
+
}
|
|
2750
|
+
function getLineRectIntersection (startLine, endLine, rect) {
|
|
2751
|
+
var res = [];
|
|
2752
|
+
var rectLines = [
|
|
2753
|
+
{ left: rect.left, top: rect.top, right: rect.left, bottom: rect.bottom, isHorizontal: false },
|
|
2754
|
+
{ left: rect.right, top: rect.top, right: rect.right, bottom: rect.bottom, isHorizontal: false },
|
|
2755
|
+
{ left: rect.left, top: rect.top, right: rect.right, bottom: rect.top, isHorizontal: true },
|
|
2756
|
+
{ left: rect.left, top: rect.bottom, right: rect.right, bottom: rect.bottom, isHorizontal: true },
|
|
2757
|
+
];
|
|
2758
|
+
for (var _i = 0, rectLines_1 = rectLines; _i < rectLines_1.length; _i++) {
|
|
2759
|
+
var rectLine = rectLines_1[_i];
|
|
2760
|
+
var intersection = rectLine.isHorizontal
|
|
2761
|
+
? findIntersectionHorizontal(startLine, endLine, rectLine)
|
|
2762
|
+
: findIntersectionVertical(startLine, endLine, rectLine);
|
|
2763
|
+
if (intersection)
|
|
2764
|
+
res.push(intersection);
|
|
2765
|
+
}
|
|
2766
|
+
if (!res.length)
|
|
2767
|
+
return null;
|
|
2768
|
+
if (res.length === 1)
|
|
2769
|
+
return res[0];
|
|
2770
|
+
// NOTE: if a line and rect have two intersection points, we return the nearest to startLinePoint
|
|
2771
|
+
return res[0].distance(startLine) < res[1].distance(startLine) ? res[0] : res[1];
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
var eventSimulator$5 = hammerhead__default.eventSandbox.eventSimulator;
|
|
2775
|
+
var messageSandbox$2 = hammerhead__default.eventSandbox.message;
|
|
2776
|
+
var positionUtils$2 = testCafeCore__default.positionUtils;
|
|
2777
|
+
var domUtils$4 = testCafeCore__default.domUtils;
|
|
2778
|
+
var styleUtils$2 = testCafeCore__default.styleUtils;
|
|
2779
|
+
var MOVE_REQUEST_CMD$1 = 'automation|move|request';
|
|
2780
|
+
var MOVE_RESPONSE_CMD$1 = 'automation|move|response';
|
|
2781
|
+
function onMoveToIframeRequest(e) {
|
|
2782
|
+
var iframePoint = new AxisValues(e.message.endX, e.message.endY);
|
|
2783
|
+
var iframeWin = e.source;
|
|
2784
|
+
var iframe = domUtils$4.findIframeByWindow(iframeWin);
|
|
2785
|
+
var iframeBorders = styleUtils$2.getBordersWidth(iframe);
|
|
2786
|
+
var iframePadding = styleUtils$2.getElementPadding(iframe);
|
|
2787
|
+
var iframeRectangle = positionUtils$2.getIframeClientCoordinates(iframe);
|
|
2788
|
+
var iframePointRelativeToParent = positionUtils$2.getIframePointRelativeToParentFrame(iframePoint, iframeWin);
|
|
2789
|
+
var cursorPosition = cursor.getPosition();
|
|
2790
|
+
var intersectionPoint = positionUtils$2.isInRectangle(cursorPosition, iframeRectangle) ? cursorPosition :
|
|
2791
|
+
getLineRectIntersection(cursorPosition, iframePointRelativeToParent, iframeRectangle);
|
|
2792
|
+
var intersectionRelatedToIframe = {
|
|
2793
|
+
x: intersectionPoint.x - iframeRectangle.left,
|
|
2794
|
+
y: intersectionPoint.y - iframeRectangle.top,
|
|
2795
|
+
};
|
|
2796
|
+
var moveOptions = new MoveOptions({
|
|
2797
|
+
modifiers: e.message.modifiers,
|
|
2798
|
+
offsetX: intersectionRelatedToIframe.x + iframeBorders.left + iframePadding.left,
|
|
2799
|
+
offsetY: intersectionRelatedToIframe.y + iframeBorders.top + iframePadding.top,
|
|
2800
|
+
speed: e.message.speed,
|
|
2801
|
+
// NOTE: we should not perform scrolling because the active window was
|
|
2802
|
+
// already scrolled to the target element before the request (GH-847)
|
|
2803
|
+
skipScrolling: true,
|
|
2804
|
+
}, false);
|
|
2805
|
+
var responseMsg = {
|
|
2806
|
+
cmd: MOVE_RESPONSE_CMD$1,
|
|
2807
|
+
x: intersectionRelatedToIframe.x,
|
|
2808
|
+
y: intersectionRelatedToIframe.y,
|
|
2649
2809
|
};
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
.
|
|
2655
|
-
.then(function (_a) {
|
|
2656
|
-
var element = _a.element, clientPoint = _a.clientPoint, screenPoint = _a.screenPoint, devicePoint = _a.devicePoint;
|
|
2657
|
-
eventArgs = {
|
|
2658
|
-
point: clientPoint,
|
|
2659
|
-
screenPoint: screenPoint,
|
|
2660
|
-
element: element,
|
|
2661
|
-
options: extend$2({
|
|
2662
|
-
clientX: clientPoint.x,
|
|
2663
|
-
clientY: clientPoint.y,
|
|
2664
|
-
screenX: devicePoint.x,
|
|
2665
|
-
screenY: devicePoint.y,
|
|
2666
|
-
}, _this.modifiers),
|
|
2667
|
-
};
|
|
2668
|
-
// NOTE: we should raise mouseup event with 'mouseActionStepDelay' after we trigger
|
|
2669
|
-
// mousedown event regardless of how long mousedown event handlers were executing
|
|
2670
|
-
return Promise$6.all([delay$1(_this.automationSettings.mouseActionStepDelay), _this._mousedown(eventArgs)]);
|
|
2810
|
+
if (cursor.getActiveWindow(window) !== iframeWin) {
|
|
2811
|
+
// const moveAutomation = new MoveAutomation(iframe, moveOptions);
|
|
2812
|
+
MoveAutomation.create(iframe, moveOptions, window, cursor)
|
|
2813
|
+
.then(function (moveAutomation) {
|
|
2814
|
+
return moveAutomation.run();
|
|
2671
2815
|
})
|
|
2672
|
-
.then(function () {
|
|
2673
|
-
.
|
|
2674
|
-
|
|
2675
|
-
eventArgs.options.timeStamp = timeStamp;
|
|
2676
|
-
return _this._click(eventArgs);
|
|
2816
|
+
.then(function () {
|
|
2817
|
+
cursor.setActiveWindow(iframeWin);
|
|
2818
|
+
messageSandbox$2.sendServiceMsg(responseMsg, iframeWin);
|
|
2677
2819
|
});
|
|
2820
|
+
}
|
|
2821
|
+
else
|
|
2822
|
+
messageSandbox$2.sendServiceMsg(responseMsg, iframeWin);
|
|
2823
|
+
}
|
|
2824
|
+
function onMoveOutRequest(e) {
|
|
2825
|
+
var parentWin = e.source;
|
|
2826
|
+
var iframeRectangle = {
|
|
2827
|
+
left: e.message.left,
|
|
2828
|
+
right: e.message.right,
|
|
2829
|
+
top: e.message.top,
|
|
2830
|
+
bottom: e.message.bottom,
|
|
2678
2831
|
};
|
|
2679
|
-
|
|
2680
|
-
|
|
2832
|
+
if (!e.message.iframeUnderCursor) {
|
|
2833
|
+
var _a = e.message, startX = _a.startX, startY = _a.startY;
|
|
2834
|
+
var clientX = startX - iframeRectangle.left;
|
|
2835
|
+
var clientY = startY - iframeRectangle.top;
|
|
2836
|
+
// NOTE: We should not emulate mouseout and mouseleave if iframe was reloaded.
|
|
2837
|
+
var element = lastHoveredElementHolder.get();
|
|
2838
|
+
if (element) {
|
|
2839
|
+
eventSimulator$5.mouseout(element, { clientX: clientX, clientY: clientY, relatedTarget: null });
|
|
2840
|
+
eventSimulator$5.mouseleave(element, { clientX: clientX, clientY: clientY, relatedTarget: null });
|
|
2841
|
+
}
|
|
2842
|
+
messageSandbox$2.sendServiceMsg({ cmd: MOVE_RESPONSE_CMD$1 }, parentWin);
|
|
2843
|
+
return;
|
|
2844
|
+
}
|
|
2845
|
+
var cursorPosition = cursor.getPosition();
|
|
2846
|
+
var startPoint = AxisValues.create(iframeRectangle).add(cursorPosition);
|
|
2847
|
+
var endPoint = new AxisValues(e.message.endX, e.message.endY);
|
|
2848
|
+
var intersectionPoint = getLineRectIntersection(startPoint, endPoint, iframeRectangle);
|
|
2849
|
+
// NOTE: We should not move the cursor out of the iframe if
|
|
2850
|
+
// the cursor path does not intersect with the iframe borders.
|
|
2851
|
+
if (!intersectionPoint) {
|
|
2852
|
+
messageSandbox$2.sendServiceMsg({
|
|
2853
|
+
cmd: MOVE_RESPONSE_CMD$1,
|
|
2854
|
+
x: iframeRectangle.left,
|
|
2855
|
+
y: iframeRectangle.top,
|
|
2856
|
+
}, parentWin);
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
var moveOptions = new MoveOptions({
|
|
2860
|
+
modifiers: e.message.modifiers,
|
|
2861
|
+
offsetX: intersectionPoint.x - iframeRectangle.left,
|
|
2862
|
+
offsetY: intersectionPoint.y - iframeRectangle.top,
|
|
2863
|
+
speed: e.message.speed,
|
|
2864
|
+
// NOTE: we should not perform scrolling because the active window was
|
|
2865
|
+
// already scrolled to the target element before the request (GH-847)
|
|
2866
|
+
skipScrolling: true,
|
|
2867
|
+
}, false);
|
|
2868
|
+
MoveAutomation.create(document.documentElement, moveOptions, window, cursor)
|
|
2869
|
+
.then(function (moveAutomation) {
|
|
2870
|
+
return moveAutomation.run();
|
|
2871
|
+
})
|
|
2872
|
+
.then(function () {
|
|
2873
|
+
var responseMsg = {
|
|
2874
|
+
cmd: MOVE_RESPONSE_CMD$1,
|
|
2875
|
+
x: intersectionPoint.x,
|
|
2876
|
+
y: intersectionPoint.y,
|
|
2877
|
+
};
|
|
2878
|
+
cursor.setActiveWindow(parentWin);
|
|
2879
|
+
messageSandbox$2.sendServiceMsg(responseMsg, parentWin);
|
|
2880
|
+
});
|
|
2881
|
+
}
|
|
2882
|
+
// Setup cross-iframe interaction
|
|
2883
|
+
messageSandbox$2.on(messageSandbox$2.SERVICE_MSG_RECEIVED_EVENT, function (e) {
|
|
2884
|
+
if (e.message.cmd === MOVE_REQUEST_CMD$1) {
|
|
2885
|
+
if (e.source.parent === window)
|
|
2886
|
+
onMoveToIframeRequest(e);
|
|
2887
|
+
else {
|
|
2888
|
+
hammerhead__default.on(hammerhead__default.EVENTS.beforeUnload, function () { return messageSandbox$2.sendServiceMsg({ cmd: MOVE_RESPONSE_CMD$1 }, e.source); });
|
|
2889
|
+
onMoveOutRequest(e);
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
});
|
|
2681
2893
|
|
|
2682
|
-
var Promise$
|
|
2683
|
-
var browserUtils$
|
|
2894
|
+
var Promise$6 = hammerhead__default.Promise;
|
|
2895
|
+
var browserUtils$4 = hammerhead__default.utils.browser;
|
|
2684
2896
|
var featureDetection$2 = hammerhead__default.utils.featureDetection;
|
|
2685
2897
|
var eventSimulator$6 = hammerhead__default.eventSandbox.eventSimulator;
|
|
2686
2898
|
var focusBlurSandbox$1 = hammerhead__default.eventSandbox.focusBlur;
|
|
2687
|
-
var nativeMethods$
|
|
2899
|
+
var nativeMethods$6 = hammerhead__default.nativeMethods;
|
|
2688
2900
|
var domUtils$5 = testCafeCore__default.domUtils;
|
|
2689
2901
|
var styleUtils$3 = testCafeCore__default.styleUtils;
|
|
2690
|
-
var delay$
|
|
2902
|
+
var delay$1 = testCafeCore__default.delay;
|
|
2691
2903
|
var selectElementUI$1 = testCafeUI.selectElement;
|
|
2692
2904
|
var FOCUS_DELAY = featureDetection$2.isTouchDevice ? 0 : 160;
|
|
2693
2905
|
var SelectChildClickAutomation = /** @class */ (function () {
|
|
@@ -2708,7 +2920,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2708
2920
|
var selectedIndex = this.parentSelect.selectedIndex;
|
|
2709
2921
|
this.childIndex = isOption ? domUtils$5.getElementIndexInParent(this.parentSelect, this.element) :
|
|
2710
2922
|
domUtils$5.getElementIndexInParent(this.parentSelect, this.element);
|
|
2711
|
-
var parent_1 = nativeMethods$
|
|
2923
|
+
var parent_1 = nativeMethods$6.nodeParentNodeGetter.call(this.element);
|
|
2712
2924
|
var parentOptGroup = domUtils$5.isOptionGroupElement(parent_1) ? parent_1 : null;
|
|
2713
2925
|
var isDisabled = this.element.disabled || parentOptGroup && parentOptGroup.disabled;
|
|
2714
2926
|
this.clickCausesChange = isOption && !isDisabled && this.childIndex !== selectedIndex;
|
|
@@ -2723,7 +2935,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2723
2935
|
var parentSelectSize = styleUtils$3.getSelectElementSize(this.parentSelect) > 1;
|
|
2724
2936
|
return {
|
|
2725
2937
|
options: this.modifiers,
|
|
2726
|
-
element: browserUtils$
|
|
2938
|
+
element: browserUtils$4.isIE && parentSelectSize ? this.parentSelect : childElement,
|
|
2727
2939
|
};
|
|
2728
2940
|
};
|
|
2729
2941
|
SelectChildClickAutomation.prototype._getMoveArguments = function () {
|
|
@@ -2753,21 +2965,21 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2753
2965
|
speed: speed,
|
|
2754
2966
|
modifiers: this.modifiers,
|
|
2755
2967
|
}, false);
|
|
2756
|
-
return MoveAutomation.create(element, window, cursor
|
|
2968
|
+
return MoveAutomation.create(element, moveOptions, window, cursor)
|
|
2757
2969
|
.then(function (moveAutomation) {
|
|
2758
2970
|
return moveAutomation.run();
|
|
2759
2971
|
})
|
|
2760
|
-
.then(function () { return delay$
|
|
2972
|
+
.then(function () { return delay$1(_this.automationSettings.mouseActionStepDelay); });
|
|
2761
2973
|
};
|
|
2762
2974
|
SelectChildClickAutomation.prototype._mousedown = function () {
|
|
2763
2975
|
var _this = this;
|
|
2764
|
-
if (browserUtils$
|
|
2976
|
+
if (browserUtils$4.isFirefox) {
|
|
2765
2977
|
eventSimulator$6.mousedown(this.eventsArgs.element, this.eventsArgs.options);
|
|
2766
2978
|
if (this.clickCausesChange)
|
|
2767
2979
|
this.parentSelect.selectedIndex = this.childIndex;
|
|
2768
2980
|
return this._focus();
|
|
2769
2981
|
}
|
|
2770
|
-
if (browserUtils$
|
|
2982
|
+
if (browserUtils$4.isIE) {
|
|
2771
2983
|
eventSimulator$6.mousedown(this.eventsArgs.element, this.eventsArgs.options);
|
|
2772
2984
|
return this._focus();
|
|
2773
2985
|
}
|
|
@@ -2776,7 +2988,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2776
2988
|
// That's why we should change the event order and raise focus before mousedown.
|
|
2777
2989
|
return this
|
|
2778
2990
|
._focus()
|
|
2779
|
-
.then(function () { return delay$
|
|
2991
|
+
.then(function () { return delay$1(FOCUS_DELAY); })
|
|
2780
2992
|
.then(function () {
|
|
2781
2993
|
eventSimulator$6.mousedown(_this.eventsArgs.element, _this.eventsArgs.options);
|
|
2782
2994
|
if (_this.clickCausesChange)
|
|
@@ -2785,23 +2997,23 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2785
2997
|
};
|
|
2786
2998
|
SelectChildClickAutomation.prototype._focus = function () {
|
|
2787
2999
|
var _this = this;
|
|
2788
|
-
return new Promise$
|
|
3000
|
+
return new Promise$6(function (resolve) {
|
|
2789
3001
|
focusBlurSandbox$1.focus(_this.parentSelect, resolve, false, true);
|
|
2790
3002
|
});
|
|
2791
3003
|
};
|
|
2792
3004
|
SelectChildClickAutomation.prototype._mouseup = function () {
|
|
2793
|
-
var elementForMouseupEvent = browserUtils$
|
|
3005
|
+
var elementForMouseupEvent = browserUtils$4.isIE ? this.parentSelect : this.eventsArgs.element;
|
|
2794
3006
|
eventSimulator$6.mouseup(elementForMouseupEvent, this.eventsArgs.options);
|
|
2795
|
-
if (browserUtils$
|
|
3007
|
+
if (browserUtils$4.isIE && this.clickCausesChange)
|
|
2796
3008
|
this.parentSelect.selectedIndex = this.childIndex;
|
|
2797
|
-
var simulateInputEventOnValueChange = browserUtils$
|
|
2798
|
-
browserUtils$
|
|
2799
|
-
var simulateChangeEventOnValueChange = simulateInputEventOnValueChange || browserUtils$
|
|
3009
|
+
var simulateInputEventOnValueChange = browserUtils$4.isFirefox || browserUtils$4.isSafari ||
|
|
3010
|
+
browserUtils$4.isChrome && browserUtils$4.version >= 53;
|
|
3011
|
+
var simulateChangeEventOnValueChange = simulateInputEventOnValueChange || browserUtils$4.isIE;
|
|
2800
3012
|
if (simulateInputEventOnValueChange && this.clickCausesChange)
|
|
2801
3013
|
eventSimulator$6.input(this.parentSelect);
|
|
2802
3014
|
if (simulateChangeEventOnValueChange && this.clickCausesChange)
|
|
2803
3015
|
eventSimulator$6.change(this.parentSelect);
|
|
2804
|
-
return Promise$
|
|
3016
|
+
return Promise$6.resolve();
|
|
2805
3017
|
};
|
|
2806
3018
|
SelectChildClickAutomation.prototype._click = function () {
|
|
2807
3019
|
eventSimulator$6.click(this.eventsArgs.element, this.eventsArgs.options);
|
|
@@ -2810,7 +3022,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2810
3022
|
var _this = this;
|
|
2811
3023
|
if (!this.parentSelect) {
|
|
2812
3024
|
eventSimulator$6.click(this.eventsArgs.element, this.eventsArgs.options);
|
|
2813
|
-
return Promise$
|
|
3025
|
+
return Promise$6.resolve();
|
|
2814
3026
|
}
|
|
2815
3027
|
if (!this.optionListExpanded)
|
|
2816
3028
|
selectElementUI$1.scrollOptionListByChild(this.element);
|
|
@@ -2831,15 +3043,15 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2831
3043
|
}());
|
|
2832
3044
|
|
|
2833
3045
|
var featureDetection$3 = hammerhead__default.utils.featureDetection;
|
|
2834
|
-
var browserUtils$
|
|
3046
|
+
var browserUtils$5 = hammerhead__default.utils.browser;
|
|
2835
3047
|
var eventSimulator$7 = hammerhead__default.eventSandbox.eventSimulator;
|
|
2836
|
-
var eventUtils$
|
|
2837
|
-
var delay$
|
|
3048
|
+
var eventUtils$2 = testCafeCore__default.eventUtils;
|
|
3049
|
+
var delay$2 = testCafeCore__default.delay;
|
|
2838
3050
|
var FIRST_CLICK_DELAY = featureDetection$3.isTouchDevice ? 0 : 160;
|
|
2839
3051
|
var DblClickAutomation = /** @class */ (function (_super) {
|
|
2840
3052
|
__extends(DblClickAutomation, _super);
|
|
2841
3053
|
function DblClickAutomation(element, clickOptions) {
|
|
2842
|
-
var _this = _super.call(this, element, clickOptions) || this;
|
|
3054
|
+
var _this = _super.call(this, element, clickOptions, window, cursor) || this;
|
|
2843
3055
|
_this.modifiers = clickOptions.modifiers;
|
|
2844
3056
|
_this.caretPos = clickOptions.caretPos;
|
|
2845
3057
|
_this.speed = clickOptions.speed;
|
|
@@ -2857,18 +3069,18 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2857
3069
|
// NOTE: we should always perform click with the highest speed
|
|
2858
3070
|
var clickOptions = new ClickOptions(this.options);
|
|
2859
3071
|
clickOptions.speed = 1;
|
|
2860
|
-
var clickAutomation = new ClickAutomation(this.element, clickOptions);
|
|
3072
|
+
var clickAutomation = new ClickAutomation(this.element, clickOptions, window, cursor);
|
|
2861
3073
|
clickAutomation.on(clickAutomation.TARGET_ELEMENT_FOUND_EVENT, function (e) { return _this.emit(_this.TARGET_ELEMENT_FOUND_EVENT, e); });
|
|
2862
3074
|
return clickAutomation.run(useStrictElementCheck)
|
|
2863
3075
|
.then(function (clickEventArgs) {
|
|
2864
|
-
return delay$
|
|
3076
|
+
return delay$2(FIRST_CLICK_DELAY).then(function () { return clickEventArgs; });
|
|
2865
3077
|
});
|
|
2866
3078
|
};
|
|
2867
3079
|
DblClickAutomation.prototype._secondClick = function (eventArgs) {
|
|
2868
3080
|
var _this = this;
|
|
2869
3081
|
//NOTE: we should not call focus after the second mousedown (except in IE) because of the native browser behavior
|
|
2870
|
-
if (browserUtils$
|
|
2871
|
-
eventUtils$
|
|
3082
|
+
if (browserUtils$5.isIE)
|
|
3083
|
+
eventUtils$2.bind(document, 'focus', eventUtils$2.preventDefault, true);
|
|
2872
3084
|
var clickOptions = new ClickOptions({
|
|
2873
3085
|
offsetX: eventArgs.screenPoint.x,
|
|
2874
3086
|
offsetY: eventArgs.screenPoint.y,
|
|
@@ -2876,14 +3088,14 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2876
3088
|
modifiers: this.modifiers,
|
|
2877
3089
|
speed: 1,
|
|
2878
3090
|
});
|
|
2879
|
-
var clickAutomation = new ClickAutomation(document.documentElement, clickOptions);
|
|
3091
|
+
var clickAutomation = new ClickAutomation(document.documentElement, clickOptions, window, cursor);
|
|
2880
3092
|
return clickAutomation.run()
|
|
2881
3093
|
.then(function (clickEventArgs) {
|
|
2882
3094
|
// NOTE: We should raise the `dblclick` event on an element that
|
|
2883
3095
|
// has been actually clicked during the second click automation.
|
|
2884
|
-
_this.eventState.dblClickElement = clickAutomation.eventState.clickElement;
|
|
2885
|
-
if (browserUtils$
|
|
2886
|
-
eventUtils$
|
|
3096
|
+
_this.eventState.dblClickElement = clickAutomation.strategy.eventState.clickElement;
|
|
3097
|
+
if (browserUtils$5.isIE)
|
|
3098
|
+
eventUtils$2.unbind(document, 'focus', eventUtils$2.preventDefault, true);
|
|
2887
3099
|
return clickEventArgs;
|
|
2888
3100
|
});
|
|
2889
3101
|
};
|
|
@@ -2902,6 +3114,82 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2902
3114
|
return DblClickAutomation;
|
|
2903
3115
|
}(VisibleElementAutomation));
|
|
2904
3116
|
|
|
3117
|
+
var browserUtils$6 = hammerhead__default.utils.browser;
|
|
3118
|
+
var Promise$7 = hammerhead__default.Promise;
|
|
3119
|
+
var nativeMethods$7 = hammerhead__default.nativeMethods;
|
|
3120
|
+
var positionUtils$3 = testCafeCore__default.positionUtils;
|
|
3121
|
+
var domUtils$6 = testCafeCore__default.domUtils;
|
|
3122
|
+
function fromPoint(point /*: AxisValuesData<number>*/, underTopShadowUIElement) {
|
|
3123
|
+
var topElement = null;
|
|
3124
|
+
return testCafeUI.hide(underTopShadowUIElement)
|
|
3125
|
+
.then(function () { return positionUtils$3.getElementFromPoint(point); })
|
|
3126
|
+
.then(function (el) {
|
|
3127
|
+
topElement = el;
|
|
3128
|
+
return testCafeUI.show(underTopShadowUIElement);
|
|
3129
|
+
})
|
|
3130
|
+
.then(function () { return topElement; });
|
|
3131
|
+
}
|
|
3132
|
+
function ensureImageMap$1(imgElement, areaElement) {
|
|
3133
|
+
var mapElement = domUtils$6.closest(areaElement, 'map');
|
|
3134
|
+
return mapElement && mapElement.name === imgElement.useMap.substring(1) ? areaElement : imgElement;
|
|
3135
|
+
}
|
|
3136
|
+
function findElementOrNonEmptyChildFromPoint$1(x, y, element) {
|
|
3137
|
+
var topElement = positionUtils$3.getElementFromPoint(x, y);
|
|
3138
|
+
var isNonEmptyChild = domUtils$6.containsElement(element, topElement) &&
|
|
3139
|
+
nativeMethods$7.nodeTextContentGetter.call(topElement).length;
|
|
3140
|
+
if (topElement && topElement === element || isNonEmptyChild)
|
|
3141
|
+
return topElement;
|
|
3142
|
+
return null;
|
|
3143
|
+
}
|
|
3144
|
+
function correctTopElementByExpectedElement$1(topElement, expectedElement) {
|
|
3145
|
+
var expectedElementDefined = expectedElement && domUtils$6.isDomElement(expectedElement);
|
|
3146
|
+
if (!expectedElementDefined || !topElement || topElement === expectedElement)
|
|
3147
|
+
return topElement;
|
|
3148
|
+
var isTREFElement = domUtils$6.getTagName(expectedElement) === 'tref';
|
|
3149
|
+
// NOTE: 'document.elementFromPoint' can't find these types of elements
|
|
3150
|
+
if (isTREFElement)
|
|
3151
|
+
return expectedElement;
|
|
3152
|
+
// NOTE: T299665 - Incorrect click automation for images with an associated map element in Firefox
|
|
3153
|
+
// All browsers return the <area> element from document.getElementFromPoint, but
|
|
3154
|
+
// Firefox returns the <img> element. We should accomplish this for Firefox as well.
|
|
3155
|
+
var isImageMapArea = domUtils$6.getTagName(expectedElement) === 'area' && domUtils$6.isImgElement(topElement);
|
|
3156
|
+
if (browserUtils$6.isFirefox && isImageMapArea)
|
|
3157
|
+
return ensureImageMap$1(topElement, expectedElement);
|
|
3158
|
+
// NOTE: try to find a multi-line link by its rectangle (T163678)
|
|
3159
|
+
var isLinkOrChildExpected = domUtils$6.isAnchorElement(expectedElement) ||
|
|
3160
|
+
domUtils$6.getParents(expectedElement, 'a').length;
|
|
3161
|
+
var isTopElementChildOfLink = isLinkOrChildExpected &&
|
|
3162
|
+
domUtils$6.containsElement(expectedElement, topElement) &&
|
|
3163
|
+
nativeMethods$7.nodeTextContentGetter.call(topElement).length;
|
|
3164
|
+
var shouldSearchForMultilineLink = isLinkOrChildExpected && !isTopElementChildOfLink &&
|
|
3165
|
+
nativeMethods$7.nodeTextContentGetter.call(expectedElement).length;
|
|
3166
|
+
if (!shouldSearchForMultilineLink)
|
|
3167
|
+
return topElement;
|
|
3168
|
+
var linkRect = expectedElement.getBoundingClientRect();
|
|
3169
|
+
return findElementOrNonEmptyChildFromPoint$1(linkRect.right - 1, linkRect.top + 1, expectedElement) ||
|
|
3170
|
+
findElementOrNonEmptyChildFromPoint$1(linkRect.left + 1, linkRect.bottom - 1, expectedElement) ||
|
|
3171
|
+
topElement;
|
|
3172
|
+
}
|
|
3173
|
+
function getElementFromPoint$2(point /*: AxisValuesData<number>*/, expectedElement) {
|
|
3174
|
+
return fromPoint(point)
|
|
3175
|
+
.then(function (topElement) {
|
|
3176
|
+
var foundElement = topElement;
|
|
3177
|
+
// NOTE: when trying to get an element by elementFromPoint in iframe and the target
|
|
3178
|
+
// element is under any of shadow-ui elements, you will get null (only in IE).
|
|
3179
|
+
// In this case, you should hide a top window's shadow-ui root to obtain an element.
|
|
3180
|
+
var resChain = Promise$7.resolve(topElement);
|
|
3181
|
+
if (!foundElement && isIframeWindow(window) && point.x > 0 && point.y > 0) {
|
|
3182
|
+
resChain = resChain
|
|
3183
|
+
.then(function () { return fromPoint(point, true); })
|
|
3184
|
+
.then(function (element) {
|
|
3185
|
+
foundElement = element;
|
|
3186
|
+
return element;
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
return resChain.then(function (element) { return correctTopElementByExpectedElement$1(element, expectedElement); });
|
|
3190
|
+
});
|
|
3191
|
+
}
|
|
3192
|
+
|
|
2905
3193
|
var DragAndDropState = /** @class */ (function () {
|
|
2906
3194
|
function DragAndDropState() {
|
|
2907
3195
|
this.enabled = false;
|
|
@@ -2919,8 +3207,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2919
3207
|
var urlUtils = hammerhead__default.utils.url;
|
|
2920
3208
|
var DataTransfer = hammerhead__default.eventSandbox.DataTransfer;
|
|
2921
3209
|
var DragDataStore = hammerhead__default.eventSandbox.DragDataStore;
|
|
2922
|
-
var eventUtils$
|
|
2923
|
-
var domUtils$
|
|
3210
|
+
var eventUtils$3 = testCafeCore__default.eventUtils;
|
|
3211
|
+
var domUtils$7 = testCafeCore__default.domUtils;
|
|
2924
3212
|
// Utils
|
|
2925
3213
|
function findDraggableElement(element) {
|
|
2926
3214
|
var parentNode = element;
|
|
@@ -2933,13 +3221,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2933
3221
|
}
|
|
2934
3222
|
var DragMoveAutomation = /** @class */ (function (_super) {
|
|
2935
3223
|
__extends(DragMoveAutomation, _super);
|
|
2936
|
-
function DragMoveAutomation(element, offset, win, cursor
|
|
2937
|
-
var _this = _super.call(this, element, offset, win, cursor
|
|
3224
|
+
function DragMoveAutomation(element, offset, moveOptions, win, cursor) {
|
|
3225
|
+
var _this = _super.call(this, element, offset, moveOptions, win, cursor) || this;
|
|
2938
3226
|
_this.dragElement = null;
|
|
2939
3227
|
_this.dragAndDropState = new DragAndDropState();
|
|
2940
3228
|
return _this;
|
|
2941
3229
|
}
|
|
2942
|
-
DragMoveAutomation.create = function (el, win, cursor
|
|
3230
|
+
DragMoveAutomation.create = function (el, moveOptions, win, cursor) {
|
|
2943
3231
|
return __awaiter(this, void 0, void 0, function () {
|
|
2944
3232
|
var _a, element, offset;
|
|
2945
3233
|
return __generator(this, function (_b) {
|
|
@@ -2947,7 +3235,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2947
3235
|
case 0: return [4 /*yield*/, MoveAutomation.getTarget(el, win, new AxisValues(moveOptions.offsetX, moveOptions.offsetY))];
|
|
2948
3236
|
case 1:
|
|
2949
3237
|
_a = _b.sent(), element = _a.element, offset = _a.offset;
|
|
2950
|
-
return [2 /*return*/, new DragMoveAutomation(element, offset, win, cursor
|
|
3238
|
+
return [2 /*return*/, new DragMoveAutomation(element, offset, moveOptions, win, cursor)];
|
|
2951
3239
|
}
|
|
2952
3240
|
});
|
|
2953
3241
|
});
|
|
@@ -2961,7 +3249,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2961
3249
|
.then(function (_a) {
|
|
2962
3250
|
var eventOptions = _a.eventOptions, eventSequenceOptions = _a.eventSequenceOptions;
|
|
2963
3251
|
eventOptions.dataTransfer = _this.dragAndDropState.dataTransfer;
|
|
2964
|
-
eventOptions.buttons = eventUtils$
|
|
3252
|
+
eventOptions.buttons = eventUtils$3.BUTTONS_PARAMETER.leftButton;
|
|
2965
3253
|
eventSequenceOptions.holdLeftButton = true;
|
|
2966
3254
|
return { eventOptions: eventOptions, eventSequenceOptions: eventSequenceOptions };
|
|
2967
3255
|
});
|
|
@@ -2981,7 +3269,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2981
3269
|
};
|
|
2982
3270
|
DragMoveAutomation.prototype.run = function () {
|
|
2983
3271
|
var _this = this;
|
|
2984
|
-
return getElementFromPoint$
|
|
3272
|
+
return getElementFromPoint$2(this.cursor.getPosition())
|
|
2985
3273
|
.then(function (topElement) {
|
|
2986
3274
|
_this.dragElement = topElement;
|
|
2987
3275
|
var draggable = findDraggableElement(_this.dragElement);
|
|
@@ -2992,8 +3280,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2992
3280
|
_this.dragAndDropState.element = _this.dragElement;
|
|
2993
3281
|
_this.dragAndDropState.dataStore = new DragDataStore();
|
|
2994
3282
|
_this.dragAndDropState.dataTransfer = new DataTransfer(_this.dragAndDropState.dataStore);
|
|
2995
|
-
var isLink = domUtils$
|
|
2996
|
-
if (isLink || domUtils$
|
|
3283
|
+
var isLink = domUtils$7.isAnchorElement(_this.dragElement);
|
|
3284
|
+
if (isLink || domUtils$7.isImgElement(_this.dragElement)) {
|
|
2997
3285
|
var srcAttr = isLink ? 'href' : 'src';
|
|
2998
3286
|
var parsedUrl = urlUtils.parseProxyUrl(_this.dragElement[srcAttr]);
|
|
2999
3287
|
var src = parsedUrl ? parsedUrl.destUrl : _this.dragElement[srcAttr];
|
|
@@ -3012,14 +3300,14 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3012
3300
|
|
|
3013
3301
|
var MIN_MOVING_TIME = 25;
|
|
3014
3302
|
var Promise$8 = hammerhead__default.Promise;
|
|
3015
|
-
var extend$
|
|
3303
|
+
var extend$2 = hammerhead__default.utils.extend;
|
|
3016
3304
|
var featureDetection$5 = hammerhead__default.utils.featureDetection;
|
|
3017
3305
|
var eventSimulator$8 = hammerhead__default.eventSandbox.eventSimulator;
|
|
3018
3306
|
var focusBlurSandbox$2 = hammerhead__default.eventSandbox.focusBlur;
|
|
3019
3307
|
var DragAutomationBase = /** @class */ (function (_super) {
|
|
3020
3308
|
__extends(DragAutomationBase, _super);
|
|
3021
3309
|
function DragAutomationBase(element, mouseOptions) {
|
|
3022
|
-
var _this = _super.call(this, element, mouseOptions) || this;
|
|
3310
|
+
var _this = _super.call(this, element, mouseOptions, window, cursor) || this;
|
|
3023
3311
|
_this.modifiers = mouseOptions.modifiers;
|
|
3024
3312
|
_this.speed = mouseOptions.speed;
|
|
3025
3313
|
_this.offsetX = mouseOptions.offsetX;
|
|
@@ -3056,24 +3344,33 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3056
3344
|
throw new Error('Not implemented');
|
|
3057
3345
|
};
|
|
3058
3346
|
DragAutomationBase.prototype._drag = function () {
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3347
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3348
|
+
var _a, element, offsets, endPoint, dragOptions;
|
|
3349
|
+
var _this = this;
|
|
3350
|
+
return __generator(this, function (_b) {
|
|
3351
|
+
switch (_b.label) {
|
|
3352
|
+
case 0: return [4 /*yield*/, this._getDestination()];
|
|
3353
|
+
case 1:
|
|
3354
|
+
_a = _b.sent(), element = _a.element, offsets = _a.offsets, endPoint = _a.endPoint;
|
|
3355
|
+
this.endPoint = endPoint;
|
|
3356
|
+
dragOptions = new MoveOptions({
|
|
3357
|
+
offsetX: offsets.offsetX,
|
|
3358
|
+
offsetY: offsets.offsetY,
|
|
3359
|
+
modifiers: this.modifiers,
|
|
3360
|
+
speed: this.speed,
|
|
3361
|
+
minMovingTime: MIN_MOVING_TIME,
|
|
3362
|
+
skipDefaultDragBehavior: this.simulateDefaultBehavior === false,
|
|
3363
|
+
}, false);
|
|
3364
|
+
return [2 /*return*/, DragMoveAutomation.create(element, dragOptions, window, cursor)
|
|
3365
|
+
.then(function (moveAutomation) {
|
|
3366
|
+
return moveAutomation.run();
|
|
3367
|
+
})
|
|
3368
|
+
.then(function (dragAndDropState) {
|
|
3369
|
+
_this.dragAndDropState = dragAndDropState;
|
|
3370
|
+
return testCafeCore.delay(_this.automationSettings.mouseActionStepDelay);
|
|
3371
|
+
})];
|
|
3372
|
+
}
|
|
3373
|
+
});
|
|
3077
3374
|
});
|
|
3078
3375
|
};
|
|
3079
3376
|
DragAutomationBase.prototype._mouseup = function () {
|
|
@@ -3083,11 +3380,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3083
3380
|
.then(function () {
|
|
3084
3381
|
var point = testCafeCore.positionUtils.offsetToClientCoords(_this.endPoint);
|
|
3085
3382
|
var topElement = null;
|
|
3086
|
-
var options = extend$
|
|
3383
|
+
var options = extend$2({
|
|
3087
3384
|
clientX: point.x,
|
|
3088
3385
|
clientY: point.y,
|
|
3089
3386
|
}, _this.modifiers);
|
|
3090
|
-
return getElementFromPoint$
|
|
3387
|
+
return getElementFromPoint$2(point)
|
|
3091
3388
|
.then(function (element) {
|
|
3092
3389
|
topElement = element;
|
|
3093
3390
|
if (!topElement)
|
|
@@ -3101,7 +3398,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3101
3398
|
}
|
|
3102
3399
|
else
|
|
3103
3400
|
eventSimulator$8[_this.upEvent](topElement, options);
|
|
3104
|
-
return getElementFromPoint$
|
|
3401
|
+
return getElementFromPoint$2(point);
|
|
3105
3402
|
})
|
|
3106
3403
|
.then(function (element) {
|
|
3107
3404
|
//B231323
|
|
@@ -3120,7 +3417,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3120
3417
|
eventArgs = {
|
|
3121
3418
|
point: clientPoint,
|
|
3122
3419
|
element: element,
|
|
3123
|
-
options: extend$
|
|
3420
|
+
options: extend$2({
|
|
3124
3421
|
clientX: clientPoint.x,
|
|
3125
3422
|
clientY: clientPoint.y,
|
|
3126
3423
|
}, _this.modifiers),
|
|
@@ -3135,6 +3432,18 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3135
3432
|
return DragAutomationBase;
|
|
3136
3433
|
}(VisibleElementAutomation));
|
|
3137
3434
|
|
|
3435
|
+
var browserUtils$7 = hammerhead__default.utils.browser;
|
|
3436
|
+
function getAutomationPoint$1(element, offsetX, offsetY) {
|
|
3437
|
+
var roundFn = browserUtils$7.isFirefox ? Math.ceil : Math.round;
|
|
3438
|
+
var elementOffset = testCafeCore.positionUtils.getOffsetPosition(element, roundFn);
|
|
3439
|
+
var left = element === document.documentElement ? 0 : elementOffset.left;
|
|
3440
|
+
var top = element === document.documentElement ? 0 : elementOffset.top;
|
|
3441
|
+
return {
|
|
3442
|
+
x: left + offsetX,
|
|
3443
|
+
y: top + offsetY,
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3138
3447
|
var styleUtils$4 = testCafeCore__default.styleUtils;
|
|
3139
3448
|
var DragToOffsetAutomation = /** @class */ (function (_super) {
|
|
3140
3449
|
__extends(DragToOffsetAutomation, _super);
|
|
@@ -3145,7 +3454,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3145
3454
|
return _this;
|
|
3146
3455
|
}
|
|
3147
3456
|
DragToOffsetAutomation.prototype._getDestination = function () {
|
|
3148
|
-
var startPoint = getAutomationPoint(this.element, this.offsetX, this.offsetY);
|
|
3457
|
+
var startPoint = getAutomationPoint$1(this.element, this.offsetX, this.offsetY);
|
|
3149
3458
|
var maxX = styleUtils$4.getWidth(document);
|
|
3150
3459
|
var maxY = styleUtils$4.getHeight(document);
|
|
3151
3460
|
var endPoint = {
|
|
@@ -3166,7 +3475,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3166
3475
|
return DragToOffsetAutomation;
|
|
3167
3476
|
}(DragAutomationBase));
|
|
3168
3477
|
|
|
3169
|
-
var positionUtils$
|
|
3478
|
+
var positionUtils$4 = testCafeCore__default.positionUtils;
|
|
3170
3479
|
var DragToElementAutomation = /** @class */ (function (_super) {
|
|
3171
3480
|
__extends(DragToElementAutomation, _super);
|
|
3172
3481
|
function DragToElementAutomation(element, destinationElement, dragToElementOptions) {
|
|
@@ -3177,14 +3486,24 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3177
3486
|
return _this;
|
|
3178
3487
|
}
|
|
3179
3488
|
DragToElementAutomation.prototype._getDestination = function () {
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3489
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3490
|
+
var element, elementRect, offsets, endPoint;
|
|
3491
|
+
return __generator(this, function (_a) {
|
|
3492
|
+
switch (_a.label) {
|
|
3493
|
+
case 0:
|
|
3494
|
+
element = this.destinationElement;
|
|
3495
|
+
elementRect = positionUtils$4.getElementRectangle(element);
|
|
3496
|
+
return [4 /*yield*/, getOffsetOptions(element, this.destinationOffsetX, this.destinationOffsetY)];
|
|
3497
|
+
case 1:
|
|
3498
|
+
offsets = _a.sent();
|
|
3499
|
+
endPoint = {
|
|
3500
|
+
x: elementRect.left + offsets.offsetX,
|
|
3501
|
+
y: elementRect.top + offsets.offsetY,
|
|
3502
|
+
};
|
|
3503
|
+
return [2 /*return*/, { element: element, offsets: offsets, endPoint: endPoint }];
|
|
3504
|
+
}
|
|
3505
|
+
});
|
|
3506
|
+
});
|
|
3188
3507
|
};
|
|
3189
3508
|
return DragToElementAutomation;
|
|
3190
3509
|
}(DragAutomationBase));
|
|
@@ -3192,7 +3511,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3192
3511
|
var HoverAutomation = /** @class */ (function (_super) {
|
|
3193
3512
|
__extends(HoverAutomation, _super);
|
|
3194
3513
|
function HoverAutomation(element, hoverOptions) {
|
|
3195
|
-
return _super.call(this, element, hoverOptions) || this;
|
|
3514
|
+
return _super.call(this, element, hoverOptions, window, cursor) || this;
|
|
3196
3515
|
}
|
|
3197
3516
|
HoverAutomation.prototype.run = function (useStrictElementCheck) {
|
|
3198
3517
|
return this._ensureElement(useStrictElementCheck, true);
|
|
@@ -3205,7 +3524,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3205
3524
|
var eventSimulator$9 = hammerhead__default.eventSandbox.eventSimulator;
|
|
3206
3525
|
var listeners$2 = hammerhead__default.eventSandbox.listeners;
|
|
3207
3526
|
var nativeMethods$9 = hammerhead__default.nativeMethods;
|
|
3208
|
-
var domUtils$
|
|
3527
|
+
var domUtils$8 = testCafeCore__default.domUtils;
|
|
3209
3528
|
var contentEditable$1 = testCafeCore__default.contentEditable;
|
|
3210
3529
|
var textSelection$1 = testCafeCore__default.textSelection;
|
|
3211
3530
|
var WHITE_SPACES_RE = / /g;
|
|
@@ -3227,7 +3546,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3227
3546
|
var startParent = nativeMethods$9.nodeParentNodeGetter.call(startNode);
|
|
3228
3547
|
var hasStartParent = startParent && startNode.parentElement;
|
|
3229
3548
|
var browserRequiresSelectionUpdating = browserUtils$8.isChrome && browserUtils$8.version < 58 || browserUtils$8.isSafari;
|
|
3230
|
-
if (browserRequiresSelectionUpdating || !hasStartParent || !domUtils$
|
|
3549
|
+
if (browserRequiresSelectionUpdating || !hasStartParent || !domUtils$8.isElementContainsNode(element, startNode)) {
|
|
3231
3550
|
selection = _getSelectionInElement(element);
|
|
3232
3551
|
if (textSelection$1.hasInverseSelectionContentEditable(element)) {
|
|
3233
3552
|
selection = {
|
|
@@ -3244,7 +3563,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3244
3563
|
var textLength = text.length;
|
|
3245
3564
|
var selectPosition = { node: nodeForTyping, offset: textLength };
|
|
3246
3565
|
var parent = nativeMethods$9.nodeParentNodeGetter.call(elementNode);
|
|
3247
|
-
if (domUtils$
|
|
3566
|
+
if (domUtils$8.getTagName(elementNode) === 'br')
|
|
3248
3567
|
parent.insertBefore(nodeForTyping, elementNode);
|
|
3249
3568
|
else if (offset > 0) {
|
|
3250
3569
|
var childNodes = nativeMethods$9.nodeChildNodesGetter.call(elementNode);
|
|
@@ -3257,7 +3576,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3257
3576
|
function _typeTextInChildTextNode(element, selection, text) {
|
|
3258
3577
|
var startNode = selection.startPos.node;
|
|
3259
3578
|
// NOTE: startNode could be moved or deleted on textInput event. Need ensure startNode.
|
|
3260
|
-
if (!domUtils$
|
|
3579
|
+
if (!domUtils$8.isElementContainsNode(element, startNode)) {
|
|
3261
3580
|
selection = _excludeInvisibleSymbolsFromSelection(_getSelectionInElement(element));
|
|
3262
3581
|
startNode = selection.startPos.node;
|
|
3263
3582
|
}
|
|
@@ -3346,7 +3665,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3346
3665
|
listeners$2.addInternalEventBeforeListener(window, ['textinput'], onTextInput);
|
|
3347
3666
|
};
|
|
3348
3667
|
var afterContentChanged = function () {
|
|
3349
|
-
nextTick
|
|
3668
|
+
nextTick()
|
|
3350
3669
|
.then(function () {
|
|
3351
3670
|
if (needRaiseInputEvent)
|
|
3352
3671
|
eventSimulator$9.input(element, text);
|
|
@@ -3354,10 +3673,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3354
3673
|
listeners$2.removeInternalEventBeforeListener(window, ['textinput'], onTextInput);
|
|
3355
3674
|
});
|
|
3356
3675
|
};
|
|
3357
|
-
if (!startNode || !endNode || !domUtils$
|
|
3358
|
-
!domUtils$
|
|
3676
|
+
if (!startNode || !endNode || !domUtils$8.isContentEditableElement(startNode) ||
|
|
3677
|
+
!domUtils$8.isContentEditableElement(endNode))
|
|
3359
3678
|
return;
|
|
3360
|
-
if (!domUtils$
|
|
3679
|
+
if (!domUtils$8.isTheSameNode(startNode, endNode)) {
|
|
3361
3680
|
textSelection$1.deleteSelectionContents(element);
|
|
3362
3681
|
// NOTE: after deleting the selection contents we should refresh the stored startNode because
|
|
3363
3682
|
// contentEditable element's content could change and we can no longer find parent elements
|
|
@@ -3365,7 +3684,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3365
3684
|
currentSelection = _updateSelectionAfterDeletionContent(element, currentSelection);
|
|
3366
3685
|
startNode = currentSelection.startPos.node;
|
|
3367
3686
|
}
|
|
3368
|
-
if (!startNode || !domUtils$
|
|
3687
|
+
if (!startNode || !domUtils$8.isContentEditableElement(startNode) || !domUtils$8.isRenderedNode(startNode))
|
|
3369
3688
|
return;
|
|
3370
3689
|
if (!simulateBeforeInput(element, text, browserUtils$8.isChrome || browserUtils$8.isFirefox))
|
|
3371
3690
|
return;
|
|
@@ -3374,7 +3693,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3374
3693
|
needProcessInput = simulateBeforeInput(element, text, browserUtils$8.isSafari);
|
|
3375
3694
|
if (needProcessInput) {
|
|
3376
3695
|
// NOTE: we can type only to the text nodes; for nodes with the 'element-node' type, we use a special behavior
|
|
3377
|
-
if (domUtils$
|
|
3696
|
+
if (domUtils$8.isElementNode(startNode))
|
|
3378
3697
|
_typeTextInElementNode(startNode, text);
|
|
3379
3698
|
else
|
|
3380
3699
|
_typeTextInChildTextNode(element, _excludeInvisibleSymbolsFromSelection(currentSelection), text);
|
|
@@ -3382,11 +3701,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3382
3701
|
afterContentChanged();
|
|
3383
3702
|
}
|
|
3384
3703
|
function _typeTextToTextEditable(element, text) {
|
|
3385
|
-
var elementValue = domUtils$
|
|
3704
|
+
var elementValue = domUtils$8.getElementValue(element);
|
|
3386
3705
|
var textLength = text.length;
|
|
3387
3706
|
var startSelection = textSelection$1.getSelectionStart(element);
|
|
3388
3707
|
var endSelection = textSelection$1.getSelectionEnd(element);
|
|
3389
|
-
var isInputTypeNumber = domUtils$
|
|
3708
|
+
var isInputTypeNumber = domUtils$8.isInputElement(element) && element.type === 'number';
|
|
3390
3709
|
if (!simulateBeforeInput(element, text, browserUtils$8.isChrome || browserUtils$8.isFirefox))
|
|
3391
3710
|
return;
|
|
3392
3711
|
var needProcessInput = simulateTextInput(element, text);
|
|
@@ -3405,7 +3724,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3405
3724
|
startSelection += 1;
|
|
3406
3725
|
endSelection += 1;
|
|
3407
3726
|
}
|
|
3408
|
-
domUtils$
|
|
3727
|
+
domUtils$8.setElementValue(element, newElementValue);
|
|
3409
3728
|
textSelection$1.select(element, startSelection + textLength, startSelection + textLength);
|
|
3410
3729
|
}
|
|
3411
3730
|
// NOTE: We should simulate the 'input' event after typing a char (B253410, T138385)
|
|
@@ -3413,21 +3732,21 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3413
3732
|
}
|
|
3414
3733
|
function _typeTextToNonTextEditable(element, text, caretPos) {
|
|
3415
3734
|
if (caretPos !== null) {
|
|
3416
|
-
var elementValue = domUtils$
|
|
3417
|
-
domUtils$
|
|
3735
|
+
var elementValue = domUtils$8.getElementValue(element);
|
|
3736
|
+
domUtils$8.setElementValue(element, elementValue.substr(0, caretPos) + text + elementValue.substr(caretPos + text.length));
|
|
3418
3737
|
}
|
|
3419
3738
|
else
|
|
3420
|
-
domUtils$
|
|
3739
|
+
domUtils$8.setElementValue(element, text);
|
|
3421
3740
|
eventSimulator$9.change(element);
|
|
3422
3741
|
eventSimulator$9.input(element, text);
|
|
3423
3742
|
}
|
|
3424
3743
|
function typeText (element, text, caretPos) {
|
|
3425
|
-
if (domUtils$
|
|
3744
|
+
if (domUtils$8.isContentEditableElement(element))
|
|
3426
3745
|
_typeTextToContentEditable(element, text);
|
|
3427
|
-
if (!domUtils$
|
|
3428
|
-
if (domUtils$
|
|
3746
|
+
if (!domUtils$8.isElementReadOnly(element)) {
|
|
3747
|
+
if (domUtils$8.isTextEditableElement(element))
|
|
3429
3748
|
_typeTextToTextEditable(element, text);
|
|
3430
|
-
else if (domUtils$
|
|
3749
|
+
else if (domUtils$8.isInputElement(element))
|
|
3431
3750
|
_typeTextToNonTextEditable(element, text, caretPos);
|
|
3432
3751
|
}
|
|
3433
3752
|
}
|
|
@@ -3677,7 +3996,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3677
3996
|
}
|
|
3678
3997
|
|
|
3679
3998
|
var browserUtils$a = hammerhead__default.utils.browser;
|
|
3680
|
-
var extend$
|
|
3999
|
+
var extend$3 = hammerhead__default.utils.extend;
|
|
3681
4000
|
var eventSimulator$a = hammerhead__default.eventSandbox.eventSimulator;
|
|
3682
4001
|
var KeyPressSimulator = /** @class */ (function () {
|
|
3683
4002
|
function KeyPressSimulator(key, eventKeyProperty) {
|
|
@@ -3729,7 +4048,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3729
4048
|
}
|
|
3730
4049
|
};
|
|
3731
4050
|
KeyPressSimulator.prototype._addKeyPropertyToEventOptions = function (eventOptions) {
|
|
3732
|
-
extend$
|
|
4051
|
+
extend$3(eventOptions, getKeyProperties(eventOptions.type === 'keypress', this.keyProperty, this.keyIdentifierProperty));
|
|
3733
4052
|
return eventOptions;
|
|
3734
4053
|
};
|
|
3735
4054
|
KeyPressSimulator.prototype.down = function (modifiersState) {
|
|
@@ -3740,7 +4059,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3740
4059
|
this.keyProperty = changeLetterCase(this.keyProperty);
|
|
3741
4060
|
var eventOptions = { keyCode: this.keyCode, type: 'keydown' };
|
|
3742
4061
|
this._addKeyPropertyToEventOptions(eventOptions);
|
|
3743
|
-
return eventSimulator$a.keydown(this.storedActiveElement, extend$
|
|
4062
|
+
return eventSimulator$a.keydown(this.storedActiveElement, extend$3(eventOptions, modifiersState));
|
|
3744
4063
|
};
|
|
3745
4064
|
KeyPressSimulator.prototype.press = function (modifiersState) {
|
|
3746
4065
|
if (!(this.isChar || this.specialKeyCode))
|
|
@@ -3758,7 +4077,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3758
4077
|
this.storedActiveElement = activeElement;
|
|
3759
4078
|
var eventOptions = { keyCode: charCode, charCode: charCode, type: 'keypress' };
|
|
3760
4079
|
this._addKeyPropertyToEventOptions(eventOptions);
|
|
3761
|
-
var raiseDefault = browserUtils$a.isAndroid || eventSimulator$a.keypress(activeElement, extend$
|
|
4080
|
+
var raiseDefault = browserUtils$a.isAndroid || eventSimulator$a.keypress(activeElement, extend$3(eventOptions, modifiersState));
|
|
3762
4081
|
if (!raiseDefault)
|
|
3763
4082
|
return raiseDefault;
|
|
3764
4083
|
activeElement = getDeepActiveElement(this.topSameDomainDocument);
|
|
@@ -3779,7 +4098,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3779
4098
|
modifiersState[this.sanitizedKey] = false;
|
|
3780
4099
|
var eventOptions = { keyCode: this.keyCode, type: 'keyup' };
|
|
3781
4100
|
this._addKeyPropertyToEventOptions(eventOptions);
|
|
3782
|
-
var raiseDefault = eventSimulator$a.keyup(getDeepActiveElement(this.topSameDomainDocument), extend$
|
|
4101
|
+
var raiseDefault = eventSimulator$a.keyup(getDeepActiveElement(this.topSameDomainDocument), extend$3(eventOptions, modifiersState));
|
|
3783
4102
|
var activeElement = getDeepActiveElement(this.topSameDomainDocument);
|
|
3784
4103
|
// NOTE: in some browsers we should emulate click on active input element while pressing "space" key
|
|
3785
4104
|
var emulateClick = !browserUtils$a.isFirefox && !browserUtils$a.isSafari &&
|
|
@@ -3827,20 +4146,20 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3827
4146
|
var eventSimulator$b = hammerhead__default.eventSandbox.eventSimulator;
|
|
3828
4147
|
var elementEditingWatcher = hammerhead__default.eventSandbox.elementEditingWatcher;
|
|
3829
4148
|
var textSelection$2 = testCafeCore__default.textSelection;
|
|
3830
|
-
var eventUtils$
|
|
3831
|
-
var domUtils$
|
|
4149
|
+
var eventUtils$4 = testCafeCore__default.eventUtils;
|
|
4150
|
+
var domUtils$9 = testCafeCore__default.domUtils;
|
|
3832
4151
|
var selectElement = testCafeUI.selectElement;
|
|
3833
4152
|
var currentTextarea = null;
|
|
3834
4153
|
var currentTextareaCursorIndent = null;
|
|
3835
4154
|
function onTextAreaBlur() {
|
|
3836
4155
|
currentTextarea = null;
|
|
3837
4156
|
currentTextareaCursorIndent = null;
|
|
3838
|
-
eventUtils$
|
|
4157
|
+
eventUtils$4.unbind(this, 'blur', onTextAreaBlur, true);
|
|
3839
4158
|
}
|
|
3840
4159
|
function updateTextAreaIndent(element) {
|
|
3841
|
-
if (domUtils$
|
|
4160
|
+
if (domUtils$9.isTextAreaElement(element)) {
|
|
3842
4161
|
if (currentTextarea !== element) {
|
|
3843
|
-
eventUtils$
|
|
4162
|
+
eventUtils$4.bind(element, 'blur', onTextAreaBlur, true);
|
|
3844
4163
|
currentTextarea = element;
|
|
3845
4164
|
}
|
|
3846
4165
|
currentTextareaCursorIndent = getLineIndentInTextarea(element);
|
|
@@ -3848,16 +4167,16 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3848
4167
|
}
|
|
3849
4168
|
function getLineIndentInTextarea(textarea) {
|
|
3850
4169
|
var inverseSelection = textSelection$2.hasInverseSelection(textarea);
|
|
3851
|
-
var textareaValue = domUtils$
|
|
4170
|
+
var textareaValue = domUtils$9.getTextAreaValue(textarea);
|
|
3852
4171
|
var cursorPosition = inverseSelection ?
|
|
3853
4172
|
textSelection$2.getSelectionStart(textarea) :
|
|
3854
4173
|
textSelection$2.getSelectionEnd(textarea);
|
|
3855
4174
|
if (!textareaValue || !cursorPosition)
|
|
3856
4175
|
return 0;
|
|
3857
|
-
return domUtils$
|
|
4176
|
+
return domUtils$9.getTextareaIndentInLine(textarea, cursorPosition);
|
|
3858
4177
|
}
|
|
3859
4178
|
function moveTextAreaCursorUp(element, withSelection) {
|
|
3860
|
-
var textareaValue = domUtils$
|
|
4179
|
+
var textareaValue = domUtils$9.getTextAreaValue(element);
|
|
3861
4180
|
if (!textareaValue)
|
|
3862
4181
|
return;
|
|
3863
4182
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
@@ -3873,7 +4192,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3873
4192
|
moveTextAreaCursor(element, startPos, endPos, hasInverseSelection, newPosition, withSelection);
|
|
3874
4193
|
}
|
|
3875
4194
|
function moveTextAreaCursorDown(element, withSelection) {
|
|
3876
|
-
var textareaValue = domUtils$
|
|
4195
|
+
var textareaValue = domUtils$9.getTextAreaValue(element);
|
|
3877
4196
|
if (!textareaValue)
|
|
3878
4197
|
return;
|
|
3879
4198
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
@@ -3914,13 +4233,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3914
4233
|
textSelection$2.select(element, newStart, newEnd);
|
|
3915
4234
|
}
|
|
3916
4235
|
function setElementValue(element, value, position) {
|
|
3917
|
-
if (domUtils$
|
|
4236
|
+
if (domUtils$9.isInputElement(element) && element.type === 'number') {
|
|
3918
4237
|
if (value.charAt(0) === '-' && value.charAt(1) === '.')
|
|
3919
4238
|
value = value.substring(1);
|
|
3920
4239
|
if (value.charAt(value.length - 1) === '.')
|
|
3921
4240
|
value = value.substring(0, value.length - 1);
|
|
3922
4241
|
}
|
|
3923
|
-
domUtils$
|
|
4242
|
+
domUtils$9.setElementValue(element, value);
|
|
3924
4243
|
textSelection$2.select(element, position, position);
|
|
3925
4244
|
eventSimulator$b.input(element);
|
|
3926
4245
|
}
|
|
@@ -3936,11 +4255,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3936
4255
|
}
|
|
3937
4256
|
if (submitButton)
|
|
3938
4257
|
eventSimulator$b.click(submitButton);
|
|
3939
|
-
else if (domUtils$
|
|
4258
|
+
else if (domUtils$9.blocksImplicitSubmission(inputElement)) {
|
|
3940
4259
|
var formInputs = form.getElementsByTagName('input');
|
|
3941
4260
|
var textInputs = [];
|
|
3942
4261
|
for (i = 0; i < formInputs.length; i++) {
|
|
3943
|
-
if (domUtils$
|
|
4262
|
+
if (domUtils$9.blocksImplicitSubmission(formInputs[i]))
|
|
3944
4263
|
textInputs.push(formInputs[i]);
|
|
3945
4264
|
}
|
|
3946
4265
|
// NOTE: the form is submitted on enter press if there is only one input of the following types on it
|
|
@@ -3954,15 +4273,15 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3954
4273
|
}
|
|
3955
4274
|
//shortcuts
|
|
3956
4275
|
function selectAll(element) {
|
|
3957
|
-
if (domUtils$
|
|
4276
|
+
if (domUtils$9.isEditableElement(element))
|
|
3958
4277
|
textSelection$2.select(element);
|
|
3959
4278
|
return Promise$a.resolve();
|
|
3960
4279
|
}
|
|
3961
4280
|
function backspace(element) {
|
|
3962
|
-
if (domUtils$
|
|
4281
|
+
if (domUtils$9.isTextEditableElementAndEditingAllowed(element)) {
|
|
3963
4282
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
3964
4283
|
var endPos = textSelection$2.getSelectionEnd(element);
|
|
3965
|
-
var value = domUtils$
|
|
4284
|
+
var value = domUtils$9.getElementValue(element).replace(/\r\n/g, '\n');
|
|
3966
4285
|
if (endPos === startPos) {
|
|
3967
4286
|
if (startPos > 0) {
|
|
3968
4287
|
setElementValue(element, value.substring(0, startPos - 1) +
|
|
@@ -3972,15 +4291,15 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3972
4291
|
else
|
|
3973
4292
|
setElementValue(element, value.substring(0, startPos) + value.substring(endPos, value.length), startPos);
|
|
3974
4293
|
}
|
|
3975
|
-
if (domUtils$
|
|
4294
|
+
if (domUtils$9.isContentEditableElement(element))
|
|
3976
4295
|
textSelection$2.deleteSelectionContents(element);
|
|
3977
4296
|
return Promise$a.resolve();
|
|
3978
4297
|
}
|
|
3979
4298
|
function del(element) {
|
|
3980
|
-
if (domUtils$
|
|
4299
|
+
if (domUtils$9.isTextEditableElementAndEditingAllowed(element)) {
|
|
3981
4300
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
3982
4301
|
var endPos = textSelection$2.getSelectionEnd(element);
|
|
3983
|
-
var value = domUtils$
|
|
4302
|
+
var value = domUtils$9.getElementValue(element).replace(/\r\n/g, '\n');
|
|
3984
4303
|
if (endPos === startPos) {
|
|
3985
4304
|
if (startPos < value.length) {
|
|
3986
4305
|
setElementValue(element, value.substring(0, startPos) +
|
|
@@ -3992,25 +4311,25 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3992
4311
|
value.substring(endPos, value.length), startPos);
|
|
3993
4312
|
}
|
|
3994
4313
|
}
|
|
3995
|
-
if (domUtils$
|
|
4314
|
+
if (domUtils$9.isContentEditableElement(element))
|
|
3996
4315
|
textSelection$2.deleteSelectionContents(element);
|
|
3997
4316
|
return Promise$a.resolve();
|
|
3998
4317
|
}
|
|
3999
4318
|
function left(element) {
|
|
4000
4319
|
var startPosition = null;
|
|
4001
4320
|
var endPosition = null;
|
|
4002
|
-
if (domUtils$
|
|
4321
|
+
if (domUtils$9.isSelectElement(element))
|
|
4003
4322
|
selectElement.switchOptionsByKeys(element, 'left');
|
|
4004
4323
|
if (isRadioButtonNavigationRequired(element))
|
|
4005
4324
|
return focusAndCheckNextRadioButton(element, true);
|
|
4006
|
-
if (domUtils$
|
|
4325
|
+
if (domUtils$9.isTextEditableElement(element)) {
|
|
4007
4326
|
startPosition = textSelection$2.getSelectionStart(element) || 0;
|
|
4008
4327
|
endPosition = textSelection$2.getSelectionEnd(element);
|
|
4009
4328
|
var newPosition = startPosition === endPosition ? startPosition - 1 : startPosition;
|
|
4010
4329
|
textSelection$2.select(element, newPosition, newPosition);
|
|
4011
4330
|
updateTextAreaIndent(element);
|
|
4012
4331
|
}
|
|
4013
|
-
if (domUtils$
|
|
4332
|
+
if (domUtils$9.isContentEditableElement(element)) {
|
|
4014
4333
|
startPosition = textSelection$2.getSelectionStart(element);
|
|
4015
4334
|
endPosition = textSelection$2.getSelectionEnd(element);
|
|
4016
4335
|
// NOTE: we only remove selection
|
|
@@ -4028,20 +4347,20 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4028
4347
|
function right(element) {
|
|
4029
4348
|
var startPosition = null;
|
|
4030
4349
|
var endPosition = null;
|
|
4031
|
-
if (domUtils$
|
|
4350
|
+
if (domUtils$9.isSelectElement(element))
|
|
4032
4351
|
selectElement.switchOptionsByKeys(element, 'right');
|
|
4033
4352
|
if (isRadioButtonNavigationRequired(element))
|
|
4034
4353
|
return focusAndCheckNextRadioButton(element, false);
|
|
4035
|
-
if (domUtils$
|
|
4354
|
+
if (domUtils$9.isTextEditableElement(element)) {
|
|
4036
4355
|
startPosition = textSelection$2.getSelectionStart(element);
|
|
4037
4356
|
endPosition = textSelection$2.getSelectionEnd(element);
|
|
4038
4357
|
var newPosition = startPosition === endPosition ? endPosition + 1 : endPosition;
|
|
4039
|
-
if (startPosition === domUtils$
|
|
4358
|
+
if (startPosition === domUtils$9.getElementValue(element).length)
|
|
4040
4359
|
newPosition = startPosition;
|
|
4041
4360
|
textSelection$2.select(element, newPosition, newPosition);
|
|
4042
4361
|
updateTextAreaIndent(element);
|
|
4043
4362
|
}
|
|
4044
|
-
if (domUtils$
|
|
4363
|
+
if (domUtils$9.isContentEditableElement(element)) {
|
|
4045
4364
|
startPosition = textSelection$2.getSelectionStart(element);
|
|
4046
4365
|
endPosition = textSelection$2.getSelectionEnd(element);
|
|
4047
4366
|
//NOTE: we only remove selection
|
|
@@ -4057,41 +4376,41 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4057
4376
|
return Promise$a.resolve();
|
|
4058
4377
|
}
|
|
4059
4378
|
function up(element) {
|
|
4060
|
-
if (domUtils$
|
|
4379
|
+
if (domUtils$9.isSelectElement(element))
|
|
4061
4380
|
selectElement.switchOptionsByKeys(element, 'up');
|
|
4062
4381
|
if (isRadioButtonNavigationRequired(element))
|
|
4063
4382
|
return focusAndCheckNextRadioButton(element, true);
|
|
4064
|
-
if (browserUtils$b.isWebKit && domUtils$
|
|
4383
|
+
if (browserUtils$b.isWebKit && domUtils$9.isInputElement(element))
|
|
4065
4384
|
return home(element);
|
|
4066
|
-
if (domUtils$
|
|
4385
|
+
if (domUtils$9.isTextAreaElement(element))
|
|
4067
4386
|
moveTextAreaCursorUp(element, false);
|
|
4068
4387
|
return Promise$a.resolve();
|
|
4069
4388
|
}
|
|
4070
4389
|
function down(element) {
|
|
4071
|
-
if (domUtils$
|
|
4390
|
+
if (domUtils$9.isSelectElement(element))
|
|
4072
4391
|
selectElement.switchOptionsByKeys(element, 'down');
|
|
4073
4392
|
if (isRadioButtonNavigationRequired(element))
|
|
4074
4393
|
return focusAndCheckNextRadioButton(element, false);
|
|
4075
|
-
if (browserUtils$b.isWebKit && domUtils$
|
|
4394
|
+
if (browserUtils$b.isWebKit && domUtils$9.isInputElement(element))
|
|
4076
4395
|
return end(element);
|
|
4077
|
-
if (domUtils$
|
|
4396
|
+
if (domUtils$9.isTextAreaElement(element))
|
|
4078
4397
|
moveTextAreaCursorDown(element, false);
|
|
4079
4398
|
return Promise$a.resolve();
|
|
4080
4399
|
}
|
|
4081
4400
|
function home(element, withSelection) {
|
|
4082
|
-
if (domUtils$
|
|
4401
|
+
if (domUtils$9.isTextEditableElement(element)) {
|
|
4083
4402
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
4084
4403
|
var endPos = textSelection$2.getSelectionEnd(element);
|
|
4085
4404
|
var inverseSelection = textSelection$2.hasInverseSelection(element);
|
|
4086
4405
|
var referencePosition = null;
|
|
4087
|
-
var isSingleLineSelection = !domUtils$
|
|
4088
|
-
domUtils$
|
|
4089
|
-
domUtils$
|
|
4406
|
+
var isSingleLineSelection = !domUtils$9.isTextAreaElement(element) ? true :
|
|
4407
|
+
domUtils$9.getTextareaLineNumberByPosition(element, startPos) ===
|
|
4408
|
+
domUtils$9.getTextareaLineNumberByPosition(element, endPos);
|
|
4090
4409
|
if (isSingleLineSelection)
|
|
4091
4410
|
referencePosition = inverseSelection ? endPos : startPos;
|
|
4092
4411
|
else
|
|
4093
4412
|
referencePosition = inverseSelection ? startPos : endPos;
|
|
4094
|
-
var valueBeforeCursor = domUtils$
|
|
4413
|
+
var valueBeforeCursor = domUtils$9.getElementValue(element).substring(0, referencePosition);
|
|
4095
4414
|
var lastLineBreakIndex = valueBeforeCursor.lastIndexOf('\n');
|
|
4096
4415
|
var newPosition = lastLineBreakIndex === -1 ? 0 : lastLineBreakIndex + 1;
|
|
4097
4416
|
var newStartPos = null;
|
|
@@ -4109,19 +4428,19 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4109
4428
|
return Promise$a.resolve();
|
|
4110
4429
|
}
|
|
4111
4430
|
function end(element, withSelection) {
|
|
4112
|
-
if (domUtils$
|
|
4431
|
+
if (domUtils$9.isTextEditableElement(element)) {
|
|
4113
4432
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
4114
4433
|
var endPos = textSelection$2.getSelectionEnd(element);
|
|
4115
4434
|
var inverseSelection = textSelection$2.hasInverseSelection(element);
|
|
4116
4435
|
var referencePosition = null;
|
|
4117
|
-
var isSingleLineSelection = !domUtils$
|
|
4118
|
-
domUtils$
|
|
4119
|
-
domUtils$
|
|
4436
|
+
var isSingleLineSelection = !domUtils$9.isTextAreaElement(element) ? true :
|
|
4437
|
+
domUtils$9.getTextareaLineNumberByPosition(element, startPos) ===
|
|
4438
|
+
domUtils$9.getTextareaLineNumberByPosition(element, endPos);
|
|
4120
4439
|
if (isSingleLineSelection)
|
|
4121
4440
|
referencePosition = inverseSelection ? endPos : startPos;
|
|
4122
4441
|
else
|
|
4123
4442
|
referencePosition = inverseSelection ? startPos : endPos;
|
|
4124
|
-
var valueAsterCursor = domUtils$
|
|
4443
|
+
var valueAsterCursor = domUtils$9.getElementValue(element).substring(referencePosition);
|
|
4125
4444
|
var firstLineBreakIndex = valueAsterCursor.indexOf('\n');
|
|
4126
4445
|
var newPosition = referencePosition;
|
|
4127
4446
|
var newStartPos = null;
|
|
@@ -4140,26 +4459,26 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4140
4459
|
return Promise$a.resolve();
|
|
4141
4460
|
}
|
|
4142
4461
|
function esc(element) {
|
|
4143
|
-
if (domUtils$
|
|
4462
|
+
if (domUtils$9.isSelectElement(element))
|
|
4144
4463
|
selectElement.collapseOptionList();
|
|
4145
4464
|
return Promise$a.resolve();
|
|
4146
4465
|
}
|
|
4147
4466
|
function shiftUp(element) {
|
|
4148
|
-
if (browserUtils$b.isWebKit && domUtils$
|
|
4467
|
+
if (browserUtils$b.isWebKit && domUtils$9.isInputElement(element))
|
|
4149
4468
|
return shiftHome(element);
|
|
4150
|
-
if (domUtils$
|
|
4469
|
+
if (domUtils$9.isTextAreaElement(element))
|
|
4151
4470
|
moveTextAreaCursorUp(element, true);
|
|
4152
4471
|
return Promise$a.resolve();
|
|
4153
4472
|
}
|
|
4154
4473
|
function shiftDown(element) {
|
|
4155
|
-
if (browserUtils$b.isWebKit && domUtils$
|
|
4474
|
+
if (browserUtils$b.isWebKit && domUtils$9.isInputElement(element))
|
|
4156
4475
|
return shiftEnd(element);
|
|
4157
|
-
if (domUtils$
|
|
4476
|
+
if (domUtils$9.isTextAreaElement(element))
|
|
4158
4477
|
moveTextAreaCursorDown(element, true);
|
|
4159
4478
|
return Promise$a.resolve();
|
|
4160
4479
|
}
|
|
4161
4480
|
function shiftLeft(element) {
|
|
4162
|
-
if (domUtils$
|
|
4481
|
+
if (domUtils$9.isTextEditableElement(element)) {
|
|
4163
4482
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
4164
4483
|
var endPos = textSelection$2.getSelectionEnd(element);
|
|
4165
4484
|
if (startPos === endPos || textSelection$2.hasInverseSelection(element))
|
|
@@ -4171,10 +4490,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4171
4490
|
return Promise$a.resolve();
|
|
4172
4491
|
}
|
|
4173
4492
|
function shiftRight(element) {
|
|
4174
|
-
if (domUtils$
|
|
4493
|
+
if (domUtils$9.isTextEditableElement(element)) {
|
|
4175
4494
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
4176
4495
|
var endPos = textSelection$2.getSelectionEnd(element);
|
|
4177
|
-
var valueLength = domUtils$
|
|
4496
|
+
var valueLength = domUtils$9.getElementValue(element).length;
|
|
4178
4497
|
if (startPos === endPos || !textSelection$2.hasInverseSelection(element))
|
|
4179
4498
|
textSelection$2.select(element, startPos, Math.min(endPos + 1, valueLength));
|
|
4180
4499
|
else
|
|
@@ -4190,33 +4509,33 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4190
4509
|
return end(element, true);
|
|
4191
4510
|
}
|
|
4192
4511
|
function enter(element) {
|
|
4193
|
-
if (domUtils$
|
|
4512
|
+
if (domUtils$9.isSelectElement(element))
|
|
4194
4513
|
selectElement.collapseOptionList();
|
|
4195
4514
|
//submit form on enter pressed
|
|
4196
|
-
if (domUtils$
|
|
4515
|
+
if (domUtils$9.isInputElement(element)) {
|
|
4197
4516
|
if (!browserUtils$b.isIE)
|
|
4198
4517
|
elementEditingWatcher.processElementChanging(element);
|
|
4199
|
-
var form = domUtils$
|
|
4518
|
+
var form = domUtils$9.getParents(element, 'form')[0];
|
|
4200
4519
|
// NOTE: if a user presses enter when a form input is focused and the form has
|
|
4201
4520
|
// a submit button, the browser sends the click event to the submit button
|
|
4202
4521
|
if (form)
|
|
4203
4522
|
submitFormOnEnterPressInInput(form, element);
|
|
4204
4523
|
}
|
|
4205
|
-
else if (domUtils$
|
|
4524
|
+
else if (domUtils$9.isTextAreaElement(element)) {
|
|
4206
4525
|
var startPos = textSelection$2.getSelectionStart(element);
|
|
4207
|
-
var value = domUtils$
|
|
4526
|
+
var value = domUtils$9.getTextAreaValue(element);
|
|
4208
4527
|
var valueBeforeCursor = value.substring(0, startPos);
|
|
4209
4528
|
var valueAfterCursor = value.substring(startPos);
|
|
4210
4529
|
var newPosition = startPos + 1;
|
|
4211
4530
|
setElementValue(element, valueBeforeCursor + String.fromCharCode(10) + valueAfterCursor, newPosition);
|
|
4212
4531
|
}
|
|
4213
4532
|
//S173120
|
|
4214
|
-
else if (element.tagName && domUtils$
|
|
4533
|
+
else if (element.tagName && domUtils$9.isAnchorElement(element))
|
|
4215
4534
|
eventSimulator$b.click(element);
|
|
4216
4535
|
return Promise$a.resolve();
|
|
4217
4536
|
}
|
|
4218
4537
|
function isRadioButtonNavigationRequired(element) {
|
|
4219
|
-
return domUtils$
|
|
4538
|
+
return domUtils$9.isRadioButtonElement(element) && !browserUtils$b.isFirefox;
|
|
4220
4539
|
}
|
|
4221
4540
|
function focusAndCheckNextRadioButton(element, reverse) {
|
|
4222
4541
|
return focusNextElementOnNavigationButton(element, reverse, false)
|
|
@@ -4229,11 +4548,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4229
4548
|
if (skipRadioGroups === void 0) { skipRadioGroups = true; }
|
|
4230
4549
|
if (!element)
|
|
4231
4550
|
return Promise$a.resolve();
|
|
4232
|
-
if (domUtils$
|
|
4551
|
+
if (domUtils$9.isSelectElement(element))
|
|
4233
4552
|
selectElement.collapseOptionList();
|
|
4234
4553
|
return focusNextElement(element, reverse, skipRadioGroups)
|
|
4235
4554
|
.then(function (nextElement) {
|
|
4236
|
-
if (nextElement && domUtils$
|
|
4555
|
+
if (nextElement && domUtils$9.isTextEditableInput(nextElement))
|
|
4237
4556
|
textSelection$2.select(nextElement);
|
|
4238
4557
|
return nextElement;
|
|
4239
4558
|
});
|
|
@@ -4397,14 +4716,14 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4397
4716
|
}());
|
|
4398
4717
|
|
|
4399
4718
|
var Promise$c = hammerhead__default.Promise;
|
|
4400
|
-
var extend$
|
|
4719
|
+
var extend$4 = hammerhead__default.utils.extend;
|
|
4401
4720
|
var browserUtils$d = hammerhead__default.utils.browser;
|
|
4402
4721
|
var eventSimulator$c = hammerhead__default.eventSandbox.eventSimulator;
|
|
4403
|
-
var domUtils$
|
|
4722
|
+
var domUtils$a = testCafeCore__default.domUtils, eventUtils$5 = testCafeCore__default.eventUtils, delay$3 = testCafeCore__default.delay;
|
|
4404
4723
|
var RClickAutomation = /** @class */ (function (_super) {
|
|
4405
4724
|
__extends(RClickAutomation, _super);
|
|
4406
4725
|
function RClickAutomation(element, clickOptions) {
|
|
4407
|
-
var _this = _super.call(this, element, clickOptions) || this;
|
|
4726
|
+
var _this = _super.call(this, element, clickOptions, window, cursor) || this;
|
|
4408
4727
|
_this.modifiers = clickOptions.modifiers;
|
|
4409
4728
|
_this.caretPos = clickOptions.caretPos;
|
|
4410
4729
|
_this.eventState = {
|
|
@@ -4418,22 +4737,22 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4418
4737
|
return cursor
|
|
4419
4738
|
.rightButtonDown()
|
|
4420
4739
|
.then(function () {
|
|
4421
|
-
_this.eventState.activeElementBeforeMouseDown = domUtils$
|
|
4740
|
+
_this.eventState.activeElementBeforeMouseDown = domUtils$a.getActiveElement();
|
|
4422
4741
|
_this.eventState.simulateDefaultBehavior = eventSimulator$c.mousedown(eventArgs.element, eventArgs.options);
|
|
4423
4742
|
return _this._focus(eventArgs);
|
|
4424
4743
|
});
|
|
4425
4744
|
};
|
|
4426
4745
|
RClickAutomation.prototype._focus = function (eventArgs) {
|
|
4427
4746
|
if (this.simulateDefaultBehavior === false)
|
|
4428
|
-
return nextTick
|
|
4747
|
+
return nextTick();
|
|
4429
4748
|
// NOTE: If a target element is a contentEditable element, we need to call focusAndSetSelection directly for
|
|
4430
4749
|
// this element. Otherwise, if the element obtained by elementFromPoint is a child of the contentEditable
|
|
4431
4750
|
// element, a selection position may be calculated incorrectly (by using the caretPos option).
|
|
4432
|
-
var elementForFocus = domUtils$
|
|
4751
|
+
var elementForFocus = domUtils$a.isContentEditableElement(this.element) ? this.element : eventArgs.element;
|
|
4433
4752
|
// NOTE: IE doesn't perform focus if active element has been changed while executing mousedown
|
|
4434
|
-
var simulateFocus = !browserUtils$d.isIE || this.eventState.activeElementBeforeMouseDown === domUtils$
|
|
4753
|
+
var simulateFocus = !browserUtils$d.isIE || this.eventState.activeElementBeforeMouseDown === domUtils$a.getActiveElement();
|
|
4435
4754
|
return focusAndSetSelection(elementForFocus, simulateFocus, this.caretPos)
|
|
4436
|
-
.then(function () { return nextTick
|
|
4755
|
+
.then(function () { return nextTick(); });
|
|
4437
4756
|
};
|
|
4438
4757
|
RClickAutomation.prototype._mouseup = function (eventArgs) {
|
|
4439
4758
|
var _this = this;
|
|
@@ -4447,7 +4766,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4447
4766
|
._getElementForEvent(eventArgs)
|
|
4448
4767
|
.then(function (element) {
|
|
4449
4768
|
eventSimulator$c.contextmenu(element, eventArgs.options);
|
|
4450
|
-
if (!domUtils$
|
|
4769
|
+
if (!domUtils$a.isElementFocusable(element))
|
|
4451
4770
|
focusByRelatedElement(element);
|
|
4452
4771
|
});
|
|
4453
4772
|
};
|
|
@@ -4461,17 +4780,17 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4461
4780
|
eventArgs = {
|
|
4462
4781
|
point: clientPoint,
|
|
4463
4782
|
element: element,
|
|
4464
|
-
options: extend$
|
|
4783
|
+
options: extend$4({
|
|
4465
4784
|
clientX: clientPoint.x,
|
|
4466
4785
|
clientY: clientPoint.y,
|
|
4467
4786
|
screenX: devicePoint.x,
|
|
4468
4787
|
screenY: devicePoint.y,
|
|
4469
|
-
button: eventUtils$
|
|
4788
|
+
button: eventUtils$5.BUTTON.right,
|
|
4470
4789
|
}, _this.modifiers),
|
|
4471
4790
|
};
|
|
4472
4791
|
// NOTE: we should raise mouseup event with 'mouseActionStepDelay' after we trigger
|
|
4473
4792
|
// mousedown event regardless of how long mousedown event handlers were executing
|
|
4474
|
-
return Promise$c.all([delay$
|
|
4793
|
+
return Promise$c.all([delay$3(_this.automationSettings.mouseActionStepDelay), _this._mousedown(eventArgs)]);
|
|
4475
4794
|
})
|
|
4476
4795
|
.then(function () { return _this._mouseup(eventArgs); })
|
|
4477
4796
|
.then(function () { return _this._contextmenu(eventArgs); });
|
|
@@ -4480,23 +4799,23 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4480
4799
|
}(VisibleElementAutomation));
|
|
4481
4800
|
|
|
4482
4801
|
var browserUtils$e = hammerhead__default.utils.browser;
|
|
4483
|
-
var domUtils$
|
|
4484
|
-
var positionUtils$
|
|
4802
|
+
var domUtils$b = testCafeCore__default.domUtils;
|
|
4803
|
+
var positionUtils$5 = testCafeCore__default.positionUtils;
|
|
4485
4804
|
var styleUtils$5 = testCafeCore__default.styleUtils;
|
|
4486
4805
|
var contentEditable$2 = testCafeCore__default.contentEditable;
|
|
4487
4806
|
var arrayUtils$1 = testCafeCore__default.arrayUtils;
|
|
4488
4807
|
var MODIFIERS_LIST = ['direction', 'font-family', 'font-size', 'font-size-adjust', 'font-variant', 'font-weight', 'font-style', 'letter-spacing', 'line-height', 'text-align', 'text-indent', 'text-transform', 'word-wrap', 'word-spacing', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'border-top-width', 'border-left-width', 'border-right-width', 'border-bottom-width'];
|
|
4489
4808
|
function ensureRectangleInsideElement(element, rect) {
|
|
4490
4809
|
var elementBorders = styleUtils$5.getBordersWidth(element);
|
|
4491
|
-
var elementOffset = positionUtils$
|
|
4810
|
+
var elementOffset = positionUtils$5.getOffsetPosition(element);
|
|
4492
4811
|
// NOTE: strange behavior in Chrome - for some elements (e.g., for the 'font' element)
|
|
4493
4812
|
// scrollHeight is 0, so we use getBoundingClientRect
|
|
4494
4813
|
var elementHeight = element.scrollHeight || element.getBoundingClientRect().height;
|
|
4495
4814
|
var left = Math.ceil(rect.left);
|
|
4496
4815
|
var top = Math.ceil(rect.top);
|
|
4497
4816
|
var bottom = Math.floor(rect.bottom);
|
|
4498
|
-
if (!domUtils$
|
|
4499
|
-
var clientOffset = positionUtils$
|
|
4817
|
+
if (!domUtils$b.isTextAreaElement(element)) {
|
|
4818
|
+
var clientOffset = positionUtils$5.offsetToClientCoords({
|
|
4500
4819
|
x: elementOffset.left,
|
|
4501
4820
|
y: elementOffset.top,
|
|
4502
4821
|
});
|
|
@@ -4523,7 +4842,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4523
4842
|
};
|
|
4524
4843
|
}
|
|
4525
4844
|
function getSelectionRectangleInContentEditableElement(element, position) {
|
|
4526
|
-
var range = domUtils$
|
|
4845
|
+
var range = domUtils$b.findDocument(element).createRange();
|
|
4527
4846
|
var selectionPosition = contentEditable$2.calculateNodeAndOffsetByPosition(element, position);
|
|
4528
4847
|
range.setStart(selectionPosition.node, Math.min(selectionPosition.offset, selectionPosition.node.length));
|
|
4529
4848
|
range.setEnd(selectionPosition.node, Math.min(selectionPosition.offset, selectionPosition.node.length));
|
|
@@ -4544,13 +4863,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4544
4863
|
var clientRectAfterFakeDiv = element.getBoundingClientRect();
|
|
4545
4864
|
var topBoundDiff = clientRectAfterFakeDiv.top - clientRectBeforeFakeDiv.top;
|
|
4546
4865
|
var leftBoundDiff = clientRectAfterFakeDiv.left - clientRectBeforeFakeDiv.left;
|
|
4547
|
-
var valueLength = domUtils$
|
|
4866
|
+
var valueLength = domUtils$b.getElementValue(element).length;
|
|
4548
4867
|
try {
|
|
4549
4868
|
var range = document.createRange(); //B254723
|
|
4550
4869
|
range.setStart(hammerhead__default.nativeMethods.nodeFirstChildGetter.call(fakeDiv), Math.min(position, valueLength));
|
|
4551
4870
|
// NOTE: The range.getClientRects function returns wrong result if range length is 0 in Safari 11
|
|
4552
4871
|
range.setEnd(hammerhead__default.nativeMethods.nodeFirstChildGetter.call(fakeDiv), Math.min(position + 1, valueLength + 1));
|
|
4553
|
-
if (domUtils$
|
|
4872
|
+
if (domUtils$b.isTextAreaElement(element)) {
|
|
4554
4873
|
rect = range.getBoundingClientRect();
|
|
4555
4874
|
if (rect.width === 0 && rect.height === 0)
|
|
4556
4875
|
rect = range.getClientRects()[0];
|
|
@@ -4561,7 +4880,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4561
4880
|
catch (err) {
|
|
4562
4881
|
rect = null;
|
|
4563
4882
|
}
|
|
4564
|
-
domUtils$
|
|
4883
|
+
domUtils$b.remove(fakeDiv);
|
|
4565
4884
|
if (!rect)
|
|
4566
4885
|
return null;
|
|
4567
4886
|
return {
|
|
@@ -4575,7 +4894,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4575
4894
|
}
|
|
4576
4895
|
function createFakeDiv(element) {
|
|
4577
4896
|
var body = document.body;
|
|
4578
|
-
var elementOffset = positionUtils$
|
|
4897
|
+
var elementOffset = positionUtils$5.getOffsetPosition(element);
|
|
4579
4898
|
var elementMargin = styleUtils$5.getElementMargin(element);
|
|
4580
4899
|
var elementTop = elementOffset.top - elementMargin.top;
|
|
4581
4900
|
var elementLeft = elementOffset.left - elementMargin.left;
|
|
@@ -4599,13 +4918,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4599
4918
|
width: element.scrollWidth + 'px',
|
|
4600
4919
|
height: element.scrollHeight + 'px',
|
|
4601
4920
|
});
|
|
4602
|
-
hammerhead__default.nativeMethods.nodeTextContentSetter.call(fakeDiv, domUtils$
|
|
4921
|
+
hammerhead__default.nativeMethods.nodeTextContentSetter.call(fakeDiv, domUtils$b.getElementValue(element) + ' ');
|
|
4603
4922
|
body.appendChild(fakeDiv);
|
|
4604
4923
|
return fakeDiv;
|
|
4605
4924
|
}
|
|
4606
4925
|
function getPositionCoordinates(element, position) {
|
|
4607
4926
|
var rect = null;
|
|
4608
|
-
if (domUtils$
|
|
4927
|
+
if (domUtils$b.isContentEditableElement(element))
|
|
4609
4928
|
rect = getSelectionRectangleInContentEditableElement(element, position);
|
|
4610
4929
|
else if (typeof element.createTextRange === 'function')
|
|
4611
4930
|
rect = getTextSelectionRectangle(element, position);
|
|
@@ -4621,16 +4940,16 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4621
4940
|
};
|
|
4622
4941
|
}
|
|
4623
4942
|
function getSelectionCoordinatesByPosition(element, position) {
|
|
4624
|
-
var isTextEditable = domUtils$
|
|
4625
|
-
var isContentEditable = domUtils$
|
|
4626
|
-
var hasText = isTextEditable && domUtils$
|
|
4943
|
+
var isTextEditable = domUtils$b.isTextEditableElement(element);
|
|
4944
|
+
var isContentEditable = domUtils$b.isContentEditableElement(element);
|
|
4945
|
+
var hasText = isTextEditable && domUtils$b.getElementValue(element).length > 0 ||
|
|
4627
4946
|
isContentEditable && contentEditable$2.getContentEditableValue(element).length;
|
|
4628
4947
|
if (!hasText)
|
|
4629
|
-
return positionUtils$
|
|
4948
|
+
return positionUtils$5.findCenter(element);
|
|
4630
4949
|
return getPositionCoordinates(element, position);
|
|
4631
4950
|
}
|
|
4632
4951
|
function getSelectionCoordinatesByNodeAndOffset(element, node, offset) {
|
|
4633
|
-
var range = domUtils$
|
|
4952
|
+
var range = domUtils$b.findDocument(element).createRange();
|
|
4634
4953
|
range.setStart(node, Math.min(offset, node.length));
|
|
4635
4954
|
range.setEnd(node, Math.min(offset, node.length));
|
|
4636
4955
|
var rect = range.getClientRects()[0];
|
|
@@ -4656,20 +4975,20 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4656
4975
|
}
|
|
4657
4976
|
if (!currentPoint) {
|
|
4658
4977
|
currentPoint = getPositionCoordinates(element, startPos) ||
|
|
4659
|
-
positionUtils$
|
|
4978
|
+
positionUtils$5.findCenter(element);
|
|
4660
4979
|
}
|
|
4661
4980
|
return currentPoint;
|
|
4662
4981
|
}
|
|
4663
4982
|
function scrollEditableElementByPoint(element, point) {
|
|
4664
|
-
if (!domUtils$
|
|
4983
|
+
if (!domUtils$b.isEditableElement(element))
|
|
4665
4984
|
return;
|
|
4666
|
-
var isTextarea = domUtils$
|
|
4667
|
-
var isInputElement = domUtils$
|
|
4985
|
+
var isTextarea = domUtils$b.isTextAreaElement(element);
|
|
4986
|
+
var isInputElement = domUtils$b.isInputElement(element);
|
|
4668
4987
|
// NOTE: we don't need to scroll input elements in Mozilla and
|
|
4669
4988
|
// IE > 10 because it happens automatically on selection setting
|
|
4670
4989
|
if (isInputElement && (browserUtils$e.isFirefox || browserUtils$e.isIE && browserUtils$e.version > 10))
|
|
4671
4990
|
return;
|
|
4672
|
-
var elementOffset = positionUtils$
|
|
4991
|
+
var elementOffset = positionUtils$5.getOffsetPosition(element);
|
|
4673
4992
|
var elementBorders = styleUtils$5.getBordersWidth(element);
|
|
4674
4993
|
var elementScroll = styleUtils$5.getElementScroll(element);
|
|
4675
4994
|
var offsetX = point.x - elementOffset.left - elementBorders.left;
|
|
@@ -4692,11 +5011,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4692
5011
|
styleUtils$5.setScrollLeft(element, Math.round(scrollValue));
|
|
4693
5012
|
}
|
|
4694
5013
|
function excludeElementScroll(element, point) {
|
|
4695
|
-
var isTextEditable = domUtils$
|
|
4696
|
-
var isInputElement = domUtils$
|
|
4697
|
-
if (!(isTextEditable || domUtils$
|
|
5014
|
+
var isTextEditable = domUtils$b.isTextEditableElement(element);
|
|
5015
|
+
var isInputElement = domUtils$b.isInputElement(element);
|
|
5016
|
+
if (!(isTextEditable || domUtils$b.isContentEditableElement(element)))
|
|
4698
5017
|
return point;
|
|
4699
|
-
var elementOffset = positionUtils$
|
|
5018
|
+
var elementOffset = positionUtils$5.getOffsetPosition(element);
|
|
4700
5019
|
var elementBorders = styleUtils$5.getBordersWidth(element);
|
|
4701
5020
|
var elementScroll = styleUtils$5.getElementScroll(element);
|
|
4702
5021
|
var maxLeft = elementOffset.left + elementBorders.left + element.clientWidth;
|
|
@@ -4721,14 +5040,14 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4721
5040
|
var eventSimulator$d = hammerhead__default.eventSandbox.eventSimulator;
|
|
4722
5041
|
var focusBlurSandbox$4 = hammerhead__default.eventSandbox.focusBlur;
|
|
4723
5042
|
var contentEditable$3 = testCafeCore__default.contentEditable;
|
|
4724
|
-
var domUtils$
|
|
4725
|
-
var positionUtils$
|
|
4726
|
-
var eventUtils$
|
|
4727
|
-
var delay$
|
|
5043
|
+
var domUtils$c = testCafeCore__default.domUtils;
|
|
5044
|
+
var positionUtils$6 = testCafeCore__default.positionUtils;
|
|
5045
|
+
var eventUtils$6 = testCafeCore__default.eventUtils;
|
|
5046
|
+
var delay$4 = testCafeCore__default.delay;
|
|
4728
5047
|
var SelectBaseAutomation = /** @class */ (function (_super) {
|
|
4729
5048
|
__extends(SelectBaseAutomation, _super);
|
|
4730
5049
|
function SelectBaseAutomation(element, actionOptions) {
|
|
4731
|
-
var _this = _super.call(this, element, actionOptions) || this;
|
|
5050
|
+
var _this = _super.call(this, element, actionOptions, window, cursor) || this;
|
|
4732
5051
|
_this.absoluteStartPoint = null;
|
|
4733
5052
|
_this.absoluteEndPoint = null;
|
|
4734
5053
|
_this.clientPoint = null;
|
|
@@ -4746,8 +5065,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4746
5065
|
return _this;
|
|
4747
5066
|
}
|
|
4748
5067
|
SelectBaseAutomation._calculateEventArguments = function (point) {
|
|
4749
|
-
var clientPoint = positionUtils$
|
|
4750
|
-
return getElementFromPoint$
|
|
5068
|
+
var clientPoint = positionUtils$6.offsetToClientCoords(point);
|
|
5069
|
+
return getElementFromPoint$2(clientPoint)
|
|
4751
5070
|
.then(function (element) {
|
|
4752
5071
|
if (!element)
|
|
4753
5072
|
throw new Error(ERROR_TYPES.elementIsInvisibleError);
|
|
@@ -4764,20 +5083,20 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4764
5083
|
var _this = this;
|
|
4765
5084
|
var element = _a.element, offsetX = _a.offsetX, offsetY = _a.offsetY, speed = _a.speed;
|
|
4766
5085
|
var moveOptions = new MoveOptions({ offsetX: offsetX, offsetY: offsetY, speed: speed }, false);
|
|
4767
|
-
return MoveAutomation.create(element, window, cursor
|
|
5086
|
+
return MoveAutomation.create(element, moveOptions, window, cursor)
|
|
4768
5087
|
.then(function (moveAutomation) {
|
|
4769
5088
|
return moveAutomation.run();
|
|
4770
5089
|
})
|
|
4771
|
-
.then(function () { return delay$
|
|
5090
|
+
.then(function () { return delay$4(_this.automationSettings.mouseActionStepDelay); });
|
|
4772
5091
|
};
|
|
4773
5092
|
SelectBaseAutomation.prototype._bindMousedownHandler = function () {
|
|
4774
5093
|
var _this = this;
|
|
4775
5094
|
var onmousedown = function (e) {
|
|
4776
5095
|
_this.eventState.mousedownPrevented = e.defaultPrevented;
|
|
4777
|
-
eventUtils$
|
|
4778
|
-
eventUtils$
|
|
5096
|
+
eventUtils$6.preventDefault(e);
|
|
5097
|
+
eventUtils$6.unbind(_this.element, 'mousedown', onmousedown);
|
|
4779
5098
|
};
|
|
4780
|
-
eventUtils$
|
|
5099
|
+
eventUtils$6.bind(this.element, 'mousedown', onmousedown);
|
|
4781
5100
|
};
|
|
4782
5101
|
SelectBaseAutomation.prototype._calculateAbsoluteStartPoint = function () {
|
|
4783
5102
|
throw new Error('Not implemented');
|
|
@@ -4806,7 +5125,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4806
5125
|
// NOTE: In WebKit and IE, the mousedown event opens the select element's dropdown;
|
|
4807
5126
|
// therefore, we should prevent mousedown and hide the dropdown (B236416).
|
|
4808
5127
|
var needCloseSelectDropDown = (browserUtils$f.isWebKit || browserUtils$f.isIE) &&
|
|
4809
|
-
domUtils$
|
|
5128
|
+
domUtils$c.isSelectElement(_this.element);
|
|
4810
5129
|
if (needCloseSelectDropDown)
|
|
4811
5130
|
_this._bindMousedownHandler();
|
|
4812
5131
|
_this.eventState.simulateDefaultBehavior = eventSimulator$d[_this.downEvent](_this.eventArgs.element, _this.eventArgs.options);
|
|
@@ -4819,7 +5138,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4819
5138
|
var _this = this;
|
|
4820
5139
|
return new Promise$d(function (resolve) {
|
|
4821
5140
|
// NOTE: If the target element is a child of a contentEditable element, we need to call focus for its parent
|
|
4822
|
-
var elementForFocus = domUtils$
|
|
5141
|
+
var elementForFocus = domUtils$c.isContentEditableElement(_this.element) ?
|
|
4823
5142
|
contentEditable$3.findContentEditableParent(_this.element) : _this.element;
|
|
4824
5143
|
focusBlurSandbox$4.focus(elementForFocus, resolve, false, true);
|
|
4825
5144
|
});
|
|
@@ -4854,8 +5173,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4854
5173
|
}(VisibleElementAutomation));
|
|
4855
5174
|
|
|
4856
5175
|
var textSelection$3 = testCafeCore__default.textSelection;
|
|
4857
|
-
var domUtils$
|
|
4858
|
-
var positionUtils$
|
|
5176
|
+
var domUtils$d = testCafeCore__default.domUtils;
|
|
5177
|
+
var positionUtils$7 = testCafeCore__default.positionUtils;
|
|
4859
5178
|
var SelectTextAutomation = /** @class */ (function (_super) {
|
|
4860
5179
|
__extends(SelectTextAutomation, _super);
|
|
4861
5180
|
function SelectTextAutomation(element, startPos, endPos, actionOptions) {
|
|
@@ -4866,20 +5185,20 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4866
5185
|
}
|
|
4867
5186
|
SelectTextAutomation.prototype._calculateAbsoluteStartPoint = function () {
|
|
4868
5187
|
var point = getSelectionCoordinatesByPosition(this.element, this.startPos);
|
|
4869
|
-
return point || positionUtils$
|
|
5188
|
+
return point || positionUtils$7.findCenter(this.element);
|
|
4870
5189
|
};
|
|
4871
5190
|
SelectTextAutomation.prototype._calculateAbsoluteEndPoint = function () {
|
|
4872
5191
|
var point = getSelectionCoordinatesByPosition(this.element, this.endPos);
|
|
4873
5192
|
if (point)
|
|
4874
5193
|
return point;
|
|
4875
5194
|
// NOTE: if selection ends on an invisible symbol, we should try to find the last visible selection position
|
|
4876
|
-
if (domUtils$
|
|
5195
|
+
if (domUtils$d.isContentEditableElement(this.element))
|
|
4877
5196
|
return getLastVisibleSelectionPosition(this.element, this.startPos, this.endPos);
|
|
4878
|
-
return positionUtils$
|
|
5197
|
+
return positionUtils$7.findCenter(this.element);
|
|
4879
5198
|
};
|
|
4880
5199
|
SelectTextAutomation.prototype._setSelection = function () {
|
|
4881
|
-
var isTextEditable = domUtils$
|
|
4882
|
-
var isContentEditable = domUtils$
|
|
5200
|
+
var isTextEditable = domUtils$d.isTextEditableElement(this.element);
|
|
5201
|
+
var isContentEditable = domUtils$d.isContentEditableElement(this.element);
|
|
4883
5202
|
if (!(isTextEditable || isContentEditable) || this.eventState.simulateDefaultBehavior === false)
|
|
4884
5203
|
return;
|
|
4885
5204
|
textSelection$3.select(this.element, this.startPos, this.endPos);
|
|
@@ -4895,7 +5214,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4895
5214
|
|
|
4896
5215
|
var textSelection$4 = testCafeCore__default.textSelection;
|
|
4897
5216
|
var contentEditable$4 = testCafeCore__default.contentEditable;
|
|
4898
|
-
var positionUtils$
|
|
5217
|
+
var positionUtils$8 = testCafeCore__default.positionUtils;
|
|
4899
5218
|
var SelectEditableContentAutomation = /** @class */ (function (_super) {
|
|
4900
5219
|
__extends(SelectEditableContentAutomation, _super);
|
|
4901
5220
|
function SelectEditableContentAutomation(startNode, endNode, actionOptions) {
|
|
@@ -4922,11 +5241,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4922
5241
|
}
|
|
4923
5242
|
SelectEditableContentAutomation.prototype._calculateAbsoluteStartPoint = function () {
|
|
4924
5243
|
var point = getSelectionCoordinatesByNodeAndOffset(this.element, this.startNode, this.startOffset);
|
|
4925
|
-
return point || positionUtils$
|
|
5244
|
+
return point || positionUtils$8.findCenter(this.element);
|
|
4926
5245
|
};
|
|
4927
5246
|
SelectEditableContentAutomation.prototype._calculateAbsoluteEndPoint = function () {
|
|
4928
5247
|
var point = getSelectionCoordinatesByNodeAndOffset(this.element, this.endNode, this.endOffset);
|
|
4929
|
-
return point || positionUtils$
|
|
5248
|
+
return point || positionUtils$8.findCenter(this.element);
|
|
4930
5249
|
};
|
|
4931
5250
|
SelectEditableContentAutomation.prototype._setSelection = function () {
|
|
4932
5251
|
if (this.eventState.simulateDefaultBehavior === false)
|
|
@@ -4941,15 +5260,15 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4941
5260
|
}(SelectBaseAutomation));
|
|
4942
5261
|
|
|
4943
5262
|
var Promise$e = hammerhead__default.Promise;
|
|
4944
|
-
var extend$
|
|
5263
|
+
var extend$5 = hammerhead__default.utils.extend;
|
|
4945
5264
|
var browserUtils$g = hammerhead__default.utils.browser;
|
|
4946
5265
|
var eventSimulator$e = hammerhead__default.eventSandbox.eventSimulator;
|
|
4947
5266
|
var elementEditingWatcher$1 = hammerhead__default.eventSandbox.elementEditingWatcher;
|
|
4948
|
-
var domUtils$
|
|
5267
|
+
var domUtils$e = testCafeCore__default.domUtils;
|
|
4949
5268
|
var promiseUtils = testCafeCore__default.promiseUtils;
|
|
4950
5269
|
var contentEditable$5 = testCafeCore__default.contentEditable;
|
|
4951
5270
|
var textSelection$5 = testCafeCore__default.textSelection;
|
|
4952
|
-
var delay$
|
|
5271
|
+
var delay$5 = testCafeCore__default.delay;
|
|
4953
5272
|
var SPECIAL_KEYS = testCafeCore__default.KEY_MAPS.specialKeys;
|
|
4954
5273
|
var TypeAutomation = /** @class */ (function () {
|
|
4955
5274
|
function TypeAutomation(element, text, typeOptions) {
|
|
@@ -4982,10 +5301,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4982
5301
|
}
|
|
4983
5302
|
TypeAutomation.findTextEditableChild = function (element) {
|
|
4984
5303
|
var innerElement = null;
|
|
4985
|
-
if (!domUtils$
|
|
5304
|
+
if (!domUtils$e.isEditableElement(element)) {
|
|
4986
5305
|
var allChildren = element.querySelectorAll('*');
|
|
4987
5306
|
for (var i = 0; i < allChildren.length; i++) {
|
|
4988
|
-
if (domUtils$
|
|
5307
|
+
if (domUtils$e.isTextEditableElementAndEditingAllowed(allChildren[i])) {
|
|
4989
5308
|
innerElement = allChildren[i];
|
|
4990
5309
|
break;
|
|
4991
5310
|
}
|
|
@@ -4994,23 +5313,23 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4994
5313
|
return innerElement;
|
|
4995
5314
|
};
|
|
4996
5315
|
TypeAutomation.prototype._calculateEventArguments = function (isPressEvent) {
|
|
4997
|
-
var activeElement = domUtils$
|
|
4998
|
-
var isContentEditable = domUtils$
|
|
5316
|
+
var activeElement = domUtils$e.getActiveElement();
|
|
5317
|
+
var isContentEditable = domUtils$e.isContentEditableElement(this.element);
|
|
4999
5318
|
var element = this.eventArgs.element || this.element;
|
|
5000
5319
|
// T162478: Wrong typing and keys pressing in editor
|
|
5001
5320
|
if (!isContentEditable && activeElement !== element)
|
|
5002
5321
|
element = TypeAutomation.findTextEditableChild(activeElement) || activeElement;
|
|
5003
|
-
var options = extend$
|
|
5322
|
+
var options = extend$5({
|
|
5004
5323
|
keyCode: isPressEvent ? this.currentCharCode : this.currentKeyCode,
|
|
5005
5324
|
}, this.modifiers);
|
|
5006
5325
|
if (isPressEvent)
|
|
5007
5326
|
options.charCode = this.currentCharCode;
|
|
5008
|
-
extend$
|
|
5327
|
+
extend$5(options, getKeyProperties(isPressEvent, this.currentKey, this.currentKeyIdentifier));
|
|
5009
5328
|
return { element: element, options: options };
|
|
5010
5329
|
};
|
|
5011
5330
|
TypeAutomation.prototype._calculateTargetElement = function () {
|
|
5012
|
-
var activeElement = domUtils$
|
|
5013
|
-
var isContentEditable = domUtils$
|
|
5331
|
+
var activeElement = domUtils$e.getActiveElement();
|
|
5332
|
+
var isContentEditable = domUtils$e.isContentEditableElement(this.element);
|
|
5014
5333
|
if (isContentEditable) {
|
|
5015
5334
|
if (activeElement !== contentEditable$5.findContentEditableParent(this.element)) {
|
|
5016
5335
|
this.eventState.skipType = true;
|
|
@@ -5025,9 +5344,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5025
5344
|
};
|
|
5026
5345
|
TypeAutomation.prototype._click = function (useStrictElementCheck) {
|
|
5027
5346
|
var _this = this;
|
|
5028
|
-
var activeElement = domUtils$
|
|
5029
|
-
var isTextEditable = domUtils$
|
|
5030
|
-
var isContentEditable = domUtils$
|
|
5347
|
+
var activeElement = domUtils$e.getActiveElement();
|
|
5348
|
+
var isTextEditable = domUtils$e.isTextEditableElementAndEditingAllowed(this.element);
|
|
5349
|
+
var isContentEditable = domUtils$e.isContentEditableElement(this.element);
|
|
5031
5350
|
if (activeElement !== this.element) {
|
|
5032
5351
|
var _a = getDefaultAutomationOffsets(this.element), offsetX = _a.offsetX, offsetY = _a.offsetY;
|
|
5033
5352
|
var clickOptions = new ClickOptions({
|
|
@@ -5037,10 +5356,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5037
5356
|
caretPos: this.caretPos,
|
|
5038
5357
|
modifiers: this.modifiers,
|
|
5039
5358
|
});
|
|
5040
|
-
var clickAutomation = new ClickAutomation(this.element, clickOptions);
|
|
5359
|
+
var clickAutomation = new ClickAutomation(this.element, clickOptions, window, cursor);
|
|
5041
5360
|
return clickAutomation
|
|
5042
5361
|
.run(useStrictElementCheck)
|
|
5043
|
-
.then(function () { return delay$
|
|
5362
|
+
.then(function () { return delay$5(_this.automationSettings.mouseActionStepDelay); });
|
|
5044
5363
|
}
|
|
5045
5364
|
if (isTextEditable)
|
|
5046
5365
|
elementEditingWatcher$1.watchElementEditing(this.element);
|
|
@@ -5056,9 +5375,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5056
5375
|
var _this = this;
|
|
5057
5376
|
if (this.eventState.skipType)
|
|
5058
5377
|
return Promise$e.resolve();
|
|
5059
|
-
var isContentEditable = domUtils$
|
|
5378
|
+
var isContentEditable = domUtils$e.isContentEditableElement(this.element);
|
|
5060
5379
|
if (this.replace) {
|
|
5061
|
-
if (domUtils$
|
|
5380
|
+
if (domUtils$e.isTextEditableElementAndEditingAllowed(this.element))
|
|
5062
5381
|
textSelection$5.select(this.element);
|
|
5063
5382
|
else if (isContentEditable)
|
|
5064
5383
|
textSelection$5.deleteSelectionContents(this.element, true);
|
|
@@ -5074,7 +5393,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5074
5393
|
this.currentCharCode = this.typingText.charCodeAt(this.currentPos);
|
|
5075
5394
|
this.currentKey = this.currentKeyCode === SPECIAL_KEYS['enter'] ? 'Enter' : char;
|
|
5076
5395
|
this.currentKeyIdentifier = getKeyIdentifier(this.currentKey);
|
|
5077
|
-
this.ignoreChangeEvent = domUtils$
|
|
5396
|
+
this.ignoreChangeEvent = domUtils$e.getElementValue(this.element) === elementEditingWatcher$1.getElementSavedValue(this.element);
|
|
5078
5397
|
this._keydown();
|
|
5079
5398
|
this._keypress();
|
|
5080
5399
|
return this._keyup();
|
|
@@ -5093,8 +5412,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5093
5412
|
var _this = this;
|
|
5094
5413
|
var elementForTyping = this.eventArgs.element;
|
|
5095
5414
|
this.eventArgs = this._calculateEventArguments();
|
|
5096
|
-
var isTextEditableElement = domUtils$
|
|
5097
|
-
var isContentEditable = domUtils$
|
|
5415
|
+
var isTextEditableElement = domUtils$e.isTextEditableElement(this.element);
|
|
5416
|
+
var isContentEditable = domUtils$e.isContentEditableElement(this.element);
|
|
5098
5417
|
var shouldTypeAllText = this.paste || !isTextEditableElement && !isContentEditable;
|
|
5099
5418
|
return Promise$e
|
|
5100
5419
|
.resolve()
|
|
@@ -5117,30 +5436,30 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5117
5436
|
// was changed before the prevented keypress or keydown (GH-4881)
|
|
5118
5437
|
if (this.ignoreChangeEvent)
|
|
5119
5438
|
elementEditingWatcher$1.restartWatchingElementEditing(element);
|
|
5120
|
-
return delay$
|
|
5439
|
+
return delay$5(this.automationSettings.keyActionStepDelay);
|
|
5121
5440
|
}
|
|
5122
5441
|
var currentChar = this.typingText.charAt(this.currentPos);
|
|
5123
5442
|
var isDigit = /^\d$/.test(currentChar);
|
|
5124
5443
|
var prevChar = this.currentPos === 0 ? null : this.typingText.charAt(this.currentPos - 1);
|
|
5125
|
-
var isInputTypeNumber = domUtils$
|
|
5444
|
+
var isInputTypeNumber = domUtils$e.isInputElement(element) && element.type === 'number';
|
|
5126
5445
|
if (isInputTypeNumber) {
|
|
5127
5446
|
var selectionStart = textSelection$5.getSelectionStart(element);
|
|
5128
|
-
var valueLength = domUtils$
|
|
5447
|
+
var valueLength = domUtils$e.getInputValue(element).length;
|
|
5129
5448
|
var textHasDigits = /^\d/.test(this.typingText);
|
|
5130
5449
|
var isPermissibleSymbol = currentChar === '.' || currentChar === '-' && valueLength;
|
|
5131
5450
|
if (!isDigit && (textHasDigits || !isPermissibleSymbol || selectionStart !== 0))
|
|
5132
|
-
return delay$
|
|
5451
|
+
return delay$5(this.automationSettings.keyActionStepDelay);
|
|
5133
5452
|
// NOTE: allow to type '.' or '-' only if it is the first symbol and the input already has
|
|
5134
5453
|
// a value, or if '.' or '-' are added to a digit. Otherwise, the value won't be set.
|
|
5135
5454
|
if (isDigit && (prevChar === '.' || prevChar === '-' && !valueLength))
|
|
5136
5455
|
currentChar = prevChar + currentChar;
|
|
5137
5456
|
}
|
|
5138
5457
|
typeText(element, currentChar, null);
|
|
5139
|
-
return delay$
|
|
5458
|
+
return delay$5(this.automationSettings.keyActionStepDelay);
|
|
5140
5459
|
};
|
|
5141
5460
|
TypeAutomation.prototype._typeAllText = function (element) {
|
|
5142
5461
|
typeText(element, this.typingText, this.caretPos);
|
|
5143
|
-
return delay$
|
|
5462
|
+
return delay$5(this.automationSettings.keyActionStepDelay);
|
|
5144
5463
|
};
|
|
5145
5464
|
TypeAutomation.prototype.run = function (useStrictElementCheck) {
|
|
5146
5465
|
var _this = this;
|
|
@@ -5174,10 +5493,10 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5174
5493
|
return UploadAutomation;
|
|
5175
5494
|
}());
|
|
5176
5495
|
|
|
5177
|
-
var domUtils$
|
|
5496
|
+
var domUtils$f = testCafeCore__default.domUtils;
|
|
5178
5497
|
var contentEditable$6 = testCafeCore__default.contentEditable;
|
|
5179
5498
|
function getSelectTextAreaContentArguments(element, argumentsObject) {
|
|
5180
|
-
var value = domUtils$
|
|
5499
|
+
var value = domUtils$f.getTextAreaValue(element);
|
|
5181
5500
|
var linesArray = value && value.length ? value.split('\n') : [];
|
|
5182
5501
|
var lastLineIndex = linesArray.length - 1;
|
|
5183
5502
|
var startLineIndex = !argumentsObject.startLine ? 0 : Math.min(argumentsObject.startLine, lastLineIndex);
|
|
@@ -5189,8 +5508,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5189
5508
|
var endPos = argumentsObject.endPos === void 0 ||
|
|
5190
5509
|
argumentsObject.endPos ===
|
|
5191
5510
|
null ? endLineLength : Math.min(argumentsObject.endPos, endLineLength);
|
|
5192
|
-
var startLinePosition = domUtils$
|
|
5193
|
-
var endLinePosition = domUtils$
|
|
5511
|
+
var startLinePosition = domUtils$f.getTextareaPositionByLineAndOffset(element, startLineIndex, 0);
|
|
5512
|
+
var endLinePosition = domUtils$f.getTextareaPositionByLineAndOffset(element, endLineIndex, 0);
|
|
5194
5513
|
return {
|
|
5195
5514
|
startPos: startLinePosition + startPos,
|
|
5196
5515
|
endPos: endLinePosition + endPos,
|
|
@@ -5198,9 +5517,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5198
5517
|
}
|
|
5199
5518
|
function calculateSelectTextArguments (element, argumentsObject) {
|
|
5200
5519
|
if (argumentsObject === void 0) { argumentsObject = {}; }
|
|
5201
|
-
var isTextEditable = domUtils$
|
|
5520
|
+
var isTextEditable = domUtils$f.isTextEditableElement(element);
|
|
5202
5521
|
var firstPos = isTextEditable ? 0 : contentEditable$6.getFirstVisiblePosition(element);
|
|
5203
|
-
var lastPos = isTextEditable ? domUtils$
|
|
5522
|
+
var lastPos = isTextEditable ? domUtils$f.getElementValue(element).length : contentEditable$6.getLastVisiblePosition(element);
|
|
5204
5523
|
var startPos = !argumentsObject.startPos ? firstPos : Math.min(argumentsObject.startPos, lastPos);
|
|
5205
5524
|
var endPos = argumentsObject.endPos === void 0 ||
|
|
5206
5525
|
argumentsObject.endPos === null ? lastPos : Math.min(argumentsObject.endPos, lastPos);
|
|
@@ -5246,7 +5565,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5246
5565
|
exports$1.getNextFocusableElement = getNextFocusableElement;
|
|
5247
5566
|
exports$1.SHORTCUT_TYPE = SHORTCUT_TYPE;
|
|
5248
5567
|
exports$1.getSelectionCoordinatesByPosition = getSelectionCoordinatesByPosition;
|
|
5249
|
-
exports$1.getElementFromPoint = getElementFromPoint$
|
|
5568
|
+
exports$1.getElementFromPoint = getElementFromPoint$2;
|
|
5250
5569
|
var nativeMethods$c = hammerhead__default.nativeMethods;
|
|
5251
5570
|
var evalIframeScript = hammerhead__default.EVENTS.evalIframeScript;
|
|
5252
5571
|
nativeMethods$c.objectDefineProperty(window, '%testCafeAutomation%', { configurable: true, value: exports$1 });
|