testcafe 2.0.2 → 2.1.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/CHANGELOG.md +20 -0
- package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/index.js +10 -17
- package/lib/cli/argument-parser/index.js +2 -1
- package/lib/cli/cli.js +3 -2
- package/lib/client/automation/index.js +281 -165
- package/lib/client/automation/index.min.js +1 -1
- package/lib/client/browser/idle-page/index.js +1 -1
- package/lib/client/core/index.js +340 -58
- package/lib/client/core/index.min.js +1 -1
- package/lib/client/driver/command-executors/client-functions/selector-executor/filter.js +5 -3
- package/lib/client/driver/command-executors/client-functions/selector-executor/utils.js +2 -17
- package/lib/client/driver/index.js +471 -525
- package/lib/client/driver/index.min.js +1 -1
- package/lib/client/ui/index.js +13 -76
- package/lib/client/ui/index.min.js +1 -1
- package/lib/configuration/default-values.js +3 -2
- package/lib/configuration/option-names.js +2 -1
- package/lib/configuration/testcafe-configuration.js +4 -1
- package/lib/errors/test-run/templates.js +7 -4
- package/lib/errors/types.js +2 -1
- package/lib/proxyless/request-pipeline/constants.js +2 -4
- package/lib/proxyless/request-pipeline/index.js +29 -5
- package/lib/proxyless/request-pipeline/safe-api.js +52 -0
- package/lib/proxyless/request-pipeline/special-handlers.js +7 -18
- package/lib/proxyless/resource-injector.js +14 -15
- package/lib/proxyless/types.js +1 -1
- package/lib/proxyless/utils/cdp.js +6 -2
- package/lib/services/compiler/host.js +1 -1
- package/lib/shared/errors/element-hidden-reasons.js +49 -0
- package/lib/shared/errors/index.js +17 -10
- package/lib/shared/errors/selector-error-ctor-callback.js +1 -1
- package/lib/test-run/commands/options.js +2 -1
- package/package.json +4 -4
- package/ts-defs/index.d.ts +1 -0
- package/lib/client/core/deps/hammerhead.js +0 -24
- package/lib/client/core/utils/array.js +0 -76
- package/lib/client/core/utils/dom.js +0 -459
- package/lib/client/core/utils/position.js +0 -246
- package/lib/client/core/utils/style.js +0 -98
- package/lib/client/core/utils/values/axis-values.js +0 -43
- package/lib/client/core/utils/values/boundary-values.js +0 -41
- package/lib/client/core/utils/values/dimensions.js +0 -17
- package/lib/client/driver/deps/testcafe-ui.js +0 -24
- package/lib/shared/errors/automation-errors.js +0 -8
|
@@ -68,7 +68,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
68
68
|
function step(op) {
|
|
69
69
|
if (f)
|
|
70
70
|
throw new TypeError("Generator is already executing.");
|
|
71
|
-
while (_)
|
|
71
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
72
72
|
try {
|
|
73
73
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
74
74
|
return t;
|
|
@@ -235,6 +235,64 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
235
235
|
removeRequestHooks: 'remove-request-hooks',
|
|
236
236
|
};
|
|
237
237
|
|
|
238
|
+
// -------------------------------------------------------------
|
|
239
|
+
function isCommandRejectableByPageError(command) {
|
|
240
|
+
return !isObservationCommand(command) && !isBrowserManipulationCommand(command) && !isServiceCommand(command) ||
|
|
241
|
+
isResizeWindowCommand(command)
|
|
242
|
+
&& !isWindowSwitchingCommand(command);
|
|
243
|
+
}
|
|
244
|
+
function isClientFunctionCommand(command) {
|
|
245
|
+
return command.type === COMMAND_TYPE.executeClientFunction ||
|
|
246
|
+
command.type === COMMAND_TYPE.executeSelector;
|
|
247
|
+
}
|
|
248
|
+
function isObservationCommand(command) {
|
|
249
|
+
return isClientFunctionCommand(command) ||
|
|
250
|
+
command.type === COMMAND_TYPE.wait ||
|
|
251
|
+
command.type === COMMAND_TYPE.assertion ||
|
|
252
|
+
command.type === COMMAND_TYPE.executeExpression;
|
|
253
|
+
}
|
|
254
|
+
function isWindowSwitchingCommand(command) {
|
|
255
|
+
return command.type === COMMAND_TYPE.switchToIframe || command.type === COMMAND_TYPE.switchToMainWindow;
|
|
256
|
+
}
|
|
257
|
+
function isScreenshotCommand(command) {
|
|
258
|
+
return command.type === COMMAND_TYPE.takeScreenshot ||
|
|
259
|
+
command.type === COMMAND_TYPE.takeElementScreenshot ||
|
|
260
|
+
command.type === COMMAND_TYPE.takeScreenshotOnFail;
|
|
261
|
+
}
|
|
262
|
+
function isResizeWindowCommand(command) {
|
|
263
|
+
return command.type === COMMAND_TYPE.resizeWindow ||
|
|
264
|
+
command.type === COMMAND_TYPE.resizeWindowToFitDevice ||
|
|
265
|
+
command.type === COMMAND_TYPE.maximizeWindow;
|
|
266
|
+
}
|
|
267
|
+
function isBrowserManipulationCommand(command) {
|
|
268
|
+
return isScreenshotCommand(command) || isResizeWindowCommand(command);
|
|
269
|
+
}
|
|
270
|
+
function isServiceCommand(command) {
|
|
271
|
+
return command.type === COMMAND_TYPE.testDone ||
|
|
272
|
+
command.type === COMMAND_TYPE.showAssertionRetriesStatus ||
|
|
273
|
+
command.type === COMMAND_TYPE.hideAssertionRetriesStatus ||
|
|
274
|
+
command.type === COMMAND_TYPE.setBreakpoint ||
|
|
275
|
+
command.type === COMMAND_TYPE.takeScreenshotOnFail ||
|
|
276
|
+
command.type === COMMAND_TYPE.recorder ||
|
|
277
|
+
command.type === COMMAND_TYPE.getProxyUrl;
|
|
278
|
+
}
|
|
279
|
+
function isExecutableInTopWindowOnly(command) {
|
|
280
|
+
return command.type === COMMAND_TYPE.testDone ||
|
|
281
|
+
command.type === COMMAND_TYPE.switchToMainWindow ||
|
|
282
|
+
command.type === COMMAND_TYPE.setNativeDialogHandler ||
|
|
283
|
+
command.type === COMMAND_TYPE.getNativeDialogHistory ||
|
|
284
|
+
command.type === COMMAND_TYPE.setTestSpeed ||
|
|
285
|
+
command.type === COMMAND_TYPE.showAssertionRetriesStatus ||
|
|
286
|
+
command.type === COMMAND_TYPE.hideAssertionRetriesStatus ||
|
|
287
|
+
command.type === COMMAND_TYPE.setBreakpoint ||
|
|
288
|
+
isBrowserManipulationCommand(command) && command.type !== COMMAND_TYPE.takeElementScreenshot;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
var STATUS_BAR_DEBUG_ACTION = {
|
|
292
|
+
step: 'step',
|
|
293
|
+
resume: 'resume',
|
|
294
|
+
};
|
|
295
|
+
|
|
238
296
|
// -------------------------------------------------------------
|
|
239
297
|
// WARNING: this file is used by both the client and the server.
|
|
240
298
|
// Do not use any browser or node-specific API!
|
|
@@ -337,64 +395,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
337
395
|
actionSkipJsErrorsArgumentError: 'E98',
|
|
338
396
|
actionFunctionOptionError: 'E99',
|
|
339
397
|
actionInvalidObjectPropertyError: 'E100',
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// -------------------------------------------------------------
|
|
343
|
-
function isCommandRejectableByPageError(command) {
|
|
344
|
-
return !isObservationCommand(command) && !isBrowserManipulationCommand(command) && !isServiceCommand(command) ||
|
|
345
|
-
isResizeWindowCommand(command)
|
|
346
|
-
&& !isWindowSwitchingCommand(command);
|
|
347
|
-
}
|
|
348
|
-
function isClientFunctionCommand(command) {
|
|
349
|
-
return command.type === COMMAND_TYPE.executeClientFunction ||
|
|
350
|
-
command.type === COMMAND_TYPE.executeSelector;
|
|
351
|
-
}
|
|
352
|
-
function isObservationCommand(command) {
|
|
353
|
-
return isClientFunctionCommand(command) ||
|
|
354
|
-
command.type === COMMAND_TYPE.wait ||
|
|
355
|
-
command.type === COMMAND_TYPE.assertion ||
|
|
356
|
-
command.type === COMMAND_TYPE.executeExpression;
|
|
357
|
-
}
|
|
358
|
-
function isWindowSwitchingCommand(command) {
|
|
359
|
-
return command.type === COMMAND_TYPE.switchToIframe || command.type === COMMAND_TYPE.switchToMainWindow;
|
|
360
|
-
}
|
|
361
|
-
function isScreenshotCommand(command) {
|
|
362
|
-
return command.type === COMMAND_TYPE.takeScreenshot ||
|
|
363
|
-
command.type === COMMAND_TYPE.takeElementScreenshot ||
|
|
364
|
-
command.type === COMMAND_TYPE.takeScreenshotOnFail;
|
|
365
|
-
}
|
|
366
|
-
function isResizeWindowCommand(command) {
|
|
367
|
-
return command.type === COMMAND_TYPE.resizeWindow ||
|
|
368
|
-
command.type === COMMAND_TYPE.resizeWindowToFitDevice ||
|
|
369
|
-
command.type === COMMAND_TYPE.maximizeWindow;
|
|
370
|
-
}
|
|
371
|
-
function isBrowserManipulationCommand(command) {
|
|
372
|
-
return isScreenshotCommand(command) || isResizeWindowCommand(command);
|
|
373
|
-
}
|
|
374
|
-
function isServiceCommand(command) {
|
|
375
|
-
return command.type === COMMAND_TYPE.testDone ||
|
|
376
|
-
command.type === COMMAND_TYPE.showAssertionRetriesStatus ||
|
|
377
|
-
command.type === COMMAND_TYPE.hideAssertionRetriesStatus ||
|
|
378
|
-
command.type === COMMAND_TYPE.setBreakpoint ||
|
|
379
|
-
command.type === COMMAND_TYPE.takeScreenshotOnFail ||
|
|
380
|
-
command.type === COMMAND_TYPE.recorder ||
|
|
381
|
-
command.type === COMMAND_TYPE.getProxyUrl;
|
|
382
|
-
}
|
|
383
|
-
function isExecutableInTopWindowOnly(command) {
|
|
384
|
-
return command.type === COMMAND_TYPE.testDone ||
|
|
385
|
-
command.type === COMMAND_TYPE.switchToMainWindow ||
|
|
386
|
-
command.type === COMMAND_TYPE.setNativeDialogHandler ||
|
|
387
|
-
command.type === COMMAND_TYPE.getNativeDialogHistory ||
|
|
388
|
-
command.type === COMMAND_TYPE.setTestSpeed ||
|
|
389
|
-
command.type === COMMAND_TYPE.showAssertionRetriesStatus ||
|
|
390
|
-
command.type === COMMAND_TYPE.hideAssertionRetriesStatus ||
|
|
391
|
-
command.type === COMMAND_TYPE.setBreakpoint ||
|
|
392
|
-
isBrowserManipulationCommand(command) && command.type !== COMMAND_TYPE.takeElementScreenshot;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
var STATUS_BAR_DEBUG_ACTION = {
|
|
396
|
-
step: 'step',
|
|
397
|
-
resume: 'resume',
|
|
398
|
+
actionElementIsNotTargetError: 'E101',
|
|
398
399
|
};
|
|
399
400
|
|
|
400
401
|
// Base
|
|
@@ -442,10 +443,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
442
443
|
var SelectorErrorBase = /** @class */ (function (_super) {
|
|
443
444
|
__extends(SelectorErrorBase, _super);
|
|
444
445
|
function SelectorErrorBase(code, _a, callsite) {
|
|
445
|
-
var apiFnChain =
|
|
446
|
+
var _b = _a === void 0 ? {} : _a, apiFnChain = _b.apiFnChain, apiFnIndex = _b.apiFnIndex, reason = _b.reason;
|
|
446
447
|
var _this = _super.call(this, code, callsite) || this;
|
|
447
448
|
_this.apiFnChain = apiFnChain;
|
|
448
449
|
_this.apiFnIndex = apiFnIndex;
|
|
450
|
+
_this.reason = reason;
|
|
449
451
|
return _this;
|
|
450
452
|
}
|
|
451
453
|
return SelectorErrorBase;
|
|
@@ -626,11 +628,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
626
628
|
}(SelectorErrorBase));
|
|
627
629
|
var ActionElementIsInvisibleError = /** @class */ (function (_super) {
|
|
628
630
|
__extends(ActionElementIsInvisibleError, _super);
|
|
629
|
-
function ActionElementIsInvisibleError(callsite) {
|
|
630
|
-
return _super.call(this, TEST_RUN_ERRORS.actionElementIsInvisibleError, callsite) || this;
|
|
631
|
+
function ActionElementIsInvisibleError(callsite, apiFnArgs) {
|
|
632
|
+
return _super.call(this, TEST_RUN_ERRORS.actionElementIsInvisibleError, apiFnArgs, callsite) || this;
|
|
631
633
|
}
|
|
632
634
|
return ActionElementIsInvisibleError;
|
|
633
|
-
}(
|
|
635
|
+
}(SelectorErrorBase));
|
|
634
636
|
var ActionSelectorMatchesWrongNodeTypeError = /** @class */ (function (_super) {
|
|
635
637
|
__extends(ActionSelectorMatchesWrongNodeTypeError, _super);
|
|
636
638
|
function ActionSelectorMatchesWrongNodeTypeError(nodeDescription) {
|
|
@@ -649,15 +651,22 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
649
651
|
}
|
|
650
652
|
return ActionAdditionalElementNotFoundError;
|
|
651
653
|
}(SelectorErrorBase));
|
|
654
|
+
var ActionElementIsNotTargetError = /** @class */ (function (_super) {
|
|
655
|
+
__extends(ActionElementIsNotTargetError, _super);
|
|
656
|
+
function ActionElementIsNotTargetError(callsite) {
|
|
657
|
+
return _super.call(this, TEST_RUN_ERRORS.actionElementIsNotTargetError, callsite) || this;
|
|
658
|
+
}
|
|
659
|
+
return ActionElementIsNotTargetError;
|
|
660
|
+
}(TestRunErrorBase));
|
|
652
661
|
var ActionAdditionalElementIsInvisibleError = /** @class */ (function (_super) {
|
|
653
662
|
__extends(ActionAdditionalElementIsInvisibleError, _super);
|
|
654
|
-
function ActionAdditionalElementIsInvisibleError(argumentName) {
|
|
655
|
-
var _this = _super.call(this, TEST_RUN_ERRORS.actionAdditionalElementIsInvisibleError) || this;
|
|
663
|
+
function ActionAdditionalElementIsInvisibleError(argumentName, apiFnArgs) {
|
|
664
|
+
var _this = _super.call(this, TEST_RUN_ERRORS.actionAdditionalElementIsInvisibleError, apiFnArgs) || this;
|
|
656
665
|
_this.argumentName = argumentName;
|
|
657
666
|
return _this;
|
|
658
667
|
}
|
|
659
668
|
return ActionAdditionalElementIsInvisibleError;
|
|
660
|
-
}(
|
|
669
|
+
}(SelectorErrorBase));
|
|
661
670
|
var ActionAdditionalSelectorMatchesWrongNodeTypeError = /** @class */ (function (_super) {
|
|
662
671
|
__extends(ActionAdditionalSelectorMatchesWrongNodeTypeError, _super);
|
|
663
672
|
function ActionAdditionalSelectorMatchesWrongNodeTypeError(argumentName, nodeDescription) {
|
|
@@ -941,6 +950,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
941
950
|
ActionElementIsInvisibleError: ActionElementIsInvisibleError,
|
|
942
951
|
ActionSelectorMatchesWrongNodeTypeError: ActionSelectorMatchesWrongNodeTypeError,
|
|
943
952
|
ActionAdditionalElementNotFoundError: ActionAdditionalElementNotFoundError,
|
|
953
|
+
ActionElementIsNotTargetError: ActionElementIsNotTargetError,
|
|
944
954
|
ActionAdditionalElementIsInvisibleError: ActionAdditionalElementIsInvisibleError,
|
|
945
955
|
ActionAdditionalSelectorMatchesWrongNodeTypeError: ActionAdditionalSelectorMatchesWrongNodeTypeError,
|
|
946
956
|
ActionElementNonEditableError: ActionElementNonEditableError,
|
|
@@ -1506,424 +1516,108 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
1506
1516
|
return replicator$1.addTransforms(transforms);
|
|
1507
1517
|
}
|
|
1508
1518
|
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
+
// @ts-ignore
|
|
1520
|
+
function isNodeCollection(obj) {
|
|
1521
|
+
return obj instanceof hammerhead.nativeMethods.HTMLCollection || obj instanceof hammerhead.nativeMethods.NodeList;
|
|
1522
|
+
}
|
|
1523
|
+
function castToArray(list) {
|
|
1524
|
+
var length = list.length;
|
|
1525
|
+
var result = [];
|
|
1526
|
+
for (var i = 0; i < length; i++)
|
|
1527
|
+
result.push(list[i]);
|
|
1528
|
+
return result;
|
|
1529
|
+
}
|
|
1530
|
+
function isArrayOfNodes(obj) {
|
|
1531
|
+
if (!hammerhead.nativeMethods.isArray(obj))
|
|
1532
|
+
return false;
|
|
1533
|
+
for (var i = 0; i < obj.length; i++) {
|
|
1534
|
+
// @ts-ignore
|
|
1535
|
+
if (!(obj[i] instanceof hammerhead.nativeMethods.Node))
|
|
1536
|
+
return false;
|
|
1519
1537
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1538
|
+
return true;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
var _a;
|
|
1542
|
+
var SELECTOR_FILTER_ERROR = {
|
|
1543
|
+
filterVisible: 1,
|
|
1544
|
+
filterHidden: 2,
|
|
1545
|
+
nth: 3,
|
|
1546
|
+
};
|
|
1547
|
+
var FILTER_ERROR_TO_API_RE = (_a = {},
|
|
1548
|
+
_a[SELECTOR_FILTER_ERROR.filterVisible] = /^\.filterVisible\(\)$/,
|
|
1549
|
+
_a[SELECTOR_FILTER_ERROR.filterHidden] = /^\.filterHidden\(\)$/,
|
|
1550
|
+
_a[SELECTOR_FILTER_ERROR.nth] = /^\.nth\(\d+\)$/,
|
|
1551
|
+
_a);
|
|
1552
|
+
var SelectorFilter = /** @class */ (function () {
|
|
1553
|
+
function SelectorFilter() {
|
|
1554
|
+
this._err = null;
|
|
1555
|
+
}
|
|
1556
|
+
Object.defineProperty(SelectorFilter.prototype, "error", {
|
|
1557
|
+
get: function () {
|
|
1558
|
+
return this._err;
|
|
1559
|
+
},
|
|
1560
|
+
set: function (message) {
|
|
1561
|
+
if (this._err === null)
|
|
1562
|
+
this._err = message;
|
|
1563
|
+
},
|
|
1564
|
+
enumerable: false,
|
|
1565
|
+
configurable: true
|
|
1566
|
+
});
|
|
1567
|
+
SelectorFilter.prototype.filter = function (nodes, options, apiInfo) {
|
|
1568
|
+
if (options.filterVisible) {
|
|
1569
|
+
nodes = nodes.filter(testcafeCore.positionUtils.isElementVisible);
|
|
1570
|
+
this._assertFilterError(nodes, apiInfo, SELECTOR_FILTER_ERROR.filterVisible);
|
|
1571
|
+
}
|
|
1572
|
+
if (options.filterHidden) {
|
|
1573
|
+
nodes = nodes.filter(function (n) { return !testcafeCore.positionUtils.isElementVisible(n); });
|
|
1574
|
+
this._assertFilterError(nodes, apiInfo, SELECTOR_FILTER_ERROR.filterHidden);
|
|
1575
|
+
}
|
|
1576
|
+
if (options.counterMode) {
|
|
1577
|
+
if (options.index === null)
|
|
1578
|
+
return nodes.length;
|
|
1579
|
+
return SelectorFilter._getNodeByIndex(nodes, options.index) ? 1 : 0;
|
|
1580
|
+
}
|
|
1581
|
+
if (options.collectionMode) {
|
|
1582
|
+
if (options.index !== null) {
|
|
1583
|
+
var nodeOnIndex_1 = SelectorFilter._getNodeByIndex(nodes, options.index);
|
|
1584
|
+
nodes = nodeOnIndex_1 ? [nodeOnIndex_1] : [];
|
|
1585
|
+
this._assertFilterError(nodes, apiInfo, SELECTOR_FILTER_ERROR.nth);
|
|
1586
|
+
}
|
|
1587
|
+
return nodes;
|
|
1588
|
+
}
|
|
1589
|
+
var nodeOnIndex = SelectorFilter._getNodeByIndex(nodes, options.index || 0);
|
|
1590
|
+
if (!nodeOnIndex)
|
|
1591
|
+
this.error = SelectorFilter._getErrorItem(apiInfo, SELECTOR_FILTER_ERROR.nth);
|
|
1592
|
+
return nodeOnIndex;
|
|
1522
1593
|
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1594
|
+
SelectorFilter.prototype.cast = function (searchResult) {
|
|
1595
|
+
if (searchResult === null || searchResult === void 0)
|
|
1596
|
+
return [];
|
|
1597
|
+
else if (searchResult instanceof hammerhead.nativeMethods.Node)
|
|
1598
|
+
return [searchResult];
|
|
1599
|
+
else if (isArrayOfNodes(searchResult))
|
|
1600
|
+
return searchResult;
|
|
1601
|
+
else if (isNodeCollection(searchResult))
|
|
1602
|
+
return castToArray(searchResult);
|
|
1603
|
+
throw new InvalidSelectorResultError();
|
|
1529
1604
|
};
|
|
1530
|
-
|
|
1531
|
-
if (
|
|
1532
|
-
this.
|
|
1533
|
-
this.left -= d.left;
|
|
1534
|
-
}
|
|
1535
|
-
this.bottom -= d.bottom;
|
|
1536
|
-
this.right -= d.right;
|
|
1537
|
-
return this;
|
|
1605
|
+
SelectorFilter.prototype._assertFilterError = function (filtered, apiInfo, filterError) {
|
|
1606
|
+
if (filtered.length === 0)
|
|
1607
|
+
this.error = SelectorFilter._getErrorItem(apiInfo, filterError);
|
|
1538
1608
|
};
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
if (
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1609
|
+
SelectorFilter._getErrorItem = function (_a, err) {
|
|
1610
|
+
var apiFnChain = _a.apiFnChain, apiFnID = _a.apiFnID;
|
|
1611
|
+
if (err) {
|
|
1612
|
+
for (var i = apiFnID; i < apiFnChain.length; i++) {
|
|
1613
|
+
if (FILTER_ERROR_TO_API_RE[err].test(apiFnChain[i]))
|
|
1614
|
+
return i;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
return null;
|
|
1547
1618
|
};
|
|
1548
|
-
|
|
1549
|
-
return
|
|
1550
|
-
};
|
|
1551
|
-
return BoundaryValues;
|
|
1552
|
-
}());
|
|
1553
|
-
|
|
1554
|
-
var ARRAY_METHODS_PREFIX = 'array';
|
|
1555
|
-
function createNativeMethodWrapper(methodName) {
|
|
1556
|
-
var nativeMethodName = ARRAY_METHODS_PREFIX + methodName.charAt(0).toUpperCase() + methodName.slice(1);
|
|
1557
|
-
var nativeMethod = hammerhead.nativeMethods[nativeMethodName];
|
|
1558
|
-
return function () {
|
|
1559
|
-
var args = [];
|
|
1560
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1561
|
-
args[_i] = arguments[_i];
|
|
1562
|
-
}
|
|
1563
|
-
return nativeMethod.call.apply(nativeMethod, args);
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
var filter = createNativeMethodWrapper('filter');
|
|
1567
|
-
var map = createNativeMethodWrapper('map');
|
|
1568
|
-
var slice = createNativeMethodWrapper('slice');
|
|
1569
|
-
var splice = createNativeMethodWrapper('splice');
|
|
1570
|
-
var unshift = createNativeMethodWrapper('unshift');
|
|
1571
|
-
var forEach = createNativeMethodWrapper('forEach');
|
|
1572
|
-
var indexOf = createNativeMethodWrapper('indexOf');
|
|
1573
|
-
var some = createNativeMethodWrapper('some');
|
|
1574
|
-
var reverse = createNativeMethodWrapper('reverse');
|
|
1575
|
-
var reduce = createNativeMethodWrapper('reduce');
|
|
1576
|
-
var concat = createNativeMethodWrapper('concat');
|
|
1577
|
-
var join = createNativeMethodWrapper('join');
|
|
1578
|
-
|
|
1579
|
-
var browserUtils = hammerhead__default.utils.browser;
|
|
1580
|
-
var nativeMethods = hammerhead__default.nativeMethods;
|
|
1581
|
-
// NOTE: We have to retrieve styleUtils.get from hammerhead
|
|
1582
|
-
// to avoid circular dependencies between domUtils and styleUtils
|
|
1583
|
-
var getElementStyleProperty = hammerhead__default.utils.style.get;
|
|
1584
|
-
var getActiveElement = hammerhead__default.utils.dom.getActiveElement;
|
|
1585
|
-
var findDocument = hammerhead__default.utils.dom.findDocument;
|
|
1586
|
-
var find = hammerhead__default.utils.dom.find;
|
|
1587
|
-
var isElementInDocument = hammerhead__default.utils.dom.isElementInDocument;
|
|
1588
|
-
var isElementInIframe = hammerhead__default.utils.dom.isElementInIframe;
|
|
1589
|
-
var getIframeByElement = hammerhead__default.utils.dom.getIframeByElement;
|
|
1590
|
-
var isCrossDomainWindows = hammerhead__default.utils.dom.isCrossDomainWindows;
|
|
1591
|
-
var getSelectParent = hammerhead__default.utils.dom.getSelectParent;
|
|
1592
|
-
var getChildVisibleIndex = hammerhead__default.utils.dom.getChildVisibleIndex;
|
|
1593
|
-
var getSelectVisibleChildren = hammerhead__default.utils.dom.getSelectVisibleChildren;
|
|
1594
|
-
var isElementNode = hammerhead__default.utils.dom.isElementNode;
|
|
1595
|
-
var isTextNode = hammerhead__default.utils.dom.isTextNode;
|
|
1596
|
-
var isRenderedNode = hammerhead__default.utils.dom.isRenderedNode;
|
|
1597
|
-
var isIframeElement = hammerhead__default.utils.dom.isIframeElement;
|
|
1598
|
-
var isInputElement = hammerhead__default.utils.dom.isInputElement;
|
|
1599
|
-
var isButtonElement = hammerhead__default.utils.dom.isButtonElement;
|
|
1600
|
-
var isFileInput = hammerhead__default.utils.dom.isFileInput;
|
|
1601
|
-
var isTextAreaElement = hammerhead__default.utils.dom.isTextAreaElement;
|
|
1602
|
-
var isAnchorElement = hammerhead__default.utils.dom.isAnchorElement;
|
|
1603
|
-
var isImgElement = hammerhead__default.utils.dom.isImgElement;
|
|
1604
|
-
var isFormElement = hammerhead__default.utils.dom.isFormElement;
|
|
1605
|
-
var isLabelElement = hammerhead__default.utils.dom.isLabelElement;
|
|
1606
|
-
var isSelectElement = hammerhead__default.utils.dom.isSelectElement;
|
|
1607
|
-
var isRadioButtonElement = hammerhead__default.utils.dom.isRadioButtonElement;
|
|
1608
|
-
var isColorInputElement = hammerhead__default.utils.dom.isColorInputElement;
|
|
1609
|
-
var isCheckboxElement = hammerhead__default.utils.dom.isCheckboxElement;
|
|
1610
|
-
var isOptionElement = hammerhead__default.utils.dom.isOptionElement;
|
|
1611
|
-
var isSVGElement = hammerhead__default.utils.dom.isSVGElement;
|
|
1612
|
-
var isMapElement = hammerhead__default.utils.dom.isMapElement;
|
|
1613
|
-
var isBodyElement = hammerhead__default.utils.dom.isBodyElement;
|
|
1614
|
-
var isHtmlElement = hammerhead__default.utils.dom.isHtmlElement;
|
|
1615
|
-
var isDocument = hammerhead__default.utils.dom.isDocument;
|
|
1616
|
-
var isWindow = hammerhead__default.utils.dom.isWindow;
|
|
1617
|
-
var isTextEditableInput = hammerhead__default.utils.dom.isTextEditableInput;
|
|
1618
|
-
var isTextEditableElement = hammerhead__default.utils.dom.isTextEditableElement;
|
|
1619
|
-
var isTextEditableElementAndEditingAllowed = hammerhead__default.utils.dom.isTextEditableElementAndEditingAllowed;
|
|
1620
|
-
var isContentEditableElement = hammerhead__default.utils.dom.isContentEditableElement;
|
|
1621
|
-
var isDomElement = hammerhead__default.utils.dom.isDomElement;
|
|
1622
|
-
var isShadowUIElement = hammerhead__default.utils.dom.isShadowUIElement;
|
|
1623
|
-
var isShadowRoot = hammerhead__default.utils.dom.isShadowRoot;
|
|
1624
|
-
var isElementFocusable = hammerhead__default.utils.dom.isElementFocusable;
|
|
1625
|
-
var isHammerheadAttr = hammerhead__default.utils.dom.isHammerheadAttr;
|
|
1626
|
-
var isElementReadOnly = hammerhead__default.utils.dom.isElementReadOnly;
|
|
1627
|
-
var getScrollbarSize = hammerhead__default.utils.dom.getScrollbarSize;
|
|
1628
|
-
var getMapContainer = hammerhead__default.utils.dom.getMapContainer;
|
|
1629
|
-
var getTagName = hammerhead__default.utils.dom.getTagName;
|
|
1630
|
-
var closest = hammerhead__default.utils.dom.closest;
|
|
1631
|
-
var getParents = hammerhead__default.utils.dom.getParents;
|
|
1632
|
-
var findParent = hammerhead__default.utils.dom.findParent;
|
|
1633
|
-
var getTopSameDomainWindow = hammerhead__default.utils.dom.getTopSameDomainWindow;
|
|
1634
|
-
var getParentExceptShadowRoot = hammerhead__default.utils.dom.getParentExceptShadowRoot;
|
|
1635
|
-
|
|
1636
|
-
var styleUtils = hammerhead__default.utils.style;
|
|
1637
|
-
var getBordersWidth = hammerhead__default.utils.style.getBordersWidth;
|
|
1638
|
-
var getComputedStyle = hammerhead__default.utils.style.getComputedStyle;
|
|
1639
|
-
var getElementMargin = hammerhead__default.utils.style.getElementMargin;
|
|
1640
|
-
var getElementPadding = hammerhead__default.utils.style.getElementPadding;
|
|
1641
|
-
var getElementScroll = hammerhead__default.utils.style.getElementScroll;
|
|
1642
|
-
var getOptionHeight = hammerhead__default.utils.style.getOptionHeight;
|
|
1643
|
-
var getSelectElementSize = hammerhead__default.utils.style.getSelectElementSize;
|
|
1644
|
-
var isElementVisible = hammerhead__default.utils.style.isElementVisible;
|
|
1645
|
-
var isSelectVisibleChild = hammerhead__default.utils.style.isVisibleChild;
|
|
1646
|
-
var getWidth = hammerhead__default.utils.style.getWidth;
|
|
1647
|
-
var getHeight = hammerhead__default.utils.style.getHeight;
|
|
1648
|
-
var getInnerWidth = hammerhead__default.utils.style.getInnerWidth;
|
|
1649
|
-
var getInnerHeight = hammerhead__default.utils.style.getInnerHeight;
|
|
1650
|
-
var getScrollLeft = hammerhead__default.utils.style.getScrollLeft;
|
|
1651
|
-
var getScrollTop = hammerhead__default.utils.style.getScrollTop;
|
|
1652
|
-
var setScrollLeft = hammerhead__default.utils.style.setScrollLeft;
|
|
1653
|
-
var setScrollTop = hammerhead__default.utils.style.setScrollTop;
|
|
1654
|
-
var get = hammerhead__default.utils.style.get;
|
|
1655
|
-
function isVisibilityHiddenNode(node) {
|
|
1656
|
-
return !!findParent(node, true, function (ancestor) {
|
|
1657
|
-
return isElementNode(ancestor) && styleUtils.get(ancestor, 'visibility') === 'hidden';
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
function isHiddenNode(node) {
|
|
1661
|
-
return !!findParent(node, true, function (ancestor) {
|
|
1662
|
-
return isElementNode(ancestor) && styleUtils.get(ancestor, 'display') === 'none';
|
|
1663
|
-
});
|
|
1664
|
-
}
|
|
1665
|
-
function isNotVisibleNode(node) {
|
|
1666
|
-
return !isRenderedNode(node) || isHiddenNode(node) || isVisibilityHiddenNode(node);
|
|
1667
|
-
}
|
|
1668
|
-
function hasDimensions(el) {
|
|
1669
|
-
//NOTE: it's like jquery ':visible' selector (http://blog.jquery.com/2009/02/20/jquery-1-3-2-released/)
|
|
1670
|
-
return el && !(el.offsetHeight <= 0 && el.offsetWidth <= 0);
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
var AxisValues = /** @class */ (function () {
|
|
1674
|
-
function AxisValues(x, y) {
|
|
1675
|
-
this.x = x;
|
|
1676
|
-
this.y = y;
|
|
1677
|
-
}
|
|
1678
|
-
AxisValues.create = function (a) {
|
|
1679
|
-
if ('left' in a)
|
|
1680
|
-
return new AxisValues(a.left, a.top);
|
|
1681
|
-
else if ('right' in a)
|
|
1682
|
-
return new AxisValues(a.right, a.bottom);
|
|
1683
|
-
return new AxisValues(a.x, a.y);
|
|
1684
|
-
};
|
|
1685
|
-
AxisValues.prototype.add = function (p) {
|
|
1686
|
-
this.x += p.x;
|
|
1687
|
-
this.y += p.y;
|
|
1688
|
-
return this;
|
|
1689
|
-
};
|
|
1690
|
-
AxisValues.prototype.sub = function (p) {
|
|
1691
|
-
this.x -= p.x;
|
|
1692
|
-
this.y -= p.y;
|
|
1693
|
-
return this;
|
|
1694
|
-
};
|
|
1695
|
-
AxisValues.prototype.round = function (fn) {
|
|
1696
|
-
if (fn === void 0) { fn = Math.round; }
|
|
1697
|
-
this.x = fn(this.x);
|
|
1698
|
-
this.y = fn(this.y);
|
|
1699
|
-
return this;
|
|
1700
|
-
};
|
|
1701
|
-
AxisValues.prototype.eql = function (p) {
|
|
1702
|
-
return this.x === p.x && this.y === p.y;
|
|
1703
|
-
};
|
|
1704
|
-
AxisValues.prototype.mul = function (n) {
|
|
1705
|
-
this.x *= n;
|
|
1706
|
-
this.y *= n;
|
|
1707
|
-
return this;
|
|
1708
|
-
};
|
|
1709
|
-
AxisValues.prototype.distance = function (p) {
|
|
1710
|
-
return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
|
1711
|
-
};
|
|
1712
|
-
return AxisValues;
|
|
1713
|
-
}());
|
|
1714
|
-
|
|
1715
|
-
var Dimensions = /** @class */ (function () {
|
|
1716
|
-
function Dimensions(width, height, position, borders, elScroll, scrollbar) {
|
|
1717
|
-
this.width = width;
|
|
1718
|
-
this.height = height;
|
|
1719
|
-
this.left = position.x;
|
|
1720
|
-
this.top = position.y;
|
|
1721
|
-
this.right = position.x + width;
|
|
1722
|
-
this.bottom = position.y + height;
|
|
1723
|
-
this.border = borders;
|
|
1724
|
-
this.scrollbar = scrollbar;
|
|
1725
|
-
this.scroll = elScroll;
|
|
1726
|
-
}
|
|
1727
|
-
return Dimensions;
|
|
1728
|
-
}());
|
|
1729
|
-
|
|
1730
|
-
var getElementRectangle = hammerhead__default.utils.position.getElementRectangle;
|
|
1731
|
-
var getOffsetPosition = hammerhead__default.utils.position.getOffsetPosition;
|
|
1732
|
-
var offsetToClientCoords = hammerhead__default.utils.position.offsetToClientCoords;
|
|
1733
|
-
function getClientDimensions(target) {
|
|
1734
|
-
var isHtmlElement$1 = isHtmlElement(target);
|
|
1735
|
-
var body = isHtmlElement$1 ? target.getElementsByTagName('body')[0] : null;
|
|
1736
|
-
var elementRect = target.getBoundingClientRect();
|
|
1737
|
-
var elBorders = BoundaryValues.create(getBordersWidth(target));
|
|
1738
|
-
var elScroll = getElementScroll(target);
|
|
1739
|
-
var isElementInIframe$1 = isElementInIframe(target);
|
|
1740
|
-
var isCompatMode = target.ownerDocument.compatMode === 'BackCompat';
|
|
1741
|
-
var elPosition = isHtmlElement$1 ? new AxisValues(0, 0) : AxisValues.create(elementRect);
|
|
1742
|
-
var elHeight = elementRect.height;
|
|
1743
|
-
var elWidth = elementRect.width;
|
|
1744
|
-
if (isHtmlElement$1) {
|
|
1745
|
-
if (body && isCompatMode) {
|
|
1746
|
-
elHeight = body.clientHeight;
|
|
1747
|
-
elWidth = body.clientWidth;
|
|
1748
|
-
}
|
|
1749
|
-
else {
|
|
1750
|
-
elHeight = target.clientHeight;
|
|
1751
|
-
elWidth = target.clientWidth;
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
if (isElementInIframe$1) {
|
|
1755
|
-
var iframeElement = getIframeByElement(target);
|
|
1756
|
-
if (iframeElement) {
|
|
1757
|
-
var iframeOffset = getOffsetPosition(iframeElement);
|
|
1758
|
-
var clientOffset = offsetToClientCoords(AxisValues.create(iframeOffset));
|
|
1759
|
-
var iframeBorders = getBordersWidth(iframeElement);
|
|
1760
|
-
elPosition.add(clientOffset).add(AxisValues.create(iframeBorders));
|
|
1761
|
-
if (isHtmlElement$1)
|
|
1762
|
-
elBorders.add(iframeBorders);
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
var hasRightScrollbar = !isHtmlElement$1 && getInnerWidth(target) !== target.clientWidth;
|
|
1766
|
-
var hasBottomScrollbar = !isHtmlElement$1 && getInnerHeight(target) !== target.clientHeight;
|
|
1767
|
-
var scrollbar = {
|
|
1768
|
-
right: hasRightScrollbar ? getScrollbarSize() : 0,
|
|
1769
|
-
bottom: hasBottomScrollbar ? getScrollbarSize() : 0,
|
|
1770
|
-
};
|
|
1771
|
-
return new Dimensions(elWidth, elHeight, elPosition, elBorders, elScroll, scrollbar);
|
|
1772
|
-
}
|
|
1773
|
-
function isIframeVisible(el) {
|
|
1774
|
-
return !hiddenUsingStyles(el);
|
|
1775
|
-
}
|
|
1776
|
-
function hiddenUsingStyles(el) {
|
|
1777
|
-
return get(el, 'visibility') === 'hidden' ||
|
|
1778
|
-
get(el, 'display') === 'none';
|
|
1779
|
-
}
|
|
1780
|
-
function hiddenByRectangle(el) {
|
|
1781
|
-
var elementRectangle = getElementRectangle(el);
|
|
1782
|
-
return elementRectangle.width === 0 ||
|
|
1783
|
-
elementRectangle.height === 0;
|
|
1784
|
-
}
|
|
1785
|
-
function isElementVisible$1(el) {
|
|
1786
|
-
if (isTextNode(el))
|
|
1787
|
-
return !isNotVisibleNode(el);
|
|
1788
|
-
if (!isContentEditableElement(el) &&
|
|
1789
|
-
!isSVGElement(el) &&
|
|
1790
|
-
hiddenByRectangle(el))
|
|
1791
|
-
return false;
|
|
1792
|
-
if (isMapElement(el)) {
|
|
1793
|
-
var mapContainer = getMapContainer(closest(el, 'map'));
|
|
1794
|
-
return mapContainer ? isElementVisible$1(mapContainer) : false;
|
|
1795
|
-
}
|
|
1796
|
-
if (isSelectVisibleChild(el)) {
|
|
1797
|
-
var select = getSelectParent(el);
|
|
1798
|
-
var childRealIndex = getChildVisibleIndex(select, el);
|
|
1799
|
-
var realSelectSizeValue = getSelectElementSize(select);
|
|
1800
|
-
var topVisibleIndex = Math.max(getScrollTop(select) / getOptionHeight(select), 0);
|
|
1801
|
-
var bottomVisibleIndex = topVisibleIndex + realSelectSizeValue - 1;
|
|
1802
|
-
var optionVisibleIndex = Math.max(childRealIndex - topVisibleIndex, 0);
|
|
1803
|
-
return optionVisibleIndex >= topVisibleIndex && optionVisibleIndex <= bottomVisibleIndex;
|
|
1804
|
-
}
|
|
1805
|
-
if (isSVGElement(el)) {
|
|
1806
|
-
var hiddenParent = findParent(el, true, function (parent) {
|
|
1807
|
-
return hiddenUsingStyles(parent);
|
|
1808
|
-
});
|
|
1809
|
-
if (!hiddenParent)
|
|
1810
|
-
return !hiddenByRectangle(el);
|
|
1811
|
-
return false;
|
|
1812
|
-
}
|
|
1813
|
-
return hasDimensions(el) && !hiddenUsingStyles(el);
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
// @ts-ignore
|
|
1817
|
-
function visible(el) {
|
|
1818
|
-
if (testcafeCore.domUtils.isIframeElement(el))
|
|
1819
|
-
return isIframeVisible(el);
|
|
1820
|
-
if (!hammerhead.utils.dom.isDomElement(el) && !hammerhead.utils.dom.isTextNode(el))
|
|
1821
|
-
return false;
|
|
1822
|
-
if (testcafeCore.domUtils.isOptionElement(el) || testcafeCore.domUtils.getTagName(el) === 'optgroup')
|
|
1823
|
-
return testcafeUi.selectElement.isOptionElementVisible(el);
|
|
1824
|
-
return isElementVisible$1(el);
|
|
1825
|
-
}
|
|
1826
|
-
function isNodeCollection(obj) {
|
|
1827
|
-
return obj instanceof hammerhead.nativeMethods.HTMLCollection || obj instanceof hammerhead.nativeMethods.NodeList;
|
|
1828
|
-
}
|
|
1829
|
-
function castToArray(list) {
|
|
1830
|
-
var length = list.length;
|
|
1831
|
-
var result = [];
|
|
1832
|
-
for (var i = 0; i < length; i++)
|
|
1833
|
-
result.push(list[i]);
|
|
1834
|
-
return result;
|
|
1835
|
-
}
|
|
1836
|
-
function isArrayOfNodes(obj) {
|
|
1837
|
-
if (!hammerhead.nativeMethods.isArray(obj))
|
|
1838
|
-
return false;
|
|
1839
|
-
for (var i = 0; i < obj.length; i++) {
|
|
1840
|
-
// @ts-ignore
|
|
1841
|
-
if (!(obj[i] instanceof hammerhead.nativeMethods.Node))
|
|
1842
|
-
return false;
|
|
1843
|
-
}
|
|
1844
|
-
return true;
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
var _a;
|
|
1848
|
-
var SELECTOR_FILTER_ERROR = {
|
|
1849
|
-
filterVisible: 1,
|
|
1850
|
-
filterHidden: 2,
|
|
1851
|
-
nth: 3,
|
|
1852
|
-
};
|
|
1853
|
-
var FILTER_ERROR_TO_API_RE = (_a = {},
|
|
1854
|
-
_a[SELECTOR_FILTER_ERROR.filterVisible] = /^\.filterVisible\(\)$/,
|
|
1855
|
-
_a[SELECTOR_FILTER_ERROR.filterHidden] = /^\.filterHidden\(\)$/,
|
|
1856
|
-
_a[SELECTOR_FILTER_ERROR.nth] = /^\.nth\(\d+\)$/,
|
|
1857
|
-
_a);
|
|
1858
|
-
var SelectorFilter = /** @class */ (function () {
|
|
1859
|
-
function SelectorFilter() {
|
|
1860
|
-
this._err = null;
|
|
1861
|
-
}
|
|
1862
|
-
Object.defineProperty(SelectorFilter.prototype, "error", {
|
|
1863
|
-
get: function () {
|
|
1864
|
-
return this._err;
|
|
1865
|
-
},
|
|
1866
|
-
set: function (message) {
|
|
1867
|
-
if (this._err === null)
|
|
1868
|
-
this._err = message;
|
|
1869
|
-
},
|
|
1870
|
-
enumerable: false,
|
|
1871
|
-
configurable: true
|
|
1872
|
-
});
|
|
1873
|
-
SelectorFilter.prototype.filter = function (nodes, options, apiInfo) {
|
|
1874
|
-
if (options.filterVisible) {
|
|
1875
|
-
nodes = nodes.filter(visible);
|
|
1876
|
-
this._assertFilterError(nodes, apiInfo, SELECTOR_FILTER_ERROR.filterVisible);
|
|
1877
|
-
}
|
|
1878
|
-
if (options.filterHidden) {
|
|
1879
|
-
nodes = nodes.filter(function (n) { return !visible(n); });
|
|
1880
|
-
this._assertFilterError(nodes, apiInfo, SELECTOR_FILTER_ERROR.filterHidden);
|
|
1881
|
-
}
|
|
1882
|
-
if (options.counterMode) {
|
|
1883
|
-
if (options.index === null)
|
|
1884
|
-
return nodes.length;
|
|
1885
|
-
return SelectorFilter._getNodeByIndex(nodes, options.index) ? 1 : 0;
|
|
1886
|
-
}
|
|
1887
|
-
if (options.collectionMode) {
|
|
1888
|
-
if (options.index !== null) {
|
|
1889
|
-
var nodeOnIndex_1 = SelectorFilter._getNodeByIndex(nodes, options.index);
|
|
1890
|
-
nodes = nodeOnIndex_1 ? [nodeOnIndex_1] : [];
|
|
1891
|
-
this._assertFilterError(nodes, apiInfo, SELECTOR_FILTER_ERROR.nth);
|
|
1892
|
-
}
|
|
1893
|
-
return nodes;
|
|
1894
|
-
}
|
|
1895
|
-
var nodeOnIndex = SelectorFilter._getNodeByIndex(nodes, options.index || 0);
|
|
1896
|
-
if (!nodeOnIndex)
|
|
1897
|
-
this.error = SelectorFilter._getErrorItem(apiInfo, SELECTOR_FILTER_ERROR.nth);
|
|
1898
|
-
return nodeOnIndex;
|
|
1899
|
-
};
|
|
1900
|
-
SelectorFilter.prototype.cast = function (searchResult) {
|
|
1901
|
-
if (searchResult === null || searchResult === void 0)
|
|
1902
|
-
return [];
|
|
1903
|
-
else if (searchResult instanceof hammerhead.nativeMethods.Node)
|
|
1904
|
-
return [searchResult];
|
|
1905
|
-
else if (isArrayOfNodes(searchResult))
|
|
1906
|
-
return searchResult;
|
|
1907
|
-
else if (isNodeCollection(searchResult))
|
|
1908
|
-
return castToArray(searchResult);
|
|
1909
|
-
throw new InvalidSelectorResultError();
|
|
1910
|
-
};
|
|
1911
|
-
SelectorFilter.prototype._assertFilterError = function (filtered, apiInfo, filterError) {
|
|
1912
|
-
if (filtered.length === 0)
|
|
1913
|
-
this.error = SelectorFilter._getErrorItem(apiInfo, filterError);
|
|
1914
|
-
};
|
|
1915
|
-
SelectorFilter._getErrorItem = function (_a, err) {
|
|
1916
|
-
var apiFnChain = _a.apiFnChain, apiFnID = _a.apiFnID;
|
|
1917
|
-
if (err) {
|
|
1918
|
-
for (var i = apiFnID; i < apiFnChain.length; i++) {
|
|
1919
|
-
if (FILTER_ERROR_TO_API_RE[err].test(apiFnChain[i]))
|
|
1920
|
-
return i;
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
return null;
|
|
1924
|
-
};
|
|
1925
|
-
SelectorFilter._getNodeByIndex = function (nodes, index) {
|
|
1926
|
-
return index < 0 ? nodes[nodes.length + index] : nodes[index];
|
|
1619
|
+
SelectorFilter._getNodeByIndex = function (nodes, index) {
|
|
1620
|
+
return index < 0 ? nodes[nodes.length + index] : nodes[index];
|
|
1927
1621
|
};
|
|
1928
1622
|
return SelectorFilter;
|
|
1929
1623
|
}());
|
|
@@ -2026,7 +1720,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2026
1720
|
|
|
2027
1721
|
var messageSandbox = hammerhead__default.eventSandbox.message;
|
|
2028
1722
|
var processScript = hammerhead__default.processScript;
|
|
2029
|
-
var nativeMethods
|
|
1723
|
+
var nativeMethods = hammerhead__default.nativeMethods;
|
|
2030
1724
|
var APPEARED_DIALOGS = 'testcafe|native-dialog-tracker|appeared-dialogs';
|
|
2031
1725
|
var UNEXPECTED_DIALOG = 'testcafe|native-dialog-tracker|unexpected-dialog';
|
|
2032
1726
|
var ERROR_IN_HANDLER = 'testcafe|native-dialog-tracker|error-in-handler';
|
|
@@ -2076,7 +1770,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2076
1770
|
configurable: true
|
|
2077
1771
|
});
|
|
2078
1772
|
NativeDialogTracker._getPageUrl = function () {
|
|
2079
|
-
return nativeMethods
|
|
1773
|
+
return nativeMethods.eval(GETTING_PAGE_URL_PROCESSED_SCRIPT);
|
|
2080
1774
|
};
|
|
2081
1775
|
NativeDialogTracker.prototype._initListening = function () {
|
|
2082
1776
|
var _this = this;
|
|
@@ -2351,11 +2045,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2351
2045
|
}(InterDriverMessage));
|
|
2352
2046
|
|
|
2353
2047
|
var JSON$1 = hammerhead__default.json;
|
|
2354
|
-
var nativeMethods$
|
|
2048
|
+
var nativeMethods$1 = hammerhead__default.nativeMethods;
|
|
2355
2049
|
var STORAGE_KEY_PREFIX = 'testcafe|driver|';
|
|
2356
2050
|
var Storage = /** @class */ (function () {
|
|
2357
2051
|
function Storage(window, testRunId, windowId) {
|
|
2358
|
-
this.storage = nativeMethods$
|
|
2052
|
+
this.storage = nativeMethods$1.winSessionStorageGetter.call(window);
|
|
2359
2053
|
this.storageKey = this._createStorageKey(testRunId, windowId);
|
|
2360
2054
|
this.data = {};
|
|
2361
2055
|
this._loadFromStorage();
|
|
@@ -2367,14 +2061,14 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2367
2061
|
return storageKey;
|
|
2368
2062
|
};
|
|
2369
2063
|
Storage.prototype._loadFromStorage = function () {
|
|
2370
|
-
var savedData = nativeMethods$
|
|
2064
|
+
var savedData = nativeMethods$1.storageGetItem.call(this.storage, this.storageKey);
|
|
2371
2065
|
if (savedData) {
|
|
2372
2066
|
this.data = JSON$1.parse(savedData);
|
|
2373
|
-
nativeMethods$
|
|
2067
|
+
nativeMethods$1.storageRemoveItem.call(this.storage, this.storageKey);
|
|
2374
2068
|
}
|
|
2375
2069
|
};
|
|
2376
2070
|
Storage.prototype.save = function () {
|
|
2377
|
-
nativeMethods$
|
|
2071
|
+
nativeMethods$1.storageSetItem.call(this.storage, this.storageKey, JSON$1.stringify(this.data));
|
|
2378
2072
|
};
|
|
2379
2073
|
Storage.prototype.setItem = function (prop, value) {
|
|
2380
2074
|
this.data[prop] = value;
|
|
@@ -2384,7 +2078,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2384
2078
|
return this.data[prop];
|
|
2385
2079
|
};
|
|
2386
2080
|
Storage.prototype.dispose = function () {
|
|
2387
|
-
nativeMethods$
|
|
2081
|
+
nativeMethods$1.storageRemoveItem.call(this.storage, this.storageKey);
|
|
2388
2082
|
};
|
|
2389
2083
|
return Storage;
|
|
2390
2084
|
}());
|
|
@@ -2722,7 +2416,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2722
2416
|
// Element
|
|
2723
2417
|
var elementSnapshotPropertyInitializers = {
|
|
2724
2418
|
tagName: function (element) { return element.tagName.toLowerCase(); },
|
|
2725
|
-
visible: function (element) { return isElementVisible
|
|
2419
|
+
visible: function (element) { return testcafeCore.positionUtils.isElementVisible(element); },
|
|
2726
2420
|
focused: function (element) { return hammerhead.utils.dom.getActiveElement() === element; },
|
|
2727
2421
|
attributes: function (element) {
|
|
2728
2422
|
// eslint-disable-next-line no-restricted-properties
|
|
@@ -2874,9 +2568,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2874
2568
|
}());
|
|
2875
2569
|
|
|
2876
2570
|
var Promise = hammerhead__default.Promise;
|
|
2877
|
-
var nativeMethods$
|
|
2571
|
+
var nativeMethods$2 = hammerhead__default.nativeMethods;
|
|
2878
2572
|
function delay (ms) {
|
|
2879
|
-
return new Promise(function (resolve) { return nativeMethods$
|
|
2573
|
+
return new Promise(function (resolve) { return nativeMethods$2.setTimeout.call(window, resolve, ms); });
|
|
2880
2574
|
}
|
|
2881
2575
|
|
|
2882
2576
|
function whilst(condition, iterator) {
|
|
@@ -2895,11 +2589,6 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2895
2589
|
});
|
|
2896
2590
|
}
|
|
2897
2591
|
|
|
2898
|
-
var AUTOMATION_ERROR_TYPES = {
|
|
2899
|
-
elementIsInvisibleError: 'elementIsInvisibleError',
|
|
2900
|
-
foundElementIsNotTarget: 'foundElementIsNotTarget',
|
|
2901
|
-
};
|
|
2902
|
-
|
|
2903
2592
|
// NOTE: node description by node type
|
|
2904
2593
|
var NODE_TYPE_DESCRIPTIONS = {
|
|
2905
2594
|
1: 'element',
|
|
@@ -2974,6 +2663,260 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
2974
2663
|
return ElementsRetriever;
|
|
2975
2664
|
}());
|
|
2976
2665
|
|
|
2666
|
+
var BoundaryValues = /** @class */ (function () {
|
|
2667
|
+
function BoundaryValues(top, right, bottom, left) {
|
|
2668
|
+
if (top === void 0) { top = 0; }
|
|
2669
|
+
if (right === void 0) { right = 0; }
|
|
2670
|
+
if (bottom === void 0) { bottom = 0; }
|
|
2671
|
+
if (left === void 0) { left = 0; }
|
|
2672
|
+
this.top = top;
|
|
2673
|
+
this.right = right;
|
|
2674
|
+
this.bottom = bottom;
|
|
2675
|
+
this.left = left;
|
|
2676
|
+
}
|
|
2677
|
+
BoundaryValues.create = function (v) {
|
|
2678
|
+
return new BoundaryValues(v.top, v.right, v.bottom, v.left);
|
|
2679
|
+
};
|
|
2680
|
+
BoundaryValues.prototype.add = function (d) {
|
|
2681
|
+
this.top += d.top;
|
|
2682
|
+
this.right += d.right;
|
|
2683
|
+
this.bottom += d.bottom;
|
|
2684
|
+
this.left += d.left;
|
|
2685
|
+
return this;
|
|
2686
|
+
};
|
|
2687
|
+
BoundaryValues.prototype.sub = function (d) {
|
|
2688
|
+
if ('top' in d) {
|
|
2689
|
+
this.top -= d.top;
|
|
2690
|
+
this.left -= d.left;
|
|
2691
|
+
}
|
|
2692
|
+
this.bottom -= d.bottom;
|
|
2693
|
+
this.right -= d.right;
|
|
2694
|
+
return this;
|
|
2695
|
+
};
|
|
2696
|
+
BoundaryValues.prototype.round = function (leftTopRound, rightBottomRound) {
|
|
2697
|
+
if (leftTopRound === void 0) { leftTopRound = Math.round; }
|
|
2698
|
+
if (rightBottomRound === void 0) { rightBottomRound = leftTopRound; }
|
|
2699
|
+
this.top = leftTopRound(this.top);
|
|
2700
|
+
this.right = rightBottomRound(this.right);
|
|
2701
|
+
this.bottom = rightBottomRound(this.bottom);
|
|
2702
|
+
this.left = leftTopRound(this.left);
|
|
2703
|
+
return this;
|
|
2704
|
+
};
|
|
2705
|
+
BoundaryValues.prototype.contains = function (point) {
|
|
2706
|
+
return point.x >= this.left && point.x <= this.right && point.y >= this.top && point.y <= this.bottom;
|
|
2707
|
+
};
|
|
2708
|
+
return BoundaryValues;
|
|
2709
|
+
}());
|
|
2710
|
+
|
|
2711
|
+
var ARRAY_METHODS_PREFIX = 'array';
|
|
2712
|
+
function createNativeMethodWrapper(methodName) {
|
|
2713
|
+
var nativeMethodName = ARRAY_METHODS_PREFIX + methodName.charAt(0).toUpperCase() + methodName.slice(1);
|
|
2714
|
+
var nativeMethod = hammerhead.nativeMethods[nativeMethodName];
|
|
2715
|
+
return function () {
|
|
2716
|
+
var args = [];
|
|
2717
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2718
|
+
args[_i] = arguments[_i];
|
|
2719
|
+
}
|
|
2720
|
+
return nativeMethod.call.apply(nativeMethod, args);
|
|
2721
|
+
};
|
|
2722
|
+
}
|
|
2723
|
+
var filter = createNativeMethodWrapper('filter');
|
|
2724
|
+
var map = createNativeMethodWrapper('map');
|
|
2725
|
+
var slice = createNativeMethodWrapper('slice');
|
|
2726
|
+
var splice = createNativeMethodWrapper('splice');
|
|
2727
|
+
var unshift = createNativeMethodWrapper('unshift');
|
|
2728
|
+
var forEach = createNativeMethodWrapper('forEach');
|
|
2729
|
+
var indexOf = createNativeMethodWrapper('indexOf');
|
|
2730
|
+
var some = createNativeMethodWrapper('some');
|
|
2731
|
+
var reverse = createNativeMethodWrapper('reverse');
|
|
2732
|
+
var reduce = createNativeMethodWrapper('reduce');
|
|
2733
|
+
var concat = createNativeMethodWrapper('concat');
|
|
2734
|
+
var join = createNativeMethodWrapper('join');
|
|
2735
|
+
|
|
2736
|
+
var browserUtils = hammerhead__default.utils.browser;
|
|
2737
|
+
var nativeMethods$3 = hammerhead__default.nativeMethods;
|
|
2738
|
+
// NOTE: We have to retrieve styleUtils.get from hammerhead
|
|
2739
|
+
// to avoid circular dependencies between domUtils and styleUtils
|
|
2740
|
+
var getElementStyleProperty = hammerhead__default.utils.style.get;
|
|
2741
|
+
var getActiveElement = hammerhead__default.utils.dom.getActiveElement;
|
|
2742
|
+
var findDocument = hammerhead__default.utils.dom.findDocument;
|
|
2743
|
+
var find = hammerhead__default.utils.dom.find;
|
|
2744
|
+
var isElementInDocument = hammerhead__default.utils.dom.isElementInDocument;
|
|
2745
|
+
var isElementInIframe = hammerhead__default.utils.dom.isElementInIframe;
|
|
2746
|
+
var getIframeByElement = hammerhead__default.utils.dom.getIframeByElement;
|
|
2747
|
+
var isCrossDomainWindows = hammerhead__default.utils.dom.isCrossDomainWindows;
|
|
2748
|
+
var getSelectParent = hammerhead__default.utils.dom.getSelectParent;
|
|
2749
|
+
var getChildVisibleIndex = hammerhead__default.utils.dom.getChildVisibleIndex;
|
|
2750
|
+
var getSelectVisibleChildren = hammerhead__default.utils.dom.getSelectVisibleChildren;
|
|
2751
|
+
var isElementNode = hammerhead__default.utils.dom.isElementNode;
|
|
2752
|
+
var isTextNode = hammerhead__default.utils.dom.isTextNode;
|
|
2753
|
+
var isRenderedNode = hammerhead__default.utils.dom.isRenderedNode;
|
|
2754
|
+
var isIframeElement = hammerhead__default.utils.dom.isIframeElement;
|
|
2755
|
+
var isInputElement = hammerhead__default.utils.dom.isInputElement;
|
|
2756
|
+
var isButtonElement = hammerhead__default.utils.dom.isButtonElement;
|
|
2757
|
+
var isFileInput = hammerhead__default.utils.dom.isFileInput;
|
|
2758
|
+
var isTextAreaElement = hammerhead__default.utils.dom.isTextAreaElement;
|
|
2759
|
+
var isAnchorElement = hammerhead__default.utils.dom.isAnchorElement;
|
|
2760
|
+
var isImgElement = hammerhead__default.utils.dom.isImgElement;
|
|
2761
|
+
var isFormElement = hammerhead__default.utils.dom.isFormElement;
|
|
2762
|
+
var isLabelElement = hammerhead__default.utils.dom.isLabelElement;
|
|
2763
|
+
var isSelectElement = hammerhead__default.utils.dom.isSelectElement;
|
|
2764
|
+
var isRadioButtonElement = hammerhead__default.utils.dom.isRadioButtonElement;
|
|
2765
|
+
var isColorInputElement = hammerhead__default.utils.dom.isColorInputElement;
|
|
2766
|
+
var isCheckboxElement = hammerhead__default.utils.dom.isCheckboxElement;
|
|
2767
|
+
var isOptionElement = hammerhead__default.utils.dom.isOptionElement;
|
|
2768
|
+
var isSVGElement = hammerhead__default.utils.dom.isSVGElement;
|
|
2769
|
+
var isMapElement = hammerhead__default.utils.dom.isMapElement;
|
|
2770
|
+
var isBodyElement = hammerhead__default.utils.dom.isBodyElement;
|
|
2771
|
+
var isHtmlElement = hammerhead__default.utils.dom.isHtmlElement;
|
|
2772
|
+
var isDocument = hammerhead__default.utils.dom.isDocument;
|
|
2773
|
+
var isWindow = hammerhead__default.utils.dom.isWindow;
|
|
2774
|
+
var isTextEditableInput = hammerhead__default.utils.dom.isTextEditableInput;
|
|
2775
|
+
var isTextEditableElement = hammerhead__default.utils.dom.isTextEditableElement;
|
|
2776
|
+
var isTextEditableElementAndEditingAllowed = hammerhead__default.utils.dom.isTextEditableElementAndEditingAllowed;
|
|
2777
|
+
var isContentEditableElement = hammerhead__default.utils.dom.isContentEditableElement;
|
|
2778
|
+
var isDomElement = hammerhead__default.utils.dom.isDomElement;
|
|
2779
|
+
var isShadowUIElement = hammerhead__default.utils.dom.isShadowUIElement;
|
|
2780
|
+
var isShadowRoot = hammerhead__default.utils.dom.isShadowRoot;
|
|
2781
|
+
var isElementFocusable = hammerhead__default.utils.dom.isElementFocusable;
|
|
2782
|
+
var isHammerheadAttr = hammerhead__default.utils.dom.isHammerheadAttr;
|
|
2783
|
+
var isElementReadOnly = hammerhead__default.utils.dom.isElementReadOnly;
|
|
2784
|
+
var getScrollbarSize = hammerhead__default.utils.dom.getScrollbarSize;
|
|
2785
|
+
var getMapContainer = hammerhead__default.utils.dom.getMapContainer;
|
|
2786
|
+
var getTagName = hammerhead__default.utils.dom.getTagName;
|
|
2787
|
+
var closest = hammerhead__default.utils.dom.closest;
|
|
2788
|
+
var getParents = hammerhead__default.utils.dom.getParents;
|
|
2789
|
+
var findParent = hammerhead__default.utils.dom.findParent;
|
|
2790
|
+
var getTopSameDomainWindow = hammerhead__default.utils.dom.getTopSameDomainWindow;
|
|
2791
|
+
var getParentExceptShadowRoot = hammerhead__default.utils.dom.getParentExceptShadowRoot;
|
|
2792
|
+
|
|
2793
|
+
var styleUtils = hammerhead__default.utils.style;
|
|
2794
|
+
var getBordersWidth = hammerhead__default.utils.style.getBordersWidth;
|
|
2795
|
+
var getComputedStyle = hammerhead__default.utils.style.getComputedStyle;
|
|
2796
|
+
var getElementMargin = hammerhead__default.utils.style.getElementMargin;
|
|
2797
|
+
var getElementPadding = hammerhead__default.utils.style.getElementPadding;
|
|
2798
|
+
var getElementScroll = hammerhead__default.utils.style.getElementScroll;
|
|
2799
|
+
var getOptionHeight = hammerhead__default.utils.style.getOptionHeight;
|
|
2800
|
+
var getSelectElementSize = hammerhead__default.utils.style.getSelectElementSize;
|
|
2801
|
+
var isElementVisible = hammerhead__default.utils.style.isElementVisible;
|
|
2802
|
+
var isSelectVisibleChild = hammerhead__default.utils.style.isVisibleChild;
|
|
2803
|
+
var getWidth = hammerhead__default.utils.style.getWidth;
|
|
2804
|
+
var getHeight = hammerhead__default.utils.style.getHeight;
|
|
2805
|
+
var getInnerWidth = hammerhead__default.utils.style.getInnerWidth;
|
|
2806
|
+
var getInnerHeight = hammerhead__default.utils.style.getInnerHeight;
|
|
2807
|
+
var getScrollLeft = hammerhead__default.utils.style.getScrollLeft;
|
|
2808
|
+
var getScrollTop = hammerhead__default.utils.style.getScrollTop;
|
|
2809
|
+
var setScrollLeft = hammerhead__default.utils.style.setScrollLeft;
|
|
2810
|
+
var setScrollTop = hammerhead__default.utils.style.setScrollTop;
|
|
2811
|
+
var get = hammerhead__default.utils.style.get;
|
|
2812
|
+
|
|
2813
|
+
var shadowUI = hammerhead__default.shadowUI;
|
|
2814
|
+
var nativeMethods$4 = hammerhead__default.nativeMethods;
|
|
2815
|
+
|
|
2816
|
+
var AxisValues = /** @class */ (function () {
|
|
2817
|
+
function AxisValues(x, y) {
|
|
2818
|
+
this.x = x;
|
|
2819
|
+
this.y = y;
|
|
2820
|
+
}
|
|
2821
|
+
AxisValues.create = function (a) {
|
|
2822
|
+
if ('left' in a)
|
|
2823
|
+
return new AxisValues(a.left, a.top);
|
|
2824
|
+
else if ('right' in a)
|
|
2825
|
+
return new AxisValues(a.right, a.bottom);
|
|
2826
|
+
return new AxisValues(a.x, a.y);
|
|
2827
|
+
};
|
|
2828
|
+
AxisValues.prototype.add = function (p) {
|
|
2829
|
+
this.x += p.x;
|
|
2830
|
+
this.y += p.y;
|
|
2831
|
+
return this;
|
|
2832
|
+
};
|
|
2833
|
+
AxisValues.prototype.sub = function (p) {
|
|
2834
|
+
this.x -= p.x;
|
|
2835
|
+
this.y -= p.y;
|
|
2836
|
+
return this;
|
|
2837
|
+
};
|
|
2838
|
+
AxisValues.prototype.round = function (fn) {
|
|
2839
|
+
if (fn === void 0) { fn = Math.round; }
|
|
2840
|
+
this.x = fn(this.x);
|
|
2841
|
+
this.y = fn(this.y);
|
|
2842
|
+
return this;
|
|
2843
|
+
};
|
|
2844
|
+
AxisValues.prototype.eql = function (p) {
|
|
2845
|
+
return this.x === p.x && this.y === p.y;
|
|
2846
|
+
};
|
|
2847
|
+
AxisValues.prototype.mul = function (n) {
|
|
2848
|
+
this.x *= n;
|
|
2849
|
+
this.y *= n;
|
|
2850
|
+
return this;
|
|
2851
|
+
};
|
|
2852
|
+
AxisValues.prototype.distance = function (p) {
|
|
2853
|
+
return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
|
|
2854
|
+
};
|
|
2855
|
+
return AxisValues;
|
|
2856
|
+
}());
|
|
2857
|
+
|
|
2858
|
+
var Dimensions = /** @class */ (function () {
|
|
2859
|
+
function Dimensions(width, height, position, borders, elScroll, scrollbar) {
|
|
2860
|
+
this.width = width;
|
|
2861
|
+
this.height = height;
|
|
2862
|
+
this.left = position.x;
|
|
2863
|
+
this.top = position.y;
|
|
2864
|
+
this.right = position.x + width;
|
|
2865
|
+
this.bottom = position.y + height;
|
|
2866
|
+
this.border = borders;
|
|
2867
|
+
this.scrollbar = scrollbar;
|
|
2868
|
+
this.scroll = elScroll;
|
|
2869
|
+
}
|
|
2870
|
+
return Dimensions;
|
|
2871
|
+
}());
|
|
2872
|
+
|
|
2873
|
+
var htmlUtils = hammerhead__default.utils.html;
|
|
2874
|
+
var nativeMethods$5 = hammerhead__default.nativeMethods;
|
|
2875
|
+
|
|
2876
|
+
var getElementRectangle = hammerhead__default.utils.position.getElementRectangle;
|
|
2877
|
+
var getOffsetPosition = hammerhead__default.utils.position.getOffsetPosition;
|
|
2878
|
+
var offsetToClientCoords = hammerhead__default.utils.position.offsetToClientCoords;
|
|
2879
|
+
function getClientDimensions(target) {
|
|
2880
|
+
var isHtmlElement$1 = isHtmlElement(target);
|
|
2881
|
+
var body = isHtmlElement$1 ? target.getElementsByTagName('body')[0] : null;
|
|
2882
|
+
var elementRect = target.getBoundingClientRect();
|
|
2883
|
+
var elBorders = BoundaryValues.create(getBordersWidth(target));
|
|
2884
|
+
var elScroll = getElementScroll(target);
|
|
2885
|
+
var isElementInIframe$1 = isElementInIframe(target);
|
|
2886
|
+
var isCompatMode = target.ownerDocument.compatMode === 'BackCompat';
|
|
2887
|
+
var elPosition = isHtmlElement$1 ? new AxisValues(0, 0) : AxisValues.create(elementRect);
|
|
2888
|
+
var elHeight = elementRect.height;
|
|
2889
|
+
var elWidth = elementRect.width;
|
|
2890
|
+
if (isHtmlElement$1) {
|
|
2891
|
+
if (body && isCompatMode) {
|
|
2892
|
+
elHeight = body.clientHeight;
|
|
2893
|
+
elWidth = body.clientWidth;
|
|
2894
|
+
}
|
|
2895
|
+
else {
|
|
2896
|
+
elHeight = target.clientHeight;
|
|
2897
|
+
elWidth = target.clientWidth;
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
if (isElementInIframe$1) {
|
|
2901
|
+
var iframeElement = getIframeByElement(target);
|
|
2902
|
+
if (iframeElement) {
|
|
2903
|
+
var iframeOffset = getOffsetPosition(iframeElement);
|
|
2904
|
+
var clientOffset = offsetToClientCoords(AxisValues.create(iframeOffset));
|
|
2905
|
+
var iframeBorders = getBordersWidth(iframeElement);
|
|
2906
|
+
elPosition.add(clientOffset).add(AxisValues.create(iframeBorders));
|
|
2907
|
+
if (isHtmlElement$1)
|
|
2908
|
+
elBorders.add(iframeBorders);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
var hasRightScrollbar = !isHtmlElement$1 && getInnerWidth(target) !== target.clientWidth;
|
|
2912
|
+
var hasBottomScrollbar = !isHtmlElement$1 && getInnerHeight(target) !== target.clientHeight;
|
|
2913
|
+
var scrollbar = {
|
|
2914
|
+
right: hasRightScrollbar ? getScrollbarSize() : 0,
|
|
2915
|
+
bottom: hasBottomScrollbar ? getScrollbarSize() : 0,
|
|
2916
|
+
};
|
|
2917
|
+
return new Dimensions(elWidth, elHeight, elPosition, elBorders, elScroll, scrollbar);
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2977
2920
|
function calcOffset(size) {
|
|
2978
2921
|
var offset = size / 2;
|
|
2979
2922
|
return offset < 1 ? 0 : Math.round(offset);
|
|
@@ -3076,6 +3019,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3076
3019
|
if (this._elements.length && opts && 'offsetX' in opts && 'offsetY' in opts) { // @ts-ignore
|
|
3077
3020
|
_a = getOffsetOptions(this._elements[0], opts.offsetX, opts.offsetY), offsetX = _a.offsetX, offsetY = _a.offsetY;
|
|
3078
3021
|
// @ts-ignore TODO
|
|
3022
|
+
opts.isDefaultOffset = !opts.offsetX && !opts.offsetY;
|
|
3023
|
+
// @ts-ignore TODO
|
|
3079
3024
|
opts.offsetX = offsetX;
|
|
3080
3025
|
// @ts-ignore TODO
|
|
3081
3026
|
opts.offsetY = offsetY;
|
|
@@ -3125,14 +3070,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3125
3070
|
.catch(function (err) {
|
|
3126
3071
|
if (!_this._isExecutionTimeoutExpired())
|
|
3127
3072
|
return delay(CHECK_ELEMENT_IN_AUTOMATIONS_INTERVAL);
|
|
3128
|
-
if (err.
|
|
3073
|
+
if (err.code === TEST_RUN_ERRORS.actionElementIsNotTargetError) {
|
|
3129
3074
|
// If we can't get a target element via elementFromPoint but it's
|
|
3130
3075
|
// visible we click on the point where the element is located.
|
|
3131
3076
|
strictElementCheck = false;
|
|
3132
3077
|
return hammerhead.Promise.resolve();
|
|
3133
3078
|
}
|
|
3134
|
-
throw err
|
|
3135
|
-
new ActionElementIsInvisibleError() : err;
|
|
3079
|
+
throw err;
|
|
3136
3080
|
});
|
|
3137
3081
|
});
|
|
3138
3082
|
};
|
|
@@ -3300,10 +3244,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3300
3244
|
new FunctionTransform(),
|
|
3301
3245
|
]);
|
|
3302
3246
|
};
|
|
3303
|
-
SelectorExecutor.prototype._getTimeoutErrorParams = function () {
|
|
3247
|
+
SelectorExecutor.prototype._getTimeoutErrorParams = function (el) {
|
|
3304
3248
|
var apiFnIndex = selectorFilter.error;
|
|
3305
3249
|
var apiFnChain = this.command.apiFnChain;
|
|
3306
|
-
|
|
3250
|
+
var reason = testcafeCore.positionUtils.getHiddenReason(el);
|
|
3251
|
+
return { apiFnIndex: apiFnIndex, apiFnChain: apiFnChain, reason: reason };
|
|
3307
3252
|
};
|
|
3308
3253
|
SelectorExecutor.prototype._getTimeoutError = function (elementExists) {
|
|
3309
3254
|
return elementExists ? this.createIsInvisibleError : this.createNotFoundError;
|
|
@@ -3315,15 +3260,15 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3315
3260
|
.then(function (el) {
|
|
3316
3261
|
var element = el;
|
|
3317
3262
|
var isElementExists = !!element;
|
|
3318
|
-
var isElementVisible = !_this.command.visibilityCheck || element &&
|
|
3263
|
+
var isElementVisible = !_this.command.visibilityCheck || element && testcafeCore.positionUtils.isElementVisible(element);
|
|
3319
3264
|
var isTimeout = hammerhead.nativeMethods.dateNow() - startTime >= _this.timeout;
|
|
3320
3265
|
if (isElementExists && (isElementVisible || hammerhead.utils.dom.isShadowRoot(element)))
|
|
3321
3266
|
return element;
|
|
3322
3267
|
if (!isTimeout)
|
|
3323
|
-
return delay(CHECK_ELEMENT_DELAY).then(function () { return _this._validateElement(args, startTime); });
|
|
3268
|
+
return testcafeCore.delay(CHECK_ELEMENT_DELAY).then(function () { return _this._validateElement(args, startTime); });
|
|
3324
3269
|
var createTimeoutError = _this.getVisibleValueMode ? null : _this._getTimeoutError(isElementExists);
|
|
3325
3270
|
if (createTimeoutError)
|
|
3326
|
-
throw createTimeoutError(_this._getTimeoutErrorParams());
|
|
3271
|
+
throw createTimeoutError(_this._getTimeoutErrorParams(element));
|
|
3327
3272
|
return null;
|
|
3328
3273
|
});
|
|
3329
3274
|
};
|
|
@@ -3374,7 +3319,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3374
3319
|
return {
|
|
3375
3320
|
selector: selector,
|
|
3376
3321
|
createNotFoundError: function (fn) { return new ActionElementNotFoundError(null, fn); },
|
|
3377
|
-
createIsInvisibleError: function () { return new ActionElementIsInvisibleError(); },
|
|
3322
|
+
createIsInvisibleError: function (fn) { return new ActionElementIsInvisibleError(null, fn); },
|
|
3378
3323
|
createHasWrongNodeTypeError: function (nodeDescription) { return new ActionSelectorMatchesWrongNodeTypeError(nodeDescription); },
|
|
3379
3324
|
};
|
|
3380
3325
|
}
|
|
@@ -3545,6 +3490,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
3545
3490
|
return [
|
|
3546
3491
|
{ name: 'offsetX', type: integerOption },
|
|
3547
3492
|
{ name: 'offsetY', type: integerOption },
|
|
3493
|
+
{ name: 'isDefaultOffset', type: booleanOption },
|
|
3548
3494
|
];
|
|
3549
3495
|
};
|
|
3550
3496
|
return OffsetOptions;
|
|
@@ -4566,8 +4512,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4566
4512
|
var Promise$2 = hammerhead__default.Promise;
|
|
4567
4513
|
var messageSandbox$2 = hammerhead__default.eventSandbox.message;
|
|
4568
4514
|
var storages = hammerhead__default.storages;
|
|
4569
|
-
var nativeMethods$
|
|
4570
|
-
var DateCtor$1 = nativeMethods$
|
|
4515
|
+
var nativeMethods$6 = hammerhead__default.nativeMethods;
|
|
4516
|
+
var DateCtor$1 = nativeMethods$6.date;
|
|
4571
4517
|
var listeners = hammerhead__default.eventSandbox.listeners;
|
|
4572
4518
|
var urlUtils = hammerhead__default.utils.url;
|
|
4573
4519
|
var TEST_DONE_SENT_FLAG = 'testcafe|driver|test-done-sent-flag';
|
|
@@ -4778,7 +4724,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4778
4724
|
var _this = this;
|
|
4779
4725
|
if (this.checkClosedChildWindowIntervalId)
|
|
4780
4726
|
return;
|
|
4781
|
-
this.checkClosedChildWindowIntervalId = nativeMethods$
|
|
4727
|
+
this.checkClosedChildWindowIntervalId = nativeMethods$6.setInterval.call(window, function () {
|
|
4782
4728
|
var firstClosedChildWindowDriverLink = testcafeCore.arrayUtils.find(_this.childWindowDriverLinks, function (childWindowDriverLink) { return childWindowDriverLink.driverWindow.closed; });
|
|
4783
4729
|
if (!firstClosedChildWindowDriverLink)
|
|
4784
4730
|
return;
|
|
@@ -4787,7 +4733,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4787
4733
|
if (!firstClosedChildWindowDriverLink.ignoreMasterSwitching)
|
|
4788
4734
|
_this._setCurrentWindowAsMaster();
|
|
4789
4735
|
if (!_this.childWindowDriverLinks.length) {
|
|
4790
|
-
nativeMethods$
|
|
4736
|
+
nativeMethods$6.clearInterval.call(window, _this.checkClosedChildWindowIntervalId);
|
|
4791
4737
|
delete _this.checkClosedChildWindowIntervalId;
|
|
4792
4738
|
}
|
|
4793
4739
|
}, CHECK_CHILD_WINDOW_CLOSED_INTERVAL);
|
|
@@ -4933,8 +4879,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4933
4879
|
if (success)
|
|
4934
4880
|
return success.result;
|
|
4935
4881
|
var errItem = arr.find(function (item) {
|
|
4936
|
-
return item.result.errCode === TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError ||
|
|
4937
|
-
item.result.errCode === TEST_RUN_ERRORS.cannotCloseWindowWithoutParent;
|
|
4882
|
+
return item.result.errCode === testcafeCore.TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError ||
|
|
4883
|
+
item.result.errCode === testcafeCore.TEST_RUN_ERRORS.cannotCloseWindowWithoutParent;
|
|
4938
4884
|
});
|
|
4939
4885
|
if (!errItem)
|
|
4940
4886
|
errItem = arr.find(function (item) { return !!item.result.errCode; });
|
|
@@ -4979,7 +4925,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4979
4925
|
if (windowExists)
|
|
4980
4926
|
return [2 /*return*/, getWindowFoundResult()];
|
|
4981
4927
|
if (!this.childWindowDriverLinks.length)
|
|
4982
|
-
return [2 /*return*/, this._getTargetWindowNotFoundResult(TEST_RUN_ERRORS.targetWindowNotFoundError)];
|
|
4928
|
+
return [2 /*return*/, this._getTargetWindowNotFoundResult(testcafeCore.TEST_RUN_ERRORS.targetWindowNotFoundError)];
|
|
4983
4929
|
searchQueries = this.childWindowDriverLinks.map(function (childWindowDriverLink) {
|
|
4984
4930
|
return childWindowDriverLink.findChildWindows(msg, WindowValidationMessageCtor);
|
|
4985
4931
|
});
|
|
@@ -4993,9 +4939,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
4993
4939
|
};
|
|
4994
4940
|
Driver._createWindowValidationError = function (_a) {
|
|
4995
4941
|
var errCode = _a.errCode;
|
|
4996
|
-
if (errCode === TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError)
|
|
4942
|
+
if (errCode === testcafeCore.TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError)
|
|
4997
4943
|
return new CannotCloseWindowWithChildrenError();
|
|
4998
|
-
if (errCode === TEST_RUN_ERRORS.cannotCloseWindowWithoutParent)
|
|
4944
|
+
if (errCode === testcafeCore.TEST_RUN_ERRORS.cannotCloseWindowWithoutParent)
|
|
4999
4945
|
return new CannotCloseWindowWithoutParentError();
|
|
5000
4946
|
return new WindowNotFoundError();
|
|
5001
4947
|
};
|
|
@@ -5003,13 +4949,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5003
4949
|
if (!this.parentWindowDriverLink) {
|
|
5004
4950
|
return Promise$2.resolve({
|
|
5005
4951
|
success: false,
|
|
5006
|
-
errCode: TEST_RUN_ERRORS.cannotCloseWindowWithoutParent,
|
|
4952
|
+
errCode: testcafeCore.TEST_RUN_ERRORS.cannotCloseWindowWithoutParent,
|
|
5007
4953
|
});
|
|
5008
4954
|
}
|
|
5009
4955
|
if (this.childWindowDriverLinks.length) {
|
|
5010
4956
|
return Promise$2.resolve({
|
|
5011
4957
|
success: false,
|
|
5012
|
-
errCode: TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError,
|
|
4958
|
+
errCode: testcafeCore.TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError,
|
|
5013
4959
|
});
|
|
5014
4960
|
}
|
|
5015
4961
|
return Promise$2.resolve({ success: true });
|
|
@@ -5361,7 +5307,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5361
5307
|
var childLinkResponseTimeout = hasSpecificTimeout
|
|
5362
5308
|
? commandSelectorTimeout
|
|
5363
5309
|
: Math.max(commandSelectorTimeout, WAIT_FOR_IFRAME_DRIVER_RESPONSE_TIMEOUT);
|
|
5364
|
-
return _this._ensureChildIframeDriverLink(nativeMethods$
|
|
5310
|
+
return _this._ensureChildIframeDriverLink(nativeMethods$6.contentWindowGetter.call(iframe), iframeErrorCtors.NotLoadedError, childLinkResponseTimeout);
|
|
5365
5311
|
})
|
|
5366
5312
|
.then(function (childDriverLink) {
|
|
5367
5313
|
childDriverLink.availabilityTimeout = commandSelectorTimeout;
|
|
@@ -5373,7 +5319,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5373
5319
|
var _this = this;
|
|
5374
5320
|
var eventHandler = null;
|
|
5375
5321
|
var timeoutPromise = new Promise$2(function (resolve) {
|
|
5376
|
-
nativeMethods$
|
|
5322
|
+
nativeMethods$6.setTimeout.call(window, function () {
|
|
5377
5323
|
_this.off(eventName, eventHandler);
|
|
5378
5324
|
resolve();
|
|
5379
5325
|
}, timeout);
|
|
@@ -5804,7 +5750,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5804
5750
|
};
|
|
5805
5751
|
Driver.prototype._onShowAssertionRetriesStatusCommand = function (command) {
|
|
5806
5752
|
this.contextStorage.setItem(ASSERTION_RETRIES_TIMEOUT, command.timeout);
|
|
5807
|
-
this.contextStorage.setItem(ASSERTION_RETRIES_START_TIME, nativeMethods$
|
|
5753
|
+
this.contextStorage.setItem(ASSERTION_RETRIES_START_TIME, nativeMethods$6.dateNow());
|
|
5808
5754
|
this.statusBar.showWaitingAssertionRetriesStatus(command.timeout);
|
|
5809
5755
|
this._onReady(new DriverStatus({ isCommandResult: true }));
|
|
5810
5756
|
};
|
|
@@ -5854,7 +5800,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5854
5800
|
return childWindowDriverLink.closeAllChildWindows();
|
|
5855
5801
|
}))
|
|
5856
5802
|
.then(function () {
|
|
5857
|
-
nativeMethods$
|
|
5803
|
+
nativeMethods$6.arrayForEach.call(_this.childWindowDriverLinks, function (childWindowDriverLink) {
|
|
5858
5804
|
childWindowDriverLink.driverWindow.close();
|
|
5859
5805
|
});
|
|
5860
5806
|
});
|
|
@@ -5892,7 +5838,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
5892
5838
|
Driver.prototype._onPrepareClientEnvironmentInDebugMode = function (command) {
|
|
5893
5839
|
// NOTE: repeat the function call wrapping produced by the 'esm' module on the client-side
|
|
5894
5840
|
// (same as on the server-side).
|
|
5895
|
-
nativeMethods$
|
|
5841
|
+
nativeMethods$6.objectDefineProperty(window, command.esmRuntime, {
|
|
5896
5842
|
value: {
|
|
5897
5843
|
g: window,
|
|
5898
5844
|
c: window.eval, //eslint-disable-line no-eval
|
|
@@ -6372,13 +6318,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
|
|
|
6372
6318
|
testCafeDriverInstance: '%testCafeDriverInstance%',
|
|
6373
6319
|
};
|
|
6374
6320
|
|
|
6375
|
-
var nativeMethods$
|
|
6321
|
+
var nativeMethods$7 = hammerhead__default.nativeMethods;
|
|
6376
6322
|
var evalIframeScript = hammerhead__default.EVENTS.evalIframeScript;
|
|
6377
|
-
nativeMethods$
|
|
6378
|
-
nativeMethods$
|
|
6379
|
-
nativeMethods$
|
|
6323
|
+
nativeMethods$7.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeDriver, { configurable: true, value: Driver });
|
|
6324
|
+
nativeMethods$7.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeIframeDriver, { configurable: true, value: IframeDriver });
|
|
6325
|
+
nativeMethods$7.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeEmbeddingUtils, { configurable: true, value: embeddingUtils });
|
|
6380
6326
|
// eslint-disable-next-line no-undef
|
|
6381
|
-
hammerhead__default.on(evalIframeScript, function (e) { return initTestCafeClientDrivers(nativeMethods$
|
|
6327
|
+
hammerhead__default.on(evalIframeScript, function (e) { return initTestCafeClientDrivers(nativeMethods$7.contentWindowGetter.call(e.iframe), true); });
|
|
6382
6328
|
|
|
6383
6329
|
}(window['%hammerhead%'], window['%hammerhead%'].Promise, window['%testCafeCore%'], window['%testCafeAutomation%'], window['%testCafeUI%']));
|
|
6384
6330
|
|