Skip to content

chore(bidi): improve request interception#39750

Open
hbenl wants to merge 1 commit intomicrosoft:mainfrom
hbenl:improve-request-interception
Open

chore(bidi): improve request interception#39750
hbenl wants to merge 1 commit intomicrosoft:mainfrom
hbenl:improve-request-interception

Conversation

@hbenl
Copy link
Collaborator

@hbenl hbenl commented Mar 18, 2026

With this PR:

  • the intercept for network.authRequired is always added so that Playwright can cancel auth requests when the test didn't set any credentials
  • the cache behavior is set to bypass for context.route(), previously this was only done for page.route()
  • the intercept and cache behavior for page.route() are now scoped to the page, previously they were set globally

Fixes the following tests:

  • library/browsercontext-credentials.spec.ts:
    • "should fail without credentials"
    • "should work with setHTTPCredentials"
  • page/page-network-response.spec.ts:
    • "should bypass disk cache when context interception is enabled"

@hbenl hbenl force-pushed the improve-request-interception branch from a2e6ca5 to 5a40de9 Compare March 18, 2026 16:31
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@hbenl hbenl force-pushed the improve-request-interception branch from 5a40de9 to aa97fc7 Compare March 18, 2026 17:04
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Test results for "MCP"

5507 passed, 343 skipped


Merge workflow run.

@github-actions
Copy link
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:754 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/inspector/recorder-api.spec.ts:120 › should type `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/trace-viewer.spec.ts:1223 › should display language-specific locators `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-set-input-files.spec.ts:297 › should detect mime type `@webkit-ubuntu-22.04-node20`

38821 passed, 845 skipped


Merge workflow run.

import { parseRawCookie } from '../cookieStore';
import * as network from '../network';
import * as bidi from './third_party/bidiProtocol';
import { BidiPage } from './bidiPage';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import { BidiPage } from './bidiPage';
import type { BidiPage } from './bidiPage';

urlPatterns: [{ type: 'pattern' }],
});
this._interceptId = intercept;
}).then(({ intercept }) => this._interceptId = intercept);
Copy link
Member

Choose a reason for hiding this comment

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

nit: let's unify the way send('network.addIntercept' and send('network.removeIntercept' are waited - either await both inline or assign both to the interceptPromise, so that we don't accidentally end up with unhandled promise rejection.

],
});

await browser._browserSession.send('network.addIntercept', { phases: [bidi.Network.InterceptPhase.AuthRequired] });
Copy link
Member

Choose a reason for hiding this comment

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

I assume it doesn't affect performance of non-auth requests.

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