testcafe 1.13.0 → 1.14.2

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 (336) hide show
  1. package/CHANGELOG.md +88 -10
  2. package/LICENSE +21 -21
  3. package/README.md +52 -48
  4. package/bin/testcafe-with-v8-flag-filter.js +0 -0
  5. package/lib/api/exportable-lib/index.js +50 -50
  6. package/lib/api/request-hooks/assert-type.js +7 -7
  7. package/lib/api/request-hooks/hook-method-names.js +11 -0
  8. package/lib/api/request-hooks/hook.js +33 -39
  9. package/lib/api/request-hooks/interfaces.js +3 -3
  10. package/lib/api/request-hooks/request-logger.js +113 -111
  11. package/lib/api/request-hooks/request-mock/create-request-mock.js +12 -0
  12. package/lib/api/request-hooks/request-mock/index.js +46 -0
  13. package/lib/api/request-hooks/request-mock.js +47 -48
  14. package/lib/api/structure/base-unit.js +11 -11
  15. package/lib/api/structure/fixture.js +75 -75
  16. package/lib/api/structure/interfaces.js +2 -2
  17. package/lib/api/structure/test-file.js +31 -31
  18. package/lib/api/structure/test-timeout.js +9 -9
  19. package/lib/api/structure/test.js +85 -85
  20. package/lib/api/structure/testing-unit.js +89 -89
  21. package/lib/api/structure/unit-type.js +9 -9
  22. package/lib/api/test-controller/assertion.js +88 -88
  23. package/lib/api/test-controller/execution-context.js +82 -82
  24. package/lib/api/test-controller/index.js +359 -319
  25. package/lib/api/test-controller/proxy.js +28 -28
  26. package/lib/api/test-page-url.js +60 -60
  27. package/lib/api/test-run-tracker.js +68 -68
  28. package/lib/api/wrap-test-function.js +49 -49
  29. package/lib/assertions/executor.js +74 -74
  30. package/lib/assertions/get-fn.js +46 -46
  31. package/lib/assertions/type.js +20 -20
  32. package/lib/assets/content-types.js +9 -9
  33. package/lib/assets/injectables.js +18 -18
  34. package/lib/browser/connection/command.js +10 -10
  35. package/lib/browser/connection/error-hints.js +9 -9
  36. package/lib/browser/connection/gateway.js +159 -159
  37. package/lib/browser/connection/get-hints.js +33 -33
  38. package/lib/browser/connection/heartbeat-status.js +8 -8
  39. package/lib/browser/connection/index.js +328 -328
  40. package/lib/browser/connection/remotes-queue.js +46 -46
  41. package/lib/browser/connection/service-routes.js +12 -12
  42. package/lib/browser/connection/status.js +12 -12
  43. package/lib/browser/interfaces.js +2 -2
  44. package/lib/browser/provider/built-in/dedicated/base.js +80 -80
  45. package/lib/browser/provider/built-in/dedicated/chrome/browser-client.js +204 -204
  46. package/lib/browser/provider/built-in/dedicated/chrome/build-chrome-args.js +17 -17
  47. package/lib/browser/provider/built-in/dedicated/chrome/config.js +110 -110
  48. package/lib/browser/provider/built-in/dedicated/chrome/create-temp-profile.js +45 -45
  49. package/lib/browser/provider/built-in/dedicated/chrome/elapsed-upperbounds.js +15 -15
  50. package/lib/browser/provider/built-in/dedicated/chrome/index.js +102 -102
  51. package/lib/browser/provider/built-in/dedicated/chrome/interfaces.js +2 -2
  52. package/lib/browser/provider/built-in/dedicated/chrome/local-chrome.js +24 -24
  53. package/lib/browser/provider/built-in/dedicated/chrome/runtime-info.js +29 -29
  54. package/lib/browser/provider/built-in/dedicated/edge/index.js +10 -10
  55. package/lib/browser/provider/built-in/dedicated/edge/runtime-info.js +29 -29
  56. package/lib/browser/provider/built-in/dedicated/firefox/config.js +33 -33
  57. package/lib/browser/provider/built-in/dedicated/firefox/create-temp-profile.js +78 -78
  58. package/lib/browser/provider/built-in/dedicated/firefox/index.js +73 -73
  59. package/lib/browser/provider/built-in/dedicated/firefox/local-firefox.js +36 -36
  60. package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/commands.js +13 -13
  61. package/lib/browser/provider/built-in/dedicated/firefox/marionette-client/index.js +200 -200
  62. package/lib/browser/provider/built-in/dedicated/firefox/runtime-info.js +17 -17
  63. package/lib/browser/provider/built-in/index.js +21 -21
  64. package/lib/browser/provider/built-in/locally-installed.js +30 -30
  65. package/lib/browser/provider/built-in/path.js +47 -47
  66. package/lib/browser/provider/built-in/remote.js +58 -58
  67. package/lib/browser/provider/index.js +303 -303
  68. package/lib/browser/provider/parse-provider-name.js +16 -16
  69. package/lib/browser/provider/plugin-host.js +121 -121
  70. package/lib/browser/provider/pool.js +115 -115
  71. package/lib/browser/provider/utils/argument-parsing.js +74 -74
  72. package/lib/browser/provider/utils/browser-starter.js +34 -34
  73. package/lib/browser/provider/utils/client-functions.js +24 -24
  74. package/lib/browser/provider/utils/get-maximized-headless-window-size.js +9 -9
  75. package/lib/cli/argument-parser.js +284 -279
  76. package/lib/cli/authentication-helper.js +35 -35
  77. package/lib/cli/cli.js +134 -134
  78. package/lib/cli/correct-browsers-and-sources.js +40 -40
  79. package/lib/cli/index.js +19 -19
  80. package/lib/cli/log.js +43 -43
  81. package/lib/cli/remotes-wizard.js +36 -36
  82. package/lib/cli/termination-handler.js +38 -38
  83. package/lib/client/automation/index.js +144 -46
  84. package/lib/client/automation/index.min.js +1 -1
  85. package/lib/client/browser/idle-page/index.html.mustache +35 -35
  86. package/lib/client/browser/idle-page/logo.svg +86 -86
  87. package/lib/client/browser/service-worker.js +4 -6
  88. package/lib/client/core/index.js +19 -13
  89. package/lib/client/core/index.min.js +1 -1
  90. package/lib/client/driver/index.js +1807 -451
  91. package/lib/client/driver/index.min.js +1 -1
  92. package/lib/client/driver/internal-properties.js +9 -9
  93. package/lib/client/test-run/iframe.js.mustache +17 -17
  94. package/lib/client/test-run/index.js.mustache +51 -51
  95. package/lib/client/ui/index.js +14 -12
  96. package/lib/client/ui/index.min.js +1 -1
  97. package/lib/client/ui/sprite.svg +42 -42
  98. package/lib/client-functions/builder-symbol.js +4 -4
  99. package/lib/client-functions/client-function-builder.js +156 -135
  100. package/lib/client-functions/replicator.js +61 -61
  101. package/lib/client-functions/return-single-prop-mode.js +8 -8
  102. package/lib/client-functions/selector-api-execution-mode.js +22 -0
  103. package/lib/client-functions/selectors/add-api.js +646 -588
  104. package/lib/client-functions/selectors/create-snapshot-methods.js +13 -13
  105. package/lib/client-functions/selectors/prepare-api-args.js +20 -20
  106. package/lib/client-functions/selectors/selector-attribute-filter.js +22 -22
  107. package/lib/client-functions/selectors/selector-builder.js +154 -150
  108. package/lib/client-functions/selectors/selector-text-filter.js +43 -43
  109. package/lib/client-functions/selectors/snapshot-properties.js +48 -48
  110. package/lib/client-functions/types.js +18 -18
  111. package/lib/compiler/babel/format-babel-produced-code.js +10 -10
  112. package/lib/compiler/babel/get-base-babel-options.js +11 -11
  113. package/lib/compiler/babel/load-libs.js +64 -62
  114. package/lib/compiler/babel/preset-stage-2.js +19 -19
  115. package/lib/compiler/compile-client-function.js +73 -73
  116. package/lib/compiler/compilers.js +33 -33
  117. package/lib/compiler/index.js +92 -92
  118. package/lib/compiler/interfaces.js +2 -2
  119. package/lib/compiler/test-file/api-based.js +146 -146
  120. package/lib/compiler/test-file/base.js +36 -36
  121. package/lib/compiler/test-file/exportble-lib-path.js +5 -5
  122. package/lib/compiler/test-file/formats/coffeescript/compiler.js +38 -38
  123. package/lib/compiler/test-file/formats/coffeescript/get-test-list.js +29 -29
  124. package/lib/compiler/test-file/formats/es-next/compiler.js +43 -43
  125. package/lib/compiler/test-file/formats/es-next/get-test-list.js +166 -166
  126. package/lib/compiler/test-file/formats/es-next/is-flow-code.js +7 -7
  127. package/lib/compiler/test-file/formats/raw.js +85 -85
  128. package/lib/compiler/test-file/formats/typescript/compiler.js +135 -135
  129. package/lib/compiler/test-file/formats/typescript/get-test-list.js +185 -185
  130. package/lib/compiler/test-file/test-file-parser-base.js +214 -214
  131. package/lib/configuration/configuration-base.js +165 -165
  132. package/lib/configuration/constants.js +9 -9
  133. package/lib/configuration/customizable-compilers.js +7 -7
  134. package/lib/configuration/default-values.js +51 -51
  135. package/lib/configuration/interfaces.js +3 -3
  136. package/lib/configuration/option-names.js +53 -53
  137. package/lib/configuration/option-source.js +9 -9
  138. package/lib/configuration/option.js +14 -14
  139. package/lib/configuration/quarantine-option-names.js +10 -0
  140. package/lib/configuration/run-option-names.js +26 -26
  141. package/lib/configuration/screenshot-option-names.js +10 -10
  142. package/lib/configuration/testcafe-configuration.js +164 -165
  143. package/lib/configuration/types.js +2 -2
  144. package/lib/configuration/typescript-configuration.js +62 -62
  145. package/lib/custom-client-scripts/assert-type.js +7 -7
  146. package/lib/custom-client-scripts/client-script-init.js +3 -3
  147. package/lib/custom-client-scripts/client-script.js +107 -108
  148. package/lib/custom-client-scripts/get-code.js +11 -11
  149. package/lib/custom-client-scripts/get-url.js +6 -6
  150. package/lib/custom-client-scripts/load.js +15 -15
  151. package/lib/custom-client-scripts/problematic-scripts.js +2 -2
  152. package/lib/custom-client-scripts/routing.js +36 -36
  153. package/lib/custom-client-scripts/utils.js +60 -60
  154. package/lib/embedding-utils.js +83 -83
  155. package/lib/errors/create-stack-filter.js +18 -18
  156. package/lib/errors/error-list.js +26 -26
  157. package/lib/errors/get-callsite.js +31 -31
  158. package/lib/errors/internal-modules-prefix.js +8 -8
  159. package/lib/errors/is-internal-stack-frame.js +46 -46
  160. package/lib/errors/process-test-fn-error.js +37 -37
  161. package/lib/errors/runtime/index.js +123 -123
  162. package/lib/errors/runtime/templates.js +116 -114
  163. package/lib/errors/runtime/type-assertions.js +112 -112
  164. package/lib/errors/stack-cleaning-hook.js +64 -64
  165. package/lib/errors/test-run/formattable-adapter.js +59 -59
  166. package/lib/errors/test-run/index.js +302 -302
  167. package/lib/errors/test-run/render-error-template.js +31 -31
  168. package/lib/errors/test-run/templates.js +93 -95
  169. package/lib/errors/test-run/utils.js +90 -85
  170. package/lib/errors/types.js +157 -155
  171. package/lib/index.js +81 -81
  172. package/lib/live/bootstrapper.js +44 -44
  173. package/lib/live/controller.js +107 -107
  174. package/lib/live/file-watcher/index.js +67 -67
  175. package/lib/live/file-watcher/modules-graph.js +58 -58
  176. package/lib/live/keyboard-observer.js +76 -76
  177. package/lib/live/logger/index.js +64 -64
  178. package/lib/live/test-run-controller.js +96 -96
  179. package/lib/live/test-run-state.js +6 -6
  180. package/lib/live/test-run.js +56 -56
  181. package/lib/live/test-runner.js +168 -168
  182. package/lib/load-assets.js +29 -29
  183. package/lib/notifications/add-rendered-warning.js +16 -16
  184. package/lib/notifications/debug-logger.js +78 -78
  185. package/lib/notifications/deprecated.js +24 -24
  186. package/lib/notifications/information-message.js +12 -12
  187. package/lib/notifications/warning-log.js +32 -31
  188. package/lib/notifications/warning-message.js +48 -48
  189. package/lib/reporter/command/command-formatter.js +120 -109
  190. package/lib/reporter/command/format-command.js +8 -8
  191. package/lib/reporter/command/interfaces.js +2 -2
  192. package/lib/reporter/index.js +319 -314
  193. package/lib/reporter/interfaces.js +2 -2
  194. package/lib/reporter/plugin-host.js +136 -137
  195. package/lib/reporter/plugin-methods.js +12 -12
  196. package/lib/role/index.js +74 -74
  197. package/lib/role/marker-symbol.js +7 -7
  198. package/lib/role/phase.js +9 -9
  199. package/lib/runner/bootstrapper.js +272 -272
  200. package/lib/runner/browser-job-result.js +9 -9
  201. package/lib/runner/browser-job.js +153 -123
  202. package/lib/runner/browser-set.js +114 -114
  203. package/lib/runner/fixture-hook-controller.js +85 -85
  204. package/lib/runner/index.js +450 -442
  205. package/lib/runner/interfaces.js +3 -3
  206. package/lib/runner/reporter-stream-controller.js +28 -28
  207. package/lib/runner/task/index.js +152 -133
  208. package/lib/runner/task/phase.js +9 -9
  209. package/lib/runner/test-run-controller.js +166 -185
  210. package/lib/runner/tested-app.js +73 -72
  211. package/lib/screenshots/capturer.js +141 -141
  212. package/lib/screenshots/constants.js +11 -11
  213. package/lib/screenshots/crop.js +111 -111
  214. package/lib/screenshots/default-extension.js +4 -4
  215. package/lib/screenshots/index.js +67 -67
  216. package/lib/screenshots/utils.js +39 -39
  217. package/lib/services/compiler/host.js +190 -106
  218. package/lib/services/compiler/io.js +9 -9
  219. package/lib/services/compiler/protocol.js +17 -16
  220. package/lib/services/compiler/service.js +225 -106
  221. package/lib/services/compiler/test-run-proxy.js +111 -73
  222. package/lib/services/interfaces.js +3 -0
  223. package/lib/services/process-title.js +8 -8
  224. package/lib/services/serialization/prepare-options.js +17 -17
  225. package/lib/services/serialization/replicator/create-replicator.js +27 -0
  226. package/lib/services/serialization/replicator/custom-error-transform.js +28 -0
  227. package/lib/services/serialization/test-structure.js +93 -77
  228. package/lib/services/utils/ipc/interfaces.js +30 -30
  229. package/lib/services/utils/ipc/io.js +108 -108
  230. package/lib/services/utils/ipc/message.js +76 -73
  231. package/lib/services/utils/ipc/packet.js +55 -55
  232. package/lib/services/utils/ipc/proxy.js +110 -118
  233. package/lib/services/utils/ipc/transport.js +64 -64
  234. package/lib/shared/errors/index.js +382 -382
  235. package/lib/shared/node-modules-folder-name.js +4 -4
  236. package/lib/test-run/bookmark.js +90 -90
  237. package/lib/test-run/browser-console-messages.js +73 -73
  238. package/lib/test-run/browser-manipulation-queue.js +92 -92
  239. package/lib/test-run/client-messages.js +9 -9
  240. package/lib/test-run/commands/actions.js +486 -425
  241. package/lib/test-run/commands/assertion.js +45 -45
  242. package/lib/test-run/commands/base.js +14 -14
  243. package/lib/test-run/commands/browser-manipulation.js +95 -95
  244. package/lib/test-run/commands/from-object.js +82 -82
  245. package/lib/test-run/commands/observation.js +61 -61
  246. package/lib/test-run/commands/options.js +231 -215
  247. package/lib/test-run/commands/service.js +54 -48
  248. package/lib/test-run/commands/type.js +65 -60
  249. package/lib/test-run/commands/utils.js +87 -87
  250. package/lib/test-run/commands/validations/argument.js +90 -90
  251. package/lib/test-run/commands/validations/factories.js +47 -47
  252. package/lib/test-run/commands/validations/initializers.js +44 -44
  253. package/lib/test-run/debug-log.js +32 -32
  254. package/lib/test-run/execute-js-expression.js +74 -74
  255. package/lib/test-run/index.js +823 -752
  256. package/lib/test-run/marker-symbol.js +7 -7
  257. package/lib/test-run/observed-callsites-storage.js +17 -17
  258. package/lib/test-run/phase.js +16 -16
  259. package/lib/test-run/session-controller.js +104 -104
  260. package/lib/testcafe.js +119 -114
  261. package/lib/utils/assignable.js +39 -39
  262. package/lib/utils/async-event-emitter.js +28 -28
  263. package/lib/utils/async-queue.js +14 -14
  264. package/lib/utils/browser-connection-timeouts.js +19 -19
  265. package/lib/utils/callsite.js +17 -17
  266. package/lib/utils/check-file-path.js +31 -31
  267. package/lib/utils/check-url.js +51 -51
  268. package/lib/utils/convert-to-best-fit-type.js +16 -16
  269. package/lib/utils/correct-file-path.js +21 -21
  270. package/lib/utils/define-lazy-property.js +13 -13
  271. package/lib/utils/delay.js +6 -6
  272. package/lib/utils/delegated-api.js +44 -44
  273. package/lib/utils/detect-display.js +6 -6
  274. package/lib/utils/detect-ffmpeg.js +44 -44
  275. package/lib/utils/diff/colors.js +29 -29
  276. package/lib/utils/diff/index.js +53 -53
  277. package/lib/utils/diff/util.js +24 -22
  278. package/lib/utils/diff.js +29 -29
  279. package/lib/utils/escape-user-agent.js +10 -10
  280. package/lib/utils/flag-list.js +17 -17
  281. package/lib/utils/get-any-key.js +8 -8
  282. package/lib/utils/get-browser.js +8 -8
  283. package/lib/utils/get-common-path.js +34 -34
  284. package/lib/utils/get-filter-fn.js +40 -40
  285. package/lib/utils/get-options/base.js +36 -36
  286. package/lib/utils/get-options/compiler.js +33 -33
  287. package/lib/utils/get-options/grep.js +15 -15
  288. package/lib/utils/get-options/index.js +21 -19
  289. package/lib/utils/get-options/meta.js +22 -22
  290. package/lib/utils/get-options/quarantine.js +92 -0
  291. package/lib/utils/get-options/screenshot.js +17 -17
  292. package/lib/utils/get-options/ssl.js +45 -45
  293. package/lib/utils/get-options/video.js +10 -10
  294. package/lib/utils/get-viewport-width.js +18 -18
  295. package/lib/utils/guard-time-execution.js +10 -10
  296. package/lib/utils/handle-errors.js +74 -74
  297. package/lib/utils/handle-tag-args.js +8 -8
  298. package/lib/utils/http.js +30 -30
  299. package/lib/utils/is-localhost.js +11 -11
  300. package/lib/utils/is-password-input.js +11 -0
  301. package/lib/utils/is-repl.js +12 -0
  302. package/lib/utils/is-window-in-iframe.js +6 -6
  303. package/lib/utils/limit-number.js +10 -10
  304. package/lib/utils/make-reg-exp.js +7 -7
  305. package/lib/utils/moment-loader.js +20 -20
  306. package/lib/utils/parse-file-list.js +71 -71
  307. package/lib/utils/parse-user-agent.js +55 -55
  308. package/lib/utils/path-pattern.js +114 -114
  309. package/lib/utils/prepare-reporters.js +30 -30
  310. package/lib/utils/prerender-callsite.js +18 -18
  311. package/lib/utils/process.js +119 -119
  312. package/lib/utils/promisified-functions.js +46 -46
  313. package/lib/utils/re-executable-promise.js +39 -39
  314. package/lib/utils/render-callsite-sync.js +29 -29
  315. package/lib/utils/render-template.js +10 -10
  316. package/lib/utils/reporter.js +30 -30
  317. package/lib/utils/resolve-path-relatively-cwd.js +7 -7
  318. package/lib/utils/string.js +105 -105
  319. package/lib/utils/temp-directory/cleanup-process/commands.js +7 -7
  320. package/lib/utils/temp-directory/cleanup-process/index.js +143 -143
  321. package/lib/utils/temp-directory/cleanup-process/worker.js +58 -58
  322. package/lib/utils/temp-directory/index.js +87 -87
  323. package/lib/utils/temp-directory/lockfile.js +56 -56
  324. package/lib/utils/thennable.js +7 -7
  325. package/lib/utils/timer.js +15 -15
  326. package/lib/utils/to-posix-path.js +8 -8
  327. package/lib/utils/types.js +2 -2
  328. package/lib/video-recorder/interfaces.js +2 -2
  329. package/lib/video-recorder/process.js +126 -126
  330. package/lib/video-recorder/recorder.js +136 -136
  331. package/lib/video-recorder/test-run-video-recorder.js +69 -69
  332. package/lib/video-recorder/videos.js +37 -37
  333. package/package.json +7 -7
  334. package/ts-defs/index.d.ts +109 -17
  335. package/ts-defs/selectors.d.ts +95 -7
  336. package/ts-defs/testcafe-scripts.d.ts +96 -8
@@ -1,14 +1,17 @@
1
- // NOTE: We should have the capability to initialize scripts with different contexts.
2
- // This is required for iframes without the src attribute because Hammerhead does not
3
- // inject scripts into such iframes. So, we wrap all scripts in initialization functions.
4
- (function () {
5
- function initTestCafeClientDrivers(window, isIFrameWithoutSrc) {
6
- var document = window.document;
7
-
8
- (function (hammerhead, Promise$3, testCafeCore, testcafeAutomation, testcafeUi) {
1
+ window['%hammerhead%'].utils.removeInjectedScript();
2
+
3
+ // NOTE: We should have the capability to initialize scripts with different contexts.
4
+ // This is required for iframes without the src attribute because Hammerhead does not
5
+ // inject scripts into such iframes. So, we wrap all scripts in initialization functions.
6
+ (function () {
7
+ function initTestCafeClientDrivers(window, isIFrameWithoutSrc) {
8
+ var document = window.document;
9
+
10
+ (function (hammerhead, Promise$8, testCafeCore, testcafeAutomation, testCafeUI) {
9
11
  var hammerhead__default = 'default' in hammerhead ? hammerhead['default'] : hammerhead;
10
- Promise$3 = Promise$3 && Object.prototype.hasOwnProperty.call(Promise$3, 'default') ? Promise$3['default'] : Promise$3;
12
+ Promise$8 = Promise$8 && Object.prototype.hasOwnProperty.call(Promise$8, 'default') ? Promise$8['default'] : Promise$8;
11
13
  var testCafeCore__default = 'default' in testCafeCore ? testCafeCore['default'] : testCafeCore;
14
+ var testCafeUI__default = 'default' in testCafeUI ? testCafeUI['default'] : testCafeUI;
12
15
 
13
16
  /*! *****************************************************************************
14
17
  Copyright (c) Microsoft Corporation.
@@ -41,7 +44,7 @@
41
44
 
42
45
  function __awaiter(thisArg, _arguments, P, generator) {
43
46
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
44
- return new (P || (P = Promise$3))(function (resolve, reject) {
47
+ return new (P || (P = Promise$8))(function (resolve, reject) {
45
48
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
46
49
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47
50
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
@@ -110,12 +113,16 @@
110
113
  // Do not use any browser or node-specific API!
111
114
  // -------------------------------------------------------------
112
115
  var COMMAND_TYPE = {
116
+ dispatchEvent: 'dispatch-event',
113
117
  click: 'click',
114
118
  rightClick: 'right-click',
115
119
  doubleClick: 'double-click',
116
120
  drag: 'drag',
117
121
  dragToElement: 'drag-to-element',
118
122
  hover: 'hover',
123
+ scroll: 'scroll',
124
+ scrollBy: 'scroll-by',
125
+ scrollIntoView: 'scroll-into-view',
119
126
  typeText: 'type-text',
120
127
  selectText: 'select-text',
121
128
  selectTextAreaContent: 'select-text-area-content',
@@ -150,6 +157,7 @@
150
157
  setNativeDialogHandler: 'set-native-dialog-handler',
151
158
  getNativeDialogHistory: 'get-native-dialog-history',
152
159
  getBrowserConsoleMessages: 'get-browser-console-messages',
160
+ getActiveElement: 'get-active-element',
153
161
  setTestSpeed: 'set-test-speed',
154
162
  setPageLoadTimeout: 'set-page-load-timeout',
155
163
  debug: 'debug',
@@ -2350,7 +2358,7 @@
2350
2358
  if (!testCafeCore.domUtils.isDomElement(el) && !testCafeCore.domUtils.isTextNode(el))
2351
2359
  return false;
2352
2360
  if (testCafeCore.domUtils.isOptionElement(el) || testCafeCore.domUtils.getTagName(el) === 'optgroup')
2353
- return testcafeUi.selectElement.isOptionElementVisible(el);
2361
+ return testCafeUI.selectElement.isOptionElementVisible(el);
2354
2362
  return testCafeCore.positionUtils.isElementVisible(el);
2355
2363
  }
2356
2364
  function IsNodeCollection(obj) {
@@ -2587,331 +2595,482 @@
2587
2595
  };
2588
2596
  }
2589
2597
 
2590
- // Ensure command element properties
2591
- function ensureElementEditable(element) {
2592
- if (!testCafeCore.domUtils.isEditableElement(element))
2593
- throw new ActionElementNonEditableError();
2598
+ var browserUtils = hammerhead__default.utils.browser;
2599
+ function getAutomationPoint(element, offsetX, offsetY) {
2600
+ var roundFn = browserUtils.isFirefox ? Math.ceil : Math.round;
2601
+ var elementOffset = testCafeCore.positionUtils.getOffsetPosition(element, roundFn);
2602
+ var left = element === document.documentElement ? 0 : elementOffset.left;
2603
+ var top = element === document.documentElement ? 0 : elementOffset.top;
2604
+ return {
2605
+ x: left + offsetX,
2606
+ y: top + offsetY
2607
+ };
2608
+ }
2609
+
2610
+ function convertToClient(element, point) {
2611
+ var elementScroll = testCafeCore.styleUtils.getElementScroll(element);
2612
+ if (!/html/i.test(element.tagName) && testCafeCore.styleUtils.hasScroll(element)) {
2613
+ point.x -= elementScroll.left;
2614
+ point.y -= elementScroll.top;
2615
+ }
2616
+ return testCafeCore.positionUtils.offsetToClientCoords(point);
2617
+ }
2618
+
2619
+ function getDevicePoint(clientPoint) {
2620
+ if (!clientPoint)
2621
+ return null;
2622
+ var screenLeft = window.screenLeft || window.screenX;
2623
+ var screenTop = window.screenTop || window.screenY;
2624
+ var x = screenLeft + clientPoint.x;
2625
+ var y = screenTop + clientPoint.y;
2626
+ return { x: x, y: y };
2627
+ }
2628
+
2629
+ function calcOffset(size) {
2630
+ var offset = size / 2;
2631
+ return offset < 1 ? 0 : Math.round(offset);
2594
2632
  }
2595
- function ensureTextAreaElement(element) {
2596
- if (!testCafeCore.domUtils.isTextAreaElement(element))
2597
- throw new ActionElementNotTextAreaError();
2633
+ function getDefaultAutomationOffsets(element) {
2634
+ var rect = testCafeCore.positionUtils.getElementRectangle(element);
2635
+ var offsetX = calcOffset(rect.width);
2636
+ var offsetY = calcOffset(rect.height);
2637
+ return { offsetX: offsetX, offsetY: offsetY };
2598
2638
  }
2599
- function ensureContentEditableElement(element, argumentTitle) {
2600
- if (!testCafeCore.domUtils.isContentEditableElement(element))
2601
- throw new ActionElementNonContentEditableError(argumentTitle);
2639
+ function getOffsetOptions(element, offsetX, offsetY) {
2640
+ var defaultOffsets = getDefaultAutomationOffsets(element);
2641
+ offsetX = typeof offsetX === 'number' ? Math.round(offsetX) : defaultOffsets.offsetX;
2642
+ offsetY = typeof offsetY === 'number' ? Math.round(offsetY) : defaultOffsets.offsetY;
2643
+ if (offsetX > 0 && offsetY > 0)
2644
+ return { offsetX: offsetX, offsetY: offsetY };
2645
+ var dimensions = testCafeCore.positionUtils.getClientDimensions(element);
2646
+ var width = Math.round(Math.max(element.scrollWidth, dimensions.width));
2647
+ var height = Math.round(Math.max(element.scrollHeight, dimensions.height));
2648
+ var maxX = dimensions.scrollbar.right + dimensions.border.left + dimensions.border.right + width;
2649
+ var maxY = dimensions.scrollbar.bottom + dimensions.border.top + dimensions.border.bottom + height;
2650
+ return {
2651
+ offsetX: offsetX < 0 ? maxX + offsetX : offsetX,
2652
+ offsetY: offsetY < 0 ? maxY + offsetY : offsetY
2653
+ };
2654
+ }
2655
+
2656
+ function isIframeWindow(window) {
2657
+ return window.top !== window;
2658
+ }
2659
+
2660
+ var domUtils = testCafeCore__default.domUtils;
2661
+ var cursorUI = !isIframeWindow(window) ? testCafeUI__default.cursorUI : testCafeUI__default.iframeCursorUI;
2662
+ // NOTE: the default position should be outside of the page (GH-794)
2663
+ var cursor = {
2664
+ x: -1,
2665
+ y: -1,
2666
+ currentActiveWindow: window.top,
2667
+ _ensureActiveWindow: function () {
2668
+ if (this.currentActiveWindow === window || this.currentActiveWindow === window.parent)
2669
+ return;
2670
+ var activeFrame = domUtils.findIframeByWindow(this.currentActiveWindow);
2671
+ if (!activeFrame || !domUtils.isElementInDocument(activeFrame))
2672
+ this.currentActiveWindow = window;
2673
+ },
2674
+ get active() {
2675
+ this._ensureActiveWindow();
2676
+ return this.currentActiveWindow === window;
2677
+ },
2678
+ set activeWindow(win) {
2679
+ this.currentActiveWindow = win;
2680
+ },
2681
+ get activeWindow() {
2682
+ this._ensureActiveWindow();
2683
+ return this.currentActiveWindow;
2684
+ },
2685
+ get position() {
2686
+ return { x: this.x, y: this.y };
2687
+ },
2688
+ get visible() {
2689
+ return !isIframeWindow(window) && cursorUI.isVisible();
2690
+ },
2691
+ move: function (newX, newY) {
2692
+ this.x = newX;
2693
+ this.y = newY;
2694
+ return cursorUI.move(this.x, this.y);
2695
+ },
2696
+ hide: function () {
2697
+ if (this.visible)
2698
+ cursorUI.hide();
2699
+ },
2700
+ show: function () {
2701
+ if (!isIframeWindow(window))
2702
+ cursorUI.show();
2703
+ },
2704
+ leftButtonDown: function () {
2705
+ return cursorUI.leftButtonDown();
2706
+ },
2707
+ rightButtonDown: function () {
2708
+ return cursorUI.rightButtonDown();
2709
+ },
2710
+ buttonUp: function () {
2711
+ return cursorUI.buttonUp();
2712
+ }
2713
+ };
2714
+
2715
+ var browserUtils$1 = hammerhead__default.utils.browser;
2716
+ var Promise$1 = hammerhead__default.Promise;
2717
+ var nativeMethods$4 = hammerhead__default.nativeMethods;
2718
+ var positionUtils = testCafeCore__default.positionUtils;
2719
+ var domUtils$1 = testCafeCore__default.domUtils;
2720
+ function getElementFromPoint(x, y, underTopShadowUIElement) {
2721
+ var topElement = null;
2722
+ return testCafeUI__default.hide(underTopShadowUIElement)
2723
+ .then(function () {
2724
+ topElement = positionUtils.getElementFromPoint(x, y);
2725
+ return testCafeUI__default.show(underTopShadowUIElement);
2726
+ })
2727
+ .then(function () { return topElement; });
2602
2728
  }
2603
- function ensureRootContainer(elements) {
2604
- // NOTE: We should find a common element for the nodes to perform the select action
2605
- if (!testCafeCore.contentEditable.getNearestCommonAncestor(elements[0], elements[1]))
2606
- throw new ActionRootContainerNotFoundError();
2607
- return elements;
2729
+ function ensureImageMap(imgElement, areaElement) {
2730
+ var mapElement = domUtils$1.closest(areaElement, 'map');
2731
+ return mapElement && mapElement.name === imgElement.useMap.substring(1) ? areaElement : imgElement;
2608
2732
  }
2609
- function ensureFileInput(element) {
2610
- if (!testCafeCore.domUtils.isFileInput(element))
2611
- throw new ActionElementIsNotFileInputError();
2733
+ function findElementOrNonEmptyChildFromPoint(x, y, element) {
2734
+ var topElement = positionUtils.getElementFromPoint(x, y);
2735
+ var isNonEmptyChild = domUtils$1.containsElement(element, topElement) &&
2736
+ nativeMethods$4.nodeTextContentGetter.call(topElement).length;
2737
+ if (topElement && topElement === element || isNonEmptyChild)
2738
+ return topElement;
2739
+ return null;
2612
2740
  }
2613
- function ensureOffsetOptions(element, options) {
2614
- var _a = testcafeAutomation.getOffsetOptions(element, options.offsetX, options.offsetY), offsetX = _a.offsetX, offsetY = _a.offsetY;
2615
- options.offsetX = offsetX;
2616
- options.offsetY = offsetY;
2741
+ function correctTopElementByExpectedElement(topElement, expectedElement) {
2742
+ var expectedElementDefined = expectedElement && domUtils$1.isDomElement(expectedElement);
2743
+ if (!expectedElementDefined || !topElement || topElement === expectedElement)
2744
+ return topElement;
2745
+ var isTREFElement = domUtils$1.getTagName(expectedElement) === 'tref';
2746
+ // NOTE: 'document.elementFromPoint' can't find these types of elements
2747
+ if (isTREFElement)
2748
+ return expectedElement;
2749
+ // NOTE: T299665 - Incorrect click automation for images with an associated map element in Firefox
2750
+ // All browsers return the <area> element from document.getElementFromPoint, but
2751
+ // Firefox returns the <img> element. We should accomplish this for Firefox as well.
2752
+ var isImageMapArea = domUtils$1.getTagName(expectedElement) === 'area' && domUtils$1.isImgElement(topElement);
2753
+ if (browserUtils$1.isFirefox && isImageMapArea)
2754
+ return ensureImageMap(topElement, expectedElement);
2755
+ // NOTE: try to find a multi-line link by its rectangle (T163678)
2756
+ var isLinkOrChildExpected = domUtils$1.isAnchorElement(expectedElement) ||
2757
+ domUtils$1.getParents(expectedElement, 'a').length;
2758
+ var isTopElementChildOfLink = isLinkOrChildExpected &&
2759
+ domUtils$1.containsElement(expectedElement, topElement) &&
2760
+ nativeMethods$4.nodeTextContentGetter.call(topElement).length;
2761
+ var shouldSearchForMultilineLink = isLinkOrChildExpected && !isTopElementChildOfLink &&
2762
+ nativeMethods$4.nodeTextContentGetter.call(expectedElement).length;
2763
+ if (!shouldSearchForMultilineLink)
2764
+ return topElement;
2765
+ var linkRect = expectedElement.getBoundingClientRect();
2766
+ return findElementOrNonEmptyChildFromPoint(linkRect.right - 1, linkRect.top + 1, expectedElement) ||
2767
+ findElementOrNonEmptyChildFromPoint(linkRect.left + 1, linkRect.bottom - 1, expectedElement) ||
2768
+ topElement;
2617
2769
  }
2618
- var MAX_DELAY_AFTER_EXECUTION = 2000;
2619
- var CHECK_ELEMENT_IN_AUTOMATIONS_INTERVAL = 250;
2620
- var DateCtor$2 = hammerhead.nativeMethods.date;
2621
- var ActionExecutor = /** @class */ (function () {
2622
- function ActionExecutor(command, globalSelectorTimeout, statusBar, testSpeed) {
2623
- this.command = command;
2624
- this.globalSelectorTimeout = globalSelectorTimeout;
2625
- this.statusBar = statusBar;
2626
- this.testSpeed = testSpeed;
2627
- this.targetElement = null;
2628
- this.elements = [];
2629
- this.ensureElementsPromise = null;
2630
- this.ensureElementsStartTime = null;
2631
- this.executionStartTime = null;
2632
- this.executionStartedHandler = null;
2633
- this.commandSelectorTimeout = null;
2634
- }
2635
- ActionExecutor.prototype._getSpecificTimeout = function () {
2636
- var hasSpecificTimeout = this.command.selector && typeof this.command.selector.timeout === 'number';
2637
- return hasSpecificTimeout ? this.command.selector.timeout : this.globalSelectorTimeout;
2638
- };
2639
- ActionExecutor.prototype._delayAfterExecution = function () {
2640
- if (!this.command.options || this.command.options.speed === 1)
2641
- return hammerhead.Promise.resolve();
2642
- return testCafeCore.delay((1 - this.command.options.speed) * MAX_DELAY_AFTER_EXECUTION);
2643
- };
2644
- ActionExecutor.prototype._isExecutionTimeoutExpired = function () {
2645
- return hammerhead.nativeMethods.dateNow() - this.executionStartTime >= this.commandSelectorTimeout;
2646
- };
2647
- ActionExecutor.prototype._ensureCommandArguments = function () {
2648
- if (this.command.type === COMMAND_TYPE.pressKey) {
2649
- var parsedKeySequence = testCafeCore.parseKeySequence(this.command.keys);
2650
- if (parsedKeySequence.error)
2651
- throw new ActionIncorrectKeysError('keys');
2770
+ function fromPoint(x, y, expectedElement) {
2771
+ var foundElement = null;
2772
+ return getElementFromPoint(x, y)
2773
+ .then(function (topElement) {
2774
+ foundElement = topElement;
2775
+ // NOTE: when trying to get an element by elementFromPoint in iframe and the target
2776
+ // element is under any of shadow-ui elements, you will get null (only in IE).
2777
+ // In this case, you should hide a top window's shadow-ui root to obtain an element.
2778
+ var resChain = Promise$1.resolve(topElement);
2779
+ if (!foundElement && isIframeWindow(window) && x > 0 && y > 0) {
2780
+ resChain = resChain
2781
+ .then(function () { return getElementFromPoint(x, y, true); })
2782
+ .then(function (element) {
2783
+ foundElement = element;
2784
+ return element;
2785
+ });
2652
2786
  }
2787
+ return resChain
2788
+ .then(function (element) { return correctTopElementByExpectedElement(element, expectedElement); })
2789
+ .then(function (correctedElement) {
2790
+ return { element: correctedElement, corrected: correctedElement !== foundElement };
2791
+ });
2792
+ });
2793
+ }
2794
+ function underCursor() {
2795
+ var cursorPosition = cursor.position;
2796
+ return fromPoint(cursorPosition.x, cursorPosition.y).then(function (_a) {
2797
+ var element = _a.element;
2798
+ return element;
2799
+ });
2800
+ }
2801
+
2802
+ var AUTOMATION_ERROR_TYPES = {
2803
+ elementIsInvisibleError: 'elementIsInvisibleError',
2804
+ foundElementIsNotTarget: 'foundElementIsNotTarget'
2805
+ };
2806
+
2807
+ var ACTION_STEP_DELAY_DEFAULT = 10;
2808
+ var MAX_MOUSE_ACTION_STEP_DELAY = 400;
2809
+ var MAX_KEY_ACTION_STEP_DELAY = 200;
2810
+ // We use an exponential function to calculate the cursor
2811
+ // speed according to general test speed
2812
+ // cursorSpeed = (maxSpeed * k) ^ speed / k
2813
+ var MAX_CURSOR_SPEED = 100; // pixels/ms
2814
+ var MAX_DRAGGING_SPEED = 4; // pixels/ms
2815
+ var CURSOR_FACTOR = 4;
2816
+ var AutomationSettings = /** @class */ (function () {
2817
+ function AutomationSettings(speed) {
2818
+ this.speedFactor = speed || 1;
2819
+ }
2820
+ Object.defineProperty(AutomationSettings.prototype, "mouseActionStepDelay", {
2821
+ get: function () {
2822
+ return this.speedFactor === 1 ? ACTION_STEP_DELAY_DEFAULT : (1 - this.speedFactor) * MAX_MOUSE_ACTION_STEP_DELAY;
2823
+ },
2824
+ enumerable: false,
2825
+ configurable: true
2826
+ });
2827
+ Object.defineProperty(AutomationSettings.prototype, "keyActionStepDelay", {
2828
+ get: function () {
2829
+ return this.speedFactor === 1 ? ACTION_STEP_DELAY_DEFAULT : (1 - this.speedFactor) * MAX_KEY_ACTION_STEP_DELAY;
2830
+ },
2831
+ enumerable: false,
2832
+ configurable: true
2833
+ });
2834
+ Object.defineProperty(AutomationSettings.prototype, "cursorSpeed", {
2835
+ get: function () {
2836
+ return Math.pow(MAX_CURSOR_SPEED * CURSOR_FACTOR, this.speedFactor) / CURSOR_FACTOR;
2837
+ },
2838
+ enumerable: false,
2839
+ configurable: true
2840
+ });
2841
+ Object.defineProperty(AutomationSettings.prototype, "draggingSpeed", {
2842
+ get: function () {
2843
+ return Math.pow(MAX_DRAGGING_SPEED * CURSOR_FACTOR, this.speedFactor) / CURSOR_FACTOR;
2844
+ },
2845
+ enumerable: false,
2846
+ configurable: true
2847
+ });
2848
+ return AutomationSettings;
2849
+ }());
2850
+
2851
+ var Promise$2 = hammerhead__default.Promise;
2852
+ var messageSandbox$1 = hammerhead__default.eventSandbox.message;
2853
+ var DEFAULT_MAX_SCROLL_MARGIN = 50;
2854
+ var SCROLL_MARGIN_INCREASE_STEP = 20;
2855
+ var SCROLL_REQUEST_CMD = 'automation|scroll|request';
2856
+ var SCROLL_RESPONSE_CMD = 'automation|scroll|response';
2857
+ // Setup cross-iframe interaction
2858
+ messageSandbox$1.on(messageSandbox$1.SERVICE_MSG_RECEIVED_EVENT, function (e) {
2859
+ if (e.message.cmd === SCROLL_REQUEST_CMD) {
2860
+ var _a = e.message, offsetX = _a.offsetX, offsetY = _a.offsetY, maxScrollMargin = _a.maxScrollMargin;
2861
+ var element = testCafeCore.domUtils.findIframeByWindow(e.source);
2862
+ var scroll_1 = new ScrollAutomation(element, { offsetX: offsetX, offsetY: offsetY });
2863
+ scroll_1.maxScrollMargin = maxScrollMargin;
2864
+ scroll_1
2865
+ .run()
2866
+ .then(function () { return messageSandbox$1.sendServiceMsg({ cmd: SCROLL_RESPONSE_CMD }, e.source); });
2867
+ }
2868
+ });
2869
+ var ScrollAutomation = /** @class */ (function () {
2870
+ function ScrollAutomation(element, scrollOptions) {
2871
+ this.element = element;
2872
+ this.offsetX = scrollOptions.offsetX;
2873
+ this.offsetY = scrollOptions.offsetY;
2874
+ this.scrollToCenter = scrollOptions.scrollToCenter;
2875
+ this.skipParentFrames = scrollOptions.skipParentFrames;
2876
+ this.raiseEvents = scrollOptions.raiseEvents;
2877
+ this.maxScrollMargin = { left: DEFAULT_MAX_SCROLL_MARGIN, top: DEFAULT_MAX_SCROLL_MARGIN };
2878
+ this.scrollWasPerformed = false;
2879
+ }
2880
+ ScrollAutomation.prototype._isScrollValuesChanged = function (scrollElement, originalScroll) {
2881
+ return testCafeCore.styleUtils.getScrollLeft(scrollElement) !== originalScroll.left
2882
+ || testCafeCore.styleUtils.getScrollTop(scrollElement) !== originalScroll.top;
2653
2883
  };
2654
- ActionExecutor.prototype._ensureCommandElements = function () {
2884
+ ScrollAutomation.prototype._setScroll = function (element, _a) {
2655
2885
  var _this = this;
2656
- var elementDescriptors = [];
2657
- if (this.command.selector)
2658
- elementDescriptors.push(createElementDescriptor(this.command.selector));
2659
- if (this.command.type === COMMAND_TYPE.dragToElement)
2660
- elementDescriptors.push(createAdditionalElementDescriptor(this.command.destinationSelector, 'destinationSelector'));
2661
- else if (this.command.type === COMMAND_TYPE.selectEditableContent) {
2662
- elementDescriptors.push(createAdditionalElementDescriptor(this.command.startSelector, 'startSelector'));
2663
- elementDescriptors.push(createAdditionalElementDescriptor(this.command.endSelector || this.command.startSelector, 'endSelector'));
2886
+ var left = _a.left, top = _a.top;
2887
+ var scrollElement = testCafeCore.domUtils.isHtmlElement(element) ? testCafeCore.domUtils.findDocument(element) : element;
2888
+ var originalScroll = {
2889
+ left: testCafeCore.styleUtils.getScrollLeft(scrollElement),
2890
+ top: testCafeCore.styleUtils.getScrollTop(scrollElement)
2891
+ };
2892
+ left = Math.max(left, 0);
2893
+ top = Math.max(top, 0);
2894
+ var scrollPromise = testCafeCore.scrollController.waitForScroll(scrollElement);
2895
+ testCafeCore.styleUtils.setScrollLeft(scrollElement, left);
2896
+ testCafeCore.styleUtils.setScrollTop(scrollElement, top);
2897
+ if (!this._isScrollValuesChanged(scrollElement, originalScroll)) {
2898
+ scrollPromise.cancel();
2899
+ return Promise$2.resolve();
2664
2900
  }
2665
- return ensureElements(elementDescriptors, this.globalSelectorTimeout)
2666
- .then(function (elements) {
2667
- _this.elements = elements;
2901
+ scrollPromise = scrollPromise.then(function () {
2902
+ _this.scrollWasPerformed = _this.scrollWasPerformed || _this._isScrollValuesChanged(scrollElement, originalScroll);
2668
2903
  });
2669
- };
2670
- ActionExecutor.prototype._ensureCommandElementsProperties = function () {
2671
- if (this.command.type === COMMAND_TYPE.selectText)
2672
- ensureElementEditable(this.elements[0]);
2673
- else if (this.command.type === COMMAND_TYPE.selectTextAreaContent)
2674
- ensureTextAreaElement(this.elements[0]);
2675
- else if (this.command.type === COMMAND_TYPE.selectEditableContent) {
2676
- ensureContentEditableElement(this.elements[0], 'startSelector');
2677
- ensureContentEditableElement(this.elements[1], 'endSelector');
2678
- ensureRootContainer(this.elements);
2904
+ return scrollPromise;
2905
+ };
2906
+ ScrollAutomation.prototype._getScrollToPoint = function (elementDimensions, _a, maxScrollMargin) {
2907
+ var x = _a.x, y = _a.y;
2908
+ var horizontalCenter = Math.floor(elementDimensions.width / 2);
2909
+ var verticalCenter = Math.floor(Math.floor(elementDimensions.height / 2));
2910
+ var leftScrollMargin = this.scrollToCenter ? horizontalCenter : Math.min(maxScrollMargin.left, horizontalCenter);
2911
+ var topScrollMargin = this.scrollToCenter ? verticalCenter : Math.min(maxScrollMargin.top, verticalCenter);
2912
+ var needForwardScrollLeft = x >= elementDimensions.scroll.left + elementDimensions.width - leftScrollMargin;
2913
+ var needBackwardScrollLeft = x <= elementDimensions.scroll.left + leftScrollMargin;
2914
+ var needForwardScrollTop = y >= elementDimensions.scroll.top + elementDimensions.height - topScrollMargin;
2915
+ var needBackwardScrollTop = y <= elementDimensions.scroll.top + topScrollMargin;
2916
+ var left = elementDimensions.scroll.left;
2917
+ var top = elementDimensions.scroll.top;
2918
+ if (needForwardScrollLeft)
2919
+ left = x - elementDimensions.width + leftScrollMargin;
2920
+ else if (needBackwardScrollLeft)
2921
+ left = x - leftScrollMargin;
2922
+ if (needForwardScrollTop)
2923
+ top = y - elementDimensions.height + topScrollMargin;
2924
+ else if (needBackwardScrollTop)
2925
+ top = y - topScrollMargin;
2926
+ return { left: left, top: top };
2927
+ };
2928
+ ScrollAutomation.prototype._getScrollToFullChildView = function (parentDimensions, childDimensions, maxScrollMargin) {
2929
+ var fullViewScrollLeft = null;
2930
+ var fullViewScrollTop = null;
2931
+ var canShowFullElementWidth = parentDimensions.width >= childDimensions.width;
2932
+ var canShowFullElementHeight = parentDimensions.height >= childDimensions.height;
2933
+ var relativePosition = testCafeCore.positionUtils.calcRelativePosition(childDimensions, parentDimensions);
2934
+ if (canShowFullElementWidth) {
2935
+ var availableLeftScrollMargin = parentDimensions.width - childDimensions.width;
2936
+ var leftScrollMargin = Math.min(maxScrollMargin.left, availableLeftScrollMargin);
2937
+ if (this.scrollToCenter)
2938
+ leftScrollMargin = availableLeftScrollMargin / 2;
2939
+ if (relativePosition.left < leftScrollMargin) {
2940
+ fullViewScrollLeft = Math.round(parentDimensions.scroll.left + relativePosition.left -
2941
+ leftScrollMargin);
2942
+ }
2943
+ else if (relativePosition.right < leftScrollMargin) {
2944
+ fullViewScrollLeft = Math.round(parentDimensions.scroll.left +
2945
+ Math.min(relativePosition.left, -relativePosition.right) +
2946
+ leftScrollMargin);
2947
+ }
2679
2948
  }
2680
- else if (this.command.type === COMMAND_TYPE.setFilesToUpload || this.command.type === COMMAND_TYPE.clearUpload)
2681
- ensureFileInput(this.elements[0]);
2949
+ if (canShowFullElementHeight) {
2950
+ var availableTopScrollMargin = parentDimensions.height - childDimensions.height;
2951
+ var topScrollMargin = Math.min(maxScrollMargin.top, availableTopScrollMargin);
2952
+ if (this.scrollToCenter)
2953
+ topScrollMargin = availableTopScrollMargin / 2;
2954
+ if (relativePosition.top < topScrollMargin)
2955
+ fullViewScrollTop = Math.round(parentDimensions.scroll.top + relativePosition.top - topScrollMargin);
2956
+ else if (relativePosition.bottom < topScrollMargin) {
2957
+ fullViewScrollTop = Math.round(parentDimensions.scroll.top +
2958
+ Math.min(relativePosition.top, -relativePosition.bottom) +
2959
+ topScrollMargin);
2960
+ }
2961
+ }
2962
+ return {
2963
+ left: fullViewScrollLeft,
2964
+ top: fullViewScrollTop
2965
+ };
2682
2966
  };
2683
- ActionExecutor.prototype._ensureCommandOptions = function () {
2684
- if (this.elements.length && this.command.options && 'offsetX' in this.command.options && 'offsetY' in this.command.options)
2685
- ensureOffsetOptions(this.elements[0], this.command.options);
2967
+ ScrollAutomation._getChildPoint = function (parentDimensions, childDimensions, offsets) {
2968
+ return {
2969
+ x: childDimensions.left - parentDimensions.left + parentDimensions.scroll.left +
2970
+ childDimensions.border.left + offsets.x,
2971
+ y: childDimensions.top - parentDimensions.top + parentDimensions.scroll.top +
2972
+ childDimensions.border.top + offsets.y
2973
+ };
2686
2974
  };
2687
- ActionExecutor.prototype._createAutomation = function () {
2688
- var selectArgs = null;
2689
- switch (this.command.type) {
2690
- case COMMAND_TYPE.click:
2691
- if (/option|optgroup/.test(testCafeCore.domUtils.getTagName(this.elements[0])))
2692
- return new testcafeAutomation.SelectChildClick(this.elements[0], this.command.options);
2693
- return new testcafeAutomation.Click(this.elements[0], this.command.options);
2694
- case COMMAND_TYPE.rightClick:
2695
- return new testcafeAutomation.RClick(this.elements[0], this.command.options);
2696
- case COMMAND_TYPE.doubleClick:
2697
- return new testcafeAutomation.DblClick(this.elements[0], this.command.options);
2698
- case COMMAND_TYPE.hover:
2699
- return new testcafeAutomation.Hover(this.elements[0], this.command.options);
2700
- case COMMAND_TYPE.drag:
2701
- return new testcafeAutomation.DragToOffset(this.elements[0], this.command.dragOffsetX, this.command.dragOffsetY, this.command.options);
2702
- case COMMAND_TYPE.dragToElement:
2703
- return new testcafeAutomation.DragToElement(this.elements[0], this.elements[1], this.command.options);
2704
- case COMMAND_TYPE.typeText:
2705
- // eslint-disable-next-line no-restricted-properties
2706
- return new testcafeAutomation.Type(this.elements[0], this.command.text, this.command.options);
2707
- case COMMAND_TYPE.selectText:
2708
- case COMMAND_TYPE.selectTextAreaContent:
2709
- selectArgs = testcafeAutomation.calculateSelectTextArguments(this.elements[0], this.command);
2710
- return new testcafeAutomation.SelectText(this.elements[0], selectArgs.startPos, selectArgs.endPos, this.command.options);
2711
- case COMMAND_TYPE.selectEditableContent:
2712
- return new testcafeAutomation.SelectEditableContent(this.elements[0], this.elements[1], this.command.options);
2713
- case COMMAND_TYPE.pressKey:
2714
- return new testcafeAutomation.Press(testCafeCore.parseKeySequence(this.command.keys).combinations, this.command.options);
2715
- case COMMAND_TYPE.setFilesToUpload:
2716
- return new testcafeAutomation.Upload(this.elements[0], this.command.filePath, function (filePaths, scannedFilePaths) { return new ActionCannotFindFileToUploadError(filePaths, scannedFilePaths); });
2717
- case COMMAND_TYPE.clearUpload:
2718
- return new testcafeAutomation.Upload(this.elements[0]);
2975
+ ScrollAutomation.prototype._getScrollPosition = function (parentDimensions, childDimensions, offsets, maxScrollMargin) {
2976
+ var childPoint = ScrollAutomation._getChildPoint(parentDimensions, childDimensions, offsets);
2977
+ var scrollToPoint = this._getScrollToPoint(parentDimensions, childPoint, maxScrollMargin);
2978
+ var scrollToFullView = this._getScrollToFullChildView(parentDimensions, childDimensions, maxScrollMargin);
2979
+ var left = Math.max(scrollToFullView.left === null ? scrollToPoint.left : scrollToFullView.left, 0);
2980
+ var top = Math.max(scrollToFullView.top === null ? scrollToPoint.top : scrollToFullView.top, 0);
2981
+ return { left: left, top: top };
2982
+ };
2983
+ ScrollAutomation._getChildPointAfterScroll = function (parentDimensions, childDimensions, currentScroll, offsets) {
2984
+ var x = Math.round(childDimensions.left + parentDimensions.scroll.left - currentScroll.left + offsets.x);
2985
+ var y = Math.round(childDimensions.top + parentDimensions.scroll.top - currentScroll.top + offsets.y);
2986
+ return { x: x, y: y };
2987
+ };
2988
+ ScrollAutomation.prototype._isChildFullyVisible = function (parentDimensions, childDimensions, offsets) {
2989
+ var _a = ScrollAutomation._getChildPointAfterScroll(parentDimensions, childDimensions, parentDimensions.scroll, offsets), x = _a.x, y = _a.y;
2990
+ var zeroMargin = { left: 0, top: 0 };
2991
+ var _b = this._getScrollPosition(parentDimensions, childDimensions, offsets, zeroMargin), left = _b.left, top = _b.top;
2992
+ return !this._isTargetElementObscuredInPoint(x, y) &&
2993
+ left === parentDimensions.scroll.left && top === parentDimensions.scroll.top;
2994
+ };
2995
+ ScrollAutomation.prototype._scrollToChild = function (parent, child, offsets) {
2996
+ var parentDimensions = testCafeCore.positionUtils.getClientDimensions(parent);
2997
+ var childDimensions = testCafeCore.positionUtils.getClientDimensions(child);
2998
+ var windowWidth = testCafeCore.styleUtils.getInnerWidth(window);
2999
+ var windowHeight = testCafeCore.styleUtils.getInnerHeight(window);
3000
+ var scrollPos = parentDimensions.scroll;
3001
+ var needScroll = !this._isChildFullyVisible(parentDimensions, childDimensions, offsets);
3002
+ while (needScroll) {
3003
+ scrollPos = this._getScrollPosition(parentDimensions, childDimensions, offsets, this.maxScrollMargin);
3004
+ var _a = ScrollAutomation._getChildPointAfterScroll(parentDimensions, childDimensions, scrollPos, offsets), x = _a.x, y = _a.y;
3005
+ var isTargetObscured = this._isTargetElementObscuredInPoint(x, y);
3006
+ this.maxScrollMargin.left += SCROLL_MARGIN_INCREASE_STEP;
3007
+ if (this.maxScrollMargin.left >= windowWidth) {
3008
+ this.maxScrollMargin.left = DEFAULT_MAX_SCROLL_MARGIN;
3009
+ this.maxScrollMargin.top += SCROLL_MARGIN_INCREASE_STEP;
3010
+ }
3011
+ needScroll = isTargetObscured && this.maxScrollMargin.top < windowHeight;
2719
3012
  }
2720
- return null;
3013
+ this.maxScrollMargin = { left: DEFAULT_MAX_SCROLL_MARGIN, top: DEFAULT_MAX_SCROLL_MARGIN };
3014
+ return this._setScroll(parent, scrollPos);
2721
3015
  };
2722
- ActionExecutor.prototype._runAction = function (strictElementCheck) {
2723
- var _this = this;
2724
- return this
2725
- ._ensureCommandElements()
2726
- .then(function () { return _this._ensureCommandElementsProperties(); })
2727
- .then(function () {
2728
- _this._ensureCommandOptions();
2729
- var automation = _this._createAutomation();
2730
- if (automation.TARGET_ELEMENT_FOUND_EVENT) {
2731
- automation.on(automation.TARGET_ELEMENT_FOUND_EVENT, function (e) {
2732
- _this.targetElement = e.element;
2733
- _this.statusBar.hideWaitingElementStatus(true);
2734
- _this.executionStartedHandler();
2735
- });
2736
- }
2737
- else {
2738
- _this.statusBar.hideWaitingElementStatus(true);
2739
- _this.executionStartedHandler();
2740
- }
2741
- return automation
2742
- .run(strictElementCheck);
2743
- });
3016
+ ScrollAutomation.prototype._scrollElement = function () {
3017
+ if (!testCafeCore.styleUtils.hasScroll(this.element))
3018
+ return Promise$2.resolve();
3019
+ var elementDimensions = testCafeCore.positionUtils.getClientDimensions(this.element);
3020
+ var scroll = this._getScrollToPoint(elementDimensions, { x: this.offsetX, y: this.offsetY }, this.maxScrollMargin);
3021
+ return this._setScroll(this.element, scroll);
2744
3022
  };
2745
- ActionExecutor.prototype._runRecursively = function () {
3023
+ ScrollAutomation.prototype._scrollParents = function () {
2746
3024
  var _this = this;
2747
- var actionFinished = false;
2748
- var strictElementCheck = true;
2749
- return testCafeCore.promiseUtils.whilst(function () { return !actionFinished; }, function () {
3025
+ var parents = testCafeCore.styleUtils.getScrollableParents(this.element);
3026
+ var currentChild = this.element;
3027
+ var currentOffsetX = this.offsetX - Math.round(testCafeCore.styleUtils.getScrollLeft(currentChild));
3028
+ var currentOffsetY = this.offsetY - Math.round(testCafeCore.styleUtils.getScrollTop(currentChild));
3029
+ var childDimensions = null;
3030
+ var parentDimensions = null;
3031
+ var scrollParentsPromise = testCafeCore.promiseUtils.times(parents.length, function (i) {
2750
3032
  return _this
2751
- ._runAction(strictElementCheck)
3033
+ ._scrollToChild(parents[i], currentChild, { x: currentOffsetX, y: currentOffsetY })
2752
3034
  .then(function () {
2753
- actionFinished = true;
2754
- })
2755
- .catch(function (err) {
2756
- if (_this._isExecutionTimeoutExpired()) {
2757
- if (err.message === testcafeAutomation.ERROR_TYPES.foundElementIsNotTarget) {
2758
- // If we can't get a target element via elementFromPoint but it's
2759
- // visible we click on the point where the element is located.
2760
- strictElementCheck = false;
2761
- return hammerhead.Promise.resolve();
2762
- }
2763
- throw err.message === testcafeAutomation.ERROR_TYPES.elementIsInvisibleError ?
2764
- new ActionElementIsInvisibleError() : err;
2765
- }
2766
- return testCafeCore.delay(CHECK_ELEMENT_IN_AUTOMATIONS_INTERVAL);
3035
+ childDimensions = testCafeCore.positionUtils.getClientDimensions(currentChild);
3036
+ parentDimensions = testCafeCore.positionUtils.getClientDimensions(parents[i]);
3037
+ currentOffsetX += childDimensions.left - parentDimensions.left + parentDimensions.border.left;
3038
+ currentOffsetY += childDimensions.top - parentDimensions.top + parentDimensions.border.top;
3039
+ currentChild = parents[i];
2767
3040
  });
2768
3041
  });
3042
+ return scrollParentsPromise
3043
+ .then(function () {
3044
+ if (isIframeWindow(window) && !_this.skipParentFrames) {
3045
+ return testCafeCore.sendRequestToFrame({
3046
+ cmd: SCROLL_REQUEST_CMD,
3047
+ offsetX: currentOffsetX,
3048
+ offsetY: currentOffsetY,
3049
+ maxScrollMargin: _this.maxScrollMargin
3050
+ }, SCROLL_RESPONSE_CMD, window.parent);
3051
+ }
3052
+ return Promise$2.resolve();
3053
+ });
2769
3054
  };
2770
- ActionExecutor.prototype.execute = function () {
3055
+ ScrollAutomation._getFixedAncestorOrSelf = function (element) {
3056
+ return testCafeCore.domUtils.findParent(element, true, testCafeCore.styleUtils.isFixedElement);
3057
+ };
3058
+ ScrollAutomation.prototype._isTargetElementObscuredInPoint = function (x, y) {
3059
+ var elementInPoint = testCafeCore.positionUtils.getElementFromPoint(x, y);
3060
+ if (!elementInPoint)
3061
+ return false;
3062
+ var fixedElement = ScrollAutomation._getFixedAncestorOrSelf(elementInPoint);
3063
+ return fixedElement && !fixedElement.contains(this.element);
3064
+ };
3065
+ ScrollAutomation.prototype.run = function () {
2771
3066
  var _this = this;
2772
- if (this.command.options && !this.command.options.speed)
2773
- this.command.options.speed = this.testSpeed;
2774
- var startPromise = new hammerhead.Promise(function (resolve) {
2775
- _this.executionStartedHandler = resolve;
2776
- });
2777
- var completionPromise = new hammerhead.Promise(function (resolve) {
2778
- _this.executionStartTime = new DateCtor$2();
2779
- try {
2780
- _this._ensureCommandArguments();
2781
- }
2782
- catch (err) {
2783
- resolve(new DriverStatus({ isCommandResult: true, executionError: err }));
2784
- return;
2785
- }
2786
- _this.commandSelectorTimeout = _this._getSpecificTimeout();
2787
- _this.statusBar.showWaitingElementStatus(_this.commandSelectorTimeout);
2788
- var _a = runWithBarriers(function () { return _this._runRecursively(); }), actionPromise = _a.actionPromise, barriersPromise = _a.barriersPromise;
2789
- actionPromise
2790
- .then(function () { return hammerhead.Promise.all([
2791
- _this._delayAfterExecution(),
2792
- barriersPromise
2793
- ]); })
2794
- .then(function () {
2795
- var status = { isCommandResult: true };
2796
- var elements = __spreadArrays(_this.elements);
2797
- if (_this.targetElement)
2798
- elements[0] = _this.targetElement;
2799
- status.result = createReplicator(new SelectorElementActionTransform()).encode(elements);
2800
- resolve(new DriverStatus(status));
2801
- })
2802
- .catch(function (err) {
2803
- return _this.statusBar.hideWaitingElementStatus(false)
2804
- .then(function () { return resolve(new DriverStatus({ isCommandResult: true, executionError: err })); });
2805
- });
2806
- });
2807
- return { startPromise: startPromise, completionPromise: completionPromise };
2808
- };
2809
- return ActionExecutor;
2810
- }());
2811
- function executeAction(command, globalSelectorTimeout, statusBar, testSpeed) {
2812
- var actionExecutor = new ActionExecutor(command, globalSelectorTimeout, statusBar, testSpeed);
2813
- return actionExecutor.execute();
2814
- }
2815
-
2816
- // -------------------------------------------------------------
2817
- // WARNING: this file is used by both the client and the server.
2818
- // Do not use any browser or node-specific API!
2819
- // -------------------------------------------------------------
2820
- function limitNumber (value, min, max) {
2821
- return Math.min(Math.max(min, value), max);
2822
- }
2823
-
2824
- function determineDimensionBounds(bounds, maximum) {
2825
- var hasMin = typeof bounds.min === 'number';
2826
- var hasMax = typeof bounds.max === 'number';
2827
- var hasLength = typeof bounds.length === 'number';
2828
- if (hasLength)
2829
- bounds.length = limitNumber(bounds.length, 0, maximum);
2830
- if (hasMin && bounds.min < 0)
2831
- bounds.min += maximum;
2832
- if (hasMax && bounds.max < 0)
2833
- bounds.max += maximum;
2834
- if (!hasMin)
2835
- bounds.min = hasMax && hasLength ? bounds.max - bounds.length : 0;
2836
- if (!hasMax)
2837
- bounds.max = hasLength ? bounds.min + bounds.length : maximum;
2838
- bounds.min = limitNumber(bounds.min, 0, maximum);
2839
- bounds.max = limitNumber(bounds.max, 0, maximum);
2840
- bounds.length = bounds.max - bounds.min;
2841
- return bounds;
2842
- }
2843
- function determineScrollPoint(cropStart, cropEnd, viewportBound) {
2844
- return Math.round(cropStart + limitNumber(cropEnd - cropStart, 0, viewportBound) / 2);
2845
- }
2846
- function ensureCropOptions(element, options) {
2847
- var elementRectangle = element.getBoundingClientRect();
2848
- var elementBounds = {
2849
- left: elementRectangle.left,
2850
- right: elementRectangle.right,
2851
- top: elementRectangle.top,
2852
- bottom: elementRectangle.bottom
3067
+ return this
3068
+ ._scrollElement()
3069
+ .then(function () { return _this._scrollParents(); })
3070
+ .then(function () { return _this.scrollWasPerformed; });
2853
3071
  };
2854
- var elementMargin = testCafeCore.styleUtils.getElementMargin(element);
2855
- var elementPadding = testCafeCore.styleUtils.getElementPadding(element);
2856
- var elementBordersWidth = testCafeCore.styleUtils.getBordersWidth(element);
2857
- options.originOffset = { x: 0, y: 0 };
2858
- var scrollRight = elementBounds.left + element.scrollWidth + elementBordersWidth.left + elementBordersWidth.right;
2859
- var scrollBottom = elementBounds.top + element.scrollHeight + elementBordersWidth.top + elementBordersWidth.bottom;
2860
- elementBounds.right = Math.max(elementBounds.right, scrollRight);
2861
- elementBounds.bottom = Math.max(elementBounds.bottom, scrollBottom);
2862
- if (!options.includeBorders || !options.includePaddings) {
2863
- options.originOffset.x += elementBordersWidth.left;
2864
- options.originOffset.y += elementBordersWidth.top;
2865
- elementBounds.left += elementBordersWidth.left;
2866
- elementBounds.top += elementBordersWidth.top;
2867
- elementBounds.right -= elementBordersWidth.right;
2868
- elementBounds.bottom -= elementBordersWidth.bottom;
2869
- if (!options.includePaddings) {
2870
- options.originOffset.x += elementPadding.left;
2871
- options.originOffset.y += elementPadding.top;
2872
- elementBounds.left += elementPadding.left;
2873
- elementBounds.top += elementPadding.top;
2874
- elementBounds.right -= elementPadding.right;
2875
- elementBounds.bottom -= elementPadding.bottom;
2876
- }
2877
- }
2878
- else if (options.includeMargins) {
2879
- options.originOffset.x -= elementMargin.left;
2880
- options.originOffset.y -= elementMargin.top;
2881
- elementBounds.left -= elementMargin.left;
2882
- elementBounds.top -= elementMargin.top;
2883
- elementBounds.right += elementMargin.right;
2884
- elementBounds.bottom += elementMargin.bottom;
2885
- }
2886
- elementBounds.width = elementBounds.right - elementBounds.left;
2887
- elementBounds.height = elementBounds.bottom - elementBounds.top;
2888
- var horizontalCropBounds = determineDimensionBounds({ min: options.crop.left, max: options.crop.right, length: options.crop.width }, elementBounds.width);
2889
- var verticalCropBounds = determineDimensionBounds({ min: options.crop.top, max: options.crop.bottom, length: options.crop.height }, elementBounds.height);
2890
- options.crop.left = horizontalCropBounds.min;
2891
- options.crop.right = horizontalCropBounds.max;
2892
- options.crop.width = horizontalCropBounds.length;
2893
- options.crop.top = verticalCropBounds.min;
2894
- options.crop.bottom = verticalCropBounds.max;
2895
- options.crop.height = verticalCropBounds.length;
2896
- if (options.crop.width <= 0 || options.crop.height <= 0)
2897
- throw new InvalidElementScreenshotDimensionsError(options.crop.width, options.crop.height);
2898
- var viewportDimensions = testCafeCore.styleUtils.getViewportDimensions();
2899
- if (elementBounds.width > viewportDimensions.width || elementBounds.height > viewportDimensions.height)
2900
- options.scrollToCenter = true;
2901
- var hasScrollTargetX = typeof options.scrollTargetX === 'number';
2902
- var hasScrollTargetY = typeof options.scrollTargetY === 'number';
2903
- if (!hasScrollTargetX)
2904
- options.scrollTargetX = determineScrollPoint(options.crop.left, options.crop.right, viewportDimensions.width);
2905
- if (!hasScrollTargetY)
2906
- options.scrollTargetY = determineScrollPoint(options.crop.top, options.crop.bottom, viewportDimensions.height);
2907
- var _a = testcafeAutomation.getOffsetOptions(element, options.scrollTargetX, options.scrollTargetY), offsetX = _a.offsetX, offsetY = _a.offsetY;
2908
- options.scrollTargetX = offsetX;
2909
- options.scrollTargetY = offsetY;
2910
- var isScrollTargetXValid = !hasScrollTargetX || options.scrollTargetX >= options.crop.left && options.scrollTargetX <= options.crop.right;
2911
- var isScrollTargetYValid = !hasScrollTargetY || options.scrollTargetY >= options.crop.top && options.scrollTargetY <= options.crop.bottom;
2912
- if (!isScrollTargetXValid || !isScrollTargetYValid)
2913
- throw new ActionInvalidScrollTargetError(isScrollTargetXValid, isScrollTargetYValid);
2914
- }
3072
+ return ScrollAutomation;
3073
+ }());
2915
3074
 
2916
3075
  // -------------------------------------------------------------
2917
3076
  // WARNING: this file is used by both the client and the server.
@@ -3106,90 +3265,1276 @@
3106
3265
  { name: 'skipDefaultDragBehavior', type: booleanOption }
3107
3266
  ]);
3108
3267
  };
3109
- return MoveOptions;
3110
- }(MouseOptions));
3111
- // Type
3112
- var TypeOptions = /** @class */ (function (_super) {
3113
- __extends(TypeOptions, _super);
3114
- function TypeOptions(obj, validate) {
3115
- var _this = _super.call(this) || this;
3116
- _this.replace = false;
3117
- _this.paste = false;
3118
- _this._assignFrom(obj, validate);
3119
- return _this;
3120
- }
3121
- TypeOptions.prototype._getAssignableProperties = function () {
3122
- return _super.prototype._getAssignableProperties.call(this).concat([
3123
- { name: 'replace', type: booleanOption },
3124
- { name: 'paste', type: booleanOption }
3125
- ]);
3268
+ return MoveOptions;
3269
+ }(MouseOptions));
3270
+ // Type
3271
+ var TypeOptions = /** @class */ (function (_super) {
3272
+ __extends(TypeOptions, _super);
3273
+ function TypeOptions(obj, validate) {
3274
+ var _this = _super.call(this) || this;
3275
+ _this.replace = false;
3276
+ _this.paste = false;
3277
+ _this.confidential = void 0;
3278
+ _this._assignFrom(obj, validate);
3279
+ return _this;
3280
+ }
3281
+ TypeOptions.prototype._getAssignableProperties = function () {
3282
+ return _super.prototype._getAssignableProperties.call(this).concat([
3283
+ { name: 'replace', type: booleanOption },
3284
+ { name: 'paste', type: booleanOption },
3285
+ { name: 'confidential', type: booleanOption }
3286
+ ]);
3287
+ };
3288
+ return TypeOptions;
3289
+ }(ClickOptions));
3290
+ // DragToElement
3291
+ var DragToElementOptions = /** @class */ (function (_super) {
3292
+ __extends(DragToElementOptions, _super);
3293
+ function DragToElementOptions(obj, validate) {
3294
+ var _this = _super.call(this, obj, validate) || this;
3295
+ _this.destinationOffsetX = null;
3296
+ _this.destinationOffsetY = null;
3297
+ _this._assignFrom(obj, validate);
3298
+ return _this;
3299
+ }
3300
+ DragToElementOptions.prototype._getAssignableProperties = function () {
3301
+ return _super.prototype._getAssignableProperties.call(this).concat([
3302
+ { name: 'destinationOffsetX', type: integerOption },
3303
+ { name: 'destinationOffsetY', type: integerOption }
3304
+ ]);
3305
+ };
3306
+ return DragToElementOptions;
3307
+ }(MouseOptions));
3308
+ //ResizeToFitDevice
3309
+ var ResizeToFitDeviceOptions = /** @class */ (function (_super) {
3310
+ __extends(ResizeToFitDeviceOptions, _super);
3311
+ function ResizeToFitDeviceOptions(obj, validate) {
3312
+ var _this = _super.call(this) || this;
3313
+ _this.portraitOrientation = false;
3314
+ _this._assignFrom(obj, validate);
3315
+ return _this;
3316
+ }
3317
+ ResizeToFitDeviceOptions.prototype._getAssignableProperties = function () {
3318
+ return [
3319
+ { name: 'portraitOrientation', type: booleanOption }
3320
+ ];
3321
+ };
3322
+ return ResizeToFitDeviceOptions;
3323
+ }(Assignable));
3324
+ //Assertion
3325
+ var AssertionOptions = /** @class */ (function (_super) {
3326
+ __extends(AssertionOptions, _super);
3327
+ function AssertionOptions(obj, validate) {
3328
+ var _this = _super.call(this) || this;
3329
+ _this.timeout = void 0;
3330
+ _this.allowUnawaitedPromise = false;
3331
+ _this._assignFrom(obj, validate);
3332
+ return _this;
3333
+ }
3334
+ AssertionOptions.prototype._getAssignableProperties = function () {
3335
+ return [
3336
+ { name: 'timeout', type: positiveIntegerOption },
3337
+ { name: 'allowUnawaitedPromise', type: booleanOption }
3338
+ ];
3339
+ };
3340
+ return AssertionOptions;
3341
+ }(Assignable));
3342
+ // Press
3343
+ var PressOptions = /** @class */ (function (_super) {
3344
+ __extends(PressOptions, _super);
3345
+ function PressOptions(obj, validate) {
3346
+ var _this = _super.call(this) || this;
3347
+ _this.confidential = void 0;
3348
+ _this._assignFrom(obj, validate);
3349
+ return _this;
3350
+ }
3351
+ PressOptions.prototype._getAssignableProperties = function () {
3352
+ return _super.prototype._getAssignableProperties.call(this).concat([
3353
+ { name: 'confidential', type: booleanOption }
3354
+ ]);
3355
+ };
3356
+ return PressOptions;
3357
+ }(ActionOptions));
3358
+
3359
+ function getPointsDistance(start, end) {
3360
+ return Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
3361
+ }
3362
+ function findLineAndRectSideIntersection(startLinePoint, endLinePoint, rectSide) {
3363
+ var intersectionX = null;
3364
+ var haveIntersectionInBounds = null;
3365
+ if (rectSide.isHorizontal) {
3366
+ intersectionX = testCafeCore.positionUtils.getLineXByYCoord(startLinePoint, endLinePoint, rectSide.y1);
3367
+ haveIntersectionInBounds = intersectionX && intersectionX >= rectSide.x1 && intersectionX <= rectSide.x2;
3368
+ return haveIntersectionInBounds ? { x: intersectionX, y: rectSide.y1 } : null;
3369
+ }
3370
+ var intersectionY = testCafeCore.positionUtils.getLineYByXCoord(startLinePoint, endLinePoint, rectSide.x1);
3371
+ haveIntersectionInBounds = intersectionY && intersectionY >= rectSide.y1 && intersectionY <= rectSide.y2;
3372
+ return haveIntersectionInBounds ? { x: rectSide.x1, y: intersectionY } : null;
3373
+ }
3374
+ function getLineRectIntersection (startLinePoint, endLinePoint, rect) {
3375
+ var res = [];
3376
+ var intersection = null;
3377
+ var rectLines = [
3378
+ { x1: rect.left, y1: rect.top, x2: rect.left, y2: rect.bottom, isHorizontal: false },
3379
+ { x1: rect.right, y1: rect.top, x2: rect.right, y2: rect.bottom, isHorizontal: false },
3380
+ { x1: rect.left, y1: rect.top, x2: rect.right, y2: rect.top, isHorizontal: true },
3381
+ { x1: rect.left, y1: rect.bottom, x2: rect.right, y2: rect.bottom, isHorizontal: true } // bottom-side
3382
+ ];
3383
+ for (var i = 0; i < rectLines.length; i++) {
3384
+ intersection = findLineAndRectSideIntersection(startLinePoint, endLinePoint, rectLines[i]);
3385
+ if (intersection)
3386
+ res.push(intersection);
3387
+ }
3388
+ if (!res.length)
3389
+ return null;
3390
+ if (res.length === 1)
3391
+ return res[0];
3392
+ // NOTE: if a line and rect have two intersection points, we return the nearest to startLinePoint
3393
+ return getPointsDistance(startLinePoint, res[0]) < getPointsDistance(startLinePoint, res[1]) ? res[0] : res[1];
3394
+ }
3395
+
3396
+ var Promise$3 = hammerhead__default.Promise;
3397
+ var nativeMethods$5 = hammerhead__default.nativeMethods;
3398
+ function nextTick () {
3399
+ return new Promise$3(function (resolve) { return nativeMethods$5.setTimeout.call(window, resolve, 0); });
3400
+ }
3401
+
3402
+ var DragAndDropState = /** @class */ (function () {
3403
+ function DragAndDropState() {
3404
+ this.enabled = false;
3405
+ this.dropAllowed = false;
3406
+ this.element = null;
3407
+ this.dataTransfer = null;
3408
+ this.dataStore = null;
3409
+ }
3410
+ return DragAndDropState;
3411
+ }());
3412
+
3413
+ var browserUtils$2 = hammerhead__default.utils.browser;
3414
+ var MoveEventSequenceBase = /** @class */ (function () {
3415
+ function MoveEventSequenceBase(_a) {
3416
+ var moveEvent = _a.moveEvent;
3417
+ this.dragAndDropMode = false;
3418
+ this.dropAllowed = false;
3419
+ this.moveEvent = moveEvent;
3420
+ }
3421
+ MoveEventSequenceBase.prototype.setup = function () {
3422
+ this.dragAndDropMode = false;
3423
+ this.dropAllowed = false;
3424
+ };
3425
+ MoveEventSequenceBase.prototype.leaveElement = function ( /* currentElement, prevElement, commonAncestor, options */) {
3426
+ };
3427
+ MoveEventSequenceBase.prototype.move = function ( /* element, options */) {
3428
+ };
3429
+ MoveEventSequenceBase.prototype.enterElement = function ( /* currentElement, prevElement, commonAncestor, options */) {
3430
+ };
3431
+ MoveEventSequenceBase.prototype.dragAndDrop = function ( /* dragElement, currentElement, prevElement, options, dragDataStore */) {
3432
+ };
3433
+ MoveEventSequenceBase.prototype.teardown = function ( /* currentElement, eventOptions, prevElement */) {
3434
+ };
3435
+ MoveEventSequenceBase.prototype.run = function (currentElement, prevElement, options, dragElement, dragDataStore) {
3436
+ // NOTE: if last hovered element was in an iframe that has been removed, IE
3437
+ // raises an exception when we try to compare it with the current element
3438
+ var prevElementInDocument = prevElement && testCafeCore.domUtils.isElementInDocument(prevElement);
3439
+ var prevElementInRemovedIframe = prevElement && testCafeCore.domUtils.isElementInIframe(prevElement) &&
3440
+ !testCafeCore.domUtils.getIframeByElement(prevElement);
3441
+ if (!prevElementInDocument || prevElementInRemovedIframe)
3442
+ prevElement = null;
3443
+ var elementChanged = currentElement !== prevElement;
3444
+ var commonAncestor = elementChanged ? testCafeCore.domUtils.getCommonAncestor(currentElement, prevElement) : null;
3445
+ this.setup();
3446
+ if (elementChanged && !!prevElement)
3447
+ this.leaveElement(currentElement, prevElement, commonAncestor, options);
3448
+ if (browserUtils$2.isIE)
3449
+ this.move(currentElement, options);
3450
+ if (elementChanged && testCafeCore.domUtils.isElementInDocument(currentElement))
3451
+ this.enterElement(currentElement, prevElement, commonAncestor, options);
3452
+ if (!browserUtils$2.isIE)
3453
+ this.move(currentElement, options);
3454
+ this.dragAndDrop(dragElement, currentElement, prevElement, options, dragDataStore);
3455
+ this.teardown(currentElement, options, prevElement);
3456
+ var dragAndDropMode = this.dragAndDropMode;
3457
+ var dropAllowed = this.dropAllowed;
3458
+ this.dragAndDropMode = false;
3459
+ this.dropAllowed = false;
3460
+ return { dragAndDropMode: dragAndDropMode, dropAllowed: dropAllowed };
3461
+ };
3462
+ return MoveEventSequenceBase;
3463
+ }());
3464
+
3465
+ var eventSimulator = hammerhead__default.eventSandbox.eventSimulator;
3466
+ var extend = hammerhead__default.utils.extend;
3467
+ var nativeMethods$6 = hammerhead__default.nativeMethods;
3468
+ var MoveBehaviour = /** @class */ (function () {
3469
+ function MoveBehaviour() {
3470
+ }
3471
+ MoveBehaviour.leaveElement = function (currentElement, prevElement, commonAncestor, options) {
3472
+ eventSimulator.mouseout(prevElement, extend({ relatedTarget: currentElement }, options));
3473
+ var currentParent = prevElement;
3474
+ while (currentParent && currentParent !== commonAncestor) {
3475
+ eventSimulator.mouseleave(currentParent, extend({ relatedTarget: currentElement }, options));
3476
+ currentParent = nativeMethods$6.nodeParentNodeGetter.call(currentParent);
3477
+ }
3478
+ };
3479
+ MoveBehaviour.enterElement = function (currentElement, prevElement, commonAncestor, options) {
3480
+ eventSimulator.mouseover(currentElement, extend({ relatedTarget: prevElement }, options));
3481
+ var currentParent = currentElement;
3482
+ var mouseenterElements = [];
3483
+ while (currentParent && currentParent !== commonAncestor) {
3484
+ mouseenterElements.push(currentParent);
3485
+ currentParent = testCafeCore.domUtils.getParentExceptShadowRoot(currentParent);
3486
+ }
3487
+ for (var i = mouseenterElements.length - 1; i > -1; i--)
3488
+ eventSimulator.mouseenter(mouseenterElements[i], extend({ relatedTarget: prevElement }, options));
3489
+ };
3490
+ MoveBehaviour.move = function (moveEvent, element, options) {
3491
+ eventSimulator[moveEvent](element, options);
3492
+ };
3493
+ return MoveBehaviour;
3494
+ }());
3495
+ var DragAndDropBehavior = /** @class */ (function () {
3496
+ function DragAndDropBehavior() {
3497
+ }
3498
+ DragAndDropBehavior.dragAndDrop = function (dragElement, currentElement, prevElement, options) {
3499
+ eventSimulator.drag(dragElement, options);
3500
+ var currentElementChanged = currentElement !== prevElement;
3501
+ if (currentElementChanged) {
3502
+ if (testCafeCore.domUtils.isElementInDocument(currentElement)) {
3503
+ options.relatedTarget = prevElement;
3504
+ eventSimulator.dragenter(currentElement, options);
3505
+ }
3506
+ if (prevElement) {
3507
+ options.relatedTarget = currentElement;
3508
+ eventSimulator.dragleave(prevElement, options);
3509
+ }
3510
+ }
3511
+ return !eventSimulator.dragover(currentElement, options);
3512
+ };
3513
+ return DragAndDropBehavior;
3514
+ }());
3515
+
3516
+ var eventSimulator$1 = hammerhead__default.eventSandbox.eventSimulator;
3517
+ var TOUCH_MOVE_EVENT_NAME = 'touchmove';
3518
+ var MoveEventSequence = /** @class */ (function (_super) {
3519
+ __extends(MoveEventSequence, _super);
3520
+ function MoveEventSequence(options) {
3521
+ var _this = _super.call(this, options) || this;
3522
+ _this.holdLeftButton = options.holdLeftButton;
3523
+ return _this;
3524
+ }
3525
+ MoveEventSequence.prototype.leaveElement = function (currentElement, prevElement, commonAncestor, options) {
3526
+ MoveBehaviour.leaveElement(currentElement, prevElement, commonAncestor, options);
3527
+ };
3528
+ MoveEventSequence.prototype.enterElement = function (currentElement, prevElement, commonAncestor, options) {
3529
+ MoveBehaviour.enterElement(currentElement, prevElement, commonAncestor, options);
3530
+ };
3531
+ MoveEventSequence.prototype.move = function (element, options) {
3532
+ if (this._needEmulateMoveEvent())
3533
+ MoveBehaviour.move(this.moveEvent, element, options);
3534
+ };
3535
+ MoveEventSequence.prototype.teardown = function (currentElement, eventOptions, prevElement) {
3536
+ // NOTE: we need to add an extra 'mousemove' if the element was changed because sometimes
3537
+ // the client script requires several 'mousemove' events for an element (T246904)
3538
+ if (this._needEmulateMoveEvent() && testCafeCore.domUtils.isElementInDocument(currentElement) && currentElement !== prevElement)
3539
+ eventSimulator$1[this.moveEvent](currentElement, eventOptions);
3540
+ };
3541
+ MoveEventSequence.prototype._needEmulateMoveEvent = function () {
3542
+ return this.moveEvent !== TOUCH_MOVE_EVENT_NAME || this.holdLeftButton;
3543
+ };
3544
+ return MoveEventSequence;
3545
+ }(MoveEventSequenceBase));
3546
+
3547
+ var DragAndDropMoveEventSequence = /** @class */ (function (_super) {
3548
+ __extends(DragAndDropMoveEventSequence, _super);
3549
+ function DragAndDropMoveEventSequence() {
3550
+ return _super !== null && _super.apply(this, arguments) || this;
3551
+ }
3552
+ DragAndDropMoveEventSequence.prototype.setup = function () {
3553
+ _super.prototype.setup.call(this);
3554
+ this.dragAndDropMode = true;
3555
+ };
3556
+ DragAndDropMoveEventSequence.prototype.dragAndDrop = function (dragElement, currentElement, prevElement, options) {
3557
+ this.dropAllowed = DragAndDropBehavior.dragAndDrop(dragElement, currentElement, prevElement, options);
3558
+ };
3559
+ return DragAndDropMoveEventSequence;
3560
+ }(MoveEventSequenceBase));
3561
+
3562
+ var eventSimulator$2 = hammerhead__default.eventSandbox.eventSimulator;
3563
+ var DragAndDropFirstMoveEventSequence = /** @class */ (function (_super) {
3564
+ __extends(DragAndDropFirstMoveEventSequence, _super);
3565
+ function DragAndDropFirstMoveEventSequence() {
3566
+ return _super !== null && _super.apply(this, arguments) || this;
3567
+ }
3568
+ DragAndDropFirstMoveEventSequence.prototype.setup = function () {
3569
+ _super.prototype.setup.call(this);
3570
+ this.dragAndDropMode = true;
3571
+ };
3572
+ DragAndDropFirstMoveEventSequence.prototype.leaveElement = function (currentElement, prevElement, commonAncestor, options) {
3573
+ MoveBehaviour.leaveElement(currentElement, prevElement, commonAncestor, options);
3574
+ };
3575
+ DragAndDropFirstMoveEventSequence.prototype.move = function (element, option) {
3576
+ MoveBehaviour.move(this.moveEvent, element, option);
3577
+ };
3578
+ DragAndDropFirstMoveEventSequence.prototype.enterElement = function (currentElement, prevElement, commonAncestor, options) {
3579
+ MoveBehaviour.enterElement(currentElement, prevElement, commonAncestor, options);
3580
+ };
3581
+ DragAndDropFirstMoveEventSequence.prototype.dragAndDrop = function (dragElement, currentElement, prevElement, options, dragDataStore) {
3582
+ var dragAllowed = eventSimulator$2.dragstart(dragElement, options);
3583
+ dragDataStore.setReadOnlyMode();
3584
+ if (!dragAllowed) {
3585
+ this.dragAndDropMode = false;
3586
+ return;
3587
+ }
3588
+ this.dropAllowed = DragAndDropBehavior.dragAndDrop(dragElement, currentElement, prevElement, options);
3589
+ };
3590
+ DragAndDropFirstMoveEventSequence.prototype.run = function (currentElement, prevElement, options, dragElement, dragDataStore) {
3591
+ return _super.prototype.run.call(this, currentElement, null, options, dragElement, dragDataStore);
3592
+ };
3593
+ return DragAndDropFirstMoveEventSequence;
3594
+ }(MoveEventSequenceBase));
3595
+
3596
+ function createEventSequence(dragAndDropEnabled, firstMovingStepOccured, options) {
3597
+ if (!dragAndDropEnabled)
3598
+ return new MoveEventSequence(options);
3599
+ if (firstMovingStepOccured)
3600
+ return new DragAndDropMoveEventSequence(options);
3601
+ return new DragAndDropFirstMoveEventSequence(options);
3602
+ }
3603
+
3604
+ var lastHoveredElement = null;
3605
+ var lastHoveredElementHolder = {
3606
+ get: function () {
3607
+ return lastHoveredElement;
3608
+ },
3609
+ set: function (element) {
3610
+ lastHoveredElement = element;
3611
+ }
3612
+ };
3613
+
3614
+ var Promise$4 = hammerhead__default.Promise;
3615
+ var nativeMethods$7 = hammerhead__default.nativeMethods;
3616
+ var featureDetection = hammerhead__default.utils.featureDetection;
3617
+ var htmlUtils = hammerhead__default.utils.html;
3618
+ var urlUtils = hammerhead__default.utils.url;
3619
+ var eventSimulator$3 = hammerhead__default.eventSandbox.eventSimulator;
3620
+ var messageSandbox$2 = hammerhead__default.eventSandbox.message;
3621
+ var DataTransfer = hammerhead__default.eventSandbox.DataTransfer;
3622
+ var DragDataStore = hammerhead__default.eventSandbox.DragDataStore;
3623
+ var positionUtils$1 = testCafeCore__default.positionUtils;
3624
+ var domUtils$2 = testCafeCore__default.domUtils;
3625
+ var styleUtils = testCafeCore__default.styleUtils;
3626
+ var eventUtils = testCafeCore__default.eventUtils;
3627
+ var promiseUtils = testCafeCore__default.promiseUtils;
3628
+ var sendRequestToFrame = testCafeCore__default.sendRequestToFrame;
3629
+ var MOVE_REQUEST_CMD = 'automation|move|request';
3630
+ var MOVE_RESPONSE_CMD = 'automation|move|response';
3631
+ // Setup cross-iframe interaction
3632
+ messageSandbox$2.on(messageSandbox$2.SERVICE_MSG_RECEIVED_EVENT, function (e) {
3633
+ if (e.message.cmd === MOVE_REQUEST_CMD) {
3634
+ if (e.source.parent === window)
3635
+ MoveAutomation.onMoveToIframeRequest(e);
3636
+ else {
3637
+ hammerhead__default.on(hammerhead__default.EVENTS.beforeUnload, function () { return messageSandbox$2.sendServiceMsg({ cmd: MOVE_RESPONSE_CMD }, e.source); });
3638
+ MoveAutomation.onMoveOutRequest(e);
3639
+ }
3640
+ }
3641
+ });
3642
+ // Utils
3643
+ function findDraggableElement(element) {
3644
+ var parentNode = element;
3645
+ while (parentNode) {
3646
+ if (parentNode.draggable)
3647
+ return parentNode;
3648
+ parentNode = nativeMethods$7.nodeParentNodeGetter.call(parentNode);
3649
+ }
3650
+ return null;
3651
+ }
3652
+ var MoveAutomation = /** @class */ (function () {
3653
+ function MoveAutomation(element, moveOptions) {
3654
+ this.touchMode = featureDetection.isTouchDevice;
3655
+ this.moveEvent = this.touchMode ? 'touchmove' : 'mousemove';
3656
+ this.holdLeftButton = moveOptions.holdLeftButton;
3657
+ this.dragElement = null;
3658
+ this.dragAndDropState = new DragAndDropState();
3659
+ this.automationSettings = new AutomationSettings(moveOptions.speed);
3660
+ var target = MoveAutomation.getTarget(element, moveOptions.offsetX, moveOptions.offsetY);
3661
+ this.element = target.element;
3662
+ this.offsetX = target.offsetX;
3663
+ this.offsetY = target.offsetY;
3664
+ this.speed = moveOptions.speed;
3665
+ this.cursorSpeed = this.holdLeftButton ? this.automationSettings.draggingSpeed : this.automationSettings.cursorSpeed;
3666
+ this.minMovingTime = moveOptions.minMovingTime || null;
3667
+ this.modifiers = moveOptions.modifiers || {};
3668
+ this.skipScrolling = moveOptions.skipScrolling;
3669
+ this.skipDefaultDragBehavior = moveOptions.skipDefaultDragBehavior;
3670
+ this.endPoint = null;
3671
+ // moving state
3672
+ this.movingTime = null;
3673
+ this.x = null;
3674
+ this.y = null;
3675
+ this.startTime = null;
3676
+ this.endTime = null;
3677
+ this.distanceX = null;
3678
+ this.distanceY = null;
3679
+ this.firstMovingStepOccured = false;
3680
+ }
3681
+ MoveAutomation.getTarget = function (el, offsetX, offsetY) {
3682
+ // NOTE: if the target point (considering offsets) is out of
3683
+ // the element change the target element to the document element
3684
+ var relateToDocument = !positionUtils$1.containsOffset(el, offsetX, offsetY);
3685
+ var relatedPoint = relateToDocument ? getAutomationPoint(el, offsetX, offsetY) : { x: offsetX, y: offsetY };
3686
+ return {
3687
+ element: relateToDocument ? document.documentElement : el,
3688
+ offsetX: relatedPoint.x,
3689
+ offsetY: relatedPoint.y
3690
+ };
3691
+ };
3692
+ MoveAutomation.onMoveToIframeRequest = function (e) {
3693
+ var iframePoint = {
3694
+ x: e.message.endX,
3695
+ y: e.message.endY
3696
+ };
3697
+ var iframeWin = e.source;
3698
+ var iframe = domUtils$2.findIframeByWindow(iframeWin);
3699
+ var iframeBorders = styleUtils.getBordersWidth(iframe);
3700
+ var iframePadding = styleUtils.getElementPadding(iframe);
3701
+ var iframeRectangle = positionUtils$1.getIframeClientCoordinates(iframe);
3702
+ var iframePointRelativeToParent = positionUtils$1.getIframePointRelativeToParentFrame(iframePoint, iframeWin);
3703
+ var cursorPosition = cursor.position;
3704
+ var intersectionPoint = positionUtils$1.isInRectangle(cursorPosition, iframeRectangle) ? cursorPosition :
3705
+ getLineRectIntersection(cursorPosition, iframePointRelativeToParent, iframeRectangle);
3706
+ var intersectionRelatedToIframe = {
3707
+ x: intersectionPoint.x - iframeRectangle.left,
3708
+ y: intersectionPoint.y - iframeRectangle.top
3709
+ };
3710
+ var moveOptions = new MoveOptions({
3711
+ modifiers: e.message.modifiers,
3712
+ offsetX: intersectionRelatedToIframe.x + iframeBorders.left + iframePadding.left,
3713
+ offsetY: intersectionRelatedToIframe.y + iframeBorders.top + iframePadding.top,
3714
+ speed: e.message.speed,
3715
+ // NOTE: we should not perform scrolling because the active window was
3716
+ // already scrolled to the target element before the request (GH-847)
3717
+ skipScrolling: true
3718
+ }, false);
3719
+ var moveAutomation = new MoveAutomation(iframe, moveOptions);
3720
+ var responseMsg = {
3721
+ cmd: MOVE_RESPONSE_CMD,
3722
+ x: intersectionRelatedToIframe.x,
3723
+ y: intersectionRelatedToIframe.y
3724
+ };
3725
+ if (cursor.activeWindow !== iframeWin) {
3726
+ moveAutomation
3727
+ .run()
3728
+ .then(function () {
3729
+ cursor.activeWindow = iframeWin;
3730
+ messageSandbox$2.sendServiceMsg(responseMsg, iframeWin);
3731
+ });
3732
+ }
3733
+ else
3734
+ messageSandbox$2.sendServiceMsg(responseMsg, iframeWin);
3735
+ };
3736
+ MoveAutomation.onMoveOutRequest = function (e) {
3737
+ var parentWin = e.source;
3738
+ var iframeRectangle = {
3739
+ left: e.message.left,
3740
+ right: e.message.right,
3741
+ top: e.message.top,
3742
+ bottom: e.message.bottom
3743
+ };
3744
+ if (!e.message.iframeUnderCursor) {
3745
+ var _a = e.message, startX = _a.startX, startY = _a.startY;
3746
+ var clientX = startX - iframeRectangle.left;
3747
+ var clientY = startY - iframeRectangle.top;
3748
+ // NOTE: We should not emulate mouseout and mouseleave if iframe was reloaded.
3749
+ var element = lastHoveredElementHolder.get();
3750
+ if (element) {
3751
+ eventSimulator$3.mouseout(element, { clientX: clientX, clientY: clientY, relatedTarget: null });
3752
+ eventSimulator$3.mouseleave(element, { clientX: clientX, clientY: clientY, relatedTarget: null });
3753
+ }
3754
+ messageSandbox$2.sendServiceMsg({ cmd: MOVE_RESPONSE_CMD }, parentWin);
3755
+ return;
3756
+ }
3757
+ var cursorPosition = cursor.position;
3758
+ var startPoint = {
3759
+ x: iframeRectangle.left + cursorPosition.x,
3760
+ y: iframeRectangle.top + cursorPosition.y
3761
+ };
3762
+ var endPoint = { x: e.message.endX, y: e.message.endY };
3763
+ var intersectionPoint = getLineRectIntersection(startPoint, endPoint, iframeRectangle);
3764
+ // NOTE: We should not move the cursor out of the iframe if
3765
+ // the cursor path does not intersect with the iframe borders.
3766
+ if (!intersectionPoint) {
3767
+ messageSandbox$2.sendServiceMsg({
3768
+ cmd: MOVE_RESPONSE_CMD,
3769
+ x: iframeRectangle.left,
3770
+ y: iframeRectangle.top
3771
+ }, parentWin);
3772
+ return;
3773
+ }
3774
+ var moveOptions = new MoveOptions({
3775
+ modifiers: e.message.modifiers,
3776
+ offsetX: intersectionPoint.x - iframeRectangle.left,
3777
+ offsetY: intersectionPoint.y - iframeRectangle.top,
3778
+ speed: e.message.speed,
3779
+ // NOTE: we should not perform scrolling because the active window was
3780
+ // already scrolled to the target element before the request (GH-847)
3781
+ skipScrolling: true
3782
+ }, false);
3783
+ var moveAutomation = new MoveAutomation(document.documentElement, moveOptions);
3784
+ moveAutomation
3785
+ .run()
3786
+ .then(function () {
3787
+ var responseMsg = {
3788
+ cmd: MOVE_RESPONSE_CMD,
3789
+ x: intersectionPoint.x,
3790
+ y: intersectionPoint.y
3791
+ };
3792
+ cursor.activeWindow = parentWin;
3793
+ messageSandbox$2.sendServiceMsg(responseMsg, parentWin);
3794
+ });
3795
+ };
3796
+ MoveAutomation.prototype._getTargetClientPoint = function () {
3797
+ var scroll = styleUtils.getElementScroll(this.element);
3798
+ if (domUtils$2.isHtmlElement(this.element)) {
3799
+ return {
3800
+ x: Math.floor(this.offsetX - scroll.left),
3801
+ y: Math.floor(this.offsetY - scroll.top)
3802
+ };
3803
+ }
3804
+ var clientPosition = positionUtils$1.getClientPosition(this.element);
3805
+ var isDocumentBody = this.element.tagName && domUtils$2.isBodyElement(this.element);
3806
+ return {
3807
+ x: Math.floor(isDocumentBody ? clientPosition.x + this.offsetX : clientPosition.x + this.offsetX -
3808
+ scroll.left),
3809
+ y: Math.floor(isDocumentBody ? clientPosition.y + this.offsetY : clientPosition.y + this.offsetY -
3810
+ scroll.top)
3811
+ };
3812
+ };
3813
+ MoveAutomation.prototype._emulateEvents = function (currentElement) {
3814
+ var button = this.holdLeftButton ? eventUtils.BUTTONS_PARAMETER.leftButton : eventUtils.BUTTONS_PARAMETER.noButton;
3815
+ var devicePoint = getDevicePoint({ x: this.x, y: this.y });
3816
+ var eventOptions = {
3817
+ clientX: this.x,
3818
+ clientY: this.y,
3819
+ screenX: devicePoint.x,
3820
+ screenY: devicePoint.y,
3821
+ buttons: button,
3822
+ ctrl: this.modifiers.ctrl,
3823
+ alt: this.modifiers.alt,
3824
+ shift: this.modifiers.shift,
3825
+ meta: this.modifiers.meta,
3826
+ dataTransfer: this.dragAndDropState.dataTransfer
3827
+ };
3828
+ var eventSequenceOptions = { moveEvent: this.moveEvent, holdLeftButton: this.holdLeftButton };
3829
+ var eventSequence = createEventSequence(this.dragAndDropState.enabled, this.firstMovingStepOccured, eventSequenceOptions);
3830
+ var _a = eventSequence.run(currentElement, lastHoveredElementHolder.get(), eventOptions, this.dragElement, this.dragAndDropState.dataStore), dragAndDropMode = _a.dragAndDropMode, dropAllowed = _a.dropAllowed;
3831
+ this.firstMovingStepOccured = true;
3832
+ this.dragAndDropState.enabled = dragAndDropMode;
3833
+ this.dragAndDropState.dropAllowed = dropAllowed;
3834
+ lastHoveredElementHolder.set(currentElement);
3835
+ };
3836
+ MoveAutomation.prototype._movingStep = function () {
3837
+ var _this = this;
3838
+ if (this.touchMode && !this.holdLeftButton) {
3839
+ this.x = this.endPoint.x;
3840
+ this.y = this.endPoint.y;
3841
+ }
3842
+ else if (!this.startTime) {
3843
+ this.startTime = nativeMethods$7.dateNow();
3844
+ this.endTime = this.startTime + this.movingTime;
3845
+ // NOTE: the mousemove event can't be simulated at the point where the cursor
3846
+ // was located at the start. Therefore, we add a minimal distance 1 px.
3847
+ this.x += this.distanceX > 0 ? 1 : -1;
3848
+ this.y += this.distanceY > 0 ? 1 : -1;
3849
+ }
3850
+ else {
3851
+ var currentTime = Math.min(nativeMethods$7.dateNow(), this.endTime);
3852
+ var progress = (currentTime - this.startTime) / (this.endTime - this.startTime);
3853
+ this.x = Math.floor(this.startPoint.x + this.distanceX * progress);
3854
+ this.y = Math.floor(this.startPoint.y + this.distanceY * progress);
3855
+ }
3856
+ return cursor
3857
+ .move(this.x, this.y)
3858
+ .then(underCursor)
3859
+ // NOTE: in touch mode, events are simulated for the element for which mousedown was simulated (GH-372)
3860
+ .then(function (topElement) {
3861
+ var currentElement = _this.holdLeftButton && _this.touchMode ? _this.dragElement : topElement;
3862
+ // NOTE: it can be null in IE
3863
+ if (!currentElement)
3864
+ return null;
3865
+ return _this._emulateEvents(currentElement);
3866
+ })
3867
+ .then(nextTick);
3868
+ };
3869
+ MoveAutomation.prototype._isMovingFinished = function () {
3870
+ return this.x === this.endPoint.x && this.y === this.endPoint.y;
3871
+ };
3872
+ MoveAutomation.prototype._move = function () {
3873
+ var _this = this;
3874
+ this.startPoint = cursor.position;
3875
+ this.x = this.startPoint.x;
3876
+ this.y = this.startPoint.y;
3877
+ this.distanceX = this.endPoint.x - this.startPoint.x;
3878
+ this.distanceY = this.endPoint.y - this.startPoint.y;
3879
+ this.movingTime = Math.max(Math.abs(this.distanceX), Math.abs(this.distanceY)) / this.cursorSpeed;
3880
+ if (this.minMovingTime)
3881
+ this.movingTime = Math.max(this.movingTime, this.minMovingTime);
3882
+ return promiseUtils.whilst(function () { return !_this._isMovingFinished(); }, function () { return _this._movingStep(); });
3883
+ };
3884
+ MoveAutomation.prototype._scroll = function () {
3885
+ if (this.skipScrolling)
3886
+ return Promise$4.resolve();
3887
+ var scrollOptions = new ScrollOptions({ offsetX: this.offsetX, offsetY: this.offsetY }, false);
3888
+ var scrollAutomation = new ScrollAutomation(this.element, scrollOptions);
3889
+ return scrollAutomation.run();
3890
+ };
3891
+ MoveAutomation.prototype._moveToCurrentFrame = function () {
3892
+ if (cursor.active)
3893
+ return Promise$4.resolve();
3894
+ var _a = cursor.position, x = _a.x, y = _a.y;
3895
+ var activeWindow = cursor.activeWindow;
3896
+ var iframe = null;
3897
+ var iframeUnderCursor = null;
3898
+ var iframeRectangle = null;
3899
+ var msg = {
3900
+ cmd: MOVE_REQUEST_CMD,
3901
+ startX: x,
3902
+ startY: y,
3903
+ endX: this.endPoint.x,
3904
+ endY: this.endPoint.y,
3905
+ modifiers: this.modifiers,
3906
+ speed: this.speed
3907
+ };
3908
+ if (activeWindow.parent === window) {
3909
+ iframe = domUtils$2.findIframeByWindow(activeWindow);
3910
+ iframeRectangle = positionUtils$1.getIframeClientCoordinates(iframe);
3911
+ msg.left = iframeRectangle.left;
3912
+ msg.top = iframeRectangle.top;
3913
+ msg.right = iframeRectangle.right;
3914
+ msg.bottom = iframeRectangle.bottom;
3915
+ }
3916
+ return underCursor()
3917
+ .then(function (topElement) {
3918
+ iframeUnderCursor = topElement === iframe;
3919
+ if (activeWindow.parent === window)
3920
+ msg.iframeUnderCursor = iframeUnderCursor;
3921
+ return sendRequestToFrame(msg, MOVE_RESPONSE_CMD, activeWindow);
3922
+ })
3923
+ .then(function (message) {
3924
+ cursor.activeWindow = window;
3925
+ if (iframeUnderCursor || isIframeWindow(window))
3926
+ return cursor.move(message.x, message.y);
3927
+ return null;
3928
+ });
3929
+ };
3930
+ MoveAutomation.prototype.run = function () {
3931
+ var _this = this;
3932
+ return underCursor()
3933
+ .then(function (topElement) {
3934
+ _this.dragElement = _this.holdLeftButton ? topElement : null;
3935
+ var draggable = findDraggableElement(_this.dragElement);
3936
+ // NOTE: we should skip simulating drag&drop's native behavior if the mousedown event was prevented (GH - 2529)
3937
+ if (draggable && featureDetection.hasDataTransfer && !_this.skipDefaultDragBehavior) {
3938
+ _this.dragAndDropState.enabled = true;
3939
+ _this.dragElement = draggable;
3940
+ _this.dragAndDropState.element = _this.dragElement;
3941
+ _this.dragAndDropState.dataStore = new DragDataStore();
3942
+ _this.dragAndDropState.dataTransfer = new DataTransfer(_this.dragAndDropState.dataStore);
3943
+ var isLink = domUtils$2.isAnchorElement(_this.dragElement);
3944
+ if (isLink || domUtils$2.isImgElement(_this.dragElement)) {
3945
+ var srcAttr = isLink ? 'href' : 'src';
3946
+ var parsedUrl = urlUtils.parseProxyUrl(_this.dragElement[srcAttr]);
3947
+ var src = parsedUrl ? parsedUrl.destUrl : _this.dragElement[srcAttr];
3948
+ var outerHTML = htmlUtils.cleanUpHtml(nativeMethods$7.elementOuterHTMLGetter.call(_this.dragElement));
3949
+ _this.dragAndDropState.dataTransfer.setData('text/plain', src);
3950
+ _this.dragAndDropState.dataTransfer.setData('text/uri-list', src);
3951
+ _this.dragAndDropState.dataTransfer.setData('text/html', outerHTML);
3952
+ }
3953
+ }
3954
+ return _this._scroll();
3955
+ })
3956
+ .then(function () {
3957
+ var _a = _this._getTargetClientPoint(), x = _a.x, y = _a.y;
3958
+ var windowWidth = styleUtils.getWidth(window);
3959
+ var windowHeight = styleUtils.getHeight(window);
3960
+ if (x >= 0 && x <= windowWidth && y >= 0 && y <= windowHeight) {
3961
+ _this.endPoint = { x: x, y: y };
3962
+ return _this
3963
+ ._moveToCurrentFrame()
3964
+ .then(function () { return _this._move(); });
3965
+ }
3966
+ return null;
3967
+ })
3968
+ .then(function () { return _this.dragAndDropState; });
3969
+ };
3970
+ return MoveAutomation;
3971
+ }());
3972
+
3973
+ var extend$1 = hammerhead__default.utils.extend;
3974
+ var ElementState = /** @class */ (function () {
3975
+ function ElementState(_a) {
3976
+ var _b = _a.element, element = _b === void 0 ? null : _b, _c = _a.clientPoint, clientPoint = _c === void 0 ? null : _c, _d = _a.screenPoint, screenPoint = _d === void 0 ? null : _d, _e = _a.isTarget, isTarget = _e === void 0 ? false : _e, _f = _a.inMoving, inMoving = _f === void 0 ? false : _f;
3977
+ this.element = element;
3978
+ this.clientPoint = clientPoint;
3979
+ this.screenPoint = screenPoint;
3980
+ this.isTarget = isTarget;
3981
+ this.inMoving = inMoving;
3982
+ this.devicePoint = getDevicePoint(clientPoint);
3983
+ }
3984
+ return ElementState;
3985
+ }());
3986
+ var VisibleElementAutomation = /** @class */ (function (_super) {
3987
+ __extends(VisibleElementAutomation, _super);
3988
+ function VisibleElementAutomation(element, offsetOptions) {
3989
+ var _this = _super.call(this) || this;
3990
+ _this.TARGET_ELEMENT_FOUND_EVENT = 'automation|target-element-found-event';
3991
+ _this.element = element;
3992
+ _this.options = offsetOptions;
3993
+ _this.automationSettings = new AutomationSettings(offsetOptions.speed);
3994
+ return _this;
3995
+ }
3996
+ VisibleElementAutomation.prototype._getElementForEvent = function (eventArgs) {
3997
+ var _a = eventArgs.point, x = _a.x, y = _a.y;
3998
+ var expectedElement = testCafeCore.positionUtils.containsOffset(this.element, this.options.offsetX, this.options.offsetY) ? this.element : null;
3999
+ return fromPoint(x, y, expectedElement).then(function (_a) {
4000
+ var element = _a.element;
4001
+ return element;
4002
+ });
4003
+ };
4004
+ VisibleElementAutomation.prototype._moveToElement = function () {
4005
+ var _this = this;
4006
+ var moveOptions = new MoveOptions(extend$1({ skipScrolling: true }, this.options), false);
4007
+ var moveAutomation = new MoveAutomation(this.element, moveOptions);
4008
+ return moveAutomation
4009
+ .run()
4010
+ .then(function () { return testCafeCore.delay(_this.automationSettings.mouseActionStepDelay); });
4011
+ };
4012
+ VisibleElementAutomation.prototype._scrollToElement = function () {
4013
+ var _this = this;
4014
+ var scrollOptions = new ScrollOptions(this.options);
4015
+ var scrollAutomation = new ScrollAutomation(this.element, scrollOptions);
4016
+ var wasScrolled = false;
4017
+ return scrollAutomation
4018
+ .run()
4019
+ .then(function (scrollWasPerformed) {
4020
+ wasScrolled = scrollWasPerformed;
4021
+ return testCafeCore.delay(_this.automationSettings.mouseActionStepDelay);
4022
+ })
4023
+ .then(underCursor)
4024
+ .then(function (currentElement) {
4025
+ var elementUnderCursorContainsTarget = !!currentElement && testCafeCore.domUtils.contains(_this.element, currentElement);
4026
+ if (!elementUnderCursorContainsTarget || !wasScrolled)
4027
+ return null;
4028
+ var prevElement = lastHoveredElementHolder.get();
4029
+ var commonAncestor = testCafeCore.domUtils.getCommonAncestor(currentElement, prevElement);
4030
+ var clientPosition = testCafeCore.positionUtils.getClientPosition(currentElement);
4031
+ var devicePoint = getDevicePoint({ x: clientPosition.x, y: clientPosition.y });
4032
+ var options = {
4033
+ clientX: clientPosition.x,
4034
+ clientY: clientPosition.y,
4035
+ screenX: devicePoint.x,
4036
+ screenY: devicePoint.y,
4037
+ ctrl: false,
4038
+ alt: false,
4039
+ shift: false,
4040
+ meta: false,
4041
+ buttons: testCafeCore.eventUtils.BUTTONS_PARAMETER.leftButton
4042
+ };
4043
+ MoveBehaviour.leaveElement(currentElement, prevElement, commonAncestor, options);
4044
+ MoveBehaviour.enterElement(currentElement, prevElement, commonAncestor, options);
4045
+ lastHoveredElementHolder.set(currentElement);
4046
+ return wasScrolled;
4047
+ });
4048
+ };
4049
+ VisibleElementAutomation.prototype._getElementOffset = function () {
4050
+ var defaultOffsets = getOffsetOptions(this.element);
4051
+ var _a = this.options, offsetX = _a.offsetX, offsetY = _a.offsetY;
4052
+ offsetX = offsetX || offsetX === 0 ? offsetX : defaultOffsets.offsetX;
4053
+ offsetY = offsetY || offsetY === 0 ? offsetY : defaultOffsets.offsetY;
4054
+ return { offsetX: offsetX, offsetY: offsetY };
4055
+ };
4056
+ VisibleElementAutomation.prototype._wrapAction = function (action) {
4057
+ var _this = this;
4058
+ var _a = this._getElementOffset(), offsetX = _a.offsetX, offsetY = _a.offsetY;
4059
+ var screenPointBeforeAction = getAutomationPoint(this.element, offsetX, offsetY);
4060
+ var clientPositionBeforeAction = testCafeCore.positionUtils.getClientPosition(this.element);
4061
+ return action()
4062
+ .then(function () {
4063
+ var screenPointAfterAction = getAutomationPoint(_this.element, offsetX, offsetY);
4064
+ var clientPositionAfterAction = testCafeCore.positionUtils.getClientPosition(_this.element);
4065
+ var clientPoint = convertToClient(_this.element, screenPointAfterAction);
4066
+ var expectedElement = testCafeCore.positionUtils.containsOffset(_this.element, offsetX, offsetY) ? _this.element : null;
4067
+ return fromPoint(clientPoint.x, clientPoint.y, expectedElement)
4068
+ .then(function (_a) {
4069
+ var element = _a.element, corrected = _a.corrected;
4070
+ var foundElement = element;
4071
+ if (!foundElement)
4072
+ return new ElementState({});
4073
+ var isTarget = !expectedElement || corrected || foundElement === _this.element;
4074
+ if (!isTarget) {
4075
+ // NOTE: perform an operation with searching in dom only if necessary
4076
+ isTarget = testCafeCore.arrayUtils.indexOf(testCafeCore.domUtils.getParents(foundElement), _this.element) > -1;
4077
+ }
4078
+ var offsetPositionChanged = screenPointBeforeAction.x !== screenPointAfterAction.x ||
4079
+ screenPointBeforeAction.y !== screenPointAfterAction.y;
4080
+ var clientPositionChanged = clientPositionBeforeAction.x !== clientPositionAfterAction.x ||
4081
+ clientPositionBeforeAction.y !== clientPositionAfterAction.y;
4082
+ // NOTE: We consider the element moved if its offset position and client position
4083
+ // are changed both. If only client position was changed it means the page was
4084
+ // scrolled and the element keeps its position on the page. If only offset position was
4085
+ // changed it means the element is fixed on the page (it can be implemented via script).
4086
+ var targetElementIsMoving = offsetPositionChanged && clientPositionChanged;
4087
+ return new ElementState({
4088
+ element: element,
4089
+ clientPoint: clientPoint,
4090
+ screenPoint: screenPointAfterAction,
4091
+ isTarget: isTarget,
4092
+ inMoving: targetElementIsMoving
4093
+ });
4094
+ });
4095
+ });
4096
+ };
4097
+ VisibleElementAutomation._checkElementState = function (state, useStrictElementCheck) {
4098
+ if (!state.element)
4099
+ throw new Error(AUTOMATION_ERROR_TYPES.elementIsInvisibleError);
4100
+ if (useStrictElementCheck && (!state.isTarget || state.inMoving))
4101
+ throw new Error(AUTOMATION_ERROR_TYPES.foundElementIsNotTarget);
4102
+ return state;
4103
+ };
4104
+ VisibleElementAutomation.prototype._ensureElement = function (useStrictElementCheck, skipCheckAfterMoving, skipMoving) {
4105
+ var _this = this;
4106
+ return this
4107
+ ._wrapAction(function () { return _this._scrollToElement(); })
4108
+ .then(function (state) { return VisibleElementAutomation._checkElementState(state, useStrictElementCheck); })
4109
+ .then(function (state) {
4110
+ return skipMoving ? state : _this._wrapAction(function () { return _this._moveToElement(); });
4111
+ })
4112
+ .then(function (state) {
4113
+ if (!skipCheckAfterMoving)
4114
+ VisibleElementAutomation._checkElementState(state, useStrictElementCheck);
4115
+ return state;
4116
+ })
4117
+ .then(function (state) {
4118
+ _this.emit(_this.TARGET_ELEMENT_FOUND_EVENT, { element: state.element });
4119
+ return {
4120
+ element: state.element,
4121
+ clientPoint: state.clientPoint,
4122
+ screenPoint: state.screenPoint,
4123
+ devicePoint: state.devicePoint
4124
+ };
4125
+ });
4126
+ };
4127
+ return VisibleElementAutomation;
4128
+ }(testCafeCore.serviceUtils.EventEmitter));
4129
+
4130
+ var Promise$5 = hammerhead__default.Promise;
4131
+ function calculatePosition(el, position) {
4132
+ var centerX = Math.floor(el.scrollWidth / 2 - el.clientWidth / 2);
4133
+ var centerY = Math.floor(el.scrollHeight / 2 - el.clientHeight / 2);
4134
+ var positions = {
4135
+ 'top': [centerX, 0],
4136
+ 'right': [el.scrollWidth, centerY],
4137
+ 'bottom': [centerX, el.scrollHeight],
4138
+ 'left': [0, centerY],
4139
+ 'topRight': [el.scrollWidth, 0],
4140
+ 'topLeft': [0, 0],
4141
+ 'bottomRight': [el.scrollWidth, el.scrollHeight],
4142
+ 'bottomLeft': [0, el.scrollHeight],
4143
+ 'center': [centerX, centerY],
4144
+ };
4145
+ return positions[position];
4146
+ }
4147
+ var SetScrollAutomation = /** @class */ (function (_super) {
4148
+ __extends(SetScrollAutomation, _super);
4149
+ function SetScrollAutomation(element, _a, offsetOptions) {
4150
+ var _b;
4151
+ var x = _a.x, y = _a.y, position = _a.position, byX = _a.byX, byY = _a.byY;
4152
+ var _this = _super.call(this, element, offsetOptions) || this;
4153
+ if (position)
4154
+ _b = calculatePosition(element, position), x = _b[0], y = _b[1];
4155
+ _this.scrollLeft = typeof x === 'number' ? x : element.scrollLeft;
4156
+ _this.scrollTop = typeof y === 'number' ? y : element.scrollTop;
4157
+ if (byX)
4158
+ _this.scrollLeft += byX;
4159
+ if (byY)
4160
+ _this.scrollTop += byY;
4161
+ return _this;
4162
+ }
4163
+ SetScrollAutomation.prototype.run = function (useStrictElementCheck) {
4164
+ var _this = this;
4165
+ var promise = Promise$5.resolve();
4166
+ if (this.element !== document.scrollingElement && this.element !== document.documentElement)
4167
+ promise = this._ensureElement(useStrictElementCheck, true, true);
4168
+ return promise
4169
+ .then(function () {
4170
+ _this.element.scrollLeft = _this.scrollLeft;
4171
+ _this.element.scrollTop = _this.scrollTop;
4172
+ });
4173
+ };
4174
+ return SetScrollAutomation;
4175
+ }(VisibleElementAutomation));
4176
+
4177
+ var ScrollIntoViewAutomation = /** @class */ (function (_super) {
4178
+ __extends(ScrollIntoViewAutomation, _super);
4179
+ function ScrollIntoViewAutomation(element, offsetOptions) {
4180
+ return _super.call(this, element, offsetOptions) || this;
4181
+ }
4182
+ ScrollIntoViewAutomation.prototype.run = function (useStrictElementCheck) {
4183
+ return this._ensureElement(useStrictElementCheck, true, true);
4184
+ };
4185
+ return ScrollIntoViewAutomation;
4186
+ }(VisibleElementAutomation));
4187
+
4188
+ // Ensure command element properties
4189
+ function ensureElementEditable(element) {
4190
+ if (!testCafeCore.domUtils.isEditableElement(element))
4191
+ throw new ActionElementNonEditableError();
4192
+ }
4193
+ function ensureTextAreaElement(element) {
4194
+ if (!testCafeCore.domUtils.isTextAreaElement(element))
4195
+ throw new ActionElementNotTextAreaError();
4196
+ }
4197
+ function ensureContentEditableElement(element, argumentTitle) {
4198
+ if (!testCafeCore.domUtils.isContentEditableElement(element))
4199
+ throw new ActionElementNonContentEditableError(argumentTitle);
4200
+ }
4201
+ function ensureRootContainer(elements) {
4202
+ // NOTE: We should find a common element for the nodes to perform the select action
4203
+ if (!testCafeCore.contentEditable.getNearestCommonAncestor(elements[0], elements[1]))
4204
+ throw new ActionRootContainerNotFoundError();
4205
+ return elements;
4206
+ }
4207
+ function ensureFileInput(element) {
4208
+ if (!testCafeCore.domUtils.isFileInput(element))
4209
+ throw new ActionElementIsNotFileInputError();
4210
+ }
4211
+ function ensureOffsetOptions(element, options) {
4212
+ var _a = testcafeAutomation.getOffsetOptions(element, options.offsetX, options.offsetY), offsetX = _a.offsetX, offsetY = _a.offsetY;
4213
+ options.offsetX = offsetX;
4214
+ options.offsetY = offsetY;
4215
+ }
4216
+ var MAX_DELAY_AFTER_EXECUTION = 2000;
4217
+ var CHECK_ELEMENT_IN_AUTOMATIONS_INTERVAL = 250;
4218
+ var DateCtor$2 = hammerhead.nativeMethods.date;
4219
+ var ActionExecutor = /** @class */ (function () {
4220
+ function ActionExecutor(command, globalSelectorTimeout, statusBar, testSpeed) {
4221
+ this.command = command;
4222
+ this.globalSelectorTimeout = globalSelectorTimeout;
4223
+ this.statusBar = statusBar;
4224
+ this.testSpeed = testSpeed;
4225
+ this.targetElement = null;
4226
+ this.elements = [];
4227
+ this.ensureElementsPromise = null;
4228
+ this.ensureElementsStartTime = null;
4229
+ this.executionStartTime = null;
4230
+ this.executionStartedHandler = null;
4231
+ this.commandSelectorTimeout = null;
4232
+ }
4233
+ ActionExecutor.prototype._getSpecificTimeout = function () {
4234
+ var hasSpecificTimeout = this.command.selector && typeof this.command.selector.timeout === 'number';
4235
+ return hasSpecificTimeout ? this.command.selector.timeout : this.globalSelectorTimeout;
4236
+ };
4237
+ ActionExecutor.prototype._delayAfterExecution = function () {
4238
+ if (!this.command.options || this.command.options.speed === 1)
4239
+ return hammerhead.Promise.resolve();
4240
+ return testCafeCore.delay((1 - this.command.options.speed) * MAX_DELAY_AFTER_EXECUTION);
4241
+ };
4242
+ ActionExecutor.prototype._isExecutionTimeoutExpired = function () {
4243
+ return hammerhead.nativeMethods.dateNow() - this.executionStartTime >= this.commandSelectorTimeout;
4244
+ };
4245
+ ActionExecutor.prototype._ensureCommandArguments = function () {
4246
+ if (this.command.type === COMMAND_TYPE.pressKey) {
4247
+ var parsedKeySequence = testCafeCore.parseKeySequence(this.command.keys);
4248
+ if (parsedKeySequence.error)
4249
+ throw new ActionIncorrectKeysError('keys');
4250
+ }
4251
+ };
4252
+ ActionExecutor.prototype._ensureCommandElements = function () {
4253
+ var _this = this;
4254
+ var elementDescriptors = [];
4255
+ if (this.command.selector)
4256
+ elementDescriptors.push(createElementDescriptor(this.command.selector));
4257
+ if (this.command.type === COMMAND_TYPE.dragToElement)
4258
+ elementDescriptors.push(createAdditionalElementDescriptor(this.command.destinationSelector, 'destinationSelector'));
4259
+ else if (this.command.type === COMMAND_TYPE.selectEditableContent) {
4260
+ elementDescriptors.push(createAdditionalElementDescriptor(this.command.startSelector, 'startSelector'));
4261
+ elementDescriptors.push(createAdditionalElementDescriptor(this.command.endSelector || this.command.startSelector, 'endSelector'));
4262
+ }
4263
+ else if (this.command.type === COMMAND_TYPE.dispatchEvent && this.command.relatedTarget)
4264
+ elementDescriptors.push(createAdditionalElementDescriptor(this.command.relatedTarget, 'relatedTarget'));
4265
+ return ensureElements(elementDescriptors, this.globalSelectorTimeout)
4266
+ .then(function (elements) {
4267
+ _this.elements = elements;
4268
+ });
4269
+ };
4270
+ ActionExecutor.prototype._ensureCommandElementsProperties = function () {
4271
+ if (this.command.type === COMMAND_TYPE.selectText)
4272
+ ensureElementEditable(this.elements[0]);
4273
+ else if (this.command.type === COMMAND_TYPE.selectTextAreaContent)
4274
+ ensureTextAreaElement(this.elements[0]);
4275
+ else if (this.command.type === COMMAND_TYPE.selectEditableContent) {
4276
+ ensureContentEditableElement(this.elements[0], 'startSelector');
4277
+ ensureContentEditableElement(this.elements[1], 'endSelector');
4278
+ ensureRootContainer(this.elements);
4279
+ }
4280
+ else if (this.command.type === COMMAND_TYPE.setFilesToUpload || this.command.type === COMMAND_TYPE.clearUpload)
4281
+ ensureFileInput(this.elements[0]);
4282
+ };
4283
+ ActionExecutor.prototype._ensureCommandOptions = function () {
4284
+ if (this.elements.length && this.command.options && 'offsetX' in this.command.options && 'offsetY' in this.command.options)
4285
+ ensureOffsetOptions(this.elements[0], this.command.options);
4286
+ };
4287
+ ActionExecutor.prototype._createAutomation = function () {
4288
+ var selectArgs = null;
4289
+ switch (this.command.type) {
4290
+ case COMMAND_TYPE.dispatchEvent:
4291
+ if (this.elements[1])
4292
+ this.command.options.relatedTarget = this.elements[1];
4293
+ return new testcafeAutomation.DispatchEvent(this.elements[0], this.command.eventName, this.command.options);
4294
+ case COMMAND_TYPE.click:
4295
+ if (/option|optgroup/.test(testCafeCore.domUtils.getTagName(this.elements[0])))
4296
+ return new testcafeAutomation.SelectChildClick(this.elements[0], this.command.options);
4297
+ return new testcafeAutomation.Click(this.elements[0], this.command.options);
4298
+ case COMMAND_TYPE.rightClick:
4299
+ return new testcafeAutomation.RClick(this.elements[0], this.command.options);
4300
+ case COMMAND_TYPE.doubleClick:
4301
+ return new testcafeAutomation.DblClick(this.elements[0], this.command.options);
4302
+ case COMMAND_TYPE.hover:
4303
+ return new testcafeAutomation.Hover(this.elements[0], this.command.options);
4304
+ case COMMAND_TYPE.drag:
4305
+ return new testcafeAutomation.DragToOffset(this.elements[0], this.command.dragOffsetX, this.command.dragOffsetY, this.command.options);
4306
+ case COMMAND_TYPE.dragToElement:
4307
+ return new testcafeAutomation.DragToElement(this.elements[0], this.elements[1], this.command.options);
4308
+ case COMMAND_TYPE.scroll: {
4309
+ var _a = this.command, x = _a.x, y = _a.y, position = _a.position, options = _a.options;
4310
+ return new SetScrollAutomation(this.elements[0], { x: x, y: y, position: position }, options);
4311
+ }
4312
+ case COMMAND_TYPE.scrollBy: {
4313
+ var _b = this.command, byX = _b.byX, byY = _b.byY, options = _b.options;
4314
+ return new SetScrollAutomation(this.elements[0], { byX: byX, byY: byY }, options);
4315
+ }
4316
+ case COMMAND_TYPE.scrollIntoView: {
4317
+ return new ScrollIntoViewAutomation(this.elements[0], this.command.options);
4318
+ }
4319
+ case COMMAND_TYPE.typeText:
4320
+ // eslint-disable-next-line no-restricted-properties
4321
+ return new testcafeAutomation.Type(this.elements[0], this.command.text, this.command.options);
4322
+ case COMMAND_TYPE.selectText:
4323
+ case COMMAND_TYPE.selectTextAreaContent:
4324
+ selectArgs = testcafeAutomation.calculateSelectTextArguments(this.elements[0], this.command);
4325
+ return new testcafeAutomation.SelectText(this.elements[0], selectArgs.startPos, selectArgs.endPos, this.command.options);
4326
+ case COMMAND_TYPE.selectEditableContent:
4327
+ return new testcafeAutomation.SelectEditableContent(this.elements[0], this.elements[1], this.command.options);
4328
+ case COMMAND_TYPE.pressKey:
4329
+ return new testcafeAutomation.Press(testCafeCore.parseKeySequence(this.command.keys).combinations, this.command.options);
4330
+ case COMMAND_TYPE.setFilesToUpload:
4331
+ return new testcafeAutomation.Upload(this.elements[0], this.command.filePath, function (filePaths, scannedFilePaths) { return new ActionCannotFindFileToUploadError(filePaths, scannedFilePaths); });
4332
+ case COMMAND_TYPE.clearUpload:
4333
+ return new testcafeAutomation.Upload(this.elements[0]);
4334
+ }
4335
+ return null;
4336
+ };
4337
+ ActionExecutor.prototype._runAction = function (strictElementCheck) {
4338
+ var _this = this;
4339
+ return this
4340
+ ._ensureCommandElements()
4341
+ .then(function () { return _this._ensureCommandElementsProperties(); })
4342
+ .then(function () {
4343
+ _this._ensureCommandOptions();
4344
+ var automation = _this._createAutomation();
4345
+ if (automation.TARGET_ELEMENT_FOUND_EVENT) {
4346
+ automation.on(automation.TARGET_ELEMENT_FOUND_EVENT, function (e) {
4347
+ _this.targetElement = e.element;
4348
+ _this.statusBar.hideWaitingElementStatus(true);
4349
+ _this.executionStartedHandler();
4350
+ });
4351
+ }
4352
+ else {
4353
+ _this.statusBar.hideWaitingElementStatus(true);
4354
+ _this.executionStartedHandler();
4355
+ }
4356
+ return automation
4357
+ .run(strictElementCheck);
4358
+ });
4359
+ };
4360
+ ActionExecutor.prototype._runRecursively = function () {
4361
+ var _this = this;
4362
+ var actionFinished = false;
4363
+ var strictElementCheck = true;
4364
+ return testCafeCore.promiseUtils.whilst(function () { return !actionFinished; }, function () {
4365
+ return _this
4366
+ ._runAction(strictElementCheck)
4367
+ .then(function () {
4368
+ actionFinished = true;
4369
+ })
4370
+ .catch(function (err) {
4371
+ if (_this._isExecutionTimeoutExpired()) {
4372
+ if (err.message === testcafeAutomation.ERROR_TYPES.foundElementIsNotTarget) {
4373
+ // If we can't get a target element via elementFromPoint but it's
4374
+ // visible we click on the point where the element is located.
4375
+ strictElementCheck = false;
4376
+ return hammerhead.Promise.resolve();
4377
+ }
4378
+ throw err.message === testcafeAutomation.ERROR_TYPES.elementIsInvisibleError ?
4379
+ new ActionElementIsInvisibleError() : err;
4380
+ }
4381
+ return testCafeCore.delay(CHECK_ELEMENT_IN_AUTOMATIONS_INTERVAL);
4382
+ });
4383
+ });
4384
+ };
4385
+ ActionExecutor.prototype.execute = function () {
4386
+ var _this = this;
4387
+ if (this.command.options && !this.command.options.speed)
4388
+ this.command.options.speed = this.testSpeed;
4389
+ var startPromise = new hammerhead.Promise(function (resolve) {
4390
+ _this.executionStartedHandler = resolve;
4391
+ });
4392
+ var completionPromise = new hammerhead.Promise(function (resolve) {
4393
+ _this.executionStartTime = new DateCtor$2();
4394
+ try {
4395
+ _this._ensureCommandArguments();
4396
+ }
4397
+ catch (err) {
4398
+ resolve(new DriverStatus({ isCommandResult: true, executionError: err }));
4399
+ return;
4400
+ }
4401
+ _this.commandSelectorTimeout = _this._getSpecificTimeout();
4402
+ _this.statusBar.showWaitingElementStatus(_this.commandSelectorTimeout);
4403
+ var _a = runWithBarriers(function () { return _this._runRecursively(); }), actionPromise = _a.actionPromise, barriersPromise = _a.barriersPromise;
4404
+ actionPromise
4405
+ .then(function () { return hammerhead.Promise.all([
4406
+ _this._delayAfterExecution(),
4407
+ barriersPromise
4408
+ ]); })
4409
+ .then(function () {
4410
+ var status = { isCommandResult: true };
4411
+ var elements = __spreadArrays(_this.elements);
4412
+ if (_this.targetElement)
4413
+ elements[0] = _this.targetElement;
4414
+ status.result = createReplicator(new SelectorElementActionTransform()).encode(elements);
4415
+ resolve(new DriverStatus(status));
4416
+ })
4417
+ .catch(function (err) {
4418
+ return _this.statusBar.hideWaitingElementStatus(false)
4419
+ .then(function () { return resolve(new DriverStatus({ isCommandResult: true, executionError: err })); });
4420
+ });
4421
+ });
4422
+ return { startPromise: startPromise, completionPromise: completionPromise };
3126
4423
  };
3127
- return TypeOptions;
3128
- }(ClickOptions));
3129
- // DragToElement
3130
- var DragToElementOptions = /** @class */ (function (_super) {
3131
- __extends(DragToElementOptions, _super);
3132
- function DragToElementOptions(obj, validate) {
3133
- var _this = _super.call(this, obj, validate) || this;
3134
- _this.destinationOffsetX = null;
3135
- _this.destinationOffsetY = null;
3136
- _this._assignFrom(obj, validate);
3137
- return _this;
3138
- }
3139
- DragToElementOptions.prototype._getAssignableProperties = function () {
3140
- return _super.prototype._getAssignableProperties.call(this).concat([
3141
- { name: 'destinationOffsetX', type: integerOption },
3142
- { name: 'destinationOffsetY', type: integerOption }
3143
- ]);
4424
+ return ActionExecutor;
4425
+ }());
4426
+ function executeAction(command, globalSelectorTimeout, statusBar, testSpeed) {
4427
+ var actionExecutor = new ActionExecutor(command, globalSelectorTimeout, statusBar, testSpeed);
4428
+ return actionExecutor.execute();
4429
+ }
4430
+
4431
+ // -------------------------------------------------------------
4432
+ // WARNING: this file is used by both the client and the server.
4433
+ // Do not use any browser or node-specific API!
4434
+ // -------------------------------------------------------------
4435
+ function limitNumber (value, min, max) {
4436
+ return Math.min(Math.max(min, value), max);
4437
+ }
4438
+
4439
+ function determineDimensionBounds(bounds, maximum) {
4440
+ var hasMin = typeof bounds.min === 'number';
4441
+ var hasMax = typeof bounds.max === 'number';
4442
+ var hasLength = typeof bounds.length === 'number';
4443
+ if (hasLength)
4444
+ bounds.length = limitNumber(bounds.length, 0, maximum);
4445
+ if (hasMin && bounds.min < 0)
4446
+ bounds.min += maximum;
4447
+ if (hasMax && bounds.max < 0)
4448
+ bounds.max += maximum;
4449
+ if (!hasMin)
4450
+ bounds.min = hasMax && hasLength ? bounds.max - bounds.length : 0;
4451
+ if (!hasMax)
4452
+ bounds.max = hasLength ? bounds.min + bounds.length : maximum;
4453
+ bounds.min = limitNumber(bounds.min, 0, maximum);
4454
+ bounds.max = limitNumber(bounds.max, 0, maximum);
4455
+ bounds.length = bounds.max - bounds.min;
4456
+ return bounds;
4457
+ }
4458
+ function determineScrollPoint(cropStart, cropEnd, viewportBound) {
4459
+ return Math.round(cropStart + limitNumber(cropEnd - cropStart, 0, viewportBound) / 2);
4460
+ }
4461
+ function ensureCropOptions(element, options) {
4462
+ var elementRectangle = element.getBoundingClientRect();
4463
+ var elementBounds = {
4464
+ left: elementRectangle.left,
4465
+ right: elementRectangle.right,
4466
+ top: elementRectangle.top,
4467
+ bottom: elementRectangle.bottom
3144
4468
  };
3145
- return DragToElementOptions;
3146
- }(MouseOptions));
3147
- //ResizeToFitDevice
3148
- var ResizeToFitDeviceOptions = /** @class */ (function (_super) {
3149
- __extends(ResizeToFitDeviceOptions, _super);
3150
- function ResizeToFitDeviceOptions(obj, validate) {
3151
- var _this = _super.call(this) || this;
3152
- _this.portraitOrientation = false;
3153
- _this._assignFrom(obj, validate);
3154
- return _this;
4469
+ var elementMargin = testCafeCore.styleUtils.getElementMargin(element);
4470
+ var elementPadding = testCafeCore.styleUtils.getElementPadding(element);
4471
+ var elementBordersWidth = testCafeCore.styleUtils.getBordersWidth(element);
4472
+ options.originOffset = { x: 0, y: 0 };
4473
+ var scrollRight = elementBounds.left + element.scrollWidth + elementBordersWidth.left + elementBordersWidth.right;
4474
+ var scrollBottom = elementBounds.top + element.scrollHeight + elementBordersWidth.top + elementBordersWidth.bottom;
4475
+ elementBounds.right = Math.max(elementBounds.right, scrollRight);
4476
+ elementBounds.bottom = Math.max(elementBounds.bottom, scrollBottom);
4477
+ if (!options.includeBorders || !options.includePaddings) {
4478
+ options.originOffset.x += elementBordersWidth.left;
4479
+ options.originOffset.y += elementBordersWidth.top;
4480
+ elementBounds.left += elementBordersWidth.left;
4481
+ elementBounds.top += elementBordersWidth.top;
4482
+ elementBounds.right -= elementBordersWidth.right;
4483
+ elementBounds.bottom -= elementBordersWidth.bottom;
4484
+ if (!options.includePaddings) {
4485
+ options.originOffset.x += elementPadding.left;
4486
+ options.originOffset.y += elementPadding.top;
4487
+ elementBounds.left += elementPadding.left;
4488
+ elementBounds.top += elementPadding.top;
4489
+ elementBounds.right -= elementPadding.right;
4490
+ elementBounds.bottom -= elementPadding.bottom;
4491
+ }
3155
4492
  }
3156
- ResizeToFitDeviceOptions.prototype._getAssignableProperties = function () {
3157
- return [
3158
- { name: 'portraitOrientation', type: booleanOption }
3159
- ];
3160
- };
3161
- return ResizeToFitDeviceOptions;
3162
- }(Assignable));
3163
- //Assertion
3164
- var AssertionOptions = /** @class */ (function (_super) {
3165
- __extends(AssertionOptions, _super);
3166
- function AssertionOptions(obj, validate) {
3167
- var _this = _super.call(this) || this;
3168
- _this.timeout = void 0;
3169
- _this.allowUnawaitedPromise = false;
3170
- _this._assignFrom(obj, validate);
3171
- return _this;
4493
+ else if (options.includeMargins) {
4494
+ options.originOffset.x -= elementMargin.left;
4495
+ options.originOffset.y -= elementMargin.top;
4496
+ elementBounds.left -= elementMargin.left;
4497
+ elementBounds.top -= elementMargin.top;
4498
+ elementBounds.right += elementMargin.right;
4499
+ elementBounds.bottom += elementMargin.bottom;
3172
4500
  }
3173
- AssertionOptions.prototype._getAssignableProperties = function () {
3174
- return [
3175
- { name: 'timeout', type: positiveIntegerOption },
3176
- { name: 'allowUnawaitedPromise', type: booleanOption }
3177
- ];
3178
- };
3179
- return AssertionOptions;
3180
- }(Assignable));
3181
-
3182
- function isIframeWindow(window) {
3183
- return window.top !== window;
4501
+ elementBounds.width = elementBounds.right - elementBounds.left;
4502
+ elementBounds.height = elementBounds.bottom - elementBounds.top;
4503
+ var horizontalCropBounds = determineDimensionBounds({ min: options.crop.left, max: options.crop.right, length: options.crop.width }, elementBounds.width);
4504
+ var verticalCropBounds = determineDimensionBounds({ min: options.crop.top, max: options.crop.bottom, length: options.crop.height }, elementBounds.height);
4505
+ options.crop.left = horizontalCropBounds.min;
4506
+ options.crop.right = horizontalCropBounds.max;
4507
+ options.crop.width = horizontalCropBounds.length;
4508
+ options.crop.top = verticalCropBounds.min;
4509
+ options.crop.bottom = verticalCropBounds.max;
4510
+ options.crop.height = verticalCropBounds.length;
4511
+ if (options.crop.width <= 0 || options.crop.height <= 0)
4512
+ throw new InvalidElementScreenshotDimensionsError(options.crop.width, options.crop.height);
4513
+ var viewportDimensions = testCafeCore.styleUtils.getViewportDimensions();
4514
+ if (elementBounds.width > viewportDimensions.width || elementBounds.height > viewportDimensions.height)
4515
+ options.scrollToCenter = true;
4516
+ var hasScrollTargetX = typeof options.scrollTargetX === 'number';
4517
+ var hasScrollTargetY = typeof options.scrollTargetY === 'number';
4518
+ if (!hasScrollTargetX)
4519
+ options.scrollTargetX = determineScrollPoint(options.crop.left, options.crop.right, viewportDimensions.width);
4520
+ if (!hasScrollTargetY)
4521
+ options.scrollTargetY = determineScrollPoint(options.crop.top, options.crop.bottom, viewportDimensions.height);
4522
+ var _a = testcafeAutomation.getOffsetOptions(element, options.scrollTargetX, options.scrollTargetY), offsetX = _a.offsetX, offsetY = _a.offsetY;
4523
+ options.scrollTargetX = offsetX;
4524
+ options.scrollTargetY = offsetY;
4525
+ var isScrollTargetXValid = !hasScrollTargetX || options.scrollTargetX >= options.crop.left && options.scrollTargetX <= options.crop.right;
4526
+ var isScrollTargetYValid = !hasScrollTargetY || options.scrollTargetY >= options.crop.top && options.scrollTargetY <= options.crop.bottom;
4527
+ if (!isScrollTargetXValid || !isScrollTargetYValid)
4528
+ throw new ActionInvalidScrollTargetError(isScrollTargetXValid, isScrollTargetYValid);
3184
4529
  }
3185
4530
 
3186
- var messageSandbox$1 = hammerhead.eventSandbox.message;
4531
+ var messageSandbox$3 = hammerhead.eventSandbox.message;
3187
4532
  var HIDING_UI_RELAYOUT_DELAY = 500;
3188
4533
  var POSSIBLE_RESIZE_ERROR_DELAY = 200;
3189
4534
  var MANIPULATION_REQUEST_CMD = 'driver|browser-manipulation|request';
3190
4535
  var MANIPULATION_RESPONSE_CMD = 'driver|browser-manipulation|response';
3191
4536
  // Setup cross-iframe interaction
3192
- messageSandbox$1.on(messageSandbox$1.SERVICE_MSG_RECEIVED_EVENT, function (e) {
4537
+ messageSandbox$3.on(messageSandbox$3.SERVICE_MSG_RECEIVED_EVENT, function (e) {
3193
4538
  if (e.message.cmd === MANIPULATION_REQUEST_CMD) {
3194
4539
  var element = testCafeCore.domUtils.findIframeByWindow(e.source);
3195
4540
  var _a = e.message, command = _a.command, cropDimensions = _a.cropDimensions;
@@ -3199,7 +4544,7 @@
3199
4544
  manipulation.element = element;
3200
4545
  manipulation
3201
4546
  .execute()
3202
- .then(function (result) { return messageSandbox$1.sendServiceMsg({ cmd: MANIPULATION_RESPONSE_CMD, result: result }, e.source); });
4547
+ .then(function (result) { return messageSandbox$3.sendServiceMsg({ cmd: MANIPULATION_RESPONSE_CMD, result: result }, e.source); });
3203
4548
  }
3204
4549
  });
3205
4550
  var ManipulationExecutor = /** @class */ (function () {
@@ -3271,15 +4616,15 @@
3271
4616
  });
3272
4617
  };
3273
4618
  ManipulationExecutor.prototype._hideUI = function () {
3274
- testcafeUi.hide();
4619
+ testCafeUI.hide();
3275
4620
  if (this.command.markData)
3276
- testcafeUi.showScreenshotMark(this.command.markData);
4621
+ testCafeUI.showScreenshotMark(this.command.markData);
3277
4622
  return testCafeCore.delay(HIDING_UI_RELAYOUT_DELAY);
3278
4623
  };
3279
4624
  ManipulationExecutor.prototype._showUI = function () {
3280
4625
  if (this.command.markData)
3281
- testcafeUi.hideScreenshotMark();
3282
- testcafeUi.show();
4626
+ testCafeUI.hideScreenshotMark();
4627
+ testCafeUI.show();
3283
4628
  };
3284
4629
  ManipulationExecutor.prototype._requestManipulation = function () {
3285
4630
  if (!isIframeWindow(window))
@@ -3392,21 +4737,21 @@
3392
4737
  });
3393
4738
  }
3394
4739
 
3395
- var Promise$1 = hammerhead__default.Promise;
4740
+ var Promise$6 = hammerhead__default.Promise;
3396
4741
  function executeChildWindowDriverLinkSelector(selector, childWindowLinks) {
3397
4742
  if (typeof selector === 'string') {
3398
4743
  var foundChildWindowDriverLink = testCafeCore.arrayUtils.find(childWindowLinks, function (link) { return link.windowId === selector; });
3399
4744
  if (!foundChildWindowDriverLink) {
3400
4745
  var error = new ChildWindowNotFoundError();
3401
- return Promise$1.reject(error);
4746
+ return Promise$6.reject(error);
3402
4747
  }
3403
4748
  // NOTE: We cannot pass the driver window of the found child window driver link
3404
4749
  // because the current Promise implementation checks the type of the value passed to the 'resolve' function.
3405
4750
  // It causes an unhandled JavaScript error on accessing to cross-domain iframe.
3406
- return Promise$1.resolve(foundChildWindowDriverLink);
4751
+ return Promise$6.resolve(foundChildWindowDriverLink);
3407
4752
  }
3408
4753
  // TODO: Query url and title properties of the all driverLinks' windows
3409
- return Promise$1.resolve(null);
4754
+ return Promise$6.resolve(null);
3410
4755
  }
3411
4756
 
3412
4757
  var ChildWindowDriverLink = /** @class */ (function () {
@@ -3480,11 +4825,11 @@
3480
4825
 
3481
4826
  var settings = hammerhead__default.settings;
3482
4827
  var transport = hammerhead__default.transport;
3483
- var Promise$2 = hammerhead__default.Promise;
3484
- var messageSandbox$2 = hammerhead__default.eventSandbox.message;
4828
+ var Promise$7 = hammerhead__default.Promise;
4829
+ var messageSandbox$4 = hammerhead__default.eventSandbox.message;
3485
4830
  var storages = hammerhead__default.storages;
3486
- var nativeMethods$4 = hammerhead__default.nativeMethods;
3487
- var DateCtor$3 = nativeMethods$4.date;
4831
+ var nativeMethods$8 = hammerhead__default.nativeMethods;
4832
+ var DateCtor$3 = nativeMethods$8.date;
3488
4833
  var listeners = hammerhead__default.eventSandbox.listeners;
3489
4834
  var TEST_DONE_SENT_FLAG = 'testcafe|driver|test-done-sent-flag';
3490
4835
  var PENDING_STATUS = 'testcafe|driver|pending-status';
@@ -3561,10 +4906,12 @@
3561
4906
  hammerhead__default.on(hammerhead__default.EVENTS.beforeFormSubmit, function (e) { return _this._onFormSubmit(e); });
3562
4907
  hammerhead__default.on(hammerhead__default.EVENTS.windowOpened, function (e) { return _this._onChildWindowOpened(e); });
3563
4908
  _this.setCustomCommandHandlers(COMMAND_TYPE.unlockPage, function () { return _this._unlockPageAfterTestIsDone(); });
4909
+ _this.setCustomCommandHandlers(COMMAND_TYPE.getActiveElement, function () { return _this._getActiveElement(); });
3564
4910
  // NOTE: initiate the child links restoring process before the window is reloaded
3565
4911
  listeners.addInternalEventBeforeListener(window, ['beforeunload'], function () {
3566
4912
  _this._sendStartToRestoreCommand();
3567
4913
  });
4914
+ _this.replicator = createReplicator([new SelectorNodeTransform()]);
3568
4915
  return _this;
3569
4916
  }
3570
4917
  Driver.prototype._isOpenedInIframe = function () {
@@ -3620,7 +4967,7 @@
3620
4967
  // NOTE: we should not send any message to the server if we've
3621
4968
  // sent the 'test-done' message but haven't got the response.
3622
4969
  if (this.skipJsErrors || this.contextStorage.getItem(TEST_DONE_SENT_FLAG))
3623
- return Promise$2.resolve();
4970
+ return Promise$7.resolve();
3624
4971
  var error = new UncaughtErrorOnPage(err.stack, err.pageUrl);
3625
4972
  if (!this.contextStorage.getItem(PENDING_PAGE_ERROR))
3626
4973
  this.contextStorage.setItem(PENDING_PAGE_ERROR, error);
@@ -3628,7 +4975,16 @@
3628
4975
  };
3629
4976
  Driver.prototype._unlockPageAfterTestIsDone = function () {
3630
4977
  testCafeCore.disableRealEventsPreventing();
3631
- return Promise$2.resolve();
4978
+ return Promise$7.resolve();
4979
+ };
4980
+ Driver.prototype._getActiveElement = function () {
4981
+ return __awaiter(this, void 0, void 0, function () {
4982
+ var activeElement;
4983
+ return __generator(this, function (_a) {
4984
+ activeElement = testCafeCore.domUtils.getActiveElement();
4985
+ return [2 /*return*/, this.replicator.encode(activeElement)];
4986
+ });
4987
+ });
3632
4988
  };
3633
4989
  Driver.prototype._failIfClientCodeExecutionIsInterrupted = function () {
3634
4990
  // NOTE: ClientFunction should be used primarily for observation. We raise
@@ -3659,7 +5015,7 @@
3659
5015
  var _this = this;
3660
5016
  if (this.checkClosedChildWindowIntervalId)
3661
5017
  return;
3662
- this.checkClosedChildWindowIntervalId = nativeMethods$4.setInterval.call(window, function () {
5018
+ this.checkClosedChildWindowIntervalId = nativeMethods$8.setInterval.call(window, function () {
3663
5019
  var firstClosedChildWindowDriverLink = testCafeCore.arrayUtils.find(_this.childWindowDriverLinks, function (childWindowDriverLink) { return childWindowDriverLink.driverWindow.closed; });
3664
5020
  if (!firstClosedChildWindowDriverLink)
3665
5021
  return;
@@ -3668,7 +5024,7 @@
3668
5024
  if (!firstClosedChildWindowDriverLink.ignoreMasterSwitching)
3669
5025
  _this._setCurrentWindowAsMaster();
3670
5026
  if (!_this.childWindowDriverLinks.length) {
3671
- nativeMethods$4.clearInterval.call(window, _this.checkClosedChildWindowIntervalId);
5027
+ nativeMethods$8.clearInterval.call(window, _this.checkClosedChildWindowIntervalId);
3672
5028
  delete _this.checkClosedChildWindowIntervalId;
3673
5029
  }
3674
5030
  }, CHECK_CHILD_WINDOW_CLOSED_INTERVAL);
@@ -3682,7 +5038,7 @@
3682
5038
  return;
3683
5039
  this.setAsMasterInProgress = true;
3684
5040
  this._clearActiveChildIframeInfo();
3685
- Promise$2.resolve()
5041
+ Promise$7.resolve()
3686
5042
  .then(function () {
3687
5043
  return testCafeCore.browser.setActiveWindowId(_this.browserActiveWindowId, hammerhead__default.createNativeXHR, _this.windowId);
3688
5044
  })
@@ -3803,7 +5159,7 @@
3803
5159
  childIframeDriverLink.sendConfirmationMessage(id);
3804
5160
  };
3805
5161
  Driver.prototype._getTargetWindowNotFoundResult = function (errCode, errMsg) {
3806
- return Promise$2.resolve({
5162
+ return Promise$7.resolve({
3807
5163
  success: false,
3808
5164
  errCode: errCode,
3809
5165
  errMsg: errMsg
@@ -3864,7 +5220,7 @@
3864
5220
  searchQueries = this.childWindowDriverLinks.map(function (childWindowDriverLink) {
3865
5221
  return childWindowDriverLink.findChildWindows(msg, WindowValidationMessageCtor);
3866
5222
  });
3867
- return [4 /*yield*/, Promise$2.all(searchQueries)];
5223
+ return [4 /*yield*/, Promise$7.all(searchQueries)];
3868
5224
  case 1:
3869
5225
  searchResults = _a.sent();
3870
5226
  return [2 /*return*/, this._getChildWindowValidateResult(searchResults)];
@@ -3882,18 +5238,18 @@
3882
5238
  };
3883
5239
  Driver.prototype._getCloseWindowFoundResult = function () {
3884
5240
  if (!this.parentWindowDriverLink) {
3885
- return Promise$2.resolve({
5241
+ return Promise$7.resolve({
3886
5242
  success: false,
3887
5243
  errCode: TEST_RUN_ERRORS.cannotCloseWindowWithoutParent
3888
5244
  });
3889
5245
  }
3890
5246
  if (this.childWindowDriverLinks.length) {
3891
- return Promise$2.resolve({
5247
+ return Promise$7.resolve({
3892
5248
  success: false,
3893
5249
  errCode: TEST_RUN_ERRORS.cannotCloseWindowWithChildrenError
3894
5250
  });
3895
5251
  }
3896
- return Promise$2.resolve({ success: true });
5252
+ return Promise$7.resolve({ success: true });
3897
5253
  };
3898
5254
  Driver.prototype._handleCloseWindowValidation = function (msg, wnd) {
3899
5255
  var _this = this;
@@ -3904,7 +5260,7 @@
3904
5260
  };
3905
5261
  Driver.prototype._handleSwitchToWindowValidation = function (msg, wnd) {
3906
5262
  var getWindowFoundResult = function () {
3907
- return Promise$2.resolve({ success: true });
5263
+ return Promise$7.resolve({ success: true });
3908
5264
  };
3909
5265
  return this._handleWindowValidation(msg, wnd, getWindowFoundResult, SwitchToWindowValidationMessage);
3910
5266
  };
@@ -3932,14 +5288,14 @@
3932
5288
  };
3933
5289
  Driver.prototype._closeWindow = function (msg) {
3934
5290
  if (!this.childWindowDriverLinks.length)
3935
- return Promise$2.resolve();
5291
+ return Promise$7.resolve();
3936
5292
  var childWindowToClose = this.childWindowDriverLinks.find(function (link) { return link.windowId === msg.windowId; });
3937
5293
  if (childWindowToClose)
3938
5294
  return this._closeWindowAndWait(childWindowToClose, msg);
3939
5295
  var searchQueries = this.childWindowDriverLinks.map(function (childWindowDriverLink) {
3940
5296
  return childWindowDriverLink.findChildWindows(msg, CloseWindowCommandMessage);
3941
5297
  });
3942
- return Promise$2.all(searchQueries);
5298
+ return Promise$7.all(searchQueries);
3943
5299
  };
3944
5300
  Driver.prototype._getWindows = function () {
3945
5301
  return __awaiter(this, void 0, void 0, function () {
@@ -3952,7 +5308,7 @@
3952
5308
  searchQueries = this.childWindowDriverLinks.map(function (childWindowDriverLink) {
3953
5309
  return childWindowDriverLink.findChildWindows({}, GetWindowsMessage);
3954
5310
  });
3955
- return [4 /*yield*/, Promise$2.all(searchQueries)];
5311
+ return [4 /*yield*/, Promise$7.all(searchQueries)];
3956
5312
  case 1:
3957
5313
  searchResults = _a.sent();
3958
5314
  result = [this._getWindowInfo()];
@@ -4003,14 +5359,14 @@
4003
5359
  Driver.prototype._switchToWindow = function (msg) {
4004
5360
  var _this = this;
4005
5361
  if (this._isTargetWindow(msg)) {
4006
- return Promise$2.resolve()
5362
+ return Promise$7.resolve()
4007
5363
  .then(function () {
4008
5364
  _this._setCurrentWindowAsMaster();
4009
5365
  });
4010
5366
  }
4011
5367
  if (!this.childWindowDriverLinks.length)
4012
- return Promise$2.resolve();
4013
- return Promise$2.all(this.childWindowDriverLinks.map(function (childWindowDriverLink) {
5368
+ return Promise$7.resolve();
5369
+ return Promise$7.all(this.childWindowDriverLinks.map(function (childWindowDriverLink) {
4014
5370
  return childWindowDriverLink.findChildWindows(msg, SwitchToWindowCommandMessage);
4015
5371
  }));
4016
5372
  };
@@ -4026,7 +5382,7 @@
4026
5382
  requestMsgId: msg.id,
4027
5383
  window: wnd
4028
5384
  });
4029
- Promise$2.resolve()
5385
+ Promise$7.resolve()
4030
5386
  .then(function () {
4031
5387
  return testCafeCore.browser.setActiveWindowId(_this.browserActiveWindowId, hammerhead__default.createNativeXHR, _this.windowId);
4032
5388
  })
@@ -4082,7 +5438,7 @@
4082
5438
  var _this = this;
4083
5439
  // NOTE: when the child window is opened in iframe we need to wait until the
4084
5440
  // child window is fully loaded
4085
- this._pendingChildWindowInIFrame = new Promise$2(function (resolve) {
5441
+ this._pendingChildWindowInIFrame = new Promise$7(function (resolve) {
4086
5442
  _this._resolvePendingChildWindowInIframe = resolve;
4087
5443
  });
4088
5444
  };
@@ -4098,7 +5454,7 @@
4098
5454
  };
4099
5455
  Driver.prototype._initChildDriverListening = function () {
4100
5456
  var _this = this;
4101
- messageSandbox$2.on(messageSandbox$2.SERVICE_MSG_RECEIVED_EVENT, function (e) {
5457
+ messageSandbox$4.on(messageSandbox$4.SERVICE_MSG_RECEIVED_EVENT, function (e) {
4102
5458
  var msg = e.message;
4103
5459
  var window = e.source;
4104
5460
  switch (msg.type) {
@@ -4148,7 +5504,7 @@
4148
5504
  };
4149
5505
  Driver.prototype._runInActiveIframe = function (command) {
4150
5506
  var _this = this;
4151
- var runningChain = Promise$2.resolve();
5507
+ var runningChain = Promise$7.resolve();
4152
5508
  var activeIframeSelector = this.contextStorage.getItem(ACTIVE_IFRAME_SELECTOR);
4153
5509
  // NOTE: if the page was reloaded we restore the active child driver link via the iframe selector
4154
5510
  if (!this.activeChildIframeDriverLink && activeIframeSelector)
@@ -4167,7 +5523,7 @@
4167
5523
  Driver.prototype._onCommandExecutedInIframe = function (status) {
4168
5524
  var _this = this;
4169
5525
  this.contextStorage.setItem(this.EXECUTING_IN_IFRAME_FLAG, false);
4170
- var promise = Promise$2.resolve();
5526
+ var promise = Promise$7.resolve();
4171
5527
  if (this._pendingChildWindowInIFrame)
4172
5528
  promise = this._pendingChildWindowInIFrame;
4173
5529
  promise.then(function () {
@@ -4200,7 +5556,7 @@
4200
5556
  .then(function (iframe) {
4201
5557
  if (!testCafeCore.domUtils.isIframeElement(iframe))
4202
5558
  throw new ActionElementNotIframeError();
4203
- return _this._ensureChildIframeDriverLink(nativeMethods$4.contentWindowGetter.call(iframe), iframeErrorCtors.NotLoadedError, commandSelectorTimeout);
5559
+ return _this._ensureChildIframeDriverLink(nativeMethods$8.contentWindowGetter.call(iframe), iframeErrorCtors.NotLoadedError, commandSelectorTimeout);
4204
5560
  })
4205
5561
  .then(function (childDriverLink) {
4206
5562
  childDriverLink.availabilityTimeout = commandSelectorTimeout;
@@ -4211,24 +5567,24 @@
4211
5567
  Driver.prototype._createWaitForEventPromise = function (eventName, timeout) {
4212
5568
  var _this = this;
4213
5569
  var eventHandler = null;
4214
- var timeoutPromise = new Promise$2(function (resolve) {
4215
- nativeMethods$4.setTimeout.call(window, function () {
5570
+ var timeoutPromise = new Promise$7(function (resolve) {
5571
+ nativeMethods$8.setTimeout.call(window, function () {
4216
5572
  _this.off(eventName, eventHandler);
4217
5573
  resolve();
4218
5574
  }, timeout);
4219
5575
  });
4220
- var resultPromise = new Promise$2(function (resolve) {
5576
+ var resultPromise = new Promise$7(function (resolve) {
4221
5577
  eventHandler = function () {
4222
5578
  this.off(eventName, eventHandler);
4223
5579
  resolve();
4224
5580
  };
4225
5581
  _this.on(eventName, eventHandler);
4226
5582
  });
4227
- return Promise$2.race([timeoutPromise, resultPromise]);
5583
+ return Promise$7.race([timeoutPromise, resultPromise]);
4228
5584
  };
4229
5585
  Driver.prototype._waitForCurrentCommandCompletion = function () {
4230
5586
  if (!this.contextStorage.getItem(this.COMMAND_EXECUTING_FLAG))
4231
- return Promise$2.resolve();
5587
+ return Promise$7.resolve();
4232
5588
  return this._createWaitForEventPromise(STATUS_WITH_COMMAND_RESULT_EVENT, COMMAND_EXECUTION_MAX_TIMEOUT);
4233
5589
  };
4234
5590
  Driver.prototype._waitForEmptyCommand = function () {
@@ -4289,7 +5645,7 @@
4289
5645
  var _this = this;
4290
5646
  if (opts === void 0) { opts = {}; }
4291
5647
  this.contextStorage.setItem(this.PENDING_WINDOW_SWITCHING_FLAG, true);
4292
- return Promise$2.resolve()
5648
+ return Promise$7.resolve()
4293
5649
  .then(function () {
4294
5650
  _this._stopInternal();
4295
5651
  return parentWindowSwitchFn(opts);
@@ -4317,7 +5673,7 @@
4317
5673
  Driver.prototype._setNativeDialogHandlerInIframes = function (dialogHandler) {
4318
5674
  var msg = new SetNativeDialogHandlerMessage(dialogHandler);
4319
5675
  for (var i = 0; i < this.childIframeDriverLinks.length; i++)
4320
- messageSandbox$2.sendServiceMsg(msg, this.childIframeDriverLinks[i].driverWindow);
5676
+ messageSandbox$4.sendServiceMsg(msg, this.childIframeDriverLinks[i].driverWindow);
4321
5677
  };
4322
5678
  // Commands handling
4323
5679
  Driver.prototype._onActionCommand = function (command) {
@@ -4511,7 +5867,7 @@
4511
5867
  case 0:
4512
5868
  if (!this.contextStorage.getItem(PENDING_CHILD_WINDOW_COUNT))
4513
5869
  return [2 /*return*/];
4514
- restoreChildWindowsPromise = new Promise$2(function (resolve) {
5870
+ restoreChildWindowsPromise = new Promise$7(function (resolve) {
4515
5871
  _this._restoreChildWindowsPromiseResolver = resolve;
4516
5872
  });
4517
5873
  _a.label = 1;
@@ -4569,7 +5925,7 @@
4569
5925
  };
4570
5926
  Driver.prototype._onShowAssertionRetriesStatusCommand = function (command) {
4571
5927
  this.contextStorage.setItem(ASSERTION_RETRIES_TIMEOUT, command.timeout);
4572
- this.contextStorage.setItem(ASSERTION_RETRIES_START_TIME, nativeMethods$4.dateNow());
5928
+ this.contextStorage.setItem(ASSERTION_RETRIES_START_TIME, nativeMethods$8.dateNow());
4573
5929
  this.statusBar.showWaitingAssertionRetriesStatus(command.timeout);
4574
5930
  this._onReady(new DriverStatus({ isCommandResult: true }));
4575
5931
  };
@@ -4612,12 +5968,12 @@
4612
5968
  Driver.prototype._closeAllChildWindows = function () {
4613
5969
  var _this = this;
4614
5970
  if (!this.childWindowDriverLinks.length)
4615
- return Promise$2.resolve();
4616
- return Promise$2.all(this.childWindowDriverLinks.map(function (childWindowDriverLink) {
5971
+ return Promise$7.resolve();
5972
+ return Promise$7.all(this.childWindowDriverLinks.map(function (childWindowDriverLink) {
4617
5973
  return childWindowDriverLink.closeAllChildWindows();
4618
5974
  }))
4619
5975
  .then(function () {
4620
- nativeMethods$4.arrayForEach.call(_this.childWindowDriverLinks, function (childWindowDriverLink) {
5976
+ nativeMethods$8.arrayForEach.call(_this.childWindowDriverLinks, function (childWindowDriverLink) {
4621
5977
  childWindowDriverLink.driverWindow.close();
4622
5978
  });
4623
5979
  });
@@ -4849,7 +6205,7 @@
4849
6205
  Driver.prototype._init = function () {
4850
6206
  this.contextStorage = new Storage(window, this.testRunId, this.windowId);
4851
6207
  this.nativeDialogsTracker = new NativeDialogTracker(this.contextStorage, this.dialogHandler);
4852
- this.statusBar = new testcafeUi.StatusBar(this.userAgent, this.fixtureName, this.testName, this.contextStorage);
6208
+ this.statusBar = new testCafeUI.StatusBar(this.userAgent, this.fixtureName, this.testName, this.contextStorage);
4853
6209
  this.statusBar.on(this.statusBar.UNLOCK_PAGE_BTN_CLICK, testCafeCore.disableRealEventsPreventing);
4854
6210
  this.speed = this.initialSpeed;
4855
6211
  this._initConsoleMessages();
@@ -4918,21 +6274,21 @@
4918
6274
  return ParentIframeDriverLink;
4919
6275
  }());
4920
6276
 
4921
- var messageSandbox$3 = hammerhead__default.eventSandbox.message;
6277
+ var messageSandbox$5 = hammerhead__default.eventSandbox.message;
4922
6278
  var IframeNativeDialogTracker = /** @class */ (function (_super) {
4923
6279
  __extends(IframeNativeDialogTracker, _super);
4924
6280
  function IframeNativeDialogTracker(dialogHandler) {
4925
6281
  return _super.call(this, null, dialogHandler) || this;
4926
6282
  }
4927
6283
  IframeNativeDialogTracker.prototype._defaultDialogHandler = function (type) {
4928
- messageSandbox$3.sendServiceMsg({
6284
+ messageSandbox$5.sendServiceMsg({
4929
6285
  type: MESSAGE_TYPE.unexpectedDialog,
4930
6286
  dialogType: type,
4931
6287
  url: NativeDialogTracker._getPageUrl()
4932
6288
  }, window.top);
4933
6289
  };
4934
6290
  IframeNativeDialogTracker.prototype._addAppearedDialogs = function (type, text) {
4935
- messageSandbox$3.sendServiceMsg({
6291
+ messageSandbox$5.sendServiceMsg({
4936
6292
  type: MESSAGE_TYPE.appearedDialog,
4937
6293
  dialogType: type,
4938
6294
  text: text,
@@ -4940,7 +6296,7 @@
4940
6296
  }, window.top);
4941
6297
  };
4942
6298
  IframeNativeDialogTracker.prototype._onHandlerError = function (type, message) {
4943
- messageSandbox$3.sendServiceMsg({
6299
+ messageSandbox$5.sendServiceMsg({
4944
6300
  type: MESSAGE_TYPE.handlerError,
4945
6301
  dialogType: type,
4946
6302
  message: message,
@@ -4950,7 +6306,7 @@
4950
6306
  return IframeNativeDialogTracker;
4951
6307
  }(NativeDialogTracker));
4952
6308
 
4953
- var messageSandbox$4 = hammerhead.eventSandbox.message;
6309
+ var messageSandbox$6 = hammerhead.eventSandbox.message;
4954
6310
  var IframeDriver = /** @class */ (function (_super) {
4955
6311
  __extends(IframeDriver, _super);
4956
6312
  function IframeDriver(testRunId, options) {
@@ -4970,7 +6326,7 @@
4970
6326
  // NOTE: when the new page is opened in the iframe we send a message to the top window
4971
6327
  // to start waiting for the new page is loaded
4972
6328
  IframeDriver.prototype._onChildWindowOpened = function () {
4973
- messageSandbox$4.sendServiceMsg(new ChildWindowIsOpenedInFrameMessage(), window.top);
6329
+ messageSandbox$6.sendServiceMsg(new ChildWindowIsOpenedInFrameMessage(), window.top);
4974
6330
  };
4975
6331
  // Messaging between drivers
4976
6332
  IframeDriver.prototype._initParentDriverListening = function () {
@@ -5012,7 +6368,7 @@
5012
6368
  IframeDriver.prototype.start = function () {
5013
6369
  var _this = this;
5014
6370
  this.nativeDialogsTracker = new IframeNativeDialogTracker(this.dialogHandler);
5015
- this.statusBar = new testcafeUi.IframeStatusBar();
6371
+ this.statusBar = new testCafeUI.IframeStatusBar();
5016
6372
  var initializePromise = this.parentDriverLink
5017
6373
  .establishConnection()
5018
6374
  .then(function (id) {
@@ -5046,21 +6402,21 @@
5046
6402
  testCafeDriverInstance: '%testCafeDriverInstance%'
5047
6403
  };
5048
6404
 
5049
- var nativeMethods$5 = hammerhead__default.nativeMethods;
6405
+ var nativeMethods$9 = hammerhead__default.nativeMethods;
5050
6406
  var evalIframeScript = hammerhead__default.EVENTS.evalIframeScript;
5051
- nativeMethods$5.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeDriver, { configurable: true, value: Driver });
5052
- nativeMethods$5.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeIframeDriver, { configurable: true, value: IframeDriver });
5053
- nativeMethods$5.objectDefineProperty(window, INTERNAL_PROPERTIES.scriptExecutionBarrier, {
6407
+ nativeMethods$9.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeDriver, { configurable: true, value: Driver });
6408
+ nativeMethods$9.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeIframeDriver, { configurable: true, value: IframeDriver });
6409
+ nativeMethods$9.objectDefineProperty(window, INTERNAL_PROPERTIES.scriptExecutionBarrier, {
5054
6410
  configurable: true,
5055
6411
  value: ScriptExecutionBarrier
5056
6412
  });
5057
- nativeMethods$5.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeEmbeddingUtils, { configurable: true, value: embeddingUtils });
6413
+ nativeMethods$9.objectDefineProperty(window, INTERNAL_PROPERTIES.testCafeEmbeddingUtils, { configurable: true, value: embeddingUtils });
5058
6414
  // eslint-disable-next-line no-undef
5059
- hammerhead__default.on(evalIframeScript, function (e) { return initTestCafeClientDrivers(nativeMethods$5.contentWindowGetter.call(e.iframe), true); });
6415
+ hammerhead__default.on(evalIframeScript, function (e) { return initTestCafeClientDrivers(nativeMethods$9.contentWindowGetter.call(e.iframe), true); });
5060
6416
 
5061
6417
  }(window['%hammerhead%'], window['%hammerhead%'].Promise, window['%testCafeCore%'], window['%testCafeAutomation%'], window['%testCafeUI%']));
5062
-
5063
- }
5064
-
5065
- initTestCafeClientDrivers(window);
5066
- })();
6418
+
6419
+ }
6420
+
6421
+ initTestCafeClientDrivers(window);
6422
+ })();