feat(driver): add reuse and navigate commands (#16420)

This commit is contained in:
Pavel Feldman 2022-08-10 10:57:28 -07:00 committed by GitHub
parent 16d9f66ff9
commit c84fbc2e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View file

@ -92,6 +92,19 @@ class ProtocolHandler {
this._playwright = playwright;
}
async resetForReuse() {
const contexts = new Set<BrowserContext>();
for (const page of this._playwright.allPages())
contexts.add(page.context());
for (const context of contexts)
await context.resetForReuse(internalMetadata, null);
}
async navigate(params: { url: string }) {
for (const p of this._playwright.allPages())
await p.mainFrame().goto(internalMetadata, params.url);
}
async setMode(params: { mode: Mode, language?: string, file?: string }) {
await gc(this._playwright);

View file

@ -157,12 +157,14 @@ export abstract class BrowserContext extends SdkObject {
return JSON.stringify(paramsCopy);
}
async resetForReuse(metadata: CallMetadata, params: channels.BrowserNewContextForReuseParams) {
async resetForReuse(metadata: CallMetadata, params: channels.BrowserNewContextForReuseParams | null) {
this.setDefaultNavigationTimeout(undefined);
this.setDefaultTimeout(undefined);
for (const key of paramsThatAllowContextReuse)
(this._options as any)[key] = params[key];
if (params) {
for (const key of paramsThatAllowContextReuse)
(this._options as any)[key] = params[key];
}
await this._cancelAllRoutesInFlight();