Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(bidi): check credentials' origin and send cancel when there are no matching credentials (#37169)

Holger Benlb659c96e03b9
diff --git a/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts b/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts
index 878a89ddd5..e5139937d9 100644
--- a/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts
+++ b/packages/playwright-core/src/server/bidi/bidiNetworkManager.ts
@@ -159,7 +159,7 @@ export class BidiNetworkManager {
private _onAuthRequired(params: bidi.Network.AuthRequiredParameters) {
const isBasic = params.response.authChallenges?.some(challenge => challenge.scheme.startsWith('Basic'));
const credentials = this._page.browserContext._options.httpCredentials;
- if (isBasic && credentials) {
+ if (isBasic && credentials && (!credentials.origin || (new URL(params.request.url).origin).toLowerCase() === credentials.origin.toLowerCase())) {
if (this._attemptedAuthentications.has(params.request.request)) {
this._session.sendMayFail('network.continueWithAuth', {
request: params.request.request,
@@ -180,7 +180,7 @@ export class BidiNetworkManager {
} else {
this._session.sendMayFail('network.continueWithAuth', {
request: params.request.request,
- action: 'default',
+ action: 'cancel',
});
}
}