Skip to content

feat(digital-credentials): support non-top-level contexts in setVirtualWalletBehavior - #4224

Open
mohamedamir wants to merge 1 commit into
GoogleChromeLabs:mainfrom
mohamedamir:feat/digital-credentials
Open

mohamedamir wants to merge 1 commit into
GoogleChromeLabs:mainfrom
mohamedamir:feat/digital-credentials

Conversation

@mohamedamir

Copy link
Copy Markdown
Contributor

This CL expands support for digitalCredentials.setVirtualWalletBehavior
to accept non-top-level contexts (subframes).

If a subframe does not have an explicitly configured virtual wallet behavior,
it falls back to the global configuration (or user context configuration),
rather than inheriting from its parent context. This is achieved by explicitly
sending the resolved behavior (which defaults to 'clear') to the subframe via
CDP to override Chromium's internal parent-inheritance behavior.

TAG=agy
CONV=ce3d0ebd-0f95-4b7d-ab74-fc357eac15ed

@mohamedamir mohamedamir changed the title [DC] Implement support for non-top-level contexts in digitalCredentials.setVirtualWalletBehavior feat(digital-credentials): support non-top-level contexts in setVirtualWalletBehavior Jul 17, 2026
@mohamedamir
mohamedamir force-pushed the feat/digital-credentials branch from 2338c60 to 8efd285 Compare July 17, 2026 08:47
Comment thread package-lock.json
@mohamedamir
mohamedamir force-pushed the feat/digital-credentials branch from 8efd285 to 695dc99 Compare July 17, 2026 09:04
@mohamedamir
mohamedamir requested a review from OrKoN July 17, 2026 09:08
Comment thread src/bidiMapper/modules/browser/ContextConfigStorage.ts Outdated
Comment thread src/bidiMapper/modules/context/BrowsingContextImpl.ts Outdated
@mohamedamir
mohamedamir force-pushed the feat/digital-credentials branch 4 times, most recently from 64e78f3 to 1c620bc Compare July 17, 2026 09:37
browsingContextStorage.addContext(context);
if (!context.isTopLevelContext()) {
context.parent!.addChild(context.id);
if (context.cdpTarget === context.parent!.cdpTarget) {

@OrKoN OrKoN Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this might be not needed (and flaky). If the local frame is just being created, there should be no behavior targeting it directly by id yet. If there is a global target behavior, it should apply via CdpTarget. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I have been investigating this.
The problem is the logic in Chromium inherits the behaviour from the parent which we decided against here.

I am sorry I overlooked this during the code review in Chromium.

What do you think is the best path forward now?
The spec doesn't define this parent-frame behaviour inheritance.
Should I update the logic in Chromium and then comeback to this PR?
Do you see any other path forward?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah I think in Chromium we should not inherit. To summarize, if Chromium does not inherit and the spec does not define inheriting:

  1. when a new target is created, the client could not have known the targetId so we only need to enable if we have userContext level configuration. The spec does not specify the userContext level configuration so we should not expect userContext configuration in the implementation.
  2. when frame exists, it can be targeted by context ID.

So indeed I think we should be good with just doing the configuration when unblocking CDP targets and removing this part. Does it sound correct?

…alWalletBehavior

This CL expands support for digitalCredentials.setVirtualWalletBehavior
to accept non-top-level contexts (subframes).

If a subframe does not have an explicitly configured virtual wallet behavior,
it falls back to the global configuration (or user context configuration),
rather than inheriting from its parent context. This is achieved by explicitly
sending the resolved behavior (which defaults to 'clear') to the subframe via
CDP to override Chromium's internal parent-inheritance behavior.

TAG=agy
CONV=ce3d0ebd-0f95-4b7d-ab74-fc357eac15ed
@mohamedamir
mohamedamir force-pushed the feat/digital-credentials branch from 1c620bc to 4584d30 Compare July 17, 2026 09:38
}),
);
}
const dcConfig = this.contextConfigStorage.getActiveConfig(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we always have a dcConfig? should not sometimes nothing be configured?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems getAtiveConfig always returns something, even when nothing is configured.
But then the logic below
const dcBehavior = dcConfig.digitalCredentialsBehavior; might indeed be undefined, which is handled in the code AFAICT.

Am I overlooking something?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it does kind of handle it but we might also save sending setVirtualWalletBehavior if nothing was configured at all (as opposed to clear action). Maybe it's something for a follow-up.

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.

2 participants