testcafe 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/bin/testcafe-with-v8-flag-filter.js +16 -3
  3. package/lib/api/exportable-lib/index.mjs +27 -0
  4. package/lib/api/structure/fixture.js +7 -3
  5. package/lib/api/structure/test.js +8 -3
  6. package/lib/api/structure/testing-unit.js +15 -1
  7. package/lib/api/test-controller/index.js +4 -4
  8. package/lib/browser/connection/gateway.js +13 -1
  9. package/lib/browser/connection/index.js +10 -1
  10. package/lib/browser/connection/service-routes.js +2 -1
  11. package/lib/browser/provider/built-in/dedicated/chrome/index.js +6 -1
  12. package/lib/browser/provider/index.js +4 -1
  13. package/lib/cli/argument-parser/index.js +58 -59
  14. package/lib/cli/cli.js +3 -2
  15. package/lib/client/automation/index.js +90 -4
  16. package/lib/client/automation/index.min.js +1 -1
  17. package/lib/client/browser/idle-page/index.js +7 -5
  18. package/lib/client/core/deps/hammerhead.js +24 -0
  19. package/lib/client/core/index.js +42 -7
  20. package/lib/client/core/index.min.js +1 -1
  21. package/lib/client/core/utils/values/axis-values.js +43 -0
  22. package/lib/client/driver/index.js +336 -211
  23. package/lib/client/driver/index.min.js +1 -1
  24. package/lib/client/test-run/iframe.js.mustache +2 -1
  25. package/lib/client/test-run/index.js.mustache +30 -28
  26. package/lib/client/ui/index.js +33 -23
  27. package/lib/client/ui/index.min.js +1 -1
  28. package/lib/compiler/babel/load-libs.js +10 -9
  29. package/lib/compiler/compilers.js +7 -7
  30. package/lib/compiler/esm-loader.js +38 -0
  31. package/lib/compiler/index.js +8 -7
  32. package/lib/compiler/interfaces.js +1 -1
  33. package/lib/compiler/prevent-module-caching-suffix.js +6 -0
  34. package/lib/compiler/test-file/add-export-api.js +3 -9
  35. package/lib/compiler/test-file/api-based.js +30 -14
  36. package/lib/compiler/test-file/base.js +4 -1
  37. package/lib/compiler/test-file/formats/coffeescript/compiler.js +5 -4
  38. package/lib/compiler/test-file/formats/es-next/compiler.js +21 -11
  39. package/lib/compiler/test-file/formats/extensions.js +15 -0
  40. package/lib/compiler/test-file/formats/typescript/compiler.js +27 -17
  41. package/lib/compiler/test-file/get-exportable-lib-path.js +17 -0
  42. package/lib/configuration/option-names.js +2 -1
  43. package/lib/custom-client-scripts/get-code.js +4 -3
  44. package/lib/custom-client-scripts/routing.js +3 -3
  45. package/lib/errors/is-internal-stack-frame.js +3 -2
  46. package/lib/errors/process-test-fn-error.js +3 -2
  47. package/lib/errors/runtime/index.js +18 -4
  48. package/lib/errors/runtime/templates.js +2 -1
  49. package/lib/errors/test-run/utils.js +8 -3
  50. package/lib/errors/types.js +2 -1
  51. package/lib/proxyless/api-base.js +25 -0
  52. package/lib/proxyless/client/event-simulator.js +40 -0
  53. package/lib/proxyless/client/types.js +11 -0
  54. package/lib/proxyless/client/utils.js +24 -0
  55. package/lib/proxyless/cookie-provider.js +3 -3
  56. package/lib/proxyless/index.js +20 -2
  57. package/lib/proxyless/request-hooks/event-factory/frame-navigated-event-based.js +40 -0
  58. package/lib/proxyless/request-hooks/event-factory/request-paused-event-based.js +95 -0
  59. package/lib/proxyless/request-hooks/event-provider.js +6 -54
  60. package/lib/proxyless/request-pipeline/context-info.js +55 -0
  61. package/lib/proxyless/request-pipeline/index.js +73 -31
  62. package/lib/proxyless/request-pipeline/resendAuthRequest.js +23 -0
  63. package/lib/proxyless/request-pipeline/special-handlers.js +2 -2
  64. package/lib/proxyless/request-pipeline/test-run-bridge.js +45 -0
  65. package/lib/proxyless/resource-injector.js +41 -29
  66. package/lib/proxyless/session-storage/index.js +39 -0
  67. package/lib/proxyless/storages-provider.js +17 -0
  68. package/lib/proxyless/types.js +8 -1
  69. package/lib/proxyless/utils/cdp.js +29 -2
  70. package/lib/proxyless/utils/get-active-client.js +8 -0
  71. package/lib/runner/bootstrapper.js +3 -2
  72. package/lib/runner/browser-job.js +1 -1
  73. package/lib/runner/task/index.js +2 -2
  74. package/lib/services/compiler/service.js +4 -4
  75. package/lib/services/utils/ipc/interfaces.js +1 -1
  76. package/lib/services/utils/ipc/proxy.js +1 -4
  77. package/lib/shared/utils/is-file-protocol.js +9 -0
  78. package/lib/test-run/commands/actions.js +2 -2
  79. package/lib/test-run/index.js +21 -6
  80. package/lib/test-run/request/send.js +20 -13
  81. package/lib/test-run/storages/base.js +16 -0
  82. package/lib/test-run/storages/factory.js +12 -0
  83. package/lib/testcafe.js +3 -3
  84. package/lib/utils/async-event-emitter.js +1 -1
  85. package/lib/utils/convert-to-best-fit-type.js +1 -1
  86. package/lib/utils/get-options/base.js +1 -1
  87. package/lib/utils/setup-sourcemap-support.js +10 -4
  88. package/package.json +13 -8
  89. package/ts-defs/index.d.ts +4 -4
  90. package/ts-defs/selectors.d.ts +2 -2
  91. package/ts-defs/testcafe-scripts.d.ts +2 -2
  92. package/lib/compiler/test-file/exportble-lib-path.js +0 -7
  93. package/lib/proxyless/request-hooks/event-factory.js +0 -95
@@ -431,6 +431,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
431
431
  var setScrollLeft = hammerhead__default.utils.style.setScrollLeft;
432
432
  var setScrollTop = hammerhead__default.utils.style.setScrollTop;
433
433
  var get = hammerhead__default.utils.style.get;
434
+ var getBordersWidthFloat = hammerhead__default.utils.style.getBordersWidthFloat;
435
+ var getElementPaddingFloat = hammerhead__default.utils.style.getElementPaddingFloat;
434
436
  function getWindowDimensions(window) {
435
437
  return new BoundaryValues(0, getWidth(window), getHeight(window), 0);
436
438
  }
@@ -2883,6 +2885,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
2883
2885
  endY: endPoint.y,
2884
2886
  modifiers: this.modifiers,
2885
2887
  speed: this.speed,
2888
+ shouldRender: this.cursor.shouldRender,
2886
2889
  };
2887
2890
  return hammerhead.Promise.resolve()
2888
2891
  .then(function () {
@@ -2963,6 +2966,16 @@ window['%hammerhead%'].utils.removeInjectedScript();
2963
2966
  Cursor.prototype.getPosition = function () {
2964
2967
  return new AxisValues(this._x, this._y);
2965
2968
  };
2969
+ Object.defineProperty(Cursor.prototype, "shouldRender", {
2970
+ get: function () {
2971
+ return this._ui.shouldRender;
2972
+ },
2973
+ set: function (val) {
2974
+ this._ui.shouldRender = val;
2975
+ },
2976
+ enumerable: false,
2977
+ configurable: true
2978
+ });
2966
2979
  Cursor.prototype.move = function (point) {
2967
2980
  this._x = point.x;
2968
2981
  this._y = point.y;
@@ -3037,6 +3050,68 @@ window['%hammerhead%'].utils.removeInjectedScript();
3037
3050
  elementOverlapped: 'elementOverlapped',
3038
3051
  };
3039
3052
 
3053
+ var EventType;
3054
+ (function (EventType) {
3055
+ EventType[EventType["Mouse"] = 0] = "Mouse";
3056
+ EventType[EventType["Key"] = 1] = "Key";
3057
+ EventType[EventType["Touch"] = 2] = "Touch";
3058
+ })(EventType || (EventType = {}));
3059
+
3060
+ var KeyModifierValues;
3061
+ (function (KeyModifierValues) {
3062
+ KeyModifierValues[KeyModifierValues["alt"] = 1] = "alt";
3063
+ KeyModifierValues[KeyModifierValues["ctrl"] = 2] = "ctrl";
3064
+ KeyModifierValues[KeyModifierValues["meta"] = 4] = "meta";
3065
+ KeyModifierValues[KeyModifierValues["shift"] = 8] = "shift";
3066
+ })(KeyModifierValues || (KeyModifierValues = {}));
3067
+
3068
+ function calculateKeyModifiersValue(modifiers) {
3069
+ var result = 0;
3070
+ if (modifiers.ctrl)
3071
+ result |= KeyModifierValues.ctrl;
3072
+ if (modifiers.alt)
3073
+ result |= KeyModifierValues.alt;
3074
+ if (modifiers.shift)
3075
+ result |= KeyModifierValues.shift;
3076
+ if (modifiers.meta)
3077
+ result |= KeyModifierValues.meta;
3078
+ return result;
3079
+ }
3080
+ function calculateMouseButtonValue(options) {
3081
+ if (!options.button)
3082
+ return 'left';
3083
+ return 'right';
3084
+ }
3085
+
3086
+ var MOUSE_EVENT_OPTIONS = {
3087
+ clickCount: 1,
3088
+ button: 'left',
3089
+ };
3090
+ var ProxylessEventSimulator = /** @class */ (function () {
3091
+ function ProxylessEventSimulator(dispatchEventFn, leftTopPoint) {
3092
+ this._dispatchEventFn = dispatchEventFn;
3093
+ this._leftTopPoint = leftTopPoint || new AxisValues(0, 0);
3094
+ }
3095
+ ProxylessEventSimulator.prototype._createMouseEventOptions = function (type, options) {
3096
+ return hammerhead.utils.extend({
3097
+ x: options.options.clientX + this._leftTopPoint.x,
3098
+ y: options.options.clientY + this._leftTopPoint.y,
3099
+ modifiers: calculateKeyModifiersValue(options.options),
3100
+ button: calculateMouseButtonValue(options.options),
3101
+ type: type,
3102
+ }, MOUSE_EVENT_OPTIONS);
3103
+ };
3104
+ ProxylessEventSimulator.prototype.mouseDown = function (options) {
3105
+ var eventOptions = this._createMouseEventOptions('mousePressed', options);
3106
+ return this._dispatchEventFn(EventType.Mouse, eventOptions);
3107
+ };
3108
+ ProxylessEventSimulator.prototype.mouseUp = function (options) {
3109
+ var eventOptions = this._createMouseEventOptions('mouseReleased', options);
3110
+ return this._dispatchEventFn(EventType.Mouse, eventOptions);
3111
+ };
3112
+ return ProxylessEventSimulator;
3113
+ }());
3114
+
3040
3115
  var AVAILABLE_OFFSET_DEEP = 2;
3041
3116
  var ElementState = /** @class */ (function () {
3042
3117
  function ElementState(_a) {
@@ -3072,7 +3147,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3072
3147
  }());
3073
3148
  var VisibleElementAutomation = /** @class */ (function (_super) {
3074
3149
  __extends(VisibleElementAutomation, _super);
3075
- function VisibleElementAutomation(element, offsetOptions, win, cursor) {
3150
+ function VisibleElementAutomation(element, offsetOptions, win, cursor, dispatchProxylessEventFn, topLeftPoint) {
3076
3151
  var _this = _super.call(this) || this;
3077
3152
  _this.TARGET_ELEMENT_FOUND_EVENT = 'automation|target-element-found-event';
3078
3153
  _this.WARNING_EVENT = 'automation|warning-event';
@@ -3081,6 +3156,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3081
3156
  _this.automationSettings = new AutomationSettings(offsetOptions.speed || 1);
3082
3157
  _this.window = win;
3083
3158
  _this.cursor = cursor;
3159
+ _this.proxylessEventSimulator = dispatchProxylessEventFn ? new ProxylessEventSimulator(dispatchProxylessEventFn, topLeftPoint) : null;
3084
3160
  // NOTE: only for legacy API
3085
3161
  _this._ensureWindowAndCursorForLegacyTests(_this);
3086
3162
  return _this;
@@ -3089,6 +3165,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
3089
3165
  automation.window = automation.window || window; // eslint-disable-line no-undef
3090
3166
  automation.cursor = cursor;
3091
3167
  };
3168
+ VisibleElementAutomation.prototype.canUseProxylessEventSimulator = function (element) {
3169
+ return !!this.proxylessEventSimulator
3170
+ && !!element
3171
+ && getTagName(element) !== 'select';
3172
+ };
3092
3173
  VisibleElementAutomation.prototype._getElementForEvent = function (eventArgs) {
3093
3174
  return __awaiter(this, void 0, void 0, function () {
3094
3175
  var expectedElement;
@@ -3109,7 +3190,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3109
3190
  return [4 /*yield*/, MoveAutomation.create(this.element, moveOptions, this.window, this.cursor)];
3110
3191
  case 1:
3111
3192
  moveAutomation = _a.sent();
3112
- return [2 /*return*/, moveAutomation
3193
+ return [2 /*return*/, moveAutomation // eslint-disable-line consistent-return
3113
3194
  .run()
3114
3195
  .then(function () { return delay(_this.automationSettings.mouseActionStepDelay); })];
3115
3196
  }
@@ -3824,16 +3905,20 @@ window['%hammerhead%'].utils.removeInjectedScript();
3824
3905
 
3825
3906
  var ClickAutomation = /** @class */ (function (_super) {
3826
3907
  __extends(ClickAutomation, _super);
3827
- function ClickAutomation(element, clickOptions, win, cursor) {
3828
- var _this = _super.call(this, element, clickOptions, win, cursor) || this;
3908
+ function ClickAutomation(element, clickOptions, win, cursor, dispatchProxylessEventFn, leftTopPoint) {
3909
+ var _this = _super.call(this, element, clickOptions, win, cursor, dispatchProxylessEventFn, leftTopPoint) || this;
3829
3910
  _this.modifiers = clickOptions.modifiers;
3830
3911
  _this.strategy = createMouseClickStrategy(_this.element, clickOptions.caretPos);
3831
3912
  return _this;
3832
3913
  }
3833
3914
  ClickAutomation.prototype._mousedown = function (eventArgs) {
3915
+ if (this.canUseProxylessEventSimulator(eventArgs.element))
3916
+ return this.proxylessEventSimulator.mouseDown(eventArgs);
3834
3917
  return this.strategy.mousedown(eventArgs);
3835
3918
  };
3836
3919
  ClickAutomation.prototype._mouseup = function (element, eventArgs) {
3920
+ if (this.canUseProxylessEventSimulator(eventArgs.element))
3921
+ return this.proxylessEventSimulator.mouseUp(eventArgs);
3837
3922
  return this.strategy.mouseup(element, eventArgs);
3838
3923
  };
3839
3924
  ClickAutomation.prototype.run = function (useStrictElementCheck) {
@@ -3935,6 +4020,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3935
4020
  var iframeRectangle = positionUtils$2.getIframeClientCoordinates(iframe);
3936
4021
  var iframePointRelativeToParent = positionUtils$2.getIframePointRelativeToParentFrame(iframePoint, iframeWin);
3937
4022
  var cursorPosition = cursor.getPosition();
4023
+ cursor.shouldRender = e.message.shouldRender;
3938
4024
  var intersectionPoint = positionUtils$2.isInRectangle(cursorPosition, iframeRectangle) ? cursorPosition :
3939
4025
  getLineRectIntersection(cursorPosition, iframePointRelativeToParent, iframeRectangle);
3940
4026
  var intersectionRelatedToIframe = {