@testim/testim-cli 3.274.0 → 3.275.0
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/npm-shrinkwrap.json +74 -28
- package/package.json +1 -1
- package/player/stepActions/dropFileStepAction.js +1 -2
- package/player/stepActions/scripts/dispatchEvents.js +100 -89
- package/player/stepActions/scripts/doClick.js +82 -84
- package/player/stepActions/scripts/doDragPath.js +84 -85
- package/player/stepActions/scripts/doubleClick.js +38 -36
- package/player/stepActions/scripts/dropEvent.js +27 -24
- package/player/stepActions/scripts/focusElement.js +9 -13
- package/player/stepActions/scripts/html5dragAction.js +15 -15
- package/player/stepActions/scripts/html5dragActionV2.js +44 -45
- package/player/stepActions/scripts/runCode.js +24 -33
- package/player/stepActions/scripts/scroll.js +27 -27
- package/player/stepActions/scripts/selectOption.js +6 -6
- package/player/stepActions/scripts/setText.js +111 -116
- package/player/stepActions/scripts/wheel.js +18 -16
- package/polyfills/index.js +4 -0
- package/testRunStatus.js +1 -25
- package/testimNpmDriver.js +1 -1
- package/player/stepActions/scripts/createDropEventLegacy.js +0 -61
|
@@ -2,42 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const doClick = (eventData, done) => {
|
|
6
|
+
const eventConstructorSupported = typeof Event === 'function';
|
|
7
7
|
|
|
8
8
|
window.__unloadNavigator = resolve;
|
|
9
9
|
|
|
10
|
-
window.addEventListener(
|
|
10
|
+
window.addEventListener('unload', window.__unloadNavigator);
|
|
11
11
|
|
|
12
12
|
function handleReactSelectFocusQuirk(context, event) {
|
|
13
13
|
function focusReactSelect(element) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return getParents(
|
|
17
|
-
return Array.apply(null, el.classList || []).indexOf("Select-control") !== -1;
|
|
18
|
-
})[0];
|
|
14
|
+
function getReactSelectRoot(_element) {
|
|
15
|
+
// eslint-disable-next-line prefer-spread
|
|
16
|
+
return getParents(_element).find((el) => Array.apply(null, el.classList || []).includes('Select-control'));
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
function getReactSelectInput(
|
|
22
|
-
|
|
23
|
-
return root ? root.querySelector(
|
|
19
|
+
function getReactSelectInput(_element) {
|
|
20
|
+
const root = getReactSelectRoot(_element);
|
|
21
|
+
return root ? root.querySelector('INPUT') : null;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
const reactSelectInput = getReactSelectInput(element);
|
|
27
25
|
if (reactSelectInput) {
|
|
28
26
|
reactSelectInput.focus();
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
if (event.type ===
|
|
30
|
+
const isReactSelectElement = context.quirks?.isReactSelect;
|
|
31
|
+
if (event.type === 'mousedown' && isReactSelectElement) {
|
|
34
32
|
focusReactSelect(context.element);
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
function handleCKEditorQuirk(context, event) {
|
|
39
|
-
|
|
40
|
-
if (event.type ===
|
|
37
|
+
const isCKEditorFrame = context.quirks?.isCKEditorFrame;
|
|
38
|
+
if (event.type === 'click' && isCKEditorFrame) {
|
|
41
39
|
document.body.focus();
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -47,13 +45,13 @@ var doClick = function (eventData, done) {
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
function resolve(result) {
|
|
50
|
-
|
|
48
|
+
const status = {
|
|
51
49
|
status: 'done',
|
|
52
|
-
result
|
|
53
|
-
success: true
|
|
50
|
+
result,
|
|
51
|
+
success: true,
|
|
54
52
|
};
|
|
55
53
|
if (context.isNonTextableElemnet) {
|
|
56
|
-
status.reason =
|
|
54
|
+
status.reason = 'Set text on non input element';
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
done(status);
|
|
@@ -61,29 +59,29 @@ var doClick = function (eventData, done) {
|
|
|
61
59
|
|
|
62
60
|
function reject(result) {
|
|
63
61
|
result = result || {};
|
|
64
|
-
|
|
62
|
+
const status = {
|
|
65
63
|
status: 'failed',
|
|
66
|
-
result
|
|
67
|
-
success: false
|
|
64
|
+
result,
|
|
65
|
+
success: false,
|
|
68
66
|
};
|
|
69
67
|
|
|
70
68
|
done(status);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
function dispatchMouseOver(element) {
|
|
74
|
-
|
|
72
|
+
const event = eventConstructorSupported ? new Event('mouseover', { composed: true }) : document.createEvent('Events');
|
|
75
73
|
event.initEvent('mouseover', true, true);
|
|
76
74
|
element.dispatchEvent(event);
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
function dispatchMouseMove(element) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
const modifiers = {};
|
|
79
|
+
const rect = element.getBoundingClientRect();
|
|
80
|
+
const clientX = rect.left + (rect.width / 2);
|
|
81
|
+
const clientY = rect.top + (rect.height / 2);
|
|
82
|
+
const button = 0;
|
|
83
|
+
const eventType = 'mousemove';
|
|
84
|
+
const event = createMouseEvent(eventType, modifiers, clientX, clientY, button);
|
|
87
85
|
element.dispatchEvent(event);
|
|
88
86
|
}
|
|
89
87
|
|
|
@@ -92,81 +90,75 @@ var doClick = function (eventData, done) {
|
|
|
92
90
|
return (point > start) && (point < end);
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return {x: clientX, y: clientY};
|
|
93
|
+
const pointerPosition = userEvent.pointerPosition || {};
|
|
94
|
+
const rect = element.getBoundingClientRect();
|
|
95
|
+
const clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
|
|
96
|
+
const clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
|
|
97
|
+
return { x: clientX, y: clientY };
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
function getEventDictionary(modifiers, clientX, clientY) {
|
|
103
101
|
return {
|
|
104
102
|
screenX: 0,
|
|
105
103
|
screenY: 0,
|
|
106
|
-
clientX
|
|
107
|
-
clientY
|
|
104
|
+
clientX,
|
|
105
|
+
clientY,
|
|
108
106
|
ctrlKey: Boolean(modifiers.ctrl),
|
|
109
107
|
altKey: Boolean(modifiers.alt),
|
|
110
108
|
shiftKey: Boolean(modifiers.shift),
|
|
111
109
|
metaKey: Boolean(modifiers.meta),
|
|
112
110
|
bubbles: true,
|
|
113
111
|
cancelable: true,
|
|
114
|
-
composed: true
|
|
112
|
+
composed: true,
|
|
115
113
|
};
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
function createPointerEvent(eventType, modifiers, clientX, clientY) {
|
|
119
117
|
if (!window.PointerEvent) {
|
|
120
|
-
return;
|
|
118
|
+
return undefined;
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
eventProperties.pointerType =
|
|
120
|
+
const eventProperties = getEventDictionary(modifiers, clientX, clientY);
|
|
121
|
+
eventProperties.pointerType = 'mouse';
|
|
124
122
|
eventProperties.isPrimary = true;
|
|
125
123
|
return new window.PointerEvent(eventType, eventProperties);
|
|
126
124
|
}
|
|
127
125
|
|
|
128
126
|
function createMouseEvent(eventType, modifiers, clientX, clientY, button) {
|
|
129
|
-
|
|
127
|
+
const event = eventConstructorSupported ? new MouseEvent('click', { composed: true }) : document.createEvent('MouseEvents');
|
|
130
128
|
event.initMouseEvent(
|
|
131
129
|
eventType,
|
|
132
|
-
true,
|
|
133
|
-
true,
|
|
134
|
-
document.defaultView,
|
|
135
|
-
1,
|
|
136
|
-
0,
|
|
137
|
-
0,
|
|
138
|
-
clientX,
|
|
139
|
-
clientY,
|
|
140
|
-
Boolean(modifiers.ctrl),
|
|
141
|
-
Boolean(modifiers.alt),
|
|
142
|
-
Boolean(modifiers.shift),
|
|
143
|
-
Boolean(modifiers.meta),
|
|
144
|
-
button,
|
|
130
|
+
true,
|
|
131
|
+
true,
|
|
132
|
+
document.defaultView,
|
|
133
|
+
1,
|
|
134
|
+
0,
|
|
135
|
+
0,
|
|
136
|
+
clientX,
|
|
137
|
+
clientY,
|
|
138
|
+
Boolean(modifiers.ctrl),
|
|
139
|
+
Boolean(modifiers.alt),
|
|
140
|
+
Boolean(modifiers.shift),
|
|
141
|
+
Boolean(modifiers.meta),
|
|
142
|
+
button,
|
|
145
143
|
document.body ? document.body.parentNode : document.documentElement);
|
|
146
144
|
return event;
|
|
147
145
|
}
|
|
148
146
|
|
|
149
147
|
function getMouseEvent(userEvent, context) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (pointerEvents.
|
|
148
|
+
const pointerEvents = ['pointerup', 'pointerdown', 'pointermove'];
|
|
149
|
+
const modifiers = context.modifiers || {};
|
|
150
|
+
const pos = getEventPosition(userEvent, context.element);
|
|
151
|
+
const button = context.button || 0;
|
|
152
|
+
const eventType = userEvent.event;
|
|
153
|
+
if (pointerEvents.includes(eventType)) {
|
|
156
154
|
return createPointerEvent(eventType, modifiers, pos.x, pos.y);
|
|
157
155
|
}
|
|
158
156
|
return createMouseEvent(eventType, modifiers, pos.x, pos.y, button);
|
|
159
157
|
}
|
|
160
158
|
|
|
161
|
-
function executeSyncEvent(event) {
|
|
162
|
-
context.element.dispatchEvent(event);
|
|
163
|
-
handleReactSelectFocusQuirk(context, event);
|
|
164
|
-
handleCKEditorQuirk(context, event);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
159
|
function findEffectiveActiveElement() {
|
|
168
|
-
|
|
169
|
-
while (activeElement.shadowRoot
|
|
160
|
+
let activeElement = document.activeElement;
|
|
161
|
+
while (activeElement.shadowRoot?.activeElement) {
|
|
170
162
|
activeElement = activeElement.shadowRoot.activeElement;
|
|
171
163
|
}
|
|
172
164
|
return activeElement;
|
|
@@ -174,49 +166,55 @@ var doClick = function (eventData, done) {
|
|
|
174
166
|
|
|
175
167
|
function executeSynchronousEventSequence(context) {
|
|
176
168
|
context.events
|
|
177
|
-
.map(
|
|
169
|
+
.map((userEvent) => {
|
|
178
170
|
try {
|
|
179
171
|
return getMouseEvent(userEvent, context);
|
|
180
172
|
} catch (e) {
|
|
181
|
-
// pointer events not supported
|
|
182
|
-
return;
|
|
173
|
+
// pointer events not supported :shrug:
|
|
174
|
+
return undefined;
|
|
183
175
|
}
|
|
184
176
|
})
|
|
185
177
|
.filter(Boolean)
|
|
186
|
-
.forEach(
|
|
178
|
+
.forEach((event) => {
|
|
179
|
+
context.element.dispatchEvent(event);
|
|
180
|
+
handleReactSelectFocusQuirk(context, event);
|
|
181
|
+
handleCKEditorQuirk(context, event);
|
|
182
|
+
});
|
|
187
183
|
|
|
188
184
|
if (window.__unloadNavigator) {
|
|
189
|
-
window.removeEventListener(
|
|
185
|
+
window.removeEventListener('unload', window.__unloadNavigator);
|
|
190
186
|
}
|
|
191
187
|
}
|
|
192
188
|
|
|
193
|
-
|
|
189
|
+
const element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
|
|
190
|
+
// eslint-disable-next-line no-var
|
|
194
191
|
var context = {
|
|
195
|
-
element
|
|
192
|
+
element,
|
|
196
193
|
events: eventData.events,
|
|
197
194
|
quirks: eventData.quirks,
|
|
198
195
|
modifiers: eventData.modifiers,
|
|
199
|
-
button: eventData.button
|
|
196
|
+
button: eventData.button,
|
|
200
197
|
};
|
|
201
198
|
|
|
202
199
|
if (!context.element) {
|
|
203
|
-
|
|
200
|
+
reject('element not found');
|
|
201
|
+
return;
|
|
204
202
|
}
|
|
205
203
|
|
|
206
204
|
dispatchMouseOver(context.element);
|
|
207
205
|
dispatchMouseMove(context.element);
|
|
208
206
|
try {
|
|
209
207
|
executeSynchronousEventSequence(context);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
const oldActiveElement = findEffectiveActiveElement();
|
|
209
|
+
const quirks = context.quirks;
|
|
210
|
+
const isReactSelectElement = quirks?.isReactSelect;
|
|
211
|
+
const isCKEditorFrame = quirks?.isCKEditorFrame;
|
|
214
212
|
if (!isReactSelectElement && !isCKEditorFrame) {
|
|
215
213
|
dispatchFocus(eventData.elementToFocusLocatedElement, oldActiveElement);
|
|
216
214
|
}
|
|
217
215
|
resolve();
|
|
218
216
|
} catch (e) {
|
|
219
|
-
|
|
217
|
+
reject(e.toString());
|
|
220
218
|
}
|
|
221
219
|
};
|
|
222
220
|
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const doDragPath = function (eventData, done) {
|
|
5
|
+
const eventConstructorSupported = typeof Event === 'function';
|
|
6
|
+
const pointerEventConstructorSupported = typeof PointerEvent === 'function';
|
|
7
|
+
const MAX_EVENT_TIMEOUT = 40; //max msec between events
|
|
8
8
|
|
|
9
9
|
window.__unloadNavigator = resolve;
|
|
10
10
|
|
|
11
|
-
window.addEventListener(
|
|
11
|
+
window.addEventListener('unload', window.__unloadNavigator);
|
|
12
12
|
|
|
13
13
|
function resolve(result) {
|
|
14
|
-
|
|
14
|
+
const status = {
|
|
15
15
|
status: 'done',
|
|
16
|
-
result
|
|
17
|
-
success: true
|
|
16
|
+
result,
|
|
17
|
+
success: true,
|
|
18
18
|
};
|
|
19
19
|
done(status);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function reject(result) {
|
|
23
23
|
result = result || {};
|
|
24
|
-
|
|
24
|
+
const status = {
|
|
25
25
|
status: 'failed',
|
|
26
|
-
result
|
|
27
|
-
success: false
|
|
26
|
+
result,
|
|
27
|
+
success: false,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
done(status);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function dispatchMouseOver(element) {
|
|
34
|
-
|
|
34
|
+
const event = eventConstructorSupported ? new Event('mouseover', { composed: true }) : document.createEvent('Events');
|
|
35
35
|
event.initEvent('mouseover', true, true);
|
|
36
36
|
|
|
37
37
|
element.dispatchEvent(event);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function dispatchMouseMove(element) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const modifiers = {};
|
|
42
|
+
const rect = element.getBoundingClientRect();
|
|
43
|
+
const clientX = rect.left + (rect.width / 2);
|
|
44
|
+
const clientY = rect.top + (rect.height / 2);
|
|
45
|
+
const button = 0;
|
|
46
|
+
const eventType = 'mousemove';
|
|
47
|
+
const event = createMouseEvent(eventType, modifiers, clientX, clientY, button);
|
|
48
48
|
|
|
49
49
|
element.dispatchEvent(event);
|
|
50
50
|
}
|
|
@@ -54,76 +54,75 @@ var doDragPath = function (eventData, done) {
|
|
|
54
54
|
return (point > start) && (point < end);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const pointerPosition = userEvent.pointerPosition || {};
|
|
58
58
|
if (context.isDrag) {
|
|
59
59
|
return { x: pointerPosition.originX || 0, y: pointerPosition.originY || 0 };
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return {x: clientX, y: clientY};
|
|
61
|
+
const rect = element.getBoundingClientRect();
|
|
62
|
+
const clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
|
|
63
|
+
const clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
|
|
64
|
+
return { x: clientX, y: clientY };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function getEventDictionary(modifiers, clientX, clientY) {
|
|
68
68
|
return {
|
|
69
69
|
screenX: 0,
|
|
70
70
|
screenY: 0,
|
|
71
|
-
clientX
|
|
72
|
-
clientY
|
|
71
|
+
clientX,
|
|
72
|
+
clientY,
|
|
73
73
|
ctrlKey: Boolean(modifiers.ctrl),
|
|
74
74
|
altKey: Boolean(modifiers.alt),
|
|
75
75
|
shiftKey: Boolean(modifiers.shift),
|
|
76
76
|
metaKey: Boolean(modifiers.meta),
|
|
77
77
|
bubbles: true,
|
|
78
78
|
cancelable: true,
|
|
79
|
-
composed: true
|
|
79
|
+
composed: true,
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
function createPointerEvent(eventType, modifiers, clientX, clientY, button) {
|
|
84
84
|
if (pointerEventConstructorSupported) {
|
|
85
|
-
|
|
86
|
-
eventProperties.pointerType =
|
|
85
|
+
const eventProperties = getEventDictionary(modifiers, clientX, clientY);
|
|
86
|
+
eventProperties.pointerType = 'mouse';
|
|
87
87
|
eventProperties.isPrimary = true;
|
|
88
88
|
return new window.PointerEvent(eventType, eventProperties);
|
|
89
|
-
|
|
90
|
-
} else {
|
|
91
|
-
var event = document.createEvent("PointerEvent");
|
|
92
|
-
event.initPointerEvent(
|
|
93
|
-
eventType,
|
|
94
|
-
true, /* bubbles */
|
|
95
|
-
true, /* cancelable */
|
|
96
|
-
document.defaultView, /* view */
|
|
97
|
-
1, /* detail */
|
|
98
|
-
0, /* screenX */
|
|
99
|
-
0, /* screenY */
|
|
100
|
-
clientX, /* clientX */
|
|
101
|
-
clientY, /* clientY */
|
|
102
|
-
Boolean(modifiers.ctrl), /* ctrl */
|
|
103
|
-
Boolean(modifiers.alt), /* alt */
|
|
104
|
-
Boolean(modifiers.shift), /* shift */
|
|
105
|
-
Boolean(modifiers.meta), /* meta */
|
|
106
|
-
button, /* button */
|
|
107
|
-
document.body ? document.body.parentNode : document.documentElement,
|
|
108
|
-
0, /* offsetYArg */
|
|
109
|
-
0, /* offsetXArg */
|
|
110
|
-
0, /* widthArg */
|
|
111
|
-
0, /* heightArg */
|
|
112
|
-
0, /* pressure */
|
|
113
|
-
0, /* rotation */
|
|
114
|
-
0, /* tiltX */
|
|
115
|
-
0, /* tiltY */
|
|
116
|
-
0, /* pointerIdArg */
|
|
117
|
-
"mouse", /* pointerType */
|
|
118
|
-
0, /* hwTimestampArg */
|
|
119
|
-
true) /* isPrimary */
|
|
120
|
-
|
|
121
|
-
return event;
|
|
122
89
|
}
|
|
90
|
+
const event = document.createEvent('PointerEvent');
|
|
91
|
+
event.initPointerEvent(
|
|
92
|
+
eventType,
|
|
93
|
+
true, /* bubbles */
|
|
94
|
+
true, /* cancelable */
|
|
95
|
+
document.defaultView, /* view */
|
|
96
|
+
1, /* detail */
|
|
97
|
+
0, /* screenX */
|
|
98
|
+
0, /* screenY */
|
|
99
|
+
clientX, /* clientX */
|
|
100
|
+
clientY, /* clientY */
|
|
101
|
+
Boolean(modifiers.ctrl), /* ctrl */
|
|
102
|
+
Boolean(modifiers.alt), /* alt */
|
|
103
|
+
Boolean(modifiers.shift), /* shift */
|
|
104
|
+
Boolean(modifiers.meta), /* meta */
|
|
105
|
+
button, /* button */
|
|
106
|
+
document.body ? document.body.parentNode : document.documentElement,
|
|
107
|
+
0, /* offsetYArg */
|
|
108
|
+
0, /* offsetXArg */
|
|
109
|
+
0, /* widthArg */
|
|
110
|
+
0, /* heightArg */
|
|
111
|
+
0, /* pressure */
|
|
112
|
+
0, /* rotation */
|
|
113
|
+
0, /* tiltX */
|
|
114
|
+
0, /* tiltY */
|
|
115
|
+
0, /* pointerIdArg */
|
|
116
|
+
'mouse', /* pointerType */
|
|
117
|
+
0, /* hwTimestampArg */
|
|
118
|
+
true, /* isPrimary */
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return event;
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
function createMouseEvent(eventType, modifiers, clientX, clientY, button) {
|
|
126
|
-
|
|
125
|
+
const event = eventConstructorSupported ? new MouseEvent('click', { composed: true }) : document.createEvent('MouseEvents');
|
|
127
126
|
event.initMouseEvent(
|
|
128
127
|
eventType,
|
|
129
128
|
true, /* bubbles */
|
|
@@ -144,12 +143,12 @@ var doDragPath = function (eventData, done) {
|
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
function getMouseEvent(userEvent, context) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (pointerEvents.
|
|
146
|
+
const pointerEvents = ['pointerup', 'pointerdown', 'pointermove'];
|
|
147
|
+
const modifiers = context.modifiers || {};
|
|
148
|
+
const pos = getEventPosition(userEvent, context.element);
|
|
149
|
+
const button = context.button || 0;
|
|
150
|
+
const eventType = userEvent.event;
|
|
151
|
+
if (pointerEvents.includes(eventType)) {
|
|
153
152
|
return createPointerEvent(eventType, modifiers, pos.x, pos.y, button);
|
|
154
153
|
}
|
|
155
154
|
return createMouseEvent(eventType, modifiers, pos.x, pos.y, button);
|
|
@@ -164,39 +163,39 @@ var doDragPath = function (eventData, done) {
|
|
|
164
163
|
return isClickInDragAndDrop();
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
function executeAsyncNextEventRecursive(index, context, done){
|
|
166
|
+
function executeAsyncNextEventRecursive(index, context, done) {
|
|
168
167
|
try {
|
|
169
|
-
|
|
168
|
+
const event = getMouseEvent(context.events[index], context);
|
|
170
169
|
if (!shouldSkipEvent(event, context)) {
|
|
171
170
|
context.element.dispatchEvent(event);
|
|
172
171
|
}
|
|
173
|
-
} catch(ignore) {}
|
|
172
|
+
} catch (ignore) { /* ignored */ }
|
|
174
173
|
|
|
175
174
|
if (index + 1 === context.events.length) {
|
|
176
175
|
done();
|
|
177
176
|
} else {
|
|
178
|
-
|
|
179
|
-
setTimeout(
|
|
180
|
-
executeAsyncNextEventRecursive(index+1, context, done);
|
|
177
|
+
const delay = Math.min(context.events[index + 1].timeStamp - context.events[index].timeStamp, MAX_EVENT_TIMEOUT);
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
executeAsyncNextEventRecursive(index + 1, context, done);
|
|
181
180
|
}, delay);
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
|
|
185
184
|
function executeAsyncEventSequence(context, done) {
|
|
186
|
-
executeAsyncNextEventRecursive(0, context,
|
|
187
|
-
|
|
185
|
+
executeAsyncNextEventRecursive(0, context, () => {
|
|
188
186
|
if (window.__unloadNavigator) {
|
|
189
|
-
window.removeEventListener(
|
|
187
|
+
window.removeEventListener('unload', window.__unloadNavigator);
|
|
190
188
|
}
|
|
191
189
|
done();
|
|
192
190
|
});
|
|
193
191
|
}
|
|
194
192
|
|
|
195
|
-
|
|
193
|
+
// eslint-disable-next-line no-undef
|
|
194
|
+
const element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
|
|
196
195
|
|
|
197
|
-
|
|
196
|
+
const context = {
|
|
198
197
|
eventIndex: 0,
|
|
199
|
-
element
|
|
198
|
+
element,
|
|
200
199
|
events: eventData.events,
|
|
201
200
|
eventType: eventData.eventType,
|
|
202
201
|
eventData: eventData.eventData,
|
|
@@ -211,16 +210,16 @@ var doDragPath = function (eventData, done) {
|
|
|
211
210
|
};
|
|
212
211
|
|
|
213
212
|
if (!context.element) {
|
|
214
|
-
|
|
213
|
+
reject('element not found');
|
|
214
|
+
return;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
dispatchMouseOver(context.element);
|
|
218
218
|
dispatchMouseMove(context.element);
|
|
219
219
|
|
|
220
|
-
executeAsyncEventSequence(context,
|
|
220
|
+
executeAsyncEventSequence(context, () => {
|
|
221
221
|
resolve();
|
|
222
222
|
});
|
|
223
|
-
|
|
224
223
|
};
|
|
225
224
|
|
|
226
225
|
module.exports = doDragPath;
|