Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch and dimiss javascript dialogs/alerts/prompts #1939

Closed
cedricbellet opened this issue Mar 30, 2017 · 5 comments · Fixed by #2106
Closed

Catch and dimiss javascript dialogs/alerts/prompts #1939

cedricbellet opened this issue Mar 30, 2017 · 5 comments · Fixed by #2106

Comments

@cedricbellet
Copy link
Contributor

lighthouse http://jetcost.com

jetcost seems to call window.confirm during a lighthouse test, and so long as the window.confirm is open, lighthouse continues to wait. tested with 1.6.3

@ebidel
Copy link
Contributor

ebidel commented Mar 30, 2017

Ugh. That's terrible.

Looks like this happens in mobile emulation. The double 'ugh' is tat the dialog translates to "Get the free Jetcost app for Android. The best deals for cheap flights in your pocket!"

Page.handleJavaScriptDialog might do the trick.

@paulirish
Copy link
Member

paulirish commented Mar 30, 2017

Yeah good call @ebidel

Interestingly there is no chrome --flag for this, but we can do it with Page.handleJavaScriptDialog

We listen for the 'Page.javascriptDialogOpening' event to fire and whenever it does, we can immediately do sendCommand('Page.handleJavaScriptDialog', {accept: true}) and all is well. We might also want to supply a promptText property to the options in case the confirm prompt is asking for some text.

image

@cedricbellet do you want to give this a shot? It'd live completely in driver.js and just get setup once we're connected.

@ebidel
Copy link
Contributor

ebidel commented Mar 30, 2017

Come to think of it, we might be able to also get a quick UX audit out of this for "Avoiding APIs that harm the user experience" :) No page in 2017 should be using dialogs/prompts like this.

@ebidel ebidel changed the title lighthouse hangs when site opens a window.confirm popup Catch and dimiss javascript dialogs/alerts/prompts Mar 30, 2017
@paulirish
Copy link
Member

Very true!

@cedricbellet
Copy link
Contributor Author

cedricbellet commented Apr 1, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants