mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-12-29 02:40:42 +00:00
fix: ignoreDefaultArgs and ignoreAllDefaultArgs (#184)
This commit is contained in:
parent
e51bb075e7
commit
eeee9c6bb1
@ -81,7 +81,8 @@ public interface BrowserType {
|
||||
/**
|
||||
* If {@code true}, Playwright does not pass its own configurations args and only uses the ones from {@code args}. If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to {@code false}.
|
||||
*/
|
||||
public Boolean ignoreDefaultArgs;
|
||||
public List<String> ignoreDefaultArgs;
|
||||
public Boolean ignoreAllDefaultArgs;
|
||||
/**
|
||||
* Network proxy settings.
|
||||
*/
|
||||
@ -143,8 +144,12 @@ public interface BrowserType {
|
||||
this.args = args;
|
||||
return this;
|
||||
}
|
||||
public LaunchOptions withIgnoreDefaultArgs(Boolean ignoreDefaultArgs) {
|
||||
this.ignoreDefaultArgs = ignoreDefaultArgs;
|
||||
public LaunchOptions withIgnoreDefaultArgs(List<String> argumentNames) {
|
||||
this.ignoreDefaultArgs = argumentNames;
|
||||
return this;
|
||||
}
|
||||
public LaunchOptions withIgnoreAllDefaultArgs(boolean ignore) {
|
||||
this.ignoreAllDefaultArgs = ignore;
|
||||
return this;
|
||||
}
|
||||
public Proxy setProxy() {
|
||||
@ -328,7 +333,8 @@ public interface BrowserType {
|
||||
/**
|
||||
* If {@code true}, then do not use any of the default arguments. If an array is given, then filter out the given default arguments. Dangerous option; use with care. Defaults to {@code false}.
|
||||
*/
|
||||
public String ignoreDefaultArgs;
|
||||
public List<String> ignoreDefaultArgs;
|
||||
public Boolean ignoreAllDefaultArgs;
|
||||
/**
|
||||
* Network proxy settings.
|
||||
*/
|
||||
@ -459,8 +465,12 @@ public interface BrowserType {
|
||||
this.args = args;
|
||||
return this;
|
||||
}
|
||||
public LaunchPersistentContextOptions withIgnoreDefaultArgs(String ignoreDefaultArgs) {
|
||||
this.ignoreDefaultArgs = ignoreDefaultArgs;
|
||||
public LaunchPersistentContextOptions withIgnoreDefaultArgs(List<String> argumentNames) {
|
||||
this.ignoreDefaultArgs = argumentNames;
|
||||
return this;
|
||||
}
|
||||
public LaunchPersistentContextOptions withIgnoreAllDefaultArgs(boolean ignore) {
|
||||
this.ignoreAllDefaultArgs = ignore;
|
||||
return this;
|
||||
}
|
||||
public Proxy setProxy() {
|
||||
|
||||
@ -199,6 +199,17 @@ public class TestDefaultBrowserContext2 extends TestBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWorkWithIgnoreDefaultArgs() {
|
||||
// Ignore arguments by name.
|
||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions().withIgnoreDefaultArgs(asList("foo"));
|
||||
Browser browser = browserType.launch(options);
|
||||
Page page = browser.newPage();
|
||||
browser.close();
|
||||
// Check that there is a way to ignore all arguments.
|
||||
new BrowserType.LaunchOptions().withIgnoreAllDefaultArgs(true);
|
||||
}
|
||||
|
||||
void shouldHavePassedURLWhenLaunchingWithIgnoreDefaultArgsTrue() {
|
||||
}
|
||||
|
||||
|
||||
@ -618,6 +618,12 @@ class Field extends Element {
|
||||
output.add(offset + access + "Path " + name + "Path;");
|
||||
return;
|
||||
}
|
||||
if (asList("BrowserType.launch.options.ignoreDefaultArgs",
|
||||
"BrowserType.launchPersistentContext.options.ignoreDefaultArgs").contains(jsonPath)) {
|
||||
output.add(offset + access + "List<String> ignoreDefaultArgs;");
|
||||
output.add(offset + access + "Boolean ignoreAllDefaultArgs;");
|
||||
return;
|
||||
}
|
||||
output.add(offset + access + type.toJava() + " " + name + ";");
|
||||
}
|
||||
|
||||
@ -682,6 +688,18 @@ class Field extends Element {
|
||||
output.add(offset + "}");
|
||||
return;
|
||||
}
|
||||
if (asList("BrowserType.launch.options.ignoreDefaultArgs",
|
||||
"BrowserType.launchPersistentContext.options.ignoreDefaultArgs").contains(jsonPath)) {
|
||||
output.add(offset + "public " + parentClass + " withIgnoreDefaultArgs(List<String> argumentNames) {");
|
||||
output.add(offset + " this.ignoreDefaultArgs = argumentNames;");
|
||||
output.add(offset + " return this;");
|
||||
output.add(offset + "}");
|
||||
output.add(offset + "public " + parentClass + " withIgnoreAllDefaultArgs(boolean ignore) {");
|
||||
output.add(offset + " this.ignoreAllDefaultArgs = ignore;");
|
||||
output.add(offset + " return this;");
|
||||
output.add(offset + "}");
|
||||
return;
|
||||
}
|
||||
if (asList("Browser.newContext.options.storageState",
|
||||
"Browser.newPage.options.storageState").contains(jsonPath)) {
|
||||
output.add(offset + "public " + parentClass + " withStorageState(BrowserContext.StorageState storageState) {");
|
||||
|
||||
@ -277,12 +277,12 @@ class Types {
|
||||
add("FileChooser.setFiles.files", "string|Array<string>|Object|Array<Object>", "String");
|
||||
add("Route.continue.overrides.postData", "string|Buffer", "byte[]");
|
||||
add("Route.fulfill.response.body", "string|Buffer", "String");
|
||||
add("BrowserType.launch.options.ignoreDefaultArgs", "boolean|Array<string>", "Boolean");
|
||||
add("BrowserType.launch.options.ignoreDefaultArgs", "boolean|Array<string>", "Custom");
|
||||
add("BrowserType.launch.options.firefoxUserPrefs", "Object<string, string|number|boolean>", "String");
|
||||
add("BrowserType.launch.options.env", "Object<string, string|number|boolean>", "Map<String, String>");
|
||||
add("BrowserType.launchPersistentContext.options.ignoreDefaultArgs", "boolean|Array<string>", "String");
|
||||
add("BrowserType.launchPersistentContext.options.ignoreDefaultArgs", "boolean|Array<string>", "Custom");
|
||||
add("BrowserType.launchPersistentContext.options.env", "Object<string, string|number|boolean>", "Map<String, String>");
|
||||
add("BrowserType.launchServer.options.ignoreDefaultArgs", "boolean|Array<string>", "String");
|
||||
add("BrowserType.launchServer.options.ignoreDefaultArgs", "boolean|Array<string>", "Custom");
|
||||
add("BrowserType.launchServer.options.firefoxUserPrefs", "Object<string, string|number|boolean>", "String");
|
||||
add("BrowserType.launchServer.options.env", "Object<string, string|number|boolean>", "Map<String, String>");
|
||||
add("Logger.log.message", "string|Error", "String");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user