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

Idea: Overwrite global Promise with webdriver.promise.Promise #61

Closed
sjelin opened this issue Nov 1, 2016 · 1 comment
Closed

Idea: Overwrite global Promise with webdriver.promise.Promise #61

sjelin opened this issue Nov 1, 2016 · 1 comment

Comments

@sjelin
Copy link
Contributor

sjelin commented Nov 1, 2016

This would allow for async/await support without breaking the control flow. It would be an option, not the default, and we'd pick a name in the Protractor config that made it obvious that this feature would be risky. Potential pitfalls:

  1. Some other code might try to do the same thing, and I see no way to merge two classes like we do with patched functions (i.e. you can't "call" the original class like you do with functions).
  2. Someone might save the global Promise somewhere before we overwrite it (for example, selenium does this, though this case isn't a problem for us).
  • This would break instanceof tests, though we could patch the webdriver.promise.Promise class to inherit from the global Promise
  • This would break equality tests, though why you might do that I don't know.
  • This could have other unexpected behavior
  1. In the internal implementation of selenium-webdriver, they sometimes use native promises. Presumably, it could cause a problem if they accidentally used webdriver.promise.Promise instead. I don't think this would be a problem though because they're require()'d first and make a point of saving the global Promise to a local variable.
  2. Savvy users might be aware of the difference between webdriver.promise.Promise and the global Promise class, and want to avoid using a webdriver promise for some reason
  3. The webdriver.promise.Promise might behave differently than the global Promise in some unforeseen way
  4. This is hacking and something unexpected could go wrong.
  5. Once async/await are native to JS, it's unclear what this will do.
@sjelin
Copy link
Contributor Author

sjelin commented Jan 20, 2017

This experiment worked, but isn't a good idea

@sjelin sjelin closed this as completed Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant