chore(bidi): improve request interception#39750
Conversation
a2e6ca5 to
5a40de9
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5a40de9 to
aa97fc7
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "MCP"5507 passed, 343 skipped Merge workflow run. |
Test results for "tests 1"7 flaky38821 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'; |
There was a problem hiding this comment.
| import { BidiPage } from './bidiPage'; | |
| import type { BidiPage } from './bidiPage'; |
| urlPatterns: [{ type: 'pattern' }], | ||
| }); | ||
| this._interceptId = intercept; | ||
| }).then(({ intercept }) => this._interceptId = intercept); |
There was a problem hiding this comment.
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] }); |
There was a problem hiding this comment.
I assume it doesn't affect performance of non-auth requests.
There was a problem hiding this comment.
Correct, it doesn't.
Furthermore, we were previously adding a BeforeRequestSent interception (impacting performance of all requests) even if only the AuthRequired interception was needed, so this PR will improve performance in some cases.
aa97fc7 to
085ac8d
Compare
085ac8d to
831a327
Compare
With this PR:
network.authRequiredis always added so that Playwright can cancel auth requests when the test didn't set any credentialsbypassforcontext.route(), previously this was only done forpage.route()page.route()are now scoped to the page, previously they were set globallyFixes the following tests:
library/browsercontext-credentials.spec.ts:page/page-network-response.spec.ts: