test: simplify node setInterval test (#20594)
This commit is contained in:
parent
93788e76e0
commit
9055b5cf6d
1 changed files with 7 additions and 24 deletions
|
@ -217,35 +217,18 @@ describe('node feature', () => {
|
||||||
|
|
||||||
describe('setInterval called under blink env in renderer process', () => {
|
describe('setInterval called under blink env in renderer process', () => {
|
||||||
it('can be scheduled in time', (done) => {
|
it('can be scheduled in time', (done) => {
|
||||||
let interval = null
|
const id = setInterval(() => {
|
||||||
let clearing = false
|
clearInterval(id)
|
||||||
const clear = () => {
|
|
||||||
if (interval === null || clearing) return
|
|
||||||
|
|
||||||
// interval might trigger while clearing (remote is slow sometimes)
|
|
||||||
clearing = true
|
|
||||||
clearInterval(interval)
|
|
||||||
clearing = false
|
|
||||||
interval = null
|
|
||||||
done()
|
done()
|
||||||
}
|
}, 10)
|
||||||
interval = setInterval(clear, 10)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can be scheduled in time from timers module', (done) => {
|
it('can be scheduled in time from timers module', (done) => {
|
||||||
let interval = null
|
const { setInterval, clearInterval } = require('timers')
|
||||||
let clearing = false
|
const id = setInterval(() => {
|
||||||
const clear = () => {
|
clearInterval(id)
|
||||||
if (interval === null || clearing) return
|
|
||||||
|
|
||||||
// interval might trigger while clearing (remote is slow sometimes)
|
|
||||||
clearing = true
|
|
||||||
require('timers').clearInterval(interval)
|
|
||||||
clearing = false
|
|
||||||
interval = null
|
|
||||||
done()
|
done()
|
||||||
}
|
}, 10)
|
||||||
interval = require('timers').setInterval(clear, 10)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue