Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore(bidi): add support for context locators#38129

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
hbenl wants to merge1 commit intomicrosoft:main
base:main
Choose a base branch
Loading
fromhbenl:context-locators

Conversation

@hbenl
Copy link
Contributor

@hbenlhbenl commentedNov 6, 2025
edited
Loading

This PR uses BiDi context locators to implementFrame.frameElement() and to fetch a frame'sname (orid) attribute.
For the latter I ran into two timing issues:

  • FrameManager.frameCommittedNewDocumentNavigation() needs to be called synchronously when the navigation is committed because it removes the old child frames, so if we wait for the frame's name to be fetched before calling it, we may remove child frames that were added after the navigation. I fixed this by calling it synchronously, passing a Promise for the name to it and awaiting that Promise only after deleting the child frames.
  • thedomcontentloaded andload events should only be fired after all child frame names have been fetched, otherwise a test may request a child frame by name before that name has been fetched.

The PRfixes#38098 and the following tests in Firefox:

  • tests/library/hit-target.spec.ts:
    • "should click into frame inside closed shadow root"
  • tests/page/elementhandle-bounding-box.spec.ts:
    • "should handle nested frames"
  • tests/page/frame-frame-element.spec.ts:
    • "should work inside closed shadow root"
    • "should work inside declarative shadow root"
  • tests/page/frame-hierarchy.spec.ts:
    • "should handle nested frames"
    • "should report frame.name()"

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dgozmandgozman requested a review fromyury-sNovember 6, 2025 22:33
@hbenlhbenl marked this pull request as draftNovember 7, 2025 13:57
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@hbenlhbenl marked this pull request as ready for reviewNovember 7, 2025 17:07
}

private_onDomContentLoaded(params:bidi.BrowsingContext.NavigationInfo){
privateasync_onDomContentLoaded(params:bidi.BrowsingContext.NavigationInfo){
Copy link
Member

Choose a reason for hiding this comment

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

Event listeners should be synchronous, we don't want to mess up the event order due to random awaits.

The frame name usually doesn't change, so we could query it on frame attach and if it arrives before the first navigation it will automatically propagate to the clients. This would be racy in some cases, but doesn't require async event handlers. We now have locators (and frame locators) that allow to select iframe elements and don't depend on this method, this could be a fallback for the folks that need to find a frame.

I don't think we should make all these handlers async just for the frame.name(). I'd rather keep the property best effort. If we want a proper fix, we'd need to make the name available synchronously.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I have updated the PR accordingly,frame.name() andpage.frame({ name }) are now best effort.
I have updated the tests to use different ways to get a frame's name or find a frame by name and disabled those tests for BiDi that explicitly want to test the behavior offrame.name() andpage.frame({ name }).

it('should report frame.name()',async({ page, server})=>{
it('should report frame.name()',async({ page, server, browserName, channel})=>{
it.skip(browserName==='firefox'&&channel?.startsWith('moz-firefox'),'frame.name() is racy with BiDi');
it.skip(channel?.startsWith('bidi-chrom'),'frame.name() is racy with BiDi');
Copy link
ContributorAuthor

@hbenlhbenlNov 10, 2025
edited
Loading

Choose a reason for hiding this comment

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

FWIW, this test could be fixed by using

expect((await (await page.frames()[1].frameElement()).getAttribute('id'))).toBe('theFrameId');expect((await (await page.frames()[2].frameElement()).getAttribute('name'))).toBe('theFrameName');

Copy link
Member

Choose a reason for hiding this comment

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

As the test's title suggests it validatesframe.name() behavior, so the code should invokename() at some point.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Yes, that's why I didn't include this in the PR. I was just mentioning it to show what the alternative toframe.name() for BiDi looks like.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@hbenl
Copy link
ContributorAuthor

CI test results compared to the last scheduled test run:https://firefox-dev.tools/playwright-bidi-dashboard/diff.html?browser=firefox&pr=38129 (all new failures seem to be intermittents, even those that are not detected as such).

this.clearWebSockets(frame);
frame._url=url;
frame._name=name;
frame._name=name||frame._name;
Copy link
Member

Choose a reason for hiding this comment

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

This should go into Bidi-specific code.

it('should report frame.name()',async({ page, server})=>{
it('should report frame.name()',async({ page, server, browserName, channel})=>{
it.skip(browserName==='firefox'&&channel?.startsWith('moz-firefox'),'frame.name() is racy with BiDi');
it.skip(channel?.startsWith('bidi-chrom'),'frame.name() is racy with BiDi');
Copy link
Member

Choose a reason for hiding this comment

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

As the test's title suggests it validatesframe.name() behavior, so the code should invokename() at some point.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@yury-s
Copy link
Member

Nice! Once the merge conflict is resolved I can merge it.

hbenl reacted with thumbs up emoji

@github-actions
Copy link
Contributor

Test results for "MCP"

2 flaky⚠️ [chrome] › mcp/cdp.spec.ts:24 › cdp server `@mcp-windows-latest`
⚠️ [chrome] › mcp/cdp.spec.ts:35 › cdp server reuse tab `@mcp-windows-latest`

2430 passed, 116 skipped


Mergeworkflow run.

@github-actions
Copy link
Contributor

Test results for "tests 1"

2 failed
❌ [playwright-test] › reporter-html.spec.ts:156 › created › should include image diff@macos-latest-node18-2
❌ [playwright-test] › runner.spec.ts:118 › should ignore subprocess creation error because of SIGINT@macos-latest-node18-2

4 flaky⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1079 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-library] › library/inspector/cli-codegen-pick-locator.spec.ts:35 › should update locator highlight `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-event-request.spec.ts:182 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node18`
⚠️ [firefox-page] › page/page-goto.spec.ts:83 › should work with Cross-Origin-Opener-Policy `@firefox-ubuntu-22.04-node18`

40255 passed, 787 skipped


Mergeworkflow run.

@hbenlhbenl requested a review fromyury-sNovember 18, 2025 08:53
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@yury-syury-sAwaiting requested review from yury-s

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Feature]: Implement support for "frame.name" in WebDriver BiDi

2 participants

@hbenl@yury-s

[8]ページ先頭

©2009-2025 Movatter.jp