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

fix(domworld): fix waitfor bindings (#6766) #6775

Merged
merged 2 commits into from Jan 25, 2021
Merged

Conversation

jschfflr
Copy link
Contributor

Please take a look! This should close #6766

Copy link
Collaborator

@johanbay johanbay left a comment

Choose a reason for hiding this comment

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

Nice detective work @jschfflr! I was not even aware that contexts have both a name and an id. Do you know whether or not it is a bug that names are added to m_activeBindings when using executionContextId but not when using executionContextName?

src/common/DOMWorld.ts Outdated Show resolved Hide resolved
@@ -512,9 +512,12 @@ export class DOMWorld {
const bind = async (name: string) => {
const expression = helper.pageBindingInitString('internal', name);
try {
// TODO: In theory, it would be enough to call this just once
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would the binding also survive page navigations if we only call it once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The binding is added to m_activeBindings in both cases and stays there until the binding is removed by calling the removeBinding cdp command. And whenever a new ExecutionContext is created, it automatically restores the bindings. This works except for the case when the binding is only exposed to a single execution context identified by an id because it will not be able to restore it.

Adding the binding by name will therefore restore it after navigations. I also added a test for that case to make sure that we don't regress.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see. It sounds like addressing contexts by name instead of id is quite appropriate for this use case then. Thanks!

@mathiasbynens
Copy link
Member

Thanks for taking a look, @johanbay! 👋

LGTM with Johan's questions answered

Co-authored-by: Johan Bay <jobay@google.com>
@jschfflr jschfflr merged commit cac540b into main Jan 25, 2021
@jschfflr jschfflr deleted the fix-waitfor-bindings branch January 25, 2021 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aria queries combined with waitFor* throws unexpected error after page navigation
3 participants