Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Fix interface conversion in document #149

Merged
merged 3 commits into from
Dec 9, 2021

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Dec 8, 2021

The error was:
panic: interface conversion: interface {} is nil, not *common.ElementHandle

The cause of the error was trying to assert a nil result in Frame.document to *ElementHandle. Of course, this is probably the surface error. There may be other causes for it, or maybe not.

It was hard to test Frame, so I used an abstraction called FrameExecutionContext. There are a lot of problems are happening with execution contexts. See: #125 and #49, for example. So, it's better to make them testable, starting here.

Fixes #53

The error was:
panic: interface conversion: interface {} is nil, not
*common.ElementHandle

The cause of the error was trying to assert a nil result
in Frame.document to *ElementHandle. Of course, this is
probably the surface error. There may be other causes
for it, or maybe not.

It was hard to test Frame, so I used an abstraction called
FrameExecutionContext. There are a lot of problems are
happening with execution contexts. See: #125 and #49, for
example. So, it's better to make them testable, starting
here.

Fixes #53
@inancgumus inancgumus requested a review from imiric December 8, 2021 15:34
@inancgumus inancgumus self-assigned this Dec 8, 2021
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

LGTM, just minor suggestions.

While this fixes the panic, I'm not sure what effects it will functionally have for all callers of Frame.document(). I guess we'll find out and deal with that if/when it happens.

Have you tested how this behaves with the script in #53?

common/frame_execution_context.go Outdated Show resolved Hide resolved
common/frame_test.go Outdated Show resolved Hide resolved
common/frame.go Outdated Show resolved Hide resolved
common/frame_test.go Outdated Show resolved Hide resolved
inancgumus added a commit that referenced this pull request Dec 9, 2021
+ Move frame execution context to frame.go

+ Remove the unnecessary Errorf in Frame.document

+ Make the test robust
@inancgumus inancgumus force-pushed the fix/53-interface-conversion-error branch from 7b0b22a to fd30521 Compare December 9, 2021 13:10
@inancgumus inancgumus requested a review from imiric December 9, 2021 13:13
@inancgumus
Copy link
Member Author

LGTM, just minor suggestions.

Thanks 🙏

While this fixes the panic, I'm not sure what effects it will functionally have for all callers of Frame.document(). I guess we'll find out and deal with that if/when it happens.

Sadly, yes, we'll find that out as we improve the tests.

Have you tested how this behaves with the script in #53?

Sure thing.

@inancgumus inancgumus added the bug Something isn't working label Dec 9, 2021
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

LGTM

Maybe update the PR description with how it behaves with the script from #53, or comment in the issue itself.

Also, the bug label is typically only useful on issues, unless your PR also introduces a bug 😛

@inancgumus inancgumus removed the bug Something isn't working label Dec 9, 2021
@inancgumus inancgumus merged commit 38ed12e into main Dec 9, 2021
@inancgumus inancgumus deleted the fix/53-interface-conversion-error branch December 9, 2021 15:22
@inancgumus
Copy link
Member Author

Maybe update the PR description with how it behaves with the script from #53, or comment in the issue itself.

It behaves like without the error 😄 More like other unsolvable errors we've seen so far.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic: interface conversion: interface {} is nil, not *common.ElementHandle
2 participants