@testim/testim-cli 3.289.0 → 3.290.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.
Files changed (217) hide show
  1. package/cli.js +22390 -122
  2. package/cli.js.map +1 -0
  3. package/npm-shrinkwrap.json +1951 -203
  4. package/package.json +9 -5
  5. package/OverrideTestDataBuilder.js +0 -117
  6. package/agent/routers/cliJsCode/index.js +0 -13
  7. package/agent/routers/cliJsCode/router.js +0 -63
  8. package/agent/routers/cliJsCode/service.js +0 -705
  9. package/agent/routers/codim/router.js +0 -69
  10. package/agent/routers/codim/router.test.js +0 -60
  11. package/agent/routers/codim/service.js +0 -193
  12. package/agent/routers/general/index.js +0 -36
  13. package/agent/routers/hybrid/registerRoutes.js +0 -81
  14. package/agent/routers/index.js +0 -56
  15. package/agent/routers/playground/router.js +0 -77
  16. package/agent/routers/playground/service.js +0 -96
  17. package/agent/routers/standalone-browser/registerRoutes.js +0 -47
  18. package/agent/server.js +0 -150
  19. package/cdpTestRunner.js +0 -86
  20. package/chromiumInstaller.js +0 -91
  21. package/cli/isCiRun.js +0 -10
  22. package/cli/onExit.js +0 -65
  23. package/cli/writeStackTrace.js +0 -27
  24. package/cliAgentMode.js +0 -384
  25. package/codim/codim-cli.js +0 -91
  26. package/codim/codim-npm-package/index.ts +0 -427
  27. package/codim/codim-npm-package/package-lock.json +0 -14
  28. package/codim/codim-npm-package/package.json +0 -14
  29. package/codim/hybrid-utils.js +0 -28
  30. package/codim/measure-perf.js +0 -41
  31. package/codim/template.js/.idea/workspace.xml +0 -57
  32. package/codim/template.js/.vscode/launch.json +0 -53
  33. package/codim/template.ts/.idea/workspace.xml +0 -57
  34. package/codim/template.ts/.vscode/launch.json +0 -55
  35. package/commons/AbortError.js +0 -12
  36. package/commons/SeleniumPerfStats.js +0 -58
  37. package/commons/chrome-launcher.js +0 -15
  38. package/commons/chromedriverWrapper.js +0 -70
  39. package/commons/config.js +0 -39
  40. package/commons/constants.js +0 -67
  41. package/commons/detectDebugger.js +0 -19
  42. package/commons/featureAvailabilityService.js +0 -26
  43. package/commons/featureFlags.js +0 -132
  44. package/commons/getSessionPlayerRequire.js +0 -28
  45. package/commons/httpRequest.js +0 -261
  46. package/commons/httpRequestCounters.js +0 -98
  47. package/commons/httpRequestCounters.test.js +0 -38
  48. package/commons/initializeUserWithAuth.js +0 -55
  49. package/commons/lazyRequire.js +0 -105
  50. package/commons/logUtils.js +0 -15
  51. package/commons/logUtils.test.js +0 -21
  52. package/commons/logger.js +0 -178
  53. package/commons/mockNetworkRuleFileSchema.json +0 -140
  54. package/commons/npmWrapper.js +0 -174
  55. package/commons/npmWrapper.test.js +0 -374
  56. package/commons/performance-logger.js +0 -71
  57. package/commons/preloadTests.js +0 -29
  58. package/commons/prepareRunner.js +0 -85
  59. package/commons/prepareRunner.test.js +0 -144
  60. package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
  61. package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
  62. package/commons/requireWithFallback.js +0 -25
  63. package/commons/runnerFileCache.js +0 -204
  64. package/commons/socket/baseSocketServiceSocketIO.js +0 -197
  65. package/commons/socket/realDataService.js +0 -59
  66. package/commons/socket/realDataServiceSocketIO.js +0 -33
  67. package/commons/socket/remoteStepService.js +0 -55
  68. package/commons/socket/remoteStepServiceSocketIO.js +0 -61
  69. package/commons/socket/socketService.js +0 -175
  70. package/commons/socket/testResultService.js +0 -62
  71. package/commons/socket/testResultServiceSocketIO.js +0 -64
  72. package/commons/testimAnalytics.js +0 -40
  73. package/commons/testimCloudflare.js +0 -83
  74. package/commons/testimCloudflare.test.js +0 -185
  75. package/commons/testimCustomToken.js +0 -124
  76. package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
  77. package/commons/testimNgrok.js +0 -90
  78. package/commons/testimNgrok.test.js +0 -140
  79. package/commons/testimServicesApi.js +0 -631
  80. package/commons/testimTunnel.js +0 -73
  81. package/commons/testimTunnel.test.js +0 -172
  82. package/commons/xhr2.js +0 -897
  83. package/coverage/SummaryToObjectReport.js +0 -19
  84. package/coverage/jsCoverage.js +0 -252
  85. package/credentialsManager.js +0 -142
  86. package/errors.js +0 -161
  87. package/executionQueue.js +0 -37
  88. package/fixLocalBuild.js +0 -24
  89. package/inputFileUtils.js +0 -103
  90. package/lib/coralogix-winston.transport.js +0 -99
  91. package/player/SeleniumProtocolError.js +0 -100
  92. package/player/WebDriverHttpRequest.js +0 -177
  93. package/player/WebdriverioWebDriverApi.js +0 -671
  94. package/player/appiumTestPlayer.js +0 -90
  95. package/player/chromeLauncherTestPlayer.js +0 -67
  96. package/player/constants.js +0 -332
  97. package/player/extensionTestPlayer.js +0 -32
  98. package/player/findElementStrategy.js +0 -154
  99. package/player/scripts/isElementDisplayed.js +0 -252
  100. package/player/seleniumTestPlayer.js +0 -140
  101. package/player/services/frameLocator.js +0 -170
  102. package/player/services/mobileFrameLocatorMock.js +0 -32
  103. package/player/services/playbackTimeoutCalculator.js +0 -175
  104. package/player/services/portSelector.js +0 -19
  105. package/player/services/tabService.js +0 -551
  106. package/player/services/tabServiceMock.js +0 -167
  107. package/player/services/windowCreationListener.js +0 -8
  108. package/player/stepActions/RefreshStepAction.js +0 -16
  109. package/player/stepActions/apiStepAction.js +0 -89
  110. package/player/stepActions/baseCliJsStepAction.js +0 -51
  111. package/player/stepActions/baseJsStepAction.js +0 -277
  112. package/player/stepActions/cliConditionStepAction.js +0 -11
  113. package/player/stepActions/cliJsStepAction.js +0 -11
  114. package/player/stepActions/dropFileStepAction.js +0 -34
  115. package/player/stepActions/evaluateExpressionStepAction.js +0 -52
  116. package/player/stepActions/extensionOnlyStepAction.js +0 -12
  117. package/player/stepActions/extractTextStepAction.js +0 -19
  118. package/player/stepActions/hoverStepAction.js +0 -55
  119. package/player/stepActions/inputFileStepAction.js +0 -199
  120. package/player/stepActions/jsCodeStepAction.js +0 -11
  121. package/player/stepActions/jsConditionStepAction.js +0 -11
  122. package/player/stepActions/locateStepAction.js +0 -159
  123. package/player/stepActions/mouseStepAction.js +0 -370
  124. package/player/stepActions/navigationStepAction.js +0 -29
  125. package/player/stepActions/nodePackageStepAction.js +0 -47
  126. package/player/stepActions/pixelValidationStepAction.js +0 -39
  127. package/player/stepActions/scripts/dispatchEvents.js +0 -282
  128. package/player/stepActions/scripts/doClick.js +0 -221
  129. package/player/stepActions/scripts/doDragPath.js +0 -225
  130. package/player/stepActions/scripts/doubleClick.js +0 -119
  131. package/player/stepActions/scripts/dropEvent.js +0 -63
  132. package/player/stepActions/scripts/focusElement.js +0 -46
  133. package/player/stepActions/scripts/html5dragAction.js +0 -56
  134. package/player/stepActions/scripts/html5dragActionV2.js +0 -312
  135. package/player/stepActions/scripts/runCode.js +0 -147
  136. package/player/stepActions/scripts/scroll.js +0 -90
  137. package/player/stepActions/scripts/selectOption.js +0 -51
  138. package/player/stepActions/scripts/setText.js +0 -415
  139. package/player/stepActions/scripts/wheel.js +0 -61
  140. package/player/stepActions/scrollStepAction.js +0 -96
  141. package/player/stepActions/selectOptionStepAction.js +0 -49
  142. package/player/stepActions/sfdcRecordedStepAction.js +0 -24
  143. package/player/stepActions/sfdcStepAction.js +0 -28
  144. package/player/stepActions/sleepStepAction.js +0 -12
  145. package/player/stepActions/specialKeyStepAction.js +0 -52
  146. package/player/stepActions/stepAction.js +0 -73
  147. package/player/stepActions/stepActionRegistrar.js +0 -111
  148. package/player/stepActions/submitStepAction.js +0 -12
  149. package/player/stepActions/tdkHybridStepAction.js +0 -18
  150. package/player/stepActions/textStepAction.js +0 -110
  151. package/player/stepActions/textValidationStepAction.js +0 -64
  152. package/player/stepActions/wheelStepAction.js +0 -41
  153. package/player/utils/cookieUtils.js +0 -39
  154. package/player/utils/eyeSdkService.js +0 -250
  155. package/player/utils/imageCaptureUtils.js +0 -267
  156. package/player/utils/screenshotUtils.js +0 -68
  157. package/player/utils/stepActionUtils.js +0 -90
  158. package/player/utils/windowUtils.js +0 -195
  159. package/player/webDriverUtils.js +0 -40
  160. package/player/webDriverUtils.test.js +0 -116
  161. package/player/webdriver.js +0 -976
  162. package/polyfills/Array.prototype.at.js +0 -13
  163. package/polyfills/index.js +0 -13
  164. package/processHandler.js +0 -79
  165. package/processHandler.test.js +0 -55
  166. package/reports/chromeReporter.js +0 -17
  167. package/reports/consoleReporter.js +0 -190
  168. package/reports/debugReporter.js +0 -82
  169. package/reports/jsonReporter.js +0 -55
  170. package/reports/junitReporter.js +0 -183
  171. package/reports/reporter.js +0 -166
  172. package/reports/reporterUtils.js +0 -54
  173. package/reports/teamCityReporter.js +0 -73
  174. package/runOptions.d.ts +0 -305
  175. package/runOptions.js +0 -1288
  176. package/runOptionsAgentFlow.js +0 -87
  177. package/runOptionsUtils.js +0 -60
  178. package/runner.js +0 -355
  179. package/runners/ParallelWorkerManager.js +0 -284
  180. package/runners/TestPlanRunner.js +0 -419
  181. package/runners/buildCodeTests.js +0 -159
  182. package/runners/runnerUtils.js +0 -81
  183. package/services/analyticsService.js +0 -96
  184. package/services/branchService.js +0 -29
  185. package/services/gridService.js +0 -357
  186. package/services/gridService.test.js +0 -357
  187. package/services/labFeaturesService.js +0 -64
  188. package/services/lambdatestService.js +0 -227
  189. package/services/lambdatestService.test.js +0 -353
  190. package/services/localRCASaver.js +0 -124
  191. package/stepPlayers/cliJsStepPlayback.js +0 -40
  192. package/stepPlayers/hybridStepPlayback.js +0 -140
  193. package/stepPlayers/nodePackageStepPlayback.js +0 -28
  194. package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
  195. package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
  196. package/stepPlayers/remoteStepPlayback.js +0 -80
  197. package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
  198. package/stepPlayers/tdkHybridStepPlayback.js +0 -112
  199. package/testRunHandler.js +0 -603
  200. package/testRunStatus.js +0 -567
  201. package/testimNpmDriver.js +0 -52
  202. package/utils/argsUtils.js +0 -91
  203. package/utils/argsUtils.test.js +0 -32
  204. package/utils/fsUtils.js +0 -174
  205. package/utils/index.js +0 -197
  206. package/utils/promiseUtils.js +0 -85
  207. package/utils/stringUtils.js +0 -98
  208. package/utils/stringUtils.test.js +0 -22
  209. package/utils/timeUtils.js +0 -25
  210. package/utils/utils.test.js +0 -27
  211. package/workers/BaseWorker.js +0 -498
  212. package/workers/BaseWorker.test.js +0 -186
  213. package/workers/WorkerAppium.js +0 -180
  214. package/workers/WorkerExtension.js +0 -192
  215. package/workers/WorkerExtensionSingleBrowser.js +0 -77
  216. package/workers/WorkerSelenium.js +0 -253
  217. package/workers/workerUtils.js +0 -20
@@ -1,225 +0,0 @@
1
- 'use strict';
2
-
3
-
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
-
9
- window.__unloadNavigator = resolve;
10
-
11
- window.addEventListener('unload', window.__unloadNavigator);
12
-
13
- function resolve(result) {
14
- const status = {
15
- status: 'done',
16
- result,
17
- success: true,
18
- };
19
- done(status);
20
- }
21
-
22
- function reject(result) {
23
- result = result || {};
24
- const status = {
25
- status: 'failed',
26
- result,
27
- success: false,
28
- };
29
-
30
- done(status);
31
- }
32
-
33
- function dispatchMouseOver(element) {
34
- const event = eventConstructorSupported ? new Event('mouseover', { composed: true }) : document.createEvent('Events');
35
- event.initEvent('mouseover', true, true);
36
-
37
- element.dispatchEvent(event);
38
- }
39
-
40
- function dispatchMouseMove(element) {
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
-
49
- element.dispatchEvent(event);
50
- }
51
-
52
- function getEventPosition(userEvent, element) {
53
- function isWithinBounds(start, end, point) {
54
- return (point > start) && (point < end);
55
- }
56
-
57
- const pointerPosition = userEvent.pointerPosition || {};
58
- if (context.isDrag) {
59
- return { x: pointerPosition.originX || 0, y: pointerPosition.originY || 0 };
60
- }
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
- }
66
-
67
- function getEventDictionary(modifiers, clientX, clientY) {
68
- return {
69
- screenX: 0,
70
- screenY: 0,
71
- clientX,
72
- clientY,
73
- ctrlKey: Boolean(modifiers.ctrl),
74
- altKey: Boolean(modifiers.alt),
75
- shiftKey: Boolean(modifiers.shift),
76
- metaKey: Boolean(modifiers.meta),
77
- bubbles: true,
78
- cancelable: true,
79
- composed: true,
80
- };
81
- }
82
-
83
- function createPointerEvent(eventType, modifiers, clientX, clientY, button) {
84
- if (pointerEventConstructorSupported) {
85
- const eventProperties = getEventDictionary(modifiers, clientX, clientY);
86
- eventProperties.pointerType = 'mouse';
87
- eventProperties.isPrimary = true;
88
- return new window.PointerEvent(eventType, eventProperties);
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;
122
- }
123
-
124
- function createMouseEvent(eventType, modifiers, clientX, clientY, button) {
125
- const event = eventConstructorSupported ? new MouseEvent('click', { composed: true }) : document.createEvent('MouseEvents');
126
- event.initMouseEvent(
127
- eventType,
128
- true, /* bubbles */
129
- true, /* cancelable */
130
- document.defaultView, /* view */
131
- 1, /* detail */
132
- 0, /* screenX */
133
- 0, /* screenY */
134
- clientX, /* clientX */
135
- clientY, /* clientY */
136
- Boolean(modifiers.ctrl), /* ctrl */
137
- Boolean(modifiers.alt), /* alt */
138
- Boolean(modifiers.shift), /* shift */
139
- Boolean(modifiers.meta), /* meta */
140
- button, /* button */
141
- document.body ? document.body.parentNode : document.documentElement);
142
- return event;
143
- }
144
-
145
- function getMouseEvent(userEvent, context) {
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)) {
152
- return createPointerEvent(eventType, modifiers, pos.x, pos.y, button);
153
- }
154
- return createMouseEvent(eventType, modifiers, pos.x, pos.y, button);
155
- }
156
-
157
- function shouldSkipEvent(currentEvent, context) {
158
- function isClickInDragAndDrop() {
159
- return currentEvent.event === 'click' &&
160
- context.isDrag &&
161
- !context.allEventsOnSameElement;
162
- }
163
- return isClickInDragAndDrop();
164
- }
165
-
166
- function executeAsyncNextEventRecursive(index, context, done) {
167
- try {
168
- const event = getMouseEvent(context.events[index], context);
169
- if (!shouldSkipEvent(event, context)) {
170
- context.element.dispatchEvent(event);
171
- }
172
- } catch (ignore) { /* ignored */ }
173
-
174
- if (index + 1 === context.events.length) {
175
- done();
176
- } else {
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);
180
- }, delay);
181
- }
182
- }
183
-
184
- function executeAsyncEventSequence(context, done) {
185
- executeAsyncNextEventRecursive(0, context, () => {
186
- if (window.__unloadNavigator) {
187
- window.removeEventListener('unload', window.__unloadNavigator);
188
- }
189
- done();
190
- });
191
- }
192
-
193
- // eslint-disable-next-line no-undef
194
- const element = eventData.isRoot ? document.documentElement : getLocatedElement(eventData.locatedElement);
195
-
196
- const context = {
197
- eventIndex: 0,
198
- element,
199
- events: eventData.events,
200
- eventType: eventData.eventType,
201
- eventData: eventData.eventData,
202
- stepId: eventData.id,
203
- testResultId: eventData.testResultId,
204
- quirks: eventData.quirks,
205
- isDoubleClick: eventData.isDoubleClick,
206
- isDrag: eventData.isDrag,
207
- useRecordedMousedown: eventData.useRecordedMousedown,
208
- trackActiveElement: eventData.trackActiveElement,
209
- allEventsOnSameElement: eventData.allEventsOnSameElement,
210
- };
211
-
212
- if (!context.element) {
213
- reject('element not found');
214
- return;
215
- }
216
-
217
- dispatchMouseOver(context.element);
218
- dispatchMouseMove(context.element);
219
-
220
- executeAsyncEventSequence(context, () => {
221
- resolve();
222
- });
223
- };
224
-
225
- module.exports = doDragPath;
@@ -1,119 +0,0 @@
1
- /* global getLocatedElement, dispatchFocus */
2
-
3
- const doubleClick = function (eventData, done) {
4
- const POINTER_EVENTS = ['pointerup', 'pointerdown', 'pointermove'];
5
- const element = getLocatedElement(eventData.locatedElement);
6
-
7
- if (!element) {
8
- throw new Error('element not found');
9
- }
10
- const events = eventData.events;
11
-
12
- const successObject = {
13
- status: 'done',
14
- success: true,
15
- };
16
-
17
- window.__unloadNavigator = function () { done(successObject); };
18
-
19
- const getEventPosition = function (userEvent) {
20
- function isWithinBounds(start, end, point) {
21
- return (point > start) && (point < end);
22
- }
23
-
24
- const pointerPosition = userEvent.pointerPosition || {};
25
- const rect = element.getBoundingClientRect();
26
- const clientX = pointerPosition.originX && isWithinBounds(rect.left, rect.left + rect.width, pointerPosition.originX) ? pointerPosition.originX : rect.left + (rect.width / 2);
27
- const clientY = pointerPosition.originY && isWithinBounds(rect.top, rect.top + rect.height, pointerPosition.originY) ? pointerPosition.originY : rect.top + (rect.height / 2);
28
- return { x: clientX, y: clientY };
29
- };
30
-
31
- const getPointerEventDictionary = function (clientX, clientY) {
32
- return {
33
- screenX: 0,
34
- screenY: 0,
35
- clientX,
36
- clientY,
37
- ctrlKey: false,
38
- altKey: false,
39
- shiftKey: false,
40
- metaKey: false,
41
- bubbles: true,
42
- cancelable: true,
43
- button: 0,
44
- pointerType: 'mouse',
45
- isPrimary: true,
46
- };
47
- };
48
-
49
- const createPointerEvent = function (eventType, clientX, clientY) {
50
- if (!window.PointerEvent) {
51
- return undefined;
52
- }
53
- const eventProperties = getPointerEventDictionary(clientX, clientY);
54
- return new window.PointerEvent(eventType, eventProperties);
55
- };
56
-
57
- const createMouseEvent = function (eventType, clientX, clientY) {
58
- const event = document.createEvent('MouseEvents');
59
- event.initMouseEvent(
60
- eventType,
61
- true, /* bubbles */
62
- true, /* cancelable */
63
- document.defaultView, /* view */
64
- 1, /* detail */
65
- 0, /* screenX */
66
- 0, /* screenY */
67
- clientX, /* clientX */
68
- clientY, /* clientY */
69
- false, /* ctrl */
70
- false, /* alt */
71
- false, /* shift */
72
- false, /* meta */
73
- 0, /* button */
74
- document.body ? document.body.parentNode : document.documentElement);
75
- return event;
76
- };
77
-
78
- const findEffectiveActiveElement = function () {
79
- let activeElement = document.activeElement;
80
- while (activeElement.shadowRoot?.activeElement) {
81
- activeElement = activeElement.shadowRoot.activeElement;
82
- }
83
- return activeElement;
84
- };
85
-
86
- const getEvent = function (userEventData) {
87
- const pos = getEventPosition(userEventData);
88
- const eventType = userEventData.event;
89
- if (POINTER_EVENTS.includes(eventType)) {
90
- return createPointerEvent(eventType, pos.x, pos.y);
91
- }
92
- return createMouseEvent(eventType, pos.x, pos.y);
93
- };
94
- try {
95
- events
96
- .map((userEventData) => getEvent(userEventData))
97
- .filter(Boolean)
98
- .forEach((event) => element.dispatchEvent(event));
99
- const oldActiveElement = findEffectiveActiveElement();
100
- dispatchFocus(eventData.elementToFocusLocatedElement, oldActiveElement);
101
- if (window.__unloadNavigator) {
102
- window.removeEventListener('unload', window.__unloadNavigator);
103
- window.__unloadNavigator = null;
104
- }
105
- done(successObject);
106
- } catch (e) {
107
- if (window.__unloadNavigator) {
108
- window.removeEventListener('unload', window.__unloadNavigator);
109
- window.__unloadNavigator = null;
110
- }
111
- done({
112
- status: 'done',
113
- result: e.toString(),
114
- success: false,
115
- });
116
- }
117
- };
118
-
119
- module.exports = doubleClick;
@@ -1,63 +0,0 @@
1
- /* global getLocatedElement, createDropEvent */
2
-
3
- 'use strict';
4
-
5
- const downloadFileAndFireDropEvent = function (locatedElement, fileUrls) {
6
- // eslint-disable-next-line no-undef
7
- const element = getLocatedElement(locatedElement);
8
-
9
- if (!element) {
10
- throw new Error('element not found');
11
- }
12
-
13
- function simpleBarrier() {
14
- let callbackIndex = -1;
15
- let doneCallbacks = 0;
16
- const results = [];
17
- const instance = {
18
- waitOn() {
19
- const curIndex = ++callbackIndex;
20
- return function (result) {
21
- if (curIndex in results) {
22
- return;
23
- }
24
- results[curIndex] = result;
25
- doneCallbacks++;
26
- if (fileUrls.length === doneCallbacks) {
27
- instance.endWithCallback(results);
28
- }
29
- };
30
- },
31
- endWith(fn) { instance.endWithCallback = fn; },
32
- };
33
- return instance;
34
- }
35
-
36
- function getBlob(url, name, cb) {
37
- const xhr = new XMLHttpRequest();
38
- xhr.open('GET', url);
39
- xhr.responseType = 'blob';
40
- xhr.onload = function () {
41
- if (this.status >= 200 && this.status < 300) {
42
- cb({ blob: xhr.response, name });
43
- } else {
44
- throw new Error('Failed to load blob response code is not between 200 - 300');
45
- }
46
- };
47
- xhr.onerror = function () {
48
- throw new Error('Failed to load blob');
49
- };
50
- xhr.send();
51
- }
52
-
53
- const barrier = simpleBarrier();
54
- fileUrls.forEach((fileUrl) => {
55
- getBlob(fileUrl.url, fileUrl.name, barrier.waitOn());
56
- });
57
- barrier.endWith((blobs) => {
58
- const event = createDropEvent(blobs);
59
- element.dispatchEvent(event);
60
- });
61
- };
62
-
63
- module.exports = downloadFileAndFireDropEvent;
@@ -1,46 +0,0 @@
1
- module.exports = function dispatchFocus(targetElement, oldActiveElement) {
2
- function createFocusEvent(eventName) {
3
- const event = document.createEvent('HTMLEvents');
4
- // TODO we want to use new Event, but mootools (used by zuora which is used by jfrog)
5
- // overrides window.Event and throws an error
6
- event.initEvent(eventName, true, false);
7
- return event;
8
- }
9
-
10
- function findEffectiveActiveElement() {
11
- let activeElement = document.activeElement;
12
- while (activeElement.shadowRoot?.activeElement) {
13
- activeElement = activeElement.shadowRoot.activeElement;
14
- }
15
- return activeElement;
16
- }
17
-
18
- function setFocus(element, oldActiveElement) {
19
- if (oldActiveElement) {
20
- oldActiveElement.dispatchEvent(createFocusEvent('focusout'));
21
- oldActiveElement.dispatchEvent(createFocusEvent('blur'));
22
- }
23
- element.dispatchEvent(createFocusEvent('focusin'));
24
- element.dispatchEvent(createFocusEvent('focus'));
25
- if (typeof element.focus === 'function') {
26
- element.focus();
27
- }
28
- const currentActiveElement = findEffectiveActiveElement();
29
- if (oldActiveElement && currentActiveElement === oldActiveElement && typeof oldActiveElement.blur === 'function') {
30
- oldActiveElement.blur();
31
- }
32
- }
33
-
34
- if (targetElement) {
35
- const elementToFocus = getLocatedElement(targetElement);
36
- if (elementToFocus && (elementToFocus !== oldActiveElement)) {
37
- try {
38
- setFocus(elementToFocus, oldActiveElement);
39
- } catch (e) {
40
- // ignore
41
- }
42
- }
43
- } else if (oldActiveElement && typeof oldActiveElement.blur === 'function') {
44
- oldActiveElement.blur();
45
- }
46
- };
@@ -1,56 +0,0 @@
1
- /* global getLocatedElement */
2
-
3
- 'use strict';
4
-
5
- const html5dndAction = function (eventData) {
6
- const data = {};
7
- function convertType(type) {
8
- if (!type?.toLowerCase) {
9
- return type;
10
- }
11
- type = type.toLowerCase();
12
- if (type === 'text') {
13
- return 'text/plain';
14
- }
15
- if (type === 'url') {
16
- return 'text/uri-list';
17
- }
18
- return type;
19
- }
20
- const dataTransfer = {
21
- data: {
22
- },
23
- setData(type, val) {
24
- data[convertType(type)] = val;
25
- },
26
- getData(type) {
27
- return data[convertType(type)];
28
- },
29
- };
30
- const fromElement = getLocatedElement(eventData.fromLocatedElement);
31
- const toElement = getLocatedElement(eventData.toLocatedElement);
32
-
33
- if (!fromElement) {
34
- throw new Error('from element not found');
35
- }
36
-
37
- if (!toElement) {
38
- throw new Error('to element not found');
39
- }
40
-
41
- const dispatchEvent = function (element, type) {
42
- const event = document.createEvent('CustomEvent');
43
- event.initCustomEvent(type, true, true, null);
44
- event.dataTransfer = dataTransfer;
45
- if (element.dispatchEvent) {
46
- element.dispatchEvent(event);
47
- } else if (element.fireEvent) {
48
- element.fireEvent(`on${type}`, event);
49
- }
50
- };
51
- dispatchEvent(fromElement, 'dragstart');
52
- dispatchEvent(toElement, 'drop');
53
- dispatchEvent(fromElement, 'dragend');
54
- };
55
-
56
- module.exports = html5dndAction;