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

Prepare Page for async migration part #2 #1345

Merged
merged 17 commits into from
May 29, 2024

Conversation

inancgumus
Copy link
Member

What?

Turns panics into errors only for Page's first set of methods. The rest will be in another PR.

Why?

To make the async migration more reliable.

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)

#1307

@inancgumus inancgumus added refactor mapping k6 browser to Goja mapping related. stability runtime stability improvements labels May 23, 2024
@inancgumus inancgumus self-assigned this May 23, 2024
@inancgumus inancgumus requested a review from ankur22 May 23, 2024 11:36
@inancgumus inancgumus marked this pull request as ready for review May 23, 2024 11:36
@@ -948,21 +948,19 @@ func (f *Frame) FrameElement() (*ElementHandle, error) {
}

// GetAttribute of the first element found that matches the selector.
func (f *Frame) GetAttribute(selector, name string, opts goja.Value) any {
func (f *Frame) GetAttribute(selector, name string, opts goja.Value) (any, error) {
Copy link
Collaborator

@ankur22 ankur22 May 28, 2024

Choose a reason for hiding this comment

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

GetAttribute should only returns a string. Having taken a quick look at the call stack it looks like we're using element.getAttribute, maybe a string instead of any?

It should also map to nil if the string is empty... not sure what the best way forward for that would be since an attribute could just be empty :/

Copy link
Member Author

@inancgumus inancgumus May 29, 2024

Choose a reason for hiding this comment

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

How about returning a bool to detect that in the mapping layer?

func (f *Frame) GetAttribute(selector, name string, opts goja.Value) (string, bool, error)

Even so, this should better go to a new issue because it'd change the existing signatures. I've tried to keep the signatures intact other than adding errors.

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! Love seeing those panics being replaced by errors ❤️

@inancgumus inancgumus merged commit 08d600e into main-async May 29, 2024
14 checks passed
@inancgumus inancgumus deleted the async/page-prepare-part2 branch May 29, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mapping k6 browser to Goja mapping related. refactor stability runtime stability improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants