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

Move goja option parsing out of frame and page goto opts #1179

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Jan 22, 2024

What?

  • Moves goja out of option parsing for frame and page goto to mapping.
  • Updates tests accordingly.
  • Adds two helpers: Referrer and NavigationTimeout for building options while mapping.

Why?

See #1162 for the main reason. Also, the reason for doing both frame and page goto options in the same PR is that the code doesn't compile without the other. Or, it would require a lot of intermediary steps which would be confusing for the commit log.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Updates: #1176

@inancgumus inancgumus changed the title Fix/goja frame page goto opts Move goja option parsing out of frame and page goto opts Jan 22, 2024
@inancgumus inancgumus self-assigned this Jan 22, 2024
@inancgumus inancgumus marked this pull request as ready for review January 22, 2024 09:54
browser/mapping.go Outdated Show resolved Hide resolved
Comment on lines +89 to +91
opts := &common.FrameGotoOptions{
Timeout: common.DefaultTimeout,
}
Copy link
Member Author

Choose a reason for hiding this comment

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

page.Goto could implicitly set a default timeout. But I think this makes it explicit and less error-prone. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, I was wondering the same. I went with the option of being explicit for now, and ensuring it matched the current behaviour. I think in a future refactor we can make it implicit.

Copy link
Member Author

@inancgumus inancgumus Jan 22, 2024

Choose a reason for hiding this comment

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

I'm on the side of keeping it explicit this way. This also gives transparent direct control to tests. Previously, we had our fair share of bugs because of time management and timeouts. Let's see :)

browser/mapping.go Outdated Show resolved Hide resolved
@inancgumus inancgumus requested review from ankur22 and removed request for ankur22 January 23, 2024 13:21
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

Why?
- Train of calls make the code less readable and maintain.
- This is a precursor for calling the methods from the mapping layer
  while parsing the options with defaults.
Areas to consider:
- frame and page gotos go hand to hand. we had to refactor both.
- explicitness
  tests must now set their timeout goto options explicitly
  this was implicit before, potentially dangerous and can
  easily lead to unexpected behavior.
- This prevents the train-of-calls issue.
- It might make it easier to navigate within the code for new
  contributors.
@inancgumus inancgumus merged commit bb6149d into main-next Jan 23, 2024
14 checks passed
@inancgumus inancgumus deleted the fix/goja-frame-page-goto-opts branch January 23, 2024 15:00
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.

3 participants