Skip to content

chore(webkit): polyfill PublicKeyCredential #35702

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Apr 23, 2025

Resolves #35433

@Skn0tt Skn0tt self-assigned this Apr 23, 2025
Copy link
Contributor

Test results for "tests 1"

5 flaky ⚠️ [chromium-library] › library/client-certificates.spec.ts:400:3 › browser › should not hang on tls errors during TLS 1.2 handshake @chromium-ubuntu-22.04-node20
⚠️ [chromium-page] › page/page-request-continue.spec.ts:72:3 › should delete header with undefined value @chromium-ubuntu-22.04-node22
⚠️ [firefox-page] › page/page-evaluate.spec.ts:424:3 › should throw for too deep reference chain @firefox-ubuntu-22.04-node18
⚠️ [chromium-library] › library/video.spec.ts:379:5 › screencast › should capture navigation @ubuntu-22.04-chromium-tip-of-tree
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node20-1

39068 passed, 799 skipped
✔️✔️✔️

Merge workflow run.

@Skn0tt Skn0tt marked this pull request as ready for review April 23, 2025 14:31
@Skn0tt Skn0tt requested a review from dgozman April 23, 2025 14:31
@@ -357,4 +358,26 @@ export class WKBrowserContext extends BrowserContext {
if (process.platform === 'win32' && this._browser.options.headful && (viewportSize.width < 250 || viewportSize.height < 240))
throw new Error(`WebKit on Windows has a minimal viewport of 250x240.`);
}

private async _polyfillPublicKeyCredential() {
if (process.platform === 'darwin' || process.platform === 'win32')
Copy link
Contributor

Choose a reason for hiding this comment

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

This should check browser's platform instead. See CRBrowser._platform() for an example.

Better yet, skip the polyfill when it's already available instead of making this check?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's already skipping the polyfill if it's available - this line is an optimisation to spare a call to addInitScript if we know it's unneeded.

} as any;
}

await this.addInitScript(`(${polyfill})()`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of using the public API that has some side-effects, do it similar to other things in _calculateBootstrapScript().


function polyfill() {
// https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential
globalThis.PublicKeyCredential ??= {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment here explaining what do we align with? Any particular Safari version? Something else? For example, I don't see parseCreationOptionsFromJSON. Do we have to polyfill things like navigator.credentials.create() as well?


private async _polyfillPublicKeyCredential() {
if (process.platform === 'darwin' || process.platform === 'win32')
return;
Copy link
Member

Choose a reason for hiding this comment

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

Why not on Windows?

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.

[Bug]: PublicKeyCredential is undefined in webkit for debian
3 participants