@testim/testim-cli 3.288.0 → 3.290.0-beta
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/cli.js +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +8 -29129
- package/package.json +16 -10
- package/OverrideTestDataBuilder.js +0 -117
- package/agent/routers/cliJsCode/index.js +0 -13
- package/agent/routers/cliJsCode/router.js +0 -63
- package/agent/routers/cliJsCode/service.js +0 -705
- package/agent/routers/codim/router.js +0 -69
- package/agent/routers/codim/router.test.js +0 -60
- package/agent/routers/codim/service.js +0 -193
- package/agent/routers/general/index.js +0 -36
- package/agent/routers/hybrid/registerRoutes.js +0 -81
- package/agent/routers/index.js +0 -56
- package/agent/routers/playground/router.js +0 -77
- package/agent/routers/playground/service.js +0 -96
- package/agent/routers/standalone-browser/registerRoutes.js +0 -47
- package/agent/server.js +0 -150
- package/cdpTestRunner.js +0 -86
- package/chromiumInstaller.js +0 -91
- package/cli/isCiRun.js +0 -10
- package/cli/onExit.js +0 -65
- package/cli/writeStackTrace.js +0 -27
- package/cliAgentMode.js +0 -384
- package/codim/codim-cli.js +0 -91
- package/codim/codim-npm-package/index.ts +0 -427
- package/codim/codim-npm-package/package-lock.json +0 -14
- package/codim/codim-npm-package/package.json +0 -14
- package/codim/hybrid-utils.js +0 -28
- package/codim/measure-perf.js +0 -41
- package/codim/template.js/.idea/workspace.xml +0 -57
- package/codim/template.js/.vscode/launch.json +0 -53
- package/codim/template.ts/.idea/workspace.xml +0 -57
- package/codim/template.ts/.vscode/launch.json +0 -55
- package/commons/AbortError.js +0 -12
- package/commons/SeleniumPerfStats.js +0 -58
- package/commons/chrome-launcher.js +0 -15
- package/commons/chromedriverWrapper.js +0 -70
- package/commons/config.js +0 -39
- package/commons/constants.js +0 -67
- package/commons/detectDebugger.js +0 -19
- package/commons/featureAvailabilityService.js +0 -26
- package/commons/featureFlags.js +0 -132
- package/commons/getSessionPlayerRequire.js +0 -28
- package/commons/httpRequest.js +0 -261
- package/commons/httpRequestCounters.js +0 -98
- package/commons/httpRequestCounters.test.js +0 -38
- package/commons/initializeUserWithAuth.js +0 -55
- package/commons/lazyRequire.js +0 -105
- package/commons/logUtils.js +0 -15
- package/commons/logUtils.test.js +0 -21
- package/commons/logger.js +0 -178
- package/commons/mockNetworkRuleFileSchema.json +0 -140
- package/commons/npmWrapper.js +0 -174
- package/commons/npmWrapper.test.js +0 -374
- package/commons/performance-logger.js +0 -71
- package/commons/preloadTests.js +0 -29
- package/commons/prepareRunner.js +0 -85
- package/commons/prepareRunner.test.js +0 -144
- package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
- package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
- package/commons/requireWithFallback.js +0 -25
- package/commons/runnerFileCache.js +0 -204
- package/commons/socket/baseSocketServiceSocketIO.js +0 -197
- package/commons/socket/realDataService.js +0 -59
- package/commons/socket/realDataServiceSocketIO.js +0 -33
- package/commons/socket/remoteStepService.js +0 -55
- package/commons/socket/remoteStepServiceSocketIO.js +0 -61
- package/commons/socket/socketService.js +0 -175
- package/commons/socket/testResultService.js +0 -62
- package/commons/socket/testResultServiceSocketIO.js +0 -64
- package/commons/testimAnalytics.js +0 -40
- package/commons/testimCloudflare.js +0 -83
- package/commons/testimCloudflare.test.js +0 -185
- package/commons/testimCustomToken.js +0 -124
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
- package/commons/testimNgrok.js +0 -90
- package/commons/testimNgrok.test.js +0 -140
- package/commons/testimServicesApi.js +0 -631
- package/commons/testimTunnel.js +0 -73
- package/commons/testimTunnel.test.js +0 -172
- package/commons/xhr2.js +0 -897
- package/coverage/SummaryToObjectReport.js +0 -19
- package/coverage/jsCoverage.js +0 -252
- package/credentialsManager.js +0 -142
- package/errors.js +0 -161
- package/executionQueue.js +0 -37
- package/fixLocalBuild.js +0 -24
- package/inputFileUtils.js +0 -103
- package/lib/coralogix-winston.transport.js +0 -99
- package/player/SeleniumProtocolError.js +0 -100
- package/player/WebDriverHttpRequest.js +0 -177
- package/player/WebdriverioWebDriverApi.js +0 -671
- package/player/appiumTestPlayer.js +0 -90
- package/player/chromeLauncherTestPlayer.js +0 -67
- package/player/constants.js +0 -332
- package/player/extensionTestPlayer.js +0 -32
- package/player/findElementStrategy.js +0 -154
- package/player/scripts/isElementDisplayed.js +0 -252
- package/player/seleniumTestPlayer.js +0 -140
- package/player/services/frameLocator.js +0 -170
- package/player/services/mobileFrameLocatorMock.js +0 -32
- package/player/services/playbackTimeoutCalculator.js +0 -175
- package/player/services/portSelector.js +0 -19
- package/player/services/tabService.js +0 -551
- package/player/services/tabServiceMock.js +0 -167
- package/player/services/windowCreationListener.js +0 -8
- package/player/stepActions/RefreshStepAction.js +0 -16
- package/player/stepActions/apiStepAction.js +0 -89
- package/player/stepActions/baseCliJsStepAction.js +0 -51
- package/player/stepActions/baseJsStepAction.js +0 -277
- package/player/stepActions/cliConditionStepAction.js +0 -11
- package/player/stepActions/cliJsStepAction.js +0 -11
- package/player/stepActions/dropFileStepAction.js +0 -34
- package/player/stepActions/evaluateExpressionStepAction.js +0 -52
- package/player/stepActions/extensionOnlyStepAction.js +0 -12
- package/player/stepActions/extractTextStepAction.js +0 -19
- package/player/stepActions/hoverStepAction.js +0 -55
- package/player/stepActions/inputFileStepAction.js +0 -199
- package/player/stepActions/jsCodeStepAction.js +0 -11
- package/player/stepActions/jsConditionStepAction.js +0 -11
- package/player/stepActions/locateStepAction.js +0 -159
- package/player/stepActions/mouseStepAction.js +0 -370
- package/player/stepActions/navigationStepAction.js +0 -29
- package/player/stepActions/nodePackageStepAction.js +0 -47
- package/player/stepActions/pixelValidationStepAction.js +0 -39
- package/player/stepActions/scripts/dispatchEvents.js +0 -282
- package/player/stepActions/scripts/doClick.js +0 -221
- package/player/stepActions/scripts/doDragPath.js +0 -225
- package/player/stepActions/scripts/doubleClick.js +0 -119
- package/player/stepActions/scripts/dropEvent.js +0 -63
- package/player/stepActions/scripts/focusElement.js +0 -46
- package/player/stepActions/scripts/html5dragAction.js +0 -56
- package/player/stepActions/scripts/html5dragActionV2.js +0 -312
- package/player/stepActions/scripts/runCode.js +0 -147
- package/player/stepActions/scripts/scroll.js +0 -90
- package/player/stepActions/scripts/selectOption.js +0 -51
- package/player/stepActions/scripts/setText.js +0 -415
- package/player/stepActions/scripts/wheel.js +0 -61
- package/player/stepActions/scrollStepAction.js +0 -96
- package/player/stepActions/selectOptionStepAction.js +0 -49
- package/player/stepActions/sfdcRecordedStepAction.js +0 -24
- package/player/stepActions/sfdcStepAction.js +0 -28
- package/player/stepActions/sleepStepAction.js +0 -12
- package/player/stepActions/specialKeyStepAction.js +0 -52
- package/player/stepActions/stepAction.js +0 -73
- package/player/stepActions/stepActionRegistrar.js +0 -111
- package/player/stepActions/submitStepAction.js +0 -12
- package/player/stepActions/tdkHybridStepAction.js +0 -18
- package/player/stepActions/textStepAction.js +0 -110
- package/player/stepActions/textValidationStepAction.js +0 -64
- package/player/stepActions/wheelStepAction.js +0 -41
- package/player/utils/cookieUtils.js +0 -39
- package/player/utils/eyeSdkService.js +0 -250
- package/player/utils/imageCaptureUtils.js +0 -267
- package/player/utils/screenshotUtils.js +0 -68
- package/player/utils/stepActionUtils.js +0 -90
- package/player/utils/windowUtils.js +0 -195
- package/player/webDriverUtils.js +0 -40
- package/player/webDriverUtils.test.js +0 -116
- package/player/webdriver.js +0 -976
- package/polyfills/Array.prototype.at.js +0 -13
- package/polyfills/index.js +0 -9
- package/processHandler.js +0 -79
- package/processHandler.test.js +0 -55
- package/reports/chromeReporter.js +0 -17
- package/reports/consoleReporter.js +0 -190
- package/reports/debugReporter.js +0 -82
- package/reports/jsonReporter.js +0 -55
- package/reports/junitReporter.js +0 -183
- package/reports/reporter.js +0 -166
- package/reports/reporterUtils.js +0 -54
- package/reports/teamCityReporter.js +0 -73
- package/runOptions.d.ts +0 -305
- package/runOptions.js +0 -1288
- package/runOptionsAgentFlow.js +0 -87
- package/runOptionsUtils.js +0 -60
- package/runner.js +0 -355
- package/runners/ParallelWorkerManager.js +0 -284
- package/runners/TestPlanRunner.js +0 -419
- package/runners/buildCodeTests.js +0 -159
- package/runners/runnerUtils.js +0 -81
- package/services/analyticsService.js +0 -96
- package/services/branchService.js +0 -29
- package/services/gridService.js +0 -357
- package/services/gridService.test.js +0 -357
- package/services/labFeaturesService.js +0 -64
- package/services/lambdatestService.js +0 -227
- package/services/lambdatestService.test.js +0 -353
- package/services/localRCASaver.js +0 -124
- package/stepPlayers/cliJsStepPlayback.js +0 -40
- package/stepPlayers/hybridStepPlayback.js +0 -140
- package/stepPlayers/nodePackageStepPlayback.js +0 -28
- package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
- package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
- package/stepPlayers/remoteStepPlayback.js +0 -80
- package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
- package/stepPlayers/tdkHybridStepPlayback.js +0 -112
- package/testRunHandler.js +0 -603
- package/testRunStatus.js +0 -567
- package/testimNpmDriver.js +0 -52
- package/utils/argsUtils.js +0 -91
- package/utils/argsUtils.test.js +0 -32
- package/utils/fsUtils.js +0 -174
- package/utils/index.js +0 -197
- package/utils/promiseUtils.js +0 -85
- package/utils/stringUtils.js +0 -98
- package/utils/stringUtils.test.js +0 -22
- package/utils/timeUtils.js +0 -25
- package/utils/utils.test.js +0 -27
- package/workers/BaseWorker.js +0 -498
- package/workers/BaseWorker.test.js +0 -186
- package/workers/WorkerAppium.js +0 -180
- package/workers/WorkerExtension.js +0 -192
- package/workers/WorkerExtensionSingleBrowser.js +0 -77
- package/workers/WorkerSelenium.js +0 -253
- 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;
|