1
0
mirror of synced 2026-05-22 18:53:15 +00:00

fix: allow building persistent context options from device (#266)

This commit is contained in:
Yury Semikhatsky
2021-02-08 15:52:32 -08:00
committed by GitHub
parent f409965c8e
commit c2690f925c
2 changed files with 11 additions and 2 deletions
@@ -622,6 +622,14 @@ public interface BrowserType {
this.viewport = Optional.ofNullable(viewport);
return this;
}
public LaunchPersistentContextOptions withDevice(DeviceDescriptor device) {
withViewport(device.viewport().width(), device.viewport().height());
withUserAgent(device.userAgent());
withDeviceScaleFactor(device.deviceScaleFactor());
withIsMobile(device.isMobile());
withHasTouch(device.hasTouch());
return this;
}
}
/**
* A path where Playwright expects to find a bundled browser executable.
@@ -1176,8 +1176,9 @@ class NestedClass extends TypeDefinition {
}
} else {
writeBuilderMethods(output, bodyOffset);
if ("Browser.newContext.options".equals(jsonPath) ||
"Browser.newPage.options".equals(jsonPath)) {
if (asList("Browser.newContext.options",
"Browser.newPage.options",
"BrowserType.launchPersistentContext.options").contains(jsonPath)) {
writeDeviceDescriptorBuilder(output, bodyOffset);
}
}