From 7922db3fda2de74ebbe62036bc66ddac1a60e42e Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Wed, 17 Oct 2018 13:27:15 -0700 Subject: [PATCH 1/2] core(driver): recover from rejection on handleJavaScriptDialog --- lighthouse-core/gather/driver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthouse-core/gather/driver.js b/lighthouse-core/gather/driver.js index 3e7b7ebda902..ba09b87bf5a5 100644 --- a/lighthouse-core/gather/driver.js +++ b/lighthouse-core/gather/driver.js @@ -1205,7 +1205,7 @@ class Driver { this.sendCommand('Page.handleJavaScriptDialog', { accept: true, promptText: 'Lighthouse prompt response', - }); + }).catch(err => log.warn('Driver', err)); }); } } From 65256ffc39778e58bb82e817ce859b477d58e91e Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Wed, 17 Oct 2018 13:38:56 -0700 Subject: [PATCH 2/2] and enable after the event --- lighthouse-core/gather/driver.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/gather/driver.js b/lighthouse-core/gather/driver.js index ba09b87bf5a5..5da3e6322294 100644 --- a/lighthouse-core/gather/driver.js +++ b/lighthouse-core/gather/driver.js @@ -1196,17 +1196,16 @@ class Driver { * @return {Promise} */ async dismissJavaScriptDialogs() { - await this.sendCommand('Page.enable'); - this.on('Page.javascriptDialogOpening', data => { log.warn('Driver', `${data.type} dialog opened by the page automatically suppressed.`); - // rejection intentionally unhandled this.sendCommand('Page.handleJavaScriptDialog', { accept: true, promptText: 'Lighthouse prompt response', }).catch(err => log.warn('Driver', err)); }); + + await this.sendCommand('Page.enable'); } }