testcafe 1.20.2-alpha.1 → 2.0.0-rc.3

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 (231) hide show
  1. package/lib/api/request-hooks/assert-type.js +2 -2
  2. package/lib/api/request-hooks/hook.js +2 -2
  3. package/lib/api/request-hooks/request-logger.js +2 -2
  4. package/lib/api/skip-js-errors/index.js +62 -0
  5. package/lib/api/structure/base-unit.js +2 -2
  6. package/lib/api/structure/fixture.js +13 -13
  7. package/lib/api/structure/test.js +18 -17
  8. package/lib/api/structure/testing-unit.js +26 -16
  9. package/lib/api/test-controller/assertion.js +5 -5
  10. package/lib/api/test-controller/execution-context.js +2 -2
  11. package/lib/api/test-controller/index.js +33 -30
  12. package/lib/api/test-controller/proxy.js +2 -2
  13. package/lib/api/test-page-url.js +4 -4
  14. package/lib/api/test-run-tracker.js +2 -2
  15. package/lib/api/wrap-test-function.js +3 -3
  16. package/lib/assertions/executor.js +4 -4
  17. package/lib/assertions/get-fn.js +3 -3
  18. package/lib/browser/connection/gateway.js +18 -18
  19. package/lib/browser/connection/get-hints.js +8 -8
  20. package/lib/browser/connection/index.js +11 -11
  21. package/lib/browser/connection/remotes-queue.js +4 -4
  22. package/lib/browser/provider/built-in/dedicated/base.js +6 -6
  23. package/lib/browser/provider/built-in/dedicated/chrome/cdp-client/index.js +10 -10
  24. package/lib/browser/provider/built-in/dedicated/chrome/config.js +17 -17
  25. package/lib/browser/provider/built-in/dedicated/chrome/create-temp-profile.js +4 -4
  26. package/lib/browser/provider/built-in/dedicated/chrome/index.js +6 -6
  27. package/lib/browser/provider/built-in/dedicated/chrome/local-chrome.js +6 -6
  28. package/lib/browser/provider/built-in/dedicated/chrome/runtime-info.js +4 -4
  29. package/lib/browser/provider/built-in/dedicated/edge/runtime-info.js +2 -2
  30. package/lib/browser/provider/built-in/dedicated/firefox/config.js +8 -8
  31. package/lib/browser/provider/built-in/dedicated/firefox/create-temp-profile.js +3 -3
  32. package/lib/browser/provider/built-in/dedicated/firefox/index.js +5 -5
  33. package/lib/browser/provider/built-in/dedicated/firefox/local-firefox.js +2 -2
  34. package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/index.js +7 -7
  35. package/lib/browser/provider/built-in/dedicated/firefox/runtime-info.js +3 -3
  36. package/lib/browser/provider/built-in/path.js +2 -2
  37. package/lib/browser/provider/built-in/remote.js +3 -3
  38. package/lib/browser/provider/index.js +5 -5
  39. package/lib/browser/provider/plugin-host.js +5 -6
  40. package/lib/browser/provider/pool.js +4 -4
  41. package/lib/browser/provider/utils/argument-parsing.js +3 -3
  42. package/lib/browser/provider/utils/browser-starter.js +2 -2
  43. package/lib/cli/argument-parser/index.js +52 -41
  44. package/lib/cli/argument-parser/parse-utils.js +2 -2
  45. package/lib/cli/authentication-helper.js +3 -3
  46. package/lib/cli/cli.js +8 -8
  47. package/lib/cli/correct-browsers-and-sources.js +2 -2
  48. package/lib/cli/index.js +2 -2
  49. package/lib/cli/log.js +3 -3
  50. package/lib/cli/remotes-wizard.js +3 -3
  51. package/lib/client/automation/index.js +120 -34
  52. package/lib/client/automation/index.min.js +1 -1
  53. package/lib/client/browser/idle-page/index.js +321 -317
  54. package/lib/client/browser/service-worker.js +244 -290
  55. package/lib/client/core/deps/hammerhead.js +12 -4
  56. package/lib/client/core/index.js +145 -55
  57. package/lib/client/core/index.min.js +1 -1
  58. package/lib/client/core/utils/dom.js +33 -28
  59. package/lib/client/core/utils/position.js +18 -14
  60. package/lib/client/core/utils/style.js +8 -4
  61. package/lib/client/driver/command-executors/client-functions/selector-executor/filter.js +5 -5
  62. package/lib/client/driver/command-executors/client-functions/selector-executor/utils.js +3 -3
  63. package/lib/client/driver/deps/hammerhead.js +12 -4
  64. package/lib/client/driver/deps/testcafe-core.js +12 -4
  65. package/lib/client/driver/deps/testcafe-ui.js +12 -4
  66. package/lib/client/driver/index.js +654 -630
  67. package/lib/client/driver/index.min.js +1 -1
  68. package/lib/client/driver/status.js +2 -2
  69. package/lib/client/ui/index.js +10 -8
  70. package/lib/client/ui/index.min.js +1 -1
  71. package/lib/client-functions/builder-symbol.js +1 -2
  72. package/lib/client-functions/client-function-builder.js +12 -12
  73. package/lib/client-functions/replicator.js +2 -2
  74. package/lib/client-functions/selector-api-execution-mode.js +2 -2
  75. package/lib/client-functions/selectors/add-api.js +48 -48
  76. package/lib/client-functions/selectors/selector-builder.js +17 -17
  77. package/lib/compiler/compile-client-function.js +6 -6
  78. package/lib/compiler/index.js +9 -9
  79. package/lib/compiler/test-file/api-based.js +8 -8
  80. package/lib/compiler/test-file/base.js +6 -6
  81. package/lib/compiler/test-file/exportble-lib-path.js +2 -2
  82. package/lib/compiler/test-file/formats/coffeescript/compiler.js +2 -2
  83. package/lib/compiler/test-file/formats/coffeescript/get-test-list.js +2 -2
  84. package/lib/compiler/test-file/formats/es-next/compiler.js +4 -4
  85. package/lib/compiler/test-file/formats/es-next/get-test-list.js +4 -4
  86. package/lib/compiler/test-file/formats/raw.js +2 -2
  87. package/lib/compiler/test-file/formats/typescript/compiler.js +11 -11
  88. package/lib/compiler/test-file/formats/typescript/get-test-list.js +3 -3
  89. package/lib/compiler/test-file/test-file-parser-base.js +3 -3
  90. package/lib/configuration/configuration-base.js +15 -15
  91. package/lib/configuration/interfaces.js +1 -1
  92. package/lib/configuration/skip-js-errors-option-names.js +11 -0
  93. package/lib/configuration/testcafe-configuration.js +21 -16
  94. package/lib/configuration/types.js +1 -1
  95. package/lib/configuration/typescript-configuration.js +4 -4
  96. package/lib/custom-client-scripts/assert-type.js +2 -2
  97. package/lib/custom-client-scripts/client-script.js +6 -6
  98. package/lib/custom-client-scripts/get-code.js +2 -2
  99. package/lib/custom-client-scripts/routing.js +3 -3
  100. package/lib/custom-client-scripts/utils.js +3 -3
  101. package/lib/dashboard/connector.js +4 -4
  102. package/lib/dashboard/get-default-project-link.js +2 -2
  103. package/lib/dashboard/index.js +26 -26
  104. package/lib/errors/create-stack-filter.js +2 -2
  105. package/lib/errors/error-list.js +2 -2
  106. package/lib/errors/get-callsite.js +2 -2
  107. package/lib/errors/is-internal-stack-frame.js +5 -5
  108. package/lib/errors/process-test-fn-error.js +2 -2
  109. package/lib/errors/runtime/index.js +10 -10
  110. package/lib/errors/runtime/templates.js +5 -2
  111. package/lib/errors/runtime/type-assertions.js +6 -6
  112. package/lib/errors/stack-cleaning-hook.js +2 -2
  113. package/lib/errors/test-run/formattable-adapter.js +7 -7
  114. package/lib/errors/test-run/index.js +25 -5
  115. package/lib/errors/test-run/render-error-template/index.js +6 -6
  116. package/lib/errors/test-run/render-error-template/utils.js +2 -2
  117. package/lib/errors/test-run/templates.js +40 -31
  118. package/lib/errors/test-run/utils.js +7 -7
  119. package/lib/errors/types.js +5 -1
  120. package/lib/index.js +1 -1
  121. package/lib/live/file-watcher/index.js +2 -2
  122. package/lib/live/keyboard-observer.js +3 -3
  123. package/lib/live/test-run-controller.js +3 -3
  124. package/lib/live/test-run.js +3 -2
  125. package/lib/live/test-runner.js +2 -2
  126. package/lib/load-assets.js +2 -2
  127. package/lib/notifications/add-rendered-warning.js +4 -4
  128. package/lib/notifications/debug-logger.js +6 -6
  129. package/lib/notifications/deprecated.js +2 -2
  130. package/lib/notifications/information-message.js +4 -3
  131. package/lib/proxyless/resource-injector.js +4 -4
  132. package/lib/reporter/command/command-formatter.js +4 -4
  133. package/lib/reporter/index.js +10 -10
  134. package/lib/reporter/plugin-host.js +7 -7
  135. package/lib/role/index.js +8 -8
  136. package/lib/role/role.js +2 -2
  137. package/lib/runner/bootstrapper.js +20 -20
  138. package/lib/runner/browser-job.js +3 -3
  139. package/lib/runner/browser-set.js +12 -12
  140. package/lib/runner/fixture-hook-controller.js +5 -5
  141. package/lib/runner/index.js +43 -33
  142. package/lib/runner/task/index.js +10 -6
  143. package/lib/runner/test-run-hook-controller.js +5 -5
  144. package/lib/runner/tested-app.js +7 -7
  145. package/lib/screenshots/capturer.js +17 -17
  146. package/lib/screenshots/crop.js +8 -8
  147. package/lib/screenshots/index.js +6 -10
  148. package/lib/screenshots/utils.js +4 -4
  149. package/lib/services/compiler/host.js +8 -8
  150. package/lib/services/compiler/service.js +13 -13
  151. package/lib/services/compiler/test-run-proxy.js +8 -8
  152. package/lib/services/serialization/replicator/transforms/callsite-record-transform.js +2 -2
  153. package/lib/services/serialization/replicator/transforms/command-base-trasform/command-constructors.js +2 -1
  154. package/lib/services/serialization/replicator/transforms/command-base-trasform/index.js +3 -3
  155. package/lib/services/serialization/replicator/transforms/raw-command-callsite-record-transform.js +2 -2
  156. package/lib/services/serialization/test-structure.js +4 -4
  157. package/lib/services/utils/ipc/interfaces.js +1 -3
  158. package/lib/services/utils/ipc/io.js +3 -3
  159. package/lib/services/utils/ipc/message.js +2 -2
  160. package/lib/services/utils/ipc/proxy.js +4 -4
  161. package/lib/services/utils/ipc/transport.js +2 -2
  162. package/lib/shared/errors/index.js +9 -2
  163. package/lib/shared/errors/selector-error-ctor-callback.js +7 -3
  164. package/lib/test-run/bookmark.js +1 -1
  165. package/lib/test-run/browser-manipulation-queue.js +3 -3
  166. package/lib/test-run/commands/actions.js +66 -46
  167. package/lib/test-run/commands/assertion.js +3 -3
  168. package/lib/test-run/commands/base.js +2 -2
  169. package/lib/test-run/commands/browser-manipulation.js +8 -8
  170. package/lib/test-run/commands/observation.js +4 -4
  171. package/lib/test-run/commands/options.js +27 -12
  172. package/lib/test-run/commands/type.js +2 -1
  173. package/lib/test-run/commands/utils.js +3 -2
  174. package/lib/test-run/commands/validations/argument.js +19 -10
  175. package/lib/test-run/commands/validations/factories.js +10 -2
  176. package/lib/test-run/commands/validations/initializers.js +4 -4
  177. package/lib/test-run/debug-log.js +4 -4
  178. package/lib/test-run/execute-js-expression/index.js +4 -4
  179. package/lib/test-run/index.js +48 -41
  180. package/lib/test-run/request/create-request-options.js +9 -9
  181. package/lib/test-run/request/process-response-data.js +2 -2
  182. package/lib/test-run/request/send.js +5 -5
  183. package/lib/testcafe.js +8 -4
  184. package/lib/utils/check-file-path.js +2 -2
  185. package/lib/utils/check-url.js +2 -2
  186. package/lib/utils/correct-file-path.js +4 -4
  187. package/lib/utils/delegated-api.js +1 -1
  188. package/lib/utils/detect-ffmpeg.js +3 -3
  189. package/lib/utils/diff/colors.js +2 -2
  190. package/lib/utils/diff/index.js +11 -7
  191. package/lib/utils/diff/util.js +5 -5
  192. package/lib/utils/diff.js +4 -4
  193. package/lib/utils/escape-user-agent.js +2 -2
  194. package/lib/utils/execute-fn-with-timeout.js +2 -2
  195. package/lib/utils/get-browser.js +2 -2
  196. package/lib/utils/get-filter-fn.js +4 -4
  197. package/lib/utils/get-options/base.js +2 -2
  198. package/lib/utils/get-options/compiler.js +2 -2
  199. package/lib/utils/get-options/dashboard.js +2 -2
  200. package/lib/utils/get-options/get-assertion-timeout.js +1 -1
  201. package/lib/utils/get-options/index.js +4 -2
  202. package/lib/utils/get-options/meta.js +2 -2
  203. package/lib/utils/get-options/quarantine.js +8 -6
  204. package/lib/utils/get-options/screenshot.js +2 -2
  205. package/lib/utils/get-options/skip-js-errors.js +35 -0
  206. package/lib/utils/get-options/ssl.js +6 -6
  207. package/lib/utils/get-options/video.js +2 -2
  208. package/lib/utils/is-password-input.js +1 -1
  209. package/lib/utils/log-entry.js +2 -2
  210. package/lib/utils/make-reg-exp.js +19 -6
  211. package/lib/utils/moment-loader.js +2 -2
  212. package/lib/utils/parse-file-list.js +7 -7
  213. package/lib/utils/path-pattern.js +4 -4
  214. package/lib/utils/prepare-reporters.js +2 -2
  215. package/lib/utils/prerender-callsite.js +6 -6
  216. package/lib/utils/process.js +7 -7
  217. package/lib/utils/promisified-functions.js +14 -14
  218. package/lib/utils/raw-command-callsite-record.js +2 -2
  219. package/lib/utils/resolve-path-relatively-cwd.js +2 -2
  220. package/lib/utils/string.js +3 -3
  221. package/lib/utils/temp-directory/cleanup-process/index.js +6 -6
  222. package/lib/utils/temp-directory/cleanup-process/worker.js +4 -4
  223. package/lib/utils/temp-directory/index.js +6 -6
  224. package/lib/utils/temp-directory/lockfile.js +2 -2
  225. package/lib/video-recorder/process.js +6 -6
  226. package/lib/video-recorder/recorder.js +9 -9
  227. package/lib/video-recorder/test-run-video-recorder.js +2 -2
  228. package/package.json +8 -7
  229. package/ts-defs/index.d.ts +46 -7
  230. package/ts-defs/selectors.d.ts +39 -0
  231. package/ts-defs/testcafe-scripts.d.ts +39 -0
@@ -11,12 +11,12 @@ window['%hammerhead%'].utils.removeInjectedScript();
11
11
  var hammerhead__default = 'default' in hammerhead ? hammerhead['default'] : hammerhead;
12
12
  Promise$3 = Promise$3 && Object.prototype.hasOwnProperty.call(Promise$3, 'default') ? Promise$3['default'] : Promise$3;
13
13
 
14
- /*! *****************************************************************************
14
+ /******************************************************************************
15
15
  Copyright (c) Microsoft Corporation.
16
-
16
+
17
17
  Permission to use, copy, modify, and/or distribute this software for any
18
18
  purpose with or without fee is hereby granted.
19
-
19
+
20
20
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
21
  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
22
  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -26,64 +26,119 @@ window['%hammerhead%'].utils.removeInjectedScript();
26
26
  PERFORMANCE OF THIS SOFTWARE.
27
27
  ***************************************************************************** */
28
28
  /* global Reflect, Promise */
29
-
30
- var extendStatics = function(d, b) {
29
+ var extendStatics = function (d, b) {
31
30
  extendStatics = Object.setPrototypeOf ||
32
31
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
33
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
32
+ function (d, b) { for (var p in b)
33
+ if (Object.prototype.hasOwnProperty.call(b, p))
34
+ d[p] = b[p]; };
34
35
  return extendStatics(d, b);
35
36
  };
36
-
37
37
  function __extends(d, b) {
38
+ if (typeof b !== "function" && b !== null)
39
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
38
40
  extendStatics(d, b);
39
41
  function __() { this.constructor = d; }
40
42
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
41
43
  }
42
-
43
44
  function __awaiter(thisArg, _arguments, P, generator) {
44
45
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
45
46
  return new (P || (P = Promise$3))(function (resolve, reject) {
46
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
47
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47
+ function fulfilled(value) { try {
48
+ step(generator.next(value));
49
+ }
50
+ catch (e) {
51
+ reject(e);
52
+ } }
53
+ function rejected(value) { try {
54
+ step(generator["throw"](value));
55
+ }
56
+ catch (e) {
57
+ reject(e);
58
+ } }
48
59
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
49
60
  step((generator = generator.apply(thisArg, _arguments || [])).next());
50
61
  });
51
62
  }
52
-
53
63
  function __generator(thisArg, body) {
54
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
55
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
64
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
65
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
66
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
56
67
  function verb(n) { return function (v) { return step([n, v]); }; }
57
68
  function step(op) {
58
- if (f) throw new TypeError("Generator is already executing.");
59
- while (_) try {
60
- 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) return t;
61
- if (y = 0, t) op = [op[0] & 2, t.value];
62
- switch (op[0]) {
63
- case 0: case 1: t = op; break;
64
- case 4: _.label++; return { value: op[1], done: false };
65
- case 5: _.label++; y = op[1]; op = [0]; continue;
66
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
67
- default:
68
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
69
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
70
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
71
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
72
- if (t[2]) _.ops.pop();
73
- _.trys.pop(); continue;
69
+ if (f)
70
+ throw new TypeError("Generator is already executing.");
71
+ while (_)
72
+ try {
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
+ return t;
75
+ if (y = 0, t)
76
+ op = [op[0] & 2, t.value];
77
+ switch (op[0]) {
78
+ case 0:
79
+ case 1:
80
+ t = op;
81
+ break;
82
+ case 4:
83
+ _.label++;
84
+ return { value: op[1], done: false };
85
+ case 5:
86
+ _.label++;
87
+ y = op[1];
88
+ op = [0];
89
+ continue;
90
+ case 7:
91
+ op = _.ops.pop();
92
+ _.trys.pop();
93
+ continue;
94
+ default:
95
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
96
+ _ = 0;
97
+ continue;
98
+ }
99
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
100
+ _.label = op[1];
101
+ break;
102
+ }
103
+ if (op[0] === 6 && _.label < t[1]) {
104
+ _.label = t[1];
105
+ t = op;
106
+ break;
107
+ }
108
+ if (t && _.label < t[2]) {
109
+ _.label = t[2];
110
+ _.ops.push(op);
111
+ break;
112
+ }
113
+ if (t[2])
114
+ _.ops.pop();
115
+ _.trys.pop();
116
+ continue;
117
+ }
118
+ op = body.call(thisArg, _);
119
+ }
120
+ catch (e) {
121
+ op = [6, e];
122
+ y = 0;
123
+ }
124
+ finally {
125
+ f = t = 0;
74
126
  }
75
- op = body.call(thisArg, _);
76
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
77
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
127
+ if (op[0] & 5)
128
+ throw op[1];
129
+ return { value: op[0] ? op[1] : void 0, done: true };
78
130
  }
79
131
  }
80
-
81
- function __spreadArrays() {
82
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
83
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
84
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
85
- r[k] = a[j];
86
- return r;
132
+ function __spreadArray(to, from, pack) {
133
+ if (pack || arguments.length === 2)
134
+ for (var i = 0, l = from.length, ar; i < l; i++) {
135
+ if (ar || !(i in from)) {
136
+ if (!ar)
137
+ ar = Array.prototype.slice.call(from, 0, i);
138
+ ar[i] = from[i];
139
+ }
140
+ }
141
+ return to.concat(ar || Array.prototype.slice.call(from));
87
142
  }
88
143
 
89
144
  // -------------------------------------------------------------
@@ -175,6 +230,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
175
230
  deleteCookies: 'delete-cookies',
176
231
  getProxyUrl: 'get-proxy-url',
177
232
  request: 'request',
233
+ skipJsErrors: 'skip-js-errors',
178
234
  };
179
235
 
180
236
  // -------------------------------------------------------------
@@ -275,6 +331,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
275
331
  actionUrlSearchParamsOptionError: 'E94',
276
332
  actionObjectOptionError: 'E95',
277
333
  actionUrlArgumentError: 'E96',
334
+ actionStringOrRegexOptionError: 'E97',
335
+ actionSkipJsErrorsArgumentError: 'E98',
336
+ actionSkipJsErrorsDependenciesArgumentError: 'E99',
278
337
  };
279
338
 
280
339
  // -------------------------------------------------------------
@@ -493,6 +552,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
493
552
  }
494
553
  return ActionStringOptionError;
495
554
  }(ActionOptionErrorBase));
555
+ var ActionStringOrRegexOptionError = /** @class */ (function (_super) {
556
+ __extends(ActionStringOrRegexOptionError, _super);
557
+ function ActionStringOrRegexOptionError(optionName, actualValue) {
558
+ return _super.call(this, TEST_RUN_ERRORS.actionStringOrRegexOptionError, optionName, actualValue) || this;
559
+ }
560
+ return ActionStringOrRegexOptionError;
561
+ }(ActionOptionErrorBase));
496
562
  var ActionDateOptionError = /** @class */ (function (_super) {
497
563
  __extends(ActionDateOptionError, _super);
498
564
  function ActionDateOptionError(optionName, actualValue) {
@@ -842,6 +908,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
842
908
  ActionBooleanOptionError: ActionBooleanOptionError,
843
909
  ActionSpeedOptionError: ActionSpeedOptionError,
844
910
  ActionStringOptionError: ActionStringOptionError,
911
+ ActionStringOrRegexOptionError: ActionStringOrRegexOptionError,
845
912
  ActionDateOptionError: ActionDateOptionError,
846
913
  ActionNumberOptionError: ActionNumberOptionError,
847
914
  ActionUrlOptionError: ActionUrlOptionError,
@@ -969,585 +1036,438 @@ window['%hammerhead%'].utils.removeInjectedScript();
969
1036
  return module = { exports: {} }, fn(module, module.exports), module.exports;
970
1037
  }
971
1038
 
972
- var replicator = createCommonjsModule(function (module) {
973
- // Const
974
- var TRANSFORMED_TYPE_KEY = '@t';
975
- var CIRCULAR_REF_KEY = '@r';
976
- var KEY_REQUIRE_ESCAPING_RE = /^#*@(t|r)$/;
977
-
978
- var GLOBAL = (function getGlobal () {
979
- // NOTE: see http://www.ecma-international.org/ecma-262/6.0/index.html#sec-performeval step 10
980
- var savedEval = eval;
981
-
982
- return savedEval('this');
983
- })();
984
-
985
- var TYPED_ARRAY_CTORS = {
986
- 'Int8Array': typeof Int8Array === 'function' ? Int8Array : void 0,
987
- 'Uint8Array': typeof Uint8Array === 'function' ? Uint8Array : void 0,
988
- 'Uint8ClampedArray': typeof Uint8ClampedArray === 'function' ? Uint8ClampedArray : void 0,
989
- 'Int16Array': typeof Int16Array === 'function' ? Int16Array : void 0,
990
- 'Uint16Array': typeof Uint16Array === 'function' ? Uint16Array : void 0,
991
- 'Int32Array': typeof Int32Array === 'function' ? Int32Array : void 0,
992
- 'Uint32Array': typeof Uint32Array === 'function' ? Uint32Array : void 0,
993
- 'Float32Array': typeof Float32Array === 'function' ? Float32Array : void 0,
994
- 'Float64Array': typeof Float64Array === 'function' ? Float64Array : void 0
995
- };
996
-
997
- var ARRAY_BUFFER_SUPPORTED = typeof ArrayBuffer === 'function';
998
- var MAP_SUPPORTED = typeof Map === 'function';
999
- var SET_SUPPORTED = typeof Set === 'function';
1000
- var BUFFER_FROM_SUPPORTED = typeof Buffer === 'function';
1001
-
1002
- var TYPED_ARRAY_SUPPORTED = function (typeName) {
1003
- return !!TYPED_ARRAY_CTORS[typeName];
1004
- };
1005
-
1006
- // Saved proto functions
1007
- var arrSlice = Array.prototype.slice;
1008
-
1009
-
1010
- // Default serializer
1011
- var JSONSerializer = {
1012
- serialize: function (val) {
1013
- return JSON.stringify(val);
1014
- },
1015
-
1016
- deserialize: function (val) {
1017
- return JSON.parse(val);
1018
- }
1019
- };
1020
-
1021
-
1022
- // EncodingTransformer
1023
- var EncodingTransformer = function (val, transforms) {
1024
- this.references = val;
1025
- this.transforms = transforms;
1026
- this.circularCandidates = [];
1027
- this.circularCandidatesDescrs = [];
1028
- this.circularRefCount = 0;
1029
- };
1030
-
1031
- EncodingTransformer._createRefMark = function (idx) {
1032
- var obj = Object.create(null);
1033
-
1034
- obj[CIRCULAR_REF_KEY] = idx;
1035
-
1036
- return obj;
1037
- };
1038
-
1039
- EncodingTransformer.prototype._createCircularCandidate = function (val, parent, key) {
1040
- this.circularCandidates.push(val);
1041
- this.circularCandidatesDescrs.push({ parent: parent, key: key, refIdx: -1 });
1042
- };
1043
-
1044
- EncodingTransformer.prototype._applyTransform = function (val, parent, key, transform) {
1045
- var result = Object.create(null);
1046
- var serializableVal = transform.toSerializable(val);
1047
-
1048
- if (typeof serializableVal === 'object')
1049
- this._createCircularCandidate(val, parent, key);
1050
-
1051
- result[TRANSFORMED_TYPE_KEY] = transform.type;
1052
- result.data = this._handleValue(serializableVal, parent, key);
1053
-
1054
- return result;
1055
- };
1056
-
1057
- EncodingTransformer.prototype._handleArray = function (arr) {
1058
- var result = [];
1059
-
1060
- for (var i = 0; i < arr.length; i++)
1061
- result[i] = this._handleValue(arr[i], result, i);
1062
-
1063
- return result;
1064
- };
1065
-
1066
- EncodingTransformer.prototype._handlePlainObject = function (obj) {
1067
- var replicator = this;
1068
- var result = Object.create(null);
1069
- var ownPropertyNames = Object.getOwnPropertyNames(obj);
1070
-
1071
- ownPropertyNames.forEach(function (key) {
1072
- var resultKey = KEY_REQUIRE_ESCAPING_RE.test(key) ? '#' + key : key;
1073
-
1074
- result[resultKey] = replicator._handleValue(obj[key], result, resultKey);
1075
- });
1076
-
1077
- return result;
1078
- };
1079
-
1080
- EncodingTransformer.prototype._handleObject = function (obj, parent, key) {
1081
- this._createCircularCandidate(obj, parent, key);
1082
-
1083
- return Array.isArray(obj) ? this._handleArray(obj) : this._handlePlainObject(obj);
1084
- };
1085
-
1086
- EncodingTransformer.prototype._ensureCircularReference = function (obj) {
1087
- var circularCandidateIdx = this.circularCandidates.indexOf(obj);
1088
-
1089
- if (circularCandidateIdx > -1) {
1090
- var descr = this.circularCandidatesDescrs[circularCandidateIdx];
1091
-
1092
- if (descr.refIdx === -1)
1093
- descr.refIdx = descr.parent ? ++this.circularRefCount : 0;
1094
-
1095
- return EncodingTransformer._createRefMark(descr.refIdx);
1096
- }
1097
-
1098
- return null;
1099
- };
1100
-
1101
- EncodingTransformer.prototype._handleValue = function (val, parent, key) {
1102
- var type = typeof val;
1103
- var isObject = type === 'object' && val !== null;
1104
-
1105
- if (isObject) {
1106
- var refMark = this._ensureCircularReference(val);
1107
-
1108
- if (refMark)
1109
- return refMark;
1110
- }
1111
-
1112
- for (var i = 0; i < this.transforms.length; i++) {
1113
- var transform = this.transforms[i];
1114
-
1115
- if (transform.shouldTransform(type, val))
1116
- return this._applyTransform(val, parent, key, transform);
1117
- }
1118
-
1119
- if (isObject)
1120
- return this._handleObject(val, parent, key);
1121
-
1122
- return val;
1123
- };
1124
-
1125
- EncodingTransformer.prototype.transform = function () {
1126
- var references = [this._handleValue(this.references, null, null)];
1127
-
1128
- for (var i = 0; i < this.circularCandidatesDescrs.length; i++) {
1129
- var descr = this.circularCandidatesDescrs[i];
1130
-
1131
- if (descr.refIdx > 0) {
1132
- references[descr.refIdx] = descr.parent[descr.key];
1133
- descr.parent[descr.key] = EncodingTransformer._createRefMark(descr.refIdx);
1134
- }
1135
- }
1136
-
1137
- return references;
1138
- };
1139
-
1140
- // DecodingTransform
1141
- var DecodingTransformer = function (references, transformsMap) {
1142
- this.references = references;
1143
- this.transformMap = transformsMap;
1144
- this.activeTransformsStack = [];
1145
- this.visitedRefs = Object.create(null);
1146
- };
1147
-
1148
- DecodingTransformer.prototype._handlePlainObject = function (obj) {
1149
- var replicator = this;
1150
- var unescaped = Object.create(null);
1151
- var ownPropertyNames = Object.getOwnPropertyNames(obj);
1152
-
1153
- ownPropertyNames.forEach(function (key) {
1154
- replicator._handleValue(obj[key], obj, key);
1155
-
1156
- if (KEY_REQUIRE_ESCAPING_RE.test(key)) {
1157
- // NOTE: use intermediate object to avoid unescaped and escaped keys interference
1158
- // E.g. unescaped "##@t" will be "#@t" which can overwrite escaped "#@t".
1159
- unescaped[key.substring(1)] = obj[key];
1160
- delete obj[key];
1161
- }
1162
- });
1163
-
1164
- for (var unsecapedKey in unescaped)
1165
- obj[unsecapedKey] = unescaped[unsecapedKey];
1166
- };
1167
-
1168
- DecodingTransformer.prototype._handleTransformedObject = function (obj, parent, key) {
1169
- var transformType = obj[TRANSFORMED_TYPE_KEY];
1170
- var transform = this.transformMap[transformType];
1171
-
1172
- if (!transform)
1173
- throw new Error('Can\'t find transform for "' + transformType + '" type.');
1174
-
1175
- this.activeTransformsStack.push(obj);
1176
- this._handleValue(obj.data, obj, 'data');
1177
- this.activeTransformsStack.pop();
1178
-
1179
- parent[key] = transform.fromSerializable(obj.data);
1180
- };
1181
-
1182
- DecodingTransformer.prototype._handleCircularSelfRefDuringTransform = function (refIdx, parent, key) {
1183
- // NOTE: we've hit a hard case: object reference itself during transformation.
1184
- // We can't dereference it since we don't have resulting object yet. And we'll
1185
- // not be able to restore reference lately because we will need to traverse
1186
- // transformed object again and reference might be unreachable or new object contain
1187
- // new circular references. As a workaround we create getter, so once transformation
1188
- // complete, dereferenced property will point to correct transformed object.
1189
- var references = this.references;
1190
- var val = void 0;
1191
-
1192
- Object.defineProperty(parent, key, {
1193
- configurable: true,
1194
- enumerable: true,
1195
-
1196
- get: function () {
1197
- if (val === void 0)
1198
- val = references[refIdx];
1199
-
1200
- return val;
1201
- },
1202
-
1203
- set: function (value) {
1204
- val = value;
1205
- return val;
1206
- }
1207
- });
1208
- };
1209
-
1210
- DecodingTransformer.prototype._handleCircularRef = function (refIdx, parent, key) {
1211
- if (this.activeTransformsStack.indexOf(this.references[refIdx]) > -1)
1212
- this._handleCircularSelfRefDuringTransform(refIdx, parent, key);
1213
-
1214
- else {
1215
- if (!this.visitedRefs[refIdx]) {
1216
- this.visitedRefs[refIdx] = true;
1217
- this._handleValue(this.references[refIdx], this.references, refIdx);
1218
- }
1219
-
1220
- parent[key] = this.references[refIdx];
1221
- }
1222
- };
1223
-
1224
- DecodingTransformer.prototype._handleValue = function (val, parent, key) {
1225
- if (typeof val !== 'object' || val === null)
1226
- return;
1227
-
1228
- var refIdx = val[CIRCULAR_REF_KEY];
1229
-
1230
- if (refIdx !== void 0)
1231
- this._handleCircularRef(refIdx, parent, key);
1232
-
1233
- else if (val[TRANSFORMED_TYPE_KEY])
1234
- this._handleTransformedObject(val, parent, key);
1235
-
1236
- else if (Array.isArray(val)) {
1237
- for (var i = 0; i < val.length; i++)
1238
- this._handleValue(val[i], val, i);
1239
- }
1240
-
1241
- else
1242
- this._handlePlainObject(val);
1243
- };
1244
-
1245
- DecodingTransformer.prototype.transform = function () {
1246
- this.visitedRefs[0] = true;
1247
- this._handleValue(this.references[0], this.references, 0);
1248
-
1249
- return this.references[0];
1250
- };
1251
-
1252
-
1253
- // Transforms
1254
- var builtInTransforms = [
1255
- {
1256
- type: '[[NaN]]',
1257
-
1258
- shouldTransform: function (type, val) {
1259
- return type === 'number' && isNaN(val);
1260
- },
1261
-
1262
- toSerializable: function () {
1263
- return '';
1264
- },
1265
-
1266
- fromSerializable: function () {
1267
- return NaN;
1268
- }
1269
- },
1270
-
1271
- {
1272
- type: '[[undefined]]',
1273
-
1274
- shouldTransform: function (type) {
1275
- return type === 'undefined';
1276
- },
1277
-
1278
- toSerializable: function () {
1279
- return '';
1280
- },
1281
-
1282
- fromSerializable: function () {
1283
- return void 0;
1284
- }
1285
- },
1286
- {
1287
- type: '[[Date]]',
1288
-
1289
- shouldTransform: function (type, val) {
1290
- return val instanceof Date;
1291
- },
1292
-
1293
- toSerializable: function (date) {
1294
- return date.getTime();
1295
- },
1296
-
1297
- fromSerializable: function (val) {
1298
- var date = new Date();
1299
-
1300
- date.setTime(val);
1301
- return date;
1302
- }
1303
- },
1304
- {
1305
- type: '[[RegExp]]',
1306
-
1307
- shouldTransform: function (type, val) {
1308
- return val instanceof RegExp;
1309
- },
1310
-
1311
- toSerializable: function (re) {
1312
- var result = {
1313
- src: re.source,
1314
- flags: ''
1315
- };
1316
-
1317
- if (re.global)
1318
- result.flags += 'g';
1319
-
1320
- if (re.ignoreCase)
1321
- result.flags += 'i';
1322
-
1323
- if (re.multiline)
1324
- result.flags += 'm';
1325
-
1326
- return result;
1327
- },
1328
-
1329
- fromSerializable: function (val) {
1330
- return new RegExp(val.src, val.flags);
1331
- }
1332
- },
1333
-
1334
- {
1335
- type: '[[Error]]',
1336
-
1337
- shouldTransform: function (type, val) {
1338
- return val instanceof Error;
1339
- },
1340
-
1341
- toSerializable: function (err) {
1342
- return {
1343
- name: err.name,
1344
- message: err.message,
1345
- stack: err.stack
1346
- };
1347
- },
1348
-
1349
- fromSerializable: function (val) {
1350
- var Ctor = GLOBAL[val.name] || Error;
1351
- var err = new Ctor(val.message);
1352
-
1353
- err.stack = val.stack;
1354
- return err;
1355
- }
1356
- },
1357
-
1358
- {
1359
- type: '[[ArrayBuffer]]',
1360
-
1361
- shouldTransform: function (type, val) {
1362
- return ARRAY_BUFFER_SUPPORTED && val instanceof ArrayBuffer;
1363
- },
1364
-
1365
- toSerializable: function (buffer) {
1366
- var view = new Int8Array(buffer);
1367
-
1368
- return arrSlice.call(view);
1369
- },
1370
-
1371
- fromSerializable: function (val) {
1372
- if (ARRAY_BUFFER_SUPPORTED) {
1373
- var buffer = new ArrayBuffer(val.length);
1374
- var view = new Int8Array(buffer);
1375
-
1376
- view.set(val);
1377
-
1378
- return buffer;
1379
- }
1380
-
1381
- return val;
1382
- }
1383
- },
1384
-
1385
- {
1386
- type: '[[Buffer]]',
1387
-
1388
- shouldTransform: function (type, val) {
1389
- return BUFFER_FROM_SUPPORTED && val instanceof Buffer;
1390
- },
1391
-
1392
- toSerializable: function (buffer) {
1393
- return arrSlice.call(buffer);
1394
- },
1395
-
1396
- fromSerializable: function (val) {
1397
- if (BUFFER_FROM_SUPPORTED)
1398
- return Buffer.from(val);
1399
-
1400
- return val;
1401
- }
1402
- },
1403
-
1404
- {
1405
- type: '[[TypedArray]]',
1406
-
1407
- shouldTransform: function (type, val) {
1408
- return Object.keys(TYPED_ARRAY_CTORS).some(function (ctorName) {
1409
- return TYPED_ARRAY_SUPPORTED(ctorName) && val instanceof TYPED_ARRAY_CTORS[ctorName];
1410
- });
1411
- },
1412
-
1413
- toSerializable: function (arr) {
1414
- return {
1415
- ctorName: arr.constructor.name,
1416
- arr: arrSlice.call(arr)
1417
- };
1418
- },
1419
-
1420
- fromSerializable: function (val) {
1421
- return TYPED_ARRAY_SUPPORTED(val.ctorName) ? new TYPED_ARRAY_CTORS[val.ctorName](val.arr) : val.arr;
1422
- }
1423
- },
1424
-
1425
- {
1426
- type: '[[Map]]',
1427
-
1428
- shouldTransform: function (type, val) {
1429
- return MAP_SUPPORTED && val instanceof Map;
1430
- },
1431
-
1432
- toSerializable: function (map) {
1433
- var flattenedKVArr = [];
1434
-
1435
- map.forEach(function (val, key) {
1436
- flattenedKVArr.push(key);
1437
- flattenedKVArr.push(val);
1438
- });
1439
-
1440
- return flattenedKVArr;
1441
- },
1442
-
1443
- fromSerializable: function (val) {
1444
- if (MAP_SUPPORTED) {
1445
- // NOTE: new Map(iterable) is not supported by all browsers
1446
- var map = new Map();
1447
-
1448
- for (var i = 0; i < val.length; i += 2)
1449
- map.set(val[i], val[i + 1]);
1450
-
1451
- return map;
1452
- }
1453
-
1454
- var kvArr = [];
1455
-
1456
- for (var j = 0; j < val.length; j += 2)
1457
- kvArr.push([val[i], val[i + 1]]);
1458
-
1459
- return kvArr;
1460
- }
1461
- },
1462
-
1463
- {
1464
- type: '[[Set]]',
1465
-
1466
- shouldTransform: function (type, val) {
1467
- return SET_SUPPORTED && val instanceof Set;
1468
- },
1469
-
1470
- toSerializable: function (set) {
1471
- var arr = [];
1472
-
1473
- set.forEach(function (val) {
1474
- arr.push(val);
1475
- });
1476
-
1477
- return arr;
1478
- },
1479
-
1480
- fromSerializable: function (val) {
1481
- if (SET_SUPPORTED) {
1482
- // NOTE: new Set(iterable) is not supported by all browsers
1483
- var set = new Set();
1484
-
1485
- for (var i = 0; i < val.length; i++)
1486
- set.add(val[i]);
1487
-
1488
- return set;
1489
- }
1490
-
1491
- return val;
1492
- }
1493
- }
1494
- ];
1495
-
1496
- // Replicator
1497
- var Replicator = module.exports = function (serializer) {
1498
- this.transforms = [];
1499
- this.transformsMap = Object.create(null);
1500
- this.serializer = serializer || JSONSerializer;
1501
-
1502
- this.addTransforms(builtInTransforms);
1503
- };
1504
-
1505
- // Manage transforms
1506
- Replicator.prototype.addTransforms = function (transforms) {
1507
- transforms = Array.isArray(transforms) ? transforms : [transforms];
1508
-
1509
- for (var i = 0; i < transforms.length; i++) {
1510
- var transform = transforms[i];
1511
-
1512
- if (this.transformsMap[transform.type])
1513
- throw new Error('Transform with type "' + transform.type + '" was already added.');
1514
-
1515
- this.transforms.push(transform);
1516
- this.transformsMap[transform.type] = transform;
1517
- }
1518
-
1519
- return this;
1520
- };
1521
-
1522
- Replicator.prototype.removeTransforms = function (transforms) {
1523
- transforms = Array.isArray(transforms) ? transforms : [transforms];
1524
-
1525
- for (var i = 0; i < transforms.length; i++) {
1526
- var transform = transforms[i];
1527
- var idx = this.transforms.indexOf(transform);
1528
-
1529
- if (idx > -1)
1530
- this.transforms.splice(idx, 1);
1531
-
1532
- delete this.transformsMap[transform.type];
1533
- }
1534
-
1535
- return this;
1536
- };
1537
-
1538
- Replicator.prototype.encode = function (val) {
1539
- var transformer = new EncodingTransformer(val, this.transforms);
1540
- var references = transformer.transform();
1541
-
1542
- return this.serializer.serialize(references);
1543
- };
1544
-
1545
- Replicator.prototype.decode = function (val) {
1546
- var references = this.serializer.deserialize(val);
1547
- var transformer = new DecodingTransformer(references, this.transformsMap);
1548
-
1549
- return transformer.transform();
1550
- };
1039
+ var replicator = createCommonjsModule(function (module) {
1040
+ // Const
1041
+ var TRANSFORMED_TYPE_KEY = '@t';
1042
+ var CIRCULAR_REF_KEY = '@r';
1043
+ var KEY_REQUIRE_ESCAPING_RE = /^#*@(t|r)$/;
1044
+ var GLOBAL = (function getGlobal() {
1045
+ // NOTE: see http://www.ecma-international.org/ecma-262/6.0/index.html#sec-performeval step 10
1046
+ var savedEval = eval;
1047
+ return savedEval('this');
1048
+ })();
1049
+ var TYPED_ARRAY_CTORS = {
1050
+ 'Int8Array': typeof Int8Array === 'function' ? Int8Array : void 0,
1051
+ 'Uint8Array': typeof Uint8Array === 'function' ? Uint8Array : void 0,
1052
+ 'Uint8ClampedArray': typeof Uint8ClampedArray === 'function' ? Uint8ClampedArray : void 0,
1053
+ 'Int16Array': typeof Int16Array === 'function' ? Int16Array : void 0,
1054
+ 'Uint16Array': typeof Uint16Array === 'function' ? Uint16Array : void 0,
1055
+ 'Int32Array': typeof Int32Array === 'function' ? Int32Array : void 0,
1056
+ 'Uint32Array': typeof Uint32Array === 'function' ? Uint32Array : void 0,
1057
+ 'Float32Array': typeof Float32Array === 'function' ? Float32Array : void 0,
1058
+ 'Float64Array': typeof Float64Array === 'function' ? Float64Array : void 0
1059
+ };
1060
+ var ARRAY_BUFFER_SUPPORTED = typeof ArrayBuffer === 'function';
1061
+ var MAP_SUPPORTED = typeof Map === 'function';
1062
+ var SET_SUPPORTED = typeof Set === 'function';
1063
+ var BUFFER_FROM_SUPPORTED = typeof Buffer === 'function';
1064
+ var TYPED_ARRAY_SUPPORTED = function (typeName) {
1065
+ return !!TYPED_ARRAY_CTORS[typeName];
1066
+ };
1067
+ // Saved proto functions
1068
+ var arrSlice = Array.prototype.slice;
1069
+ // Default serializer
1070
+ var JSONSerializer = {
1071
+ serialize: function (val) {
1072
+ return JSON.stringify(val);
1073
+ },
1074
+ deserialize: function (val) {
1075
+ return JSON.parse(val);
1076
+ }
1077
+ };
1078
+ // EncodingTransformer
1079
+ var EncodingTransformer = function (val, transforms) {
1080
+ this.references = val;
1081
+ this.transforms = transforms;
1082
+ this.circularCandidates = [];
1083
+ this.circularCandidatesDescrs = [];
1084
+ this.circularRefCount = 0;
1085
+ };
1086
+ EncodingTransformer._createRefMark = function (idx) {
1087
+ var obj = Object.create(null);
1088
+ obj[CIRCULAR_REF_KEY] = idx;
1089
+ return obj;
1090
+ };
1091
+ EncodingTransformer.prototype._createCircularCandidate = function (val, parent, key) {
1092
+ this.circularCandidates.push(val);
1093
+ this.circularCandidatesDescrs.push({ parent: parent, key: key, refIdx: -1 });
1094
+ };
1095
+ EncodingTransformer.prototype._applyTransform = function (val, parent, key, transform) {
1096
+ var result = Object.create(null);
1097
+ var serializableVal = transform.toSerializable(val);
1098
+ if (typeof serializableVal === 'object')
1099
+ this._createCircularCandidate(val, parent, key);
1100
+ result[TRANSFORMED_TYPE_KEY] = transform.type;
1101
+ result.data = this._handleValue(serializableVal, parent, key);
1102
+ return result;
1103
+ };
1104
+ EncodingTransformer.prototype._handleArray = function (arr) {
1105
+ var result = [];
1106
+ for (var i = 0; i < arr.length; i++)
1107
+ result[i] = this._handleValue(arr[i], result, i);
1108
+ return result;
1109
+ };
1110
+ EncodingTransformer.prototype._handlePlainObject = function (obj) {
1111
+ var replicator = this;
1112
+ var result = Object.create(null);
1113
+ var ownPropertyNames = Object.getOwnPropertyNames(obj);
1114
+ ownPropertyNames.forEach(function (key) {
1115
+ var resultKey = KEY_REQUIRE_ESCAPING_RE.test(key) ? '#' + key : key;
1116
+ result[resultKey] = replicator._handleValue(obj[key], result, resultKey);
1117
+ });
1118
+ return result;
1119
+ };
1120
+ EncodingTransformer.prototype._handleObject = function (obj, parent, key) {
1121
+ this._createCircularCandidate(obj, parent, key);
1122
+ return Array.isArray(obj) ? this._handleArray(obj) : this._handlePlainObject(obj);
1123
+ };
1124
+ EncodingTransformer.prototype._ensureCircularReference = function (obj) {
1125
+ var circularCandidateIdx = this.circularCandidates.indexOf(obj);
1126
+ if (circularCandidateIdx > -1) {
1127
+ var descr = this.circularCandidatesDescrs[circularCandidateIdx];
1128
+ if (descr.refIdx === -1)
1129
+ descr.refIdx = descr.parent ? ++this.circularRefCount : 0;
1130
+ return EncodingTransformer._createRefMark(descr.refIdx);
1131
+ }
1132
+ return null;
1133
+ };
1134
+ EncodingTransformer.prototype._handleValue = function (val, parent, key) {
1135
+ var type = typeof val;
1136
+ var isObject = type === 'object' && val !== null;
1137
+ if (isObject) {
1138
+ var refMark = this._ensureCircularReference(val);
1139
+ if (refMark)
1140
+ return refMark;
1141
+ }
1142
+ for (var i = 0; i < this.transforms.length; i++) {
1143
+ var transform = this.transforms[i];
1144
+ if (transform.shouldTransform(type, val))
1145
+ return this._applyTransform(val, parent, key, transform);
1146
+ }
1147
+ if (isObject)
1148
+ return this._handleObject(val, parent, key);
1149
+ return val;
1150
+ };
1151
+ EncodingTransformer.prototype.transform = function () {
1152
+ var references = [this._handleValue(this.references, null, null)];
1153
+ for (var i = 0; i < this.circularCandidatesDescrs.length; i++) {
1154
+ var descr = this.circularCandidatesDescrs[i];
1155
+ if (descr.refIdx > 0) {
1156
+ references[descr.refIdx] = descr.parent[descr.key];
1157
+ descr.parent[descr.key] = EncodingTransformer._createRefMark(descr.refIdx);
1158
+ }
1159
+ }
1160
+ return references;
1161
+ };
1162
+ // DecodingTransform
1163
+ var DecodingTransformer = function (references, transformsMap) {
1164
+ this.references = references;
1165
+ this.transformMap = transformsMap;
1166
+ this.activeTransformsStack = [];
1167
+ this.visitedRefs = Object.create(null);
1168
+ };
1169
+ DecodingTransformer.prototype._handlePlainObject = function (obj) {
1170
+ var replicator = this;
1171
+ var unescaped = Object.create(null);
1172
+ var ownPropertyNames = Object.getOwnPropertyNames(obj);
1173
+ ownPropertyNames.forEach(function (key) {
1174
+ replicator._handleValue(obj[key], obj, key);
1175
+ if (KEY_REQUIRE_ESCAPING_RE.test(key)) {
1176
+ // NOTE: use intermediate object to avoid unescaped and escaped keys interference
1177
+ // E.g. unescaped "##@t" will be "#@t" which can overwrite escaped "#@t".
1178
+ unescaped[key.substring(1)] = obj[key];
1179
+ delete obj[key];
1180
+ }
1181
+ });
1182
+ for (var unsecapedKey in unescaped)
1183
+ obj[unsecapedKey] = unescaped[unsecapedKey];
1184
+ };
1185
+ DecodingTransformer.prototype._handleTransformedObject = function (obj, parent, key) {
1186
+ var transformType = obj[TRANSFORMED_TYPE_KEY];
1187
+ var transform = this.transformMap[transformType];
1188
+ if (!transform)
1189
+ throw new Error('Can\'t find transform for "' + transformType + '" type.');
1190
+ this.activeTransformsStack.push(obj);
1191
+ this._handleValue(obj.data, obj, 'data');
1192
+ this.activeTransformsStack.pop();
1193
+ parent[key] = transform.fromSerializable(obj.data);
1194
+ };
1195
+ DecodingTransformer.prototype._handleCircularSelfRefDuringTransform = function (refIdx, parent, key) {
1196
+ // NOTE: we've hit a hard case: object reference itself during transformation.
1197
+ // We can't dereference it since we don't have resulting object yet. And we'll
1198
+ // not be able to restore reference lately because we will need to traverse
1199
+ // transformed object again and reference might be unreachable or new object contain
1200
+ // new circular references. As a workaround we create getter, so once transformation
1201
+ // complete, dereferenced property will point to correct transformed object.
1202
+ var references = this.references;
1203
+ var val = void 0;
1204
+ Object.defineProperty(parent, key, {
1205
+ configurable: true,
1206
+ enumerable: true,
1207
+ get: function () {
1208
+ if (val === void 0)
1209
+ val = references[refIdx];
1210
+ return val;
1211
+ },
1212
+ set: function (value) {
1213
+ val = value;
1214
+ return val;
1215
+ }
1216
+ });
1217
+ };
1218
+ DecodingTransformer.prototype._handleCircularRef = function (refIdx, parent, key) {
1219
+ if (this.activeTransformsStack.indexOf(this.references[refIdx]) > -1)
1220
+ this._handleCircularSelfRefDuringTransform(refIdx, parent, key);
1221
+ else {
1222
+ if (!this.visitedRefs[refIdx]) {
1223
+ this.visitedRefs[refIdx] = true;
1224
+ this._handleValue(this.references[refIdx], this.references, refIdx);
1225
+ }
1226
+ parent[key] = this.references[refIdx];
1227
+ }
1228
+ };
1229
+ DecodingTransformer.prototype._handleValue = function (val, parent, key) {
1230
+ if (typeof val !== 'object' || val === null)
1231
+ return;
1232
+ var refIdx = val[CIRCULAR_REF_KEY];
1233
+ if (refIdx !== void 0)
1234
+ this._handleCircularRef(refIdx, parent, key);
1235
+ else if (val[TRANSFORMED_TYPE_KEY])
1236
+ this._handleTransformedObject(val, parent, key);
1237
+ else if (Array.isArray(val)) {
1238
+ for (var i = 0; i < val.length; i++)
1239
+ this._handleValue(val[i], val, i);
1240
+ }
1241
+ else
1242
+ this._handlePlainObject(val);
1243
+ };
1244
+ DecodingTransformer.prototype.transform = function () {
1245
+ this.visitedRefs[0] = true;
1246
+ this._handleValue(this.references[0], this.references, 0);
1247
+ return this.references[0];
1248
+ };
1249
+ // Transforms
1250
+ var builtInTransforms = [
1251
+ {
1252
+ type: '[[NaN]]',
1253
+ shouldTransform: function (type, val) {
1254
+ return type === 'number' && isNaN(val);
1255
+ },
1256
+ toSerializable: function () {
1257
+ return '';
1258
+ },
1259
+ fromSerializable: function () {
1260
+ return NaN;
1261
+ }
1262
+ },
1263
+ {
1264
+ type: '[[undefined]]',
1265
+ shouldTransform: function (type) {
1266
+ return type === 'undefined';
1267
+ },
1268
+ toSerializable: function () {
1269
+ return '';
1270
+ },
1271
+ fromSerializable: function () {
1272
+ return void 0;
1273
+ }
1274
+ },
1275
+ {
1276
+ type: '[[Date]]',
1277
+ shouldTransform: function (type, val) {
1278
+ return val instanceof Date;
1279
+ },
1280
+ toSerializable: function (date) {
1281
+ return date.getTime();
1282
+ },
1283
+ fromSerializable: function (val) {
1284
+ var date = new Date();
1285
+ date.setTime(val);
1286
+ return date;
1287
+ }
1288
+ },
1289
+ {
1290
+ type: '[[RegExp]]',
1291
+ shouldTransform: function (type, val) {
1292
+ return val instanceof RegExp;
1293
+ },
1294
+ toSerializable: function (re) {
1295
+ var result = {
1296
+ src: re.source,
1297
+ flags: ''
1298
+ };
1299
+ if (re.global)
1300
+ result.flags += 'g';
1301
+ if (re.ignoreCase)
1302
+ result.flags += 'i';
1303
+ if (re.multiline)
1304
+ result.flags += 'm';
1305
+ return result;
1306
+ },
1307
+ fromSerializable: function (val) {
1308
+ return new RegExp(val.src, val.flags);
1309
+ }
1310
+ },
1311
+ {
1312
+ type: '[[Error]]',
1313
+ shouldTransform: function (type, val) {
1314
+ return val instanceof Error;
1315
+ },
1316
+ toSerializable: function (err) {
1317
+ return {
1318
+ name: err.name,
1319
+ message: err.message,
1320
+ stack: err.stack
1321
+ };
1322
+ },
1323
+ fromSerializable: function (val) {
1324
+ var Ctor = GLOBAL[val.name] || Error;
1325
+ var err = new Ctor(val.message);
1326
+ err.stack = val.stack;
1327
+ return err;
1328
+ }
1329
+ },
1330
+ {
1331
+ type: '[[ArrayBuffer]]',
1332
+ shouldTransform: function (type, val) {
1333
+ return ARRAY_BUFFER_SUPPORTED && val instanceof ArrayBuffer;
1334
+ },
1335
+ toSerializable: function (buffer) {
1336
+ var view = new Int8Array(buffer);
1337
+ return arrSlice.call(view);
1338
+ },
1339
+ fromSerializable: function (val) {
1340
+ if (ARRAY_BUFFER_SUPPORTED) {
1341
+ var buffer = new ArrayBuffer(val.length);
1342
+ var view = new Int8Array(buffer);
1343
+ view.set(val);
1344
+ return buffer;
1345
+ }
1346
+ return val;
1347
+ }
1348
+ },
1349
+ {
1350
+ type: '[[Buffer]]',
1351
+ shouldTransform: function (type, val) {
1352
+ return BUFFER_FROM_SUPPORTED && val instanceof Buffer;
1353
+ },
1354
+ toSerializable: function (buffer) {
1355
+ return arrSlice.call(buffer);
1356
+ },
1357
+ fromSerializable: function (val) {
1358
+ if (BUFFER_FROM_SUPPORTED)
1359
+ return Buffer.from(val);
1360
+ return val;
1361
+ }
1362
+ },
1363
+ {
1364
+ type: '[[TypedArray]]',
1365
+ shouldTransform: function (type, val) {
1366
+ return Object.keys(TYPED_ARRAY_CTORS).some(function (ctorName) {
1367
+ return TYPED_ARRAY_SUPPORTED(ctorName) && val instanceof TYPED_ARRAY_CTORS[ctorName];
1368
+ });
1369
+ },
1370
+ toSerializable: function (arr) {
1371
+ return {
1372
+ ctorName: arr.constructor.name,
1373
+ arr: arrSlice.call(arr)
1374
+ };
1375
+ },
1376
+ fromSerializable: function (val) {
1377
+ return TYPED_ARRAY_SUPPORTED(val.ctorName) ? new TYPED_ARRAY_CTORS[val.ctorName](val.arr) : val.arr;
1378
+ }
1379
+ },
1380
+ {
1381
+ type: '[[Map]]',
1382
+ shouldTransform: function (type, val) {
1383
+ return MAP_SUPPORTED && val instanceof Map;
1384
+ },
1385
+ toSerializable: function (map) {
1386
+ var flattenedKVArr = [];
1387
+ map.forEach(function (val, key) {
1388
+ flattenedKVArr.push(key);
1389
+ flattenedKVArr.push(val);
1390
+ });
1391
+ return flattenedKVArr;
1392
+ },
1393
+ fromSerializable: function (val) {
1394
+ if (MAP_SUPPORTED) {
1395
+ // NOTE: new Map(iterable) is not supported by all browsers
1396
+ var map = new Map();
1397
+ for (var i = 0; i < val.length; i += 2)
1398
+ map.set(val[i], val[i + 1]);
1399
+ return map;
1400
+ }
1401
+ var kvArr = [];
1402
+ for (var j = 0; j < val.length; j += 2)
1403
+ kvArr.push([val[i], val[i + 1]]);
1404
+ return kvArr;
1405
+ }
1406
+ },
1407
+ {
1408
+ type: '[[Set]]',
1409
+ shouldTransform: function (type, val) {
1410
+ return SET_SUPPORTED && val instanceof Set;
1411
+ },
1412
+ toSerializable: function (set) {
1413
+ var arr = [];
1414
+ set.forEach(function (val) {
1415
+ arr.push(val);
1416
+ });
1417
+ return arr;
1418
+ },
1419
+ fromSerializable: function (val) {
1420
+ if (SET_SUPPORTED) {
1421
+ // NOTE: new Set(iterable) is not supported by all browsers
1422
+ var set = new Set();
1423
+ for (var i = 0; i < val.length; i++)
1424
+ set.add(val[i]);
1425
+ return set;
1426
+ }
1427
+ return val;
1428
+ }
1429
+ }
1430
+ ];
1431
+ // Replicator
1432
+ var Replicator = module.exports = function (serializer) {
1433
+ this.transforms = [];
1434
+ this.transformsMap = Object.create(null);
1435
+ this.serializer = serializer || JSONSerializer;
1436
+ this.addTransforms(builtInTransforms);
1437
+ };
1438
+ // Manage transforms
1439
+ Replicator.prototype.addTransforms = function (transforms) {
1440
+ transforms = Array.isArray(transforms) ? transforms : [transforms];
1441
+ for (var i = 0; i < transforms.length; i++) {
1442
+ var transform = transforms[i];
1443
+ if (this.transformsMap[transform.type])
1444
+ throw new Error('Transform with type "' + transform.type + '" was already added.');
1445
+ this.transforms.push(transform);
1446
+ this.transformsMap[transform.type] = transform;
1447
+ }
1448
+ return this;
1449
+ };
1450
+ Replicator.prototype.removeTransforms = function (transforms) {
1451
+ transforms = Array.isArray(transforms) ? transforms : [transforms];
1452
+ for (var i = 0; i < transforms.length; i++) {
1453
+ var transform = transforms[i];
1454
+ var idx = this.transforms.indexOf(transform);
1455
+ if (idx > -1)
1456
+ this.transforms.splice(idx, 1);
1457
+ delete this.transformsMap[transform.type];
1458
+ }
1459
+ return this;
1460
+ };
1461
+ Replicator.prototype.encode = function (val) {
1462
+ var transformer = new EncodingTransformer(val, this.transforms);
1463
+ var references = transformer.transform();
1464
+ return this.serializer.serialize(references);
1465
+ };
1466
+ Replicator.prototype.decode = function (val) {
1467
+ var references = this.serializer.deserialize(val);
1468
+ var transformer = new DecodingTransformer(references, this.transformsMap);
1469
+ return transformer.transform();
1470
+ };
1551
1471
  });
1552
1472
 
1553
1473
  var identity = function (val) { return val; };
@@ -3018,8 +2938,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
3018
2938
  var ActionExecutor = /** @class */ (function (_super) {
3019
2939
  __extends(ActionExecutor, _super);
3020
2940
  function ActionExecutor(command, globalSelectorTimeout, testSpeed, executeSelectorFn) {
2941
+ var _this = this;
3021
2942
  var _a;
3022
- var _this = _super.call(this) || this;
2943
+ _this = _super.call(this) || this;
3023
2944
  _this._command = command;
3024
2945
  _this._targetElement = null;
3025
2946
  _this._elements = [];
@@ -3098,7 +3019,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3098
3019
  ActionExecutor.prototype._createAutomation = function () {
3099
3020
  var handler = ActionExecutor.ACTIONS_HANDLERS[this._command.type];
3100
3021
  if (!handler)
3101
- throw new Error("There is no handler for the \"" + this._command.type + "\" command.");
3022
+ throw new Error("There is no handler for the \"".concat(this._command.type, "\" command."));
3102
3023
  return handler.create(this._command, this._elements);
3103
3024
  };
3104
3025
  ActionExecutor.prototype._runAction = function (strictElementCheck) {
@@ -3160,7 +3081,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3160
3081
  barriers.wait(),
3161
3082
  ]); })
3162
3083
  .then(function () {
3163
- var elements = __spreadArrays(_this._elements);
3084
+ var elements = __spreadArray([], _this._elements, true);
3164
3085
  if (_this._targetElement)
3165
3086
  elements[0] = _this._targetElement;
3166
3087
  return elements;
@@ -3459,6 +3380,13 @@ window['%hammerhead%'].utils.removeInjectedScript();
3459
3380
  throw new ErrorCtor(name, valType);
3460
3381
  };
3461
3382
  }
3383
+ function createStringOrRegexValidator(ErrorCtor) {
3384
+ return function (name, val) {
3385
+ var valType = typeof val;
3386
+ if (valType !== 'string' && !(val instanceof RegExp))
3387
+ throw new ErrorCtor(name, valType);
3388
+ };
3389
+ }
3462
3390
  function createDateValidator(ErrorCtor) {
3463
3391
  return function (name, val) {
3464
3392
  if (!(val instanceof Date))
@@ -3499,6 +3427,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
3499
3427
  var booleanOption = createBooleanValidator(ActionBooleanOptionError);
3500
3428
  var speedOption = createSpeedValidator(ActionSpeedOptionError);
3501
3429
  var stringOption = createStringValidator(ActionStringOptionError);
3430
+ var stringOrRegexOption = createStringOrRegexValidator(ActionStringOrRegexOptionError);
3502
3431
  var dateOption = createDateValidator(ActionDateOptionError);
3503
3432
  var numberOption = createNumberValidator(ActionNumberOptionError);
3504
3433
  var urlOption = createUrlValidator(ActionUrlOptionError);
@@ -3833,6 +3762,22 @@ window['%hammerhead%'].utils.removeInjectedScript();
3833
3762
  };
3834
3763
  return GetProxyUrlOptions;
3835
3764
  }(Assignable));
3765
+ var SkipJsErrorsOptions = /** @class */ (function (_super) {
3766
+ __extends(SkipJsErrorsOptions, _super);
3767
+ function SkipJsErrorsOptions(obj, validate) {
3768
+ var _this = _super.call(this) || this;
3769
+ _this._assignFrom(obj, validate);
3770
+ return _this;
3771
+ }
3772
+ SkipJsErrorsOptions.prototype._getAssignableProperties = function () {
3773
+ return [
3774
+ { name: 'stack', type: stringOrRegexOption, required: false },
3775
+ { name: 'message', type: stringOrRegexOption, required: false },
3776
+ { name: 'pageUrl', type: stringOrRegexOption, required: false },
3777
+ ];
3778
+ };
3779
+ return SkipJsErrorsOptions;
3780
+ }(Assignable));
3836
3781
  // Initializers
3837
3782
  function initRequestAuthOption(name, val, initOptions, validate) {
3838
3783
  if (validate === void 0) { validate = true; }
@@ -4459,6 +4404,30 @@ window['%hammerhead%'].utils.removeInjectedScript();
4459
4404
  ensureElsProps: function (elements) { return ensureFileInput(elements[0]); },
4460
4405
  };
4461
4406
 
4407
+ function shouldSkipJsError(options, err) {
4408
+ return __awaiter(this, void 0, void 0, function () {
4409
+ return __generator(this, function (_a) {
4410
+ switch (_a.label) {
4411
+ case 0:
4412
+ if (!isClientFunctionCommand(options)) return [3 /*break*/, 2];
4413
+ return [4 /*yield*/, processJsErrorsFunction(options, err)];
4414
+ case 1: return [2 /*return*/, _a.sent()];
4415
+ case 2: return [2 /*return*/, options || false];
4416
+ }
4417
+ });
4418
+ });
4419
+ }
4420
+ function processJsErrorsFunction(processingFunction, err) {
4421
+ var opts = {
4422
+ stack: err.stack,
4423
+ pageUrl: err.pageUrl,
4424
+ message: err.msg,
4425
+ };
4426
+ processingFunction.args = [[opts]];
4427
+ var executor = new ClientFunctionExecutor(processingFunction);
4428
+ return executor.getResult();
4429
+ }
4430
+
4462
4431
  var settings = hammerhead__default.settings;
4463
4432
  var transport = hammerhead__default.transport;
4464
4433
  var Promise$2 = hammerhead__default.Promise;
@@ -4471,6 +4440,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
4471
4440
  var TEST_DONE_SENT_FLAG = 'testcafe|driver|test-done-sent-flag';
4472
4441
  var PENDING_STATUS = 'testcafe|driver|pending-status';
4473
4442
  var EXECUTING_CLIENT_FUNCTION_DESCRIPTOR = 'testcafe|driver|executing-client-function-descriptor';
4443
+ var EXECUTING_SKIP_JS_ERRORS_FUNCTION_FLAG = 'testcafe|driver|executing-skip-js-errors-function-flag';
4474
4444
  var SELECTOR_EXECUTION_START_TIME = 'testcafe|driver|selector-execution-start-time';
4475
4445
  var PENDING_PAGE_ERROR = 'testcafe|driver|pending-page-error';
4476
4446
  var ACTIVE_IFRAME_SELECTOR = 'testcafe|driver|active-iframe-selector';
@@ -4496,6 +4466,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
4496
4466
  var STATUS_WITH_COMMAND_RESULT_EVENT = 'status-with-command-result-event';
4497
4467
  var EMPTY_COMMAND_EVENT = 'empty-command-event';
4498
4468
  var CHILD_WINDOW_CLOSED_EVENT = 'child-window-closed';
4469
+ var SKIP_JS_ERRORS_FUNCTION_EXECUTION_COMPLETE_EVENT = 'skip-js-errors-function-execution-complete';
4499
4470
  var Driver = /** @class */ (function (_super) {
4500
4471
  __extends(Driver, _super);
4501
4472
  function Driver(testRunId, communicationUrls, runInfo, options) {
@@ -4605,14 +4576,46 @@ window['%hammerhead%'].utils.removeInjectedScript();
4605
4576
  };
4606
4577
  // Error handling
4607
4578
  Driver.prototype._onJsError = function (err) {
4608
- // NOTE: we should not send any message to the server if we've
4609
- // sent the 'test-done' message but haven't got the response.
4610
- if (this.skipJsErrors || this.contextStorage.getItem(TEST_DONE_SENT_FLAG))
4611
- return Promise$2.resolve();
4579
+ return __awaiter(this, void 0, void 0, function () {
4580
+ var e_1;
4581
+ return __generator(this, function (_a) {
4582
+ switch (_a.label) {
4583
+ case 0:
4584
+ // NOTE: we should not send any message to the server if we've
4585
+ // sent the 'test-done' message but haven't got the response.
4586
+ if (this.contextStorage.getItem(TEST_DONE_SENT_FLAG))
4587
+ return [2 /*return*/];
4588
+ if (!this.skipJsErrors) return [3 /*break*/, 6];
4589
+ this.contextStorage.setItem(EXECUTING_SKIP_JS_ERRORS_FUNCTION_FLAG, true);
4590
+ _a.label = 1;
4591
+ case 1:
4592
+ _a.trys.push([1, 3, 4, 5]);
4593
+ return [4 /*yield*/, shouldSkipJsError(this.skipJsErrors, err)];
4594
+ case 2:
4595
+ if (!(_a.sent()))
4596
+ this._setUncaughtErrorOnPage(err);
4597
+ return [3 /*break*/, 5];
4598
+ case 3:
4599
+ e_1 = _a.sent();
4600
+ if (!this.contextStorage.getItem(PENDING_PAGE_ERROR))
4601
+ this.contextStorage.setItem(PENDING_PAGE_ERROR, e_1);
4602
+ return [3 /*break*/, 5];
4603
+ case 4:
4604
+ this.contextStorage.setItem(EXECUTING_SKIP_JS_ERRORS_FUNCTION_FLAG, false);
4605
+ this.emit(SKIP_JS_ERRORS_FUNCTION_EXECUTION_COMPLETE_EVENT);
4606
+ return [7 /*endfinally*/];
4607
+ case 5: return [2 /*return*/];
4608
+ case 6:
4609
+ this._setUncaughtErrorOnPage(err);
4610
+ return [2 /*return*/];
4611
+ }
4612
+ });
4613
+ });
4614
+ };
4615
+ Driver.prototype._setUncaughtErrorOnPage = function (err) {
4612
4616
  var error = new UncaughtErrorOnPage(err.stack, err.pageUrl);
4613
4617
  if (!this.contextStorage.getItem(PENDING_PAGE_ERROR))
4614
4618
  this.contextStorage.setItem(PENDING_PAGE_ERROR, error);
4615
- return null;
4616
4619
  };
4617
4620
  Driver.prototype._unlockPageAfterTestIsDone = function () {
4618
4621
  testcafeCore.disableRealEventsPreventing();
@@ -4793,7 +4796,7 @@ window['%hammerhead%'].utils.removeInjectedScript();
4793
4796
  Driver.prototype._addChildIframeDriverLink = function (id, driverWindow) {
4794
4797
  var childIframeDriverLink = this._getChildIframeDriverLinkByWindow(driverWindow);
4795
4798
  if (!childIframeDriverLink) {
4796
- var driverId = this.testRunId + "-" + generateId();
4799
+ var driverId = "".concat(this.testRunId, "-").concat(generateId());
4797
4800
  childIframeDriverLink = new ChildIframeDriverLink(driverWindow, driverId);
4798
4801
  this.childIframeDriverLinks.push(childIframeDriverLink);
4799
4802
  }
@@ -5270,6 +5273,18 @@ window['%hammerhead%'].utils.removeInjectedScript();
5270
5273
  return Promise$2.resolve();
5271
5274
  return this._createWaitForEventPromise(STATUS_WITH_COMMAND_RESULT_EVENT, COMMAND_EXECUTION_MAX_TIMEOUT);
5272
5275
  };
5276
+ Driver.prototype._waitForSkipJsErrorFunctionCompletion = function (driverStatus) {
5277
+ var _this = this;
5278
+ if (!this.contextStorage.getItem(EXECUTING_SKIP_JS_ERRORS_FUNCTION_FLAG))
5279
+ return Promise$2.resolve(driverStatus);
5280
+ return new Promise$2(function (resolve) {
5281
+ var eventHandler = function () {
5282
+ _this.off(SKIP_JS_ERRORS_FUNCTION_EXECUTION_COMPLETE_EVENT, eventHandler);
5283
+ resolve(driverStatus);
5284
+ };
5285
+ _this.on(SKIP_JS_ERRORS_FUNCTION_EXECUTION_COMPLETE_EVENT, eventHandler);
5286
+ });
5287
+ };
5273
5288
  Driver.prototype._waitForEmptyCommand = function () {
5274
5289
  return this._createWaitForEventPromise(EMPTY_COMMAND_EVENT, EMPTY_COMMAND_EVENT_WAIT_TIMEOUT);
5275
5290
  };
@@ -5386,9 +5401,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
5386
5401
  }); })
5387
5402
  .catch(function (err) { return _this.statusBar.hideWaitingElementStatus(false)
5388
5403
  .then(function () { return new DriverStatus({ isCommandResult: true, executionError: err }); }); })
5404
+ .then(function (driverStatus) { return _this._waitForSkipJsErrorFunctionCompletion(driverStatus); })
5389
5405
  .then(function (driverStatus) {
5390
5406
  _this.contextStorage.setItem(_this.COMMAND_EXECUTING_FLAG, false);
5391
- return _this._onReady(driverStatus);
5407
+ _this.contextStorage.setItem(EXECUTING_SKIP_JS_ERRORS_FUNCTION_FLAG, false);
5408
+ _this._onReady(driverStatus);
5392
5409
  });
5393
5410
  };
5394
5411
  Driver.prototype._onSetNativeDialogHandlerCommand = function (command) {
@@ -5420,6 +5437,11 @@ window['%hammerhead%'].utils.removeInjectedScript();
5420
5437
  result: urlUtils.getProxyUrl(command.url, command.options),
5421
5438
  }));
5422
5439
  };
5440
+ Driver.prototype._onSkipJsErrorsCommand = function (_a) {
5441
+ var options = _a.options;
5442
+ this.skipJsErrors = options;
5443
+ this._onReady(new DriverStatus({ isCommandResult: true }));
5444
+ };
5423
5445
  Driver.prototype._onExecuteClientFunctionCommand = function (command) {
5424
5446
  var _this = this;
5425
5447
  this.contextStorage.setItem(EXECUTING_CLIENT_FUNCTION_DESCRIPTOR, { instantiationCallsiteName: command.instantiationCallsiteName });
@@ -5751,9 +5773,9 @@ window['%hammerhead%'].utils.removeInjectedScript();
5751
5773
  nativeMethods$4.objectDefineProperty(window, command.esmRuntime, {
5752
5774
  value: {
5753
5775
  g: window,
5754
- c: window.eval,
5776
+ c: window.eval, //eslint-disable-line no-eval
5755
5777
  },
5756
- configurable: true,
5778
+ configurable: true, // NOTE: for the 'disablePageReloads' option
5757
5779
  });
5758
5780
  this._onReady(new DriverStatus({
5759
5781
  isCommandResult: true,
@@ -5858,6 +5880,8 @@ window['%hammerhead%'].utils.removeInjectedScript();
5858
5880
  this._onPrepareClientEnvironmentInDebugMode(command);
5859
5881
  else if (command.type === COMMAND_TYPE.getProxyUrl)
5860
5882
  this._onGetProxyUrlCommand(command);
5883
+ else if (command.type === COMMAND_TYPE.skipJsErrors)
5884
+ this._onSkipJsErrorsCommand(command);
5861
5885
  else
5862
5886
  this._onActionCommand(command);
5863
5887
  };