@testim/testim-cli 3.274.0 → 3.278.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.
@@ -114,6 +114,7 @@ class TabService {
114
114
  }
115
115
 
116
116
  getMainTabUtils(sessionId) {
117
+ return {};
117
118
  }
118
119
 
119
120
  removeTabInfo(sessionId, tabId) {
@@ -3,7 +3,6 @@
3
3
  const StepAction = require('./stepAction');
4
4
  const logger = require('../../commons/logger').getLogger('drop-file-step-action');
5
5
  const downloadFileAndFireDropEvent = require('./scripts/dropEvent');
6
- const createDropEventLegacy = require('./scripts/createDropEventLegacy');
7
6
  const { codeSnippets, utils } = require('../../commons/getSessionPlayerRequire');
8
7
  const featureFlagService = require('../../commons/featureFlags');
9
8
 
@@ -21,7 +20,7 @@ class DropFileStepAction extends StepAction {
21
20
 
22
21
  const dropFileCode = `
23
22
  var getLocatedElement = ${codeSnippets.getLocatedElementCode};
24
- var createDropEvent = ${(codeSnippets.createDropEvent ? codeSnippets.createDropEvent : createDropEventLegacy).toString()};
23
+ var createDropEvent = ${codeSnippets.createDropEvent.toString()};
25
24
  var downloadFileAndFireDropEvent = ${downloadFileAndFireDropEvent.toString()};
26
25
  return downloadFileAndFireDropEvent.apply(null, arguments)
27
26
  `;
@@ -1,56 +1,54 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- var dispatchEvents = function (eventData, done) {
3
+ const dispatchEvents = function (eventData, done) {
4
4
  function getParents(el) {
5
5
  return el ? [el].concat(getParents(el.parentNode)) : [];
6
6
  }
7
7
 
8
8
  function handleReactSelectFocusQuirk(context, event) {
9
9
  function focusReactSelect(element) {
10
-
11
- function getReactSelectRoot(element) {
12
- return getParents(element).filter(function (el) {
13
- return Array.apply(null, el.classList || []).indexOf("Select-control") !== -1;
14
- })[0];
10
+ function getReactSelectRoot(_element) {
11
+ // eslint-disable-next-line prefer-spread
12
+ return getParents(_element).find((el) => Array.apply(null, el.classList || []).includes('Select-control'));
15
13
  }
16
14
 
17
- function getReactSelectInput(element) {
18
- var root = getReactSelectRoot(element);
19
- return root ? root.querySelector("INPUT") : null;
15
+ function getReactSelectInput(_element) {
16
+ const root = getReactSelectRoot(_element);
17
+ return root ? root.querySelector('INPUT') : null;
20
18
  }
21
19
 
22
- var reactSelectInput = getReactSelectInput(element);
20
+ const reactSelectInput = getReactSelectInput(element);
23
21
  if (reactSelectInput) {
24
22
  reactSelectInput.focus();
25
23
  }
26
24
  }
27
25
 
28
- var isReactSelectElement = context.quirks && context.quirks.isReactSelect;
29
- if (event.type === "mousedown" && isReactSelectElement) {
26
+ const isReactSelectElement = context.quirks?.isReactSelect;
27
+ if (event.type === 'mousedown' && isReactSelectElement) {
30
28
  focusReactSelect(context.element);
31
29
  }
32
30
  }
33
31
 
34
32
  function handleCKEditorQuirk(context, event) {
35
- var isCKEditorFrame = context.quirks && context.quirks.isCKEditorFrame;
36
- if (event.type === "click" && isCKEditorFrame) {
33
+ const isCKEditorFrame = context.quirks?.isCKEditorFrame;
34
+ if (event.type === 'click' && isCKEditorFrame) {
37
35
  document.body.focus();
38
36
  }
39
37
  }
40
38
 
41
39
  function dispatchMouseOver() {
42
- var event = document.createEvent('Events');
40
+ const event = document.createEvent('Events');
43
41
  event.initEvent('mouseover', true, true);
44
42
  context.element.dispatchEvent(event);
45
43
  }
46
44
 
47
45
  function dispatchMouseMove() {
48
- var userEvent = {
46
+ const userEvent = {
49
47
  event: 'mousemove',
50
48
  modifiers: {},
51
- button: 0
49
+ button: 0,
52
50
  };
53
- var event = createMouseEvent(userEvent);
51
+ const event = createMouseEvent(userEvent);
54
52
  context.element.dispatchEvent(event);
55
53
  }
56
54
 
@@ -59,20 +57,20 @@ var dispatchEvents = function (eventData, done) {
59
57
  return (point > start) && (point < end);
60
58
  }
61
59
 
62
- var pointerPosition = userEvent.pointerPosition || {};
63
- var rect = element.getBoundingClientRect();
64
- var clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
65
- var clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
66
- return {x: clientX, y: clientY};
60
+ const pointerPosition = userEvent.pointerPosition || {};
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 };
67
65
  }
68
66
 
69
67
  function createMouseEvent(userEvent) {
70
- var position = getEventPosition(userEvent, context.element);
71
- var modifiers = userEvent.modifiers || context.modifiers || {};
72
- var button = userEvent.button || context.button || 0;
73
- var eventType = userEvent.event;
68
+ const position = getEventPosition(userEvent, context.element);
69
+ const modifiers = userEvent.modifiers || context.modifiers || {};
70
+ const button = userEvent.button || context.button || 0;
71
+ const eventType = userEvent.event;
74
72
 
75
- var event = document.createEvent("MouseEvents");
73
+ const event = document.createEvent('MouseEvents');
76
74
  event.initMouseEvent(
77
75
  eventType,
78
76
  true, /* bubbles */
@@ -94,12 +92,12 @@ var dispatchEvents = function (eventData, done) {
94
92
  }
95
93
 
96
94
  function createPointerEvent(userEvent) {
97
- var position = getEventPosition(userEvent, context.element);
98
- var modifiers = userEvent.modifiers || context.modifiers || {};
99
- var eventType = userEvent.event;
95
+ const position = getEventPosition(userEvent, context.element);
96
+ const modifiers = userEvent.modifiers || context.modifiers || {};
97
+ const eventType = userEvent.event;
100
98
 
101
99
  if (!window.PointerEvent) {
102
- return;
100
+ return undefined;
103
101
  }
104
102
  return new window.PointerEvent(eventType, {
105
103
  screenX: 0,
@@ -113,13 +111,13 @@ var dispatchEvents = function (eventData, done) {
113
111
  bubbles: true,
114
112
  cancelable: true,
115
113
  composed: true,
116
- pointerType: "mouse",
114
+ pointerType: 'mouse',
117
115
  isPrimary: true,
118
116
  });
119
117
  }
120
118
 
121
119
  function createFocusEvent(userEvent) {
122
- var event = document.createEvent("FocusEvent");
120
+ const event = document.createEvent('FocusEvent');
123
121
  // TODO we want to use new Event, but mootools (used by zuora which is used by jfrog)
124
122
  // overrides window.Event and throws an error
125
123
  event.initEvent(userEvent.event, true, false);
@@ -127,76 +125,74 @@ var dispatchEvents = function (eventData, done) {
127
125
  }
128
126
 
129
127
  function createEvent(userEvent) {
130
- var eventType = userEvent.event;
131
- var event = document.createEvent("HTMLEvents");
128
+ const eventType = userEvent.event;
129
+ const event = document.createEvent('HTMLEvents');
132
130
  event.initEvent(eventType, true, false);
133
131
  return event;
134
132
  }
135
133
 
136
- function dispatchSyncEvent(event) {
137
- console.log("dispatching: " + event.type);
138
- console.log(event);
139
-
140
- context.element.dispatchEvent(event);
141
- handleReactSelectFocusQuirk(context, event);
142
- handleCKEditorQuirk(context, event);
143
- }
144
-
145
134
  function dispatchSyncEventSequence() {
146
135
  context.events
147
- .map(function (userEvent) {
136
+ .map((userEvent) => {
148
137
  try {
149
- if(MOUSE_EVENTS.includes(userEvent.event)) {
138
+ if (MOUSE_EVENTS.includes(userEvent.event)) {
150
139
  return createMouseEvent(userEvent);
151
- } else if (POINTER_EVENTS.includes(userEvent.event)) {
140
+ } if (POINTER_EVENTS.includes(userEvent.event)) {
152
141
  return createPointerEvent(userEvent);
153
- } else if(FOCUS_EVENTS.includes(userEvent.event)) {
142
+ } if (FOCUS_EVENTS.includes(userEvent.event)) {
154
143
  return createFocusEvent(userEvent);
155
- } else {
156
- return createEvent(userEvent);
157
144
  }
145
+ return createEvent(userEvent);
158
146
  } catch (e) {
159
- // pointer events not supported in ie11
160
- return;
147
+ // pointer events not supported :shrug:
148
+ return undefined;
161
149
  }
162
150
  })
163
151
  .filter(Boolean)
164
- .forEach(function (event) {
165
- dispatchSyncEvent(event);
152
+ .forEach((event) => {
153
+ // eslint-disable-next-line no-console
154
+ console.log(`dispatching: ${event.type}`);
155
+ // eslint-disable-next-line no-console
156
+ console.log(event);
157
+
158
+ context.element.dispatchEvent(event);
159
+ handleReactSelectFocusQuirk(context, event);
160
+ handleCKEditorQuirk(context, event);
166
161
  });
167
162
 
168
163
  if (window.__unloadNavigator) {
169
- window.removeEventListener("unload", window.__unloadNavigator);
164
+ window.removeEventListener('unload', window.__unloadNavigator);
170
165
  }
171
166
  }
172
167
 
173
168
  function findEffectiveActiveElement() {
174
- var activeElement = document.activeElement;
175
- while (activeElement.shadowRoot && activeElement.shadowRoot.activeElement) {
169
+ let activeElement = document.activeElement;
170
+ while (activeElement.shadowRoot?.activeElement) {
176
171
  activeElement = activeElement.shadowRoot.activeElement;
177
172
  }
178
173
  return activeElement;
179
174
  }
180
175
 
181
176
  function handleFocus() {
182
- var oldActiveElement = findEffectiveActiveElement();
183
- var quirks = context.quirks;
184
- var isReactSelectElement = quirks && quirks.isReactSelect;
185
- var isCKEditorFrame = quirks && quirks.isCKEditorFrame;
177
+ const oldActiveElement = findEffectiveActiveElement();
178
+ const quirks = context.quirks;
179
+ const isReactSelectElement = quirks?.isReactSelect;
180
+ const isCKEditorFrame = quirks?.isCKEditorFrame;
186
181
  if (!isReactSelectElement && !isCKEditorFrame) {
182
+ // eslint-disable-next-line no-undef
187
183
  dispatchFocus(eventData.elementToFocusLocatedElement, oldActiveElement);
188
184
  }
189
185
  }
190
186
 
191
187
  function handleSelect() {
192
- if(context.element.tagName !== OPTION_TAG_NAME) {
188
+ if (context.element.tagName !== OPTION_TAG_NAME) {
193
189
  return;
194
190
  }
195
191
 
196
- var selectEl;
197
- if(context.element.parentElement.tagName === SELECT_TAG_NAME) {
192
+ let selectEl;
193
+ if (context.element.parentElement.tagName === SELECT_TAG_NAME) {
198
194
  selectEl = context.element.parentElement;
199
- } else if(context.element.parentElement.parentElement.tagName === SELECT_TAG_NAME) {
195
+ } else if (context.element.parentElement.parentElement.tagName === SELECT_TAG_NAME) {
200
196
  selectEl = context.element.parentElement.parentElement;
201
197
  }
202
198
  selectEl.blur();
@@ -206,13 +202,13 @@ var dispatchEvents = function (eventData, done) {
206
202
 
207
203
  function fulfill(success, status, result) {
208
204
  result = result || {};
209
- var status = {
210
- success: success,
211
- status: status,
212
- result: result,
205
+ status = {
206
+ success,
207
+ status,
208
+ result,
213
209
  };
214
210
 
215
- if(isDoneFnSupplied) {
211
+ if (isDoneFnSupplied) {
216
212
  return done(status);
217
213
  }
218
214
 
@@ -227,35 +223,50 @@ var dispatchEvents = function (eventData, done) {
227
223
  return fulfill(false, 'failed', result);
228
224
  }
229
225
 
230
- var OPTION_TAG_NAME = "OPTION";
231
- var SELECT_TAG_NAME = "SELECT";
232
-
233
- var MOUSE_EVENTS = ["auxclick", "click", "contextmenu", "dblclick", "mousedown", "mouseenter", "mouseleave", "mousemove", "mouseover", "mouseout", "mouseup", "pointerlockchange", "pointerlockerror", "select", "wheel",];
234
- var POINTER_EVENTS = ["pointerover", "pointerenter", "pointerdown", "pointermove", "pointerup", "pointercancel", "pointerout", "pointerleave", "gotpointercapture", "lostpointercapture",];
235
- var FOCUS_EVENTS = ["focus", "blur", "focusin", "focusout",];
236
- var KEYBOARD_EVENTS = ["keydown", "keypress", "keyup",]; // future use
237
-
238
- var isEventConstructorSupported = typeof Event === 'function';
239
- var isDoneFnSupplied = typeof done !== 'undefined';
226
+ const OPTION_TAG_NAME = 'OPTION';
227
+ const SELECT_TAG_NAME = 'SELECT';
228
+
229
+ const MOUSE_EVENTS = [
230
+ 'auxclick',
231
+ 'click',
232
+ 'contextmenu',
233
+ 'dblclick',
234
+ 'mousedown',
235
+ 'mouseenter',
236
+ 'mouseleave',
237
+ 'mousemove',
238
+ 'mouseover',
239
+ 'mouseout',
240
+ 'mouseup',
241
+ 'pointerlockchange',
242
+ 'pointerlockerror',
243
+ 'select',
244
+ 'wheel',
245
+ ];
246
+ const POINTER_EVENTS = ['pointerover', 'pointerenter', 'pointerdown', 'pointermove', 'pointerup', 'pointercancel', 'pointerout', 'pointerleave', 'gotpointercapture', 'lostpointercapture'];
247
+ const FOCUS_EVENTS = ['focus', 'blur', 'focusin', 'focusout'];
248
+
249
+ const isDoneFnSupplied = typeof done !== 'undefined';
240
250
 
241
251
  window.__unloadNavigator = resolve;
242
- window.addEventListener("unload", window.__unloadNavigator);
252
+ window.addEventListener('unload', window.__unloadNavigator);
243
253
 
244
- var element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
254
+ // eslint-disable-next-line no-undef
255
+ const element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
245
256
  if (!element) {
246
- return reject("element not found");
257
+ return reject('element not found');
247
258
  }
248
259
 
249
- var context = {
250
- element: element,
260
+ const context = {
261
+ element,
251
262
  events: eventData.events,
252
263
  quirks: eventData.quirks,
253
264
  modifiers: eventData.modifiers,
254
265
  };
255
266
 
256
267
  try {
257
- var doMousePreparation = eventData.withMousePreparation ? eventData.withMousePreparation : true;
258
- if(doMousePreparation) {
268
+ const doMousePreparation = eventData.withMousePreparation ? eventData.withMousePreparation : true;
269
+ if (doMousePreparation) {
259
270
  dispatchMouseOver();
260
271
  dispatchMouseMove();
261
272
  }
@@ -2,42 +2,40 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- var doClick = function (eventData, done) {
6
- var eventConstructorSupported = typeof Event === 'function';
5
+ const doClick = (eventData, done) => {
6
+ const eventConstructorSupported = typeof Event === 'function';
7
7
 
8
8
  window.__unloadNavigator = resolve;
9
9
 
10
- window.addEventListener("unload", window.__unloadNavigator);
10
+ window.addEventListener('unload', window.__unloadNavigator);
11
11
 
12
12
  function handleReactSelectFocusQuirk(context, event) {
13
13
  function focusReactSelect(element) {
14
-
15
- function getReactSelectRoot(element) {
16
- return getParents(element).filter(function (el) {
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(element) {
22
- var root = getReactSelectRoot(element);
23
- return root ? root.querySelector("INPUT") : null;
19
+ function getReactSelectInput(_element) {
20
+ const root = getReactSelectRoot(_element);
21
+ return root ? root.querySelector('INPUT') : null;
24
22
  }
25
23
 
26
- var reactSelectInput = getReactSelectInput(element);
24
+ const reactSelectInput = getReactSelectInput(element);
27
25
  if (reactSelectInput) {
28
26
  reactSelectInput.focus();
29
27
  }
30
28
  }
31
29
 
32
- var isReactSelectElement = context.quirks && context.quirks.isReactSelect;
33
- if (event.type === "mousedown" && isReactSelectElement) {
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
- var isCKEditorFrame = context.quirks && context.quirks.isCKEditorFrame;
40
- if (event.type === "click" && isCKEditorFrame) {
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
- var status = {
48
+ const status = {
51
49
  status: 'done',
52
- result: result,
53
- success: true
50
+ result,
51
+ success: true,
54
52
  };
55
53
  if (context.isNonTextableElemnet) {
56
- status.reason = "Set text on non input element";
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
- var status = {
62
+ const status = {
65
63
  status: 'failed',
66
- result: 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
- var event = eventConstructorSupported ? new Event("mouseover", { composed: true }) : document.createEvent('Events');
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
- var modifiers = {};
81
- var rect = element.getBoundingClientRect();
82
- var clientX = rect.left + (rect.width / 2);
83
- var clientY = rect.top + (rect.height / 2);
84
- var button = 0;
85
- var eventType = 'mousemove';
86
- var event = createMouseEvent(eventType, modifiers, clientX, clientY, button);
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
- var pointerPosition = userEvent.pointerPosition || {};
96
- var rect = element.getBoundingClientRect();
97
- var clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
98
- var clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
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: clientX,
107
- clientY: 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
- var eventProperties = getEventDictionary(modifiers, clientX, clientY);
123
- eventProperties.pointerType = "mouse";
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
- var event = eventConstructorSupported ? new MouseEvent("click", { composed: true }) : document.createEvent("MouseEvents");
127
+ const event = eventConstructorSupported ? new MouseEvent('click', { composed: true }) : document.createEvent('MouseEvents');
130
128
  event.initMouseEvent(
131
129
  eventType,
132
- true, /* bubbles */
133
- true, /* cancelable */
134
- document.defaultView, /* view */
135
- 1, /* detail */
136
- 0, /* screenX */
137
- 0, /* screenY */
138
- clientX, /* clientX */
139
- clientY, /* clientY */
140
- Boolean(modifiers.ctrl), /* ctrl */
141
- Boolean(modifiers.alt), /* alt */
142
- Boolean(modifiers.shift), /* shift */
143
- Boolean(modifiers.meta), /* meta */
144
- button, /* 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
- var pointerEvents = ["pointerup", "pointerdown", "pointermove"];
151
- var modifiers = context.modifiers || {};
152
- var pos = getEventPosition(userEvent, context.element);
153
- var button = context.button || 0;
154
- var eventType = userEvent.event;
155
- if (pointerEvents.indexOf(eventType) > -1) {
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
- var activeElement = document.activeElement;
169
- while (activeElement.shadowRoot && activeElement.shadowRoot.activeElement) {
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(function (userEvent) {
169
+ .map((userEvent) => {
178
170
  try {
179
171
  return getMouseEvent(userEvent, context);
180
172
  } catch (e) {
181
- // pointer events not supported in ie11
182
- return;
173
+ // pointer events not supported :shrug:
174
+ return undefined;
183
175
  }
184
176
  })
185
177
  .filter(Boolean)
186
- .forEach(function (event) {executeSyncEvent(event);});
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("unload", window.__unloadNavigator);
185
+ window.removeEventListener('unload', window.__unloadNavigator);
190
186
  }
191
187
  }
192
188
 
193
- var element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
189
+ const element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
190
+ // eslint-disable-next-line no-var
194
191
  var context = {
195
- element: 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
- return reject("element not found");
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
- var oldActiveElement = findEffectiveActiveElement();
211
- var quirks = context.quirks;
212
- var isReactSelectElement = quirks && quirks.isReactSelect;
213
- var isCKEditorFrame = quirks && quirks.isCKEditorFrame;
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
- return reject(e.toString());
217
+ reject(e.toString());
220
218
  }
221
219
  };
222
220