Last change
on this file since e29cc2e was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago |
primeNG components
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | const log = require('../logger').create('launcher')
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Kill browser if it does not capture in given `captureTimeout`.
|
---|
5 | */
|
---|
6 | function CaptureTimeoutLauncher (timer, captureTimeout) {
|
---|
7 | if (!captureTimeout) {
|
---|
8 | return
|
---|
9 | }
|
---|
10 |
|
---|
11 | let pendingTimeoutId = null
|
---|
12 |
|
---|
13 | this.on('start', () => {
|
---|
14 | pendingTimeoutId = timer.setTimeout(() => {
|
---|
15 | pendingTimeoutId = null
|
---|
16 | if (this.state !== this.STATE_BEING_CAPTURED) {
|
---|
17 | return
|
---|
18 | }
|
---|
19 |
|
---|
20 | log.warn(`${this.name} has not captured in ${captureTimeout} ms, killing.`)
|
---|
21 | this.error = 'timeout'
|
---|
22 | this.kill()
|
---|
23 | }, captureTimeout)
|
---|
24 | })
|
---|
25 |
|
---|
26 | this.on('done', () => {
|
---|
27 | if (pendingTimeoutId) {
|
---|
28 | timer.clearTimeout(pendingTimeoutId)
|
---|
29 | pendingTimeoutId = null
|
---|
30 | }
|
---|
31 | })
|
---|
32 | }
|
---|
33 |
|
---|
34 | CaptureTimeoutLauncher.decoratorFactory = function (timer,
|
---|
35 | /* config.captureTimeout */ captureTimeout) {
|
---|
36 | return function (launcher) {
|
---|
37 | CaptureTimeoutLauncher.call(launcher, timer, captureTimeout)
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | CaptureTimeoutLauncher.decoratorFactory.$inject = ['timer', 'config.captureTimeout']
|
---|
42 |
|
---|
43 | module.exports = CaptureTimeoutLauncher
|
---|
Note:
See
TracBrowser
for help on using the repository browser.