test: fix flaky before-input-event test (#16027)
This commit is contained in:
parent
48abef27d8
commit
1152fecb75
1 changed files with 65 additions and 68 deletions
|
@ -292,12 +292,12 @@ describe('webContents module', () => {
|
|||
w.loadFile(path.join(fixtures, 'pages', 'key-events.html'))
|
||||
})
|
||||
|
||||
it('has the correct properties', (done) => {
|
||||
w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
|
||||
w.webContents.once('did-finish-load', () => {
|
||||
it('has the correct properties', async () => {
|
||||
await w.loadFile(path.join(fixtures, 'pages', 'base-page.html'))
|
||||
const testBeforeInput = (opts) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
w.webContents.once('before-input-event', (event, input) => {
|
||||
try {
|
||||
assert.strictEqual(input.type, opts.type)
|
||||
assert.strictEqual(input.key, opts.key)
|
||||
assert.strictEqual(input.code, opts.code)
|
||||
|
@ -307,6 +307,9 @@ describe('webContents module', () => {
|
|||
assert.strictEqual(input.alt, opts.alt)
|
||||
assert.strictEqual(input.meta, opts.meta)
|
||||
resolve()
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
|
||||
const modifiers = []
|
||||
|
@ -324,8 +327,7 @@ describe('webContents module', () => {
|
|||
})
|
||||
}
|
||||
|
||||
Promise.resolve().then(() => {
|
||||
return testBeforeInput({
|
||||
await testBeforeInput({
|
||||
type: 'keyDown',
|
||||
key: 'A',
|
||||
code: 'KeyA',
|
||||
|
@ -336,8 +338,7 @@ describe('webContents module', () => {
|
|||
meta: true,
|
||||
isAutoRepeat: true
|
||||
})
|
||||
}).then(() => {
|
||||
return testBeforeInput({
|
||||
await testBeforeInput({
|
||||
type: 'keyUp',
|
||||
key: '.',
|
||||
code: 'Period',
|
||||
|
@ -348,8 +349,7 @@ describe('webContents module', () => {
|
|||
meta: false,
|
||||
isAutoRepeat: false
|
||||
})
|
||||
}).then(() => {
|
||||
return testBeforeInput({
|
||||
await testBeforeInput({
|
||||
type: 'keyUp',
|
||||
key: '!',
|
||||
code: 'Digit1',
|
||||
|
@ -360,8 +360,7 @@ describe('webContents module', () => {
|
|||
meta: true,
|
||||
isAutoRepeat: false
|
||||
})
|
||||
}).then(() => {
|
||||
return testBeforeInput({
|
||||
await testBeforeInput({
|
||||
type: 'keyUp',
|
||||
key: 'Tab',
|
||||
code: 'Tab',
|
||||
|
@ -372,8 +371,6 @@ describe('webContents module', () => {
|
|||
meta: false,
|
||||
isAutoRepeat: true
|
||||
})
|
||||
}).then(done).catch(done)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue