提交 aedf282b 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

fix race condition for on(load) by add on(ready) event

上级 39185065
......@@ -78,9 +78,9 @@ export class Bridge extends EventEmitter {
this.on('load', this.onLoad.bind(this))
const loaded = new Promise(resolve => this.once('load', resolve))
const ready = new Promise(resolve => this.once('ready', resolve))
this.page = await this.initPage(this.browser)
await loaded
await ready
this.state.on(true)
log.verbose('PuppetWebBridge', 'init() initPage() done')
......@@ -155,6 +155,9 @@ export class Bridge extends EventEmitter {
await this.readyAngular(page)
await this.inject(page)
await this.clickSwitchAccount(page)
this.emit('ready')
} catch (e) {
log.error('PuppetWebBridge', 'init() initPage() onLoad() exception: %s', e)
this.emit('error', e)
......
......@@ -93,9 +93,9 @@ test('WechatyBro.ding()', async t => {
await bridge.quit()
t.pass('b.quit()')
profile.destroy()
} catch (err) {
t.fail('exception: ' + err.message)
} finally {
profile.destroy()
}
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册