fix: roll 1.9.1-1614654987000, rename onConsole->onConsoleMessage (#311)
This commit is contained in:
@@ -92,11 +92,11 @@ public interface Page extends AutoCloseable {
|
||||
* page.evaluate("() => console.log('hello', 5, {foo: 'bar'})");
|
||||
* }</pre>
|
||||
*/
|
||||
void onConsole(Consumer<ConsoleMessage> handler);
|
||||
void onConsoleMessage(Consumer<ConsoleMessage> handler);
|
||||
/**
|
||||
* Removes handler that was previously added with {@link #onConsole onConsole(handler)}.
|
||||
* Removes handler that was previously added with {@link #onConsoleMessage onConsoleMessage(handler)}.
|
||||
*/
|
||||
void offConsole(Consumer<ConsoleMessage> handler);
|
||||
void offConsoleMessage(Consumer<ConsoleMessage> handler);
|
||||
|
||||
/**
|
||||
* Emitted when the page crashes. Browser pages might crash if they try to allocate too much memory. When the page crashes,
|
||||
|
||||
@@ -61,7 +61,17 @@ public interface Playwright extends AutoCloseable {
|
||||
* Terminates this instance of Playwright, will also close all created browsers if they are still running.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Launches new Playwright driver process and connects to it. {@link Playwright#close Playwright.close()} should be called
|
||||
* when the instance is no longer needed.
|
||||
* <pre>{@code
|
||||
* Playwright playwright = Playwright.create()) {
|
||||
* Browser browser = playwright.webkit().launch();
|
||||
* Page page = browser.newPage();
|
||||
* page.navigate("https://www.w3.org/");
|
||||
* playwright.close();
|
||||
* }</pre>
|
||||
*/
|
||||
static Playwright create() {
|
||||
return PlaywrightImpl.create();
|
||||
}
|
||||
|
||||
@@ -262,12 +262,12 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConsole(Consumer<ConsoleMessage> handler) {
|
||||
public void onConsoleMessage(Consumer<ConsoleMessage> handler) {
|
||||
listeners.add(EventType.CONSOLE, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offConsole(Consumer<ConsoleMessage> handler) {
|
||||
public void offConsoleMessage(Consumer<ConsoleMessage> handler) {
|
||||
listeners.remove(EventType.CONSOLE, handler);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ public class TestClick extends TestBase {
|
||||
void shouldClickOffscreenButtons() {
|
||||
page.navigate(server.PREFIX + "/offscreenbuttons.html");
|
||||
List<String> messages = new ArrayList<>();
|
||||
page.onConsole(message -> messages.add(message.text()));
|
||||
page.onConsoleMessage(message -> messages.add(message.text()));
|
||||
for (int i = 0; i < 11; ++i) {
|
||||
// We might've scrolled to click a button - reset to (0, 0).
|
||||
page.evaluate("() => window.scrollTo(0, 0)");
|
||||
|
||||
@@ -110,7 +110,7 @@ public class TestGeolocation extends TestBase {
|
||||
context.grantPermissions(asList("geolocation"));
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
List<String> messages = new ArrayList<>();
|
||||
page.onConsole(message -> messages.add(message.text()));
|
||||
page.onConsoleMessage(message -> messages.add(message.text()));
|
||||
context.setGeolocation(new Geolocation(0, 0));
|
||||
page.evaluate("() => {\n" +
|
||||
" navigator.geolocation.watchPosition(pos => {\n" +
|
||||
|
||||
@@ -264,7 +264,7 @@ public class TestPageBasic extends TestBase {
|
||||
void pagePressShouldWorkForEnter() {
|
||||
page.setContent("<input onkeypress='console.log(\"press\")'></input>");
|
||||
List<ConsoleMessage> messages = new ArrayList<>();
|
||||
page.onConsole(message -> messages.add(message));
|
||||
page.onConsoleMessage(message -> messages.add(message));
|
||||
page.press("input", "Enter");
|
||||
assertEquals("press", messages.get(0).text());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TestWaitForFunction extends TestBase {
|
||||
@Test
|
||||
void shouldAvoidSideEffectsAfterTimeout() {
|
||||
int[] counter = { 0 };
|
||||
page.onConsole(message -> ++counter[0]);
|
||||
page.onConsoleMessage(message -> ++counter[0]);
|
||||
|
||||
try {
|
||||
JSHandle result = page.waitForFunction("() => {\n" +
|
||||
@@ -238,7 +238,7 @@ public class TestWaitForFunction extends TestBase {
|
||||
void shouldNotBeCalledAfterFinishingSuccessfully() {
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
List<String> messages = new ArrayList<>();
|
||||
page.onConsole(msg -> {
|
||||
page.onConsoleMessage(msg -> {
|
||||
if (msg.text().startsWith("waitForFunction")) {
|
||||
messages.add(msg.text());
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class TestWaitForFunction extends TestBase {
|
||||
void shouldNotBeCalledAfterFinishingUnsuccessfully() {
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
List<String> messages = new ArrayList<>();
|
||||
page.onConsole(msg -> {
|
||||
page.onConsoleMessage(msg -> {
|
||||
if (msg.text().startsWith("waitForFunction")) {
|
||||
messages.add(msg.text());
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.9.1-1614633211000
|
||||
1.9.1-1614654987000
|
||||
|
||||
@@ -586,7 +586,6 @@ class Method extends Element {
|
||||
|
||||
private static Map<String, String[]> customSignature = new HashMap<>();
|
||||
static {
|
||||
customSignature.put("Page.setViewportSize", new String[]{"void setViewportSize(int width, int height);"});
|
||||
customSignature.put("Playwright.create", new String[]{
|
||||
"static Playwright create() {",
|
||||
" return PlaywrightImpl.create();",
|
||||
@@ -610,11 +609,11 @@ class Method extends Element {
|
||||
}
|
||||
|
||||
void writeTo(List<String> output, String offset) {
|
||||
if (customSignature.containsKey(jsonPath)) {
|
||||
if ("Playwright.create".equals(jsonPath)) {
|
||||
writeJavadoc(params, output, offset);
|
||||
for (String line : customSignature.get(jsonPath)) {
|
||||
output.add(offset + line);
|
||||
}
|
||||
output.add(offset + "static Playwright create() {");
|
||||
output.add(offset + " return PlaywrightImpl.create();");
|
||||
output.add(offset + "}");
|
||||
return;
|
||||
}
|
||||
int numOverloads = 1;
|
||||
@@ -900,12 +899,6 @@ class Interface extends TypeDefinition {
|
||||
for (Method m : methods) {
|
||||
m.writeTo(output, offset);
|
||||
}
|
||||
if ("Playwright".equals(jsonName)) {
|
||||
output.add("");
|
||||
output.add(offset + "static Playwright create() {");
|
||||
output.add(offset + " return PlaywrightImpl.create();");
|
||||
output.add(offset + "}");
|
||||
}
|
||||
output.add("}");
|
||||
output.add("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user