-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
base: main
Are you sure you want to change the base?
Conversation
Test results for "tests 1"5 flaky39068 passed, 799 skipped Merge workflow run. |
@@ -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') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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})()`); |
There was a problem hiding this comment.
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 ??= { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not on Windows?
Resolves #35433