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

Add lifecycle event validation to WaitForLoadState #300

Merged
merged 5 commits into from
May 9, 2022

Conversation

imiric
Copy link
Contributor

@imiric imiric commented Apr 25, 2022

Previously if the user passed an invalid lifecycle event value in page.waitForLoadState() options, we would silently default to load, which might not have been the intention. This PR validates the value in LifecycleEvent.UnmarshalText() and fails the test with an error if it's invalid. It also reuses the validation in other parts where LifecycleEvent is used, such as in Frame.Goto, Frame.SetContent and Frame.WaitForNavigation options, which all used their own validation returning a less informative error.

Ideally lifecycle events should be exported as JS symbols to avoid typo situations, and so that we can have type definitons for them, but this is a stopgap solution until then.

Thanks to @wardbekker for reminding us about this!

@imiric imiric requested a review from inancgumus April 25, 2022 15:52
@imiric imiric force-pushed the feat/validate-lifecycleevent branch from e188a4d to 62fa217 Compare April 25, 2022 15:56
common/types.go Show resolved Hide resolved
common/frame.go Outdated Show resolved Hide resolved
common/frame.go Outdated Show resolved Hide resolved
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

LGTM.

common/types.go Show resolved Hide resolved
@imiric imiric merged commit 241e402 into main May 9, 2022
@imiric imiric deleted the feat/validate-lifecycleevent branch May 9, 2022 07:46
imiric pushed a commit that referenced this pull request May 9, 2022
imiric pushed a commit that referenced this pull request May 9, 2022
* Add checkHitTarget fix to release notes

* Update #264 details

* Mention the rest of v0.3.0 changes

* Update mention of JS API docs

* Mention k6 update along with other dependencies

* Mention #299 fix

* Mention #300 improvement

* Remove leftover closing paren

* Add 264 as a feature (#265)

* Update 283 comment (#265)

* Add executablePath option (#265)

* Rephrase code refactors (#265)

* Rephrase waitForFunction mention

Resolves #265 (comment)

* Mention the project roadmap as an improvement

* Mention that raf is the default waitForFunction polling option

Co-authored-by: Ivan Mirić <ivan.miric@grafana.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants