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

chore: always use number for polling interval option (#292)

This commit is contained in:
Yury Semikhatsky
2021-02-19 12:39:23 -08:00
committed by GitHub
parent c9787e2102
commit b7a822ee41
6 changed files with 13 additions and 39 deletions
@@ -257,8 +257,7 @@ public interface BrowserContext extends AutoCloseable {
*/
Page newPage();
/**
* Returns all open pages in the context. Non visible pages, such as {@code "background_page"}, will not be listed here. You can
* find them using [{@code method: ChromiumBrowserContext.backgroundPages}].
* Returns all open pages in the context.
*/
List<Page> pages();
/**
@@ -721,22 +721,18 @@ public interface Frame {
}
class WaitForFunctionOptions {
/**
* If {@code polling} is {@code 'raf'}, then {@code expression} is constantly executed in {@code requestAnimationFrame} callback. If {@code polling} is a
* number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to {@code raf}.
* If specified, then it is treated as an interval in milliseconds at which the function would be executed. By default if
* the option is not specified {@code expression} is executed in {@code requestAnimationFrame} callback.
*/
public Integer pollingInterval;
public Double pollingInterval;
/**
* maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the [{@code method: BrowserContext.setDefaultTimeout}].
*/
public Double timeout;
public WaitForFunctionOptions withRequestAnimationFrame() {
this.pollingInterval = null;
return this;
}
public WaitForFunctionOptions withPollingInterval(int millis) {
this.pollingInterval = millis;
public WaitForFunctionOptions withPollingInterval(double pollingInterval) {
this.pollingInterval = pollingInterval;
return this;
}
public WaitForFunctionOptions withTimeout(double timeout) {
@@ -1153,22 +1153,18 @@ public interface Page extends AutoCloseable {
}
class WaitForFunctionOptions {
/**
* If {@code polling} is {@code 'raf'}, then {@code expression} is constantly executed in {@code requestAnimationFrame} callback. If {@code polling} is a
* number, then it is treated as an interval in milliseconds at which the function would be executed. Defaults to {@code raf}.
* If specified, then it is treated as an interval in milliseconds at which the function would be executed. By default if
* the option is not specified {@code expression} is executed in {@code requestAnimationFrame} callback.
*/
public Integer pollingInterval;
public Double pollingInterval;
/**
* maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the [{@code method: BrowserContext.setDefaultTimeout}].
*/
public Double timeout;
public WaitForFunctionOptions withRequestAnimationFrame() {
this.pollingInterval = null;
return this;
}
public WaitForFunctionOptions withPollingInterval(int millis) {
this.pollingInterval = millis;
public WaitForFunctionOptions withPollingInterval(double pollingInterval) {
this.pollingInterval = pollingInterval;
return this;
}
public WaitForFunctionOptions withTimeout(double timeout) {
@@ -96,7 +96,7 @@ public class TestWaitForFunction extends TestBase {
@Test
void shouldPollOnRaf() {
page.evaluate("() => window['__FOO'] = 'hit'");
page.waitForFunction("() => window['__FOO'] === 'hit'", null, new Page.WaitForFunctionOptions().withRequestAnimationFrame());
page.waitForFunction("() => window['__FOO'] === 'hit'", null, new Page.WaitForFunctionOptions());
}
@Test
+1 -1
View File
@@ -1 +1 @@
1.9.0-next-1613173968000
1.9.0-next-1613765974000
@@ -697,11 +697,6 @@ class Field extends Element {
output.add(offset + "public Predicate<String> predicate;");
return;
}
if (asList("Frame.waitForFunction.options.polling",
"Page.waitForFunction.options.polling").contains(jsonPath)) {
output.add(offset + "public Integer pollingInterval;");
return;
}
String typeStr = type.toJava();
if (type.isNullable()) {
typeStr = "Optional<" + typeStr + ">";
@@ -736,18 +731,6 @@ class Field extends Element {
output.add(offset + "}");
return;
}
if (asList("Frame.waitForFunction.options.polling",
"Page.waitForFunction.options.polling").contains(jsonPath)) {
output.add(offset + "public WaitForFunctionOptions withRequestAnimationFrame() {");
output.add(offset + " this.pollingInterval = null;");
output.add(offset + " return this;");
output.add(offset + "}");
output.add(offset + "public WaitForFunctionOptions withPollingInterval(int millis) {");
output.add(offset + " this.pollingInterval = millis;");
output.add(offset + " return this;");
output.add(offset + "}");
return;
}
if (asList("Page.click.options.position",
"Page.dblclick.options.position",
"Page.hover.options.position",