singular until we have a usecase
This commit is contained in:
parent
27f8be2fe0
commit
b2722c653c
|
|
@ -69,7 +69,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||||
_closeWasCalled = false;
|
_closeWasCalled = false;
|
||||||
private _closeReason: string | undefined;
|
private _closeReason: string | undefined;
|
||||||
private _harRouters: HarRouter[] = [];
|
private _harRouters: HarRouter[] = [];
|
||||||
private _mockingProxies = new Set<MockingProxy>();
|
private _mockingProxy?: MockingProxy;
|
||||||
|
|
||||||
static from(context: channels.BrowserContextChannel): BrowserContext {
|
static from(context: channels.BrowserContextChannel): BrowserContext {
|
||||||
return (context as any)._object;
|
return (context as any)._object;
|
||||||
|
|
@ -246,8 +246,10 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||||
}
|
}
|
||||||
|
|
||||||
_subscribeToMockingProxy(mockingProxy: MockingProxy) {
|
_subscribeToMockingProxy(mockingProxy: MockingProxy) {
|
||||||
this._mockingProxies.add(mockingProxy);
|
if (this._mockingProxy)
|
||||||
mockingProxy.on(Events.MockingProxy.Route, this._onRouteListener);
|
throw new Error('Multiple mocking proxies are not supported');
|
||||||
|
this._mockingProxy = mockingProxy;
|
||||||
|
this._mockingProxy.on(Events.MockingProxy.Route, this._onRouteListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaultNavigationTimeout(timeout: number | undefined) {
|
setDefaultNavigationTimeout(timeout: number | undefined) {
|
||||||
|
|
@ -412,8 +414,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||||
private async _updateInterceptionPatterns() {
|
private async _updateInterceptionPatterns() {
|
||||||
const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
||||||
await this._channel.setNetworkInterceptionPatterns({ patterns });
|
await this._channel.setNetworkInterceptionPatterns({ patterns });
|
||||||
for (const proxy of this._mockingProxies)
|
await this._mockingProxy?.setInterceptionPatterns({ patterns });
|
||||||
await proxy.setInterceptionPatterns({ patterns });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _updateWebSocketInterceptionPatterns() {
|
private async _updateWebSocketInterceptionPatterns() {
|
||||||
|
|
@ -471,9 +472,7 @@ export class BrowserContext extends ChannelOwner<channels.BrowserContextChannel>
|
||||||
this._disposeHarRouters();
|
this._disposeHarRouters();
|
||||||
this.tracing._resetStackCounter();
|
this.tracing._resetStackCounter();
|
||||||
this.emit(Events.BrowserContext.Close, this);
|
this.emit(Events.BrowserContext.Close, this);
|
||||||
this._mockingProxies.forEach(p => {
|
this._mockingProxy?.off(Events.MockingProxy.Route, this._onRouteListener);
|
||||||
p.off(Events.MockingProxy.Route, this._onRouteListener);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async [Symbol.asyncDispose]() {
|
async [Symbol.asyncDispose]() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue