Skip to content

Add default prompt value for user prompt WebDriver tests - #12310

Merged
jgraham merged 3 commits into
web-platform-tests:masterfrom
jimevans:webdriver-prompt-defaults
Aug 13, 2018
Merged

jgraham merged 3 commits into
web-platform-tests:masterfrom
jimevans:webdriver-prompt-defaults

Conversation

@jimevans

@jimevans jimevans commented Aug 4, 2018

Copy link
Copy Markdown
Contributor

When the JavaScript prompt() function is called without a default value,
some browsers (like IE) return "undefined" for the default prompt value if
the argument is omitted. This commit refactors the user prompt handler
tests so that prompt() is called with an appropriate value for the default
value argument, providing a consistent behavior across browsers.

When the JavaScript `prompt()` function is called without a default value,
some browsers (like IE) return "undefined" for the default prompt value if
the argument is omitted. This commit refactors the user prompt handler
tests so that prompt() is called with an appropriate value for the default
value argument, providing a consistent behavior across browsers.
@andreastt

Copy link
Copy Markdown
Member

I think @whimboo should have a look at this.

@whimboo

whimboo commented Aug 6, 2018

Copy link
Copy Markdown
Contributor

Hi @jimevans. Thank you for the PR. I had a quick glance over it and two questions came up for me:

  1. Which versions of IE is your driver still supporting? As I read on the cross-browser MDN documentation for prompt this specific default value behavior is only necessary for IE7 and IE8. So I assume those are still on your compatibility list?

  2. I don't think that we should expose the default value all the way down to the tests. Also because it adds a huge amount of boiler-plate. Instead why can't we just hide it's usage inside of the create_dialog fixture? I feel it's a proper place, and we can determine it by the dialog_type argument.

@jimevans

jimevans commented Aug 6, 2018

Copy link
Copy Markdown
Contributor Author

@whimboo

  1. The docs are wrong. I tested this against IE11, and the same behavior happens even outside the WPT test harness.

  2. That’s a perfectly fine approach. I’ll refactor to make that work.

Following code review, a better approach for setting the default prompt
value for JavaScript prompts is in the create_dialog fixture.
Comment thread webdriver/tests/support/fixtures.py Outdated

dialog_params = "text"
if dialog_type == "prompt":
# For prompt() dialogs, add a value for the 'default' argument

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that IE needs that.

Comment thread webdriver/tests/support/fixtures.py Outdated
dialog_params = "text"
if dialog_type == "prompt":
# For prompt() dialogs, add a value for the 'default' argument
dialog_params += ", ''"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind, completely moving this into the script code so that we can get rid of the call to format()?


# Script completes itself when the user prompt has been opened.
# For prompt() dialogs, add a value for the 'default' argument,
# as some user agents (IE, for example) do not produce consistent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos for resisting "(i.e. IE)" :P

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jugglinmike True confession time, I very nearly did "(e.g., IE)".

@whimboo whimboo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a difference to the first version. Thanks a lot for this addition @jimevans! Would you mind to update the MDN article?

@whimboo

whimboo commented Aug 8, 2018

Copy link
Copy Markdown
Contributor

Oh, and please don't forget to squash before merge. Thanks.

@jgraham

jgraham commented Aug 13, 2018

Copy link
Copy Markdown
Contributor

wdspec timeouts.

@jgraham
jgraham merged commit 2db6b2a into web-platform-tests:master Aug 13, 2018
@jimevans
jimevans deleted the webdriver-prompt-defaults branch November 10, 2018 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants