diff --git a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java index 85898086..b647999c 100644 --- a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java +++ b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java @@ -723,7 +723,7 @@ public interface ElementHandle extends JSHandle { * @param selector A selector to query for. See [working with selectors](./selectors.md) for more details. * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evalOnSelector(String selector, String expression, Object arg); default Object evalOnSelectorAll(String selector, String expression) { @@ -742,7 +742,7 @@ public interface ElementHandle extends JSHandle { * @param selector A selector to query for. See [working with selectors](./selectors.md) for more details. * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evalOnSelectorAll(String selector, String expression, Object arg); default void fill(String value) { diff --git a/playwright/src/main/java/com/microsoft/playwright/FileChooser.java b/playwright/src/main/java/com/microsoft/playwright/FileChooser.java index 24d4dff1..905baf58 100644 --- a/playwright/src/main/java/com/microsoft/playwright/FileChooser.java +++ b/playwright/src/main/java/com/microsoft/playwright/FileChooser.java @@ -20,7 +20,7 @@ import java.nio.file.Path; import java.util.*; /** - * {@code FileChooser} objects are dispatched by the page in the [{@code event: Page.filechooser}] event. + * {@code FileChooser} objects are dispatched by the page in the [{@code event: Page.fileChooser}] event. */ public interface FileChooser { class FilePayload { diff --git a/playwright/src/main/java/com/microsoft/playwright/Frame.java b/playwright/src/main/java/com/microsoft/playwright/Frame.java index 654ebe1b..949e098f 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Frame.java +++ b/playwright/src/main/java/com/microsoft/playwright/Frame.java @@ -26,10 +26,10 @@ import java.util.regex.Pattern; * [{@code method: Frame.childFrames}] methods. * *

{@code Frame} object's lifecycle is controlled by three events, dispatched on the page object: - * - [{@code event: Page.frameattached}] - fired when the frame gets attached to the page. A Frame can be attached to the page + * - [{@code event: Page.frameAttached}] - fired when the frame gets attached to the page. A Frame can be attached to the page * only once. - * - [{@code event: Page.framenavigated}] - fired when the frame commits navigation to a different URL. - * - [{@code event: Page.framedetached}] - fired when the frame gets detached from the page. A Frame can be detached from the + * - [{@code event: Page.frameNavigated}] - fired when the frame commits navigation to a different URL. + * - [{@code event: Page.frameDetached}] - fired when the frame gets detached from the page. A Frame can be detached from the * page only once. */ public interface Frame { @@ -983,7 +983,7 @@ public interface Frame { * @param selector A selector to query for. See [working with selectors](./selectors.md) for more details. * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evalOnSelector(String selector, String expression, Object arg); default Object evalOnSelectorAll(String selector, String expression) { @@ -1002,7 +1002,7 @@ public interface Frame { * @param selector A selector to query for. See [working with selectors](./selectors.md) for more details. * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evalOnSelectorAll(String selector, String expression, Object arg); default Object evaluate(String expression) { @@ -1025,7 +1025,7 @@ public interface Frame { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evaluate(String expression, Object arg); default JSHandle evaluateHandle(String expression) { @@ -1047,7 +1047,7 @@ public interface Frame { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ JSHandle evaluateHandle(String expression, Object arg); default void fill(String selector, String value) { @@ -1459,7 +1459,7 @@ public interface Frame { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ JSHandle waitForFunction(String expression, Object arg, WaitForFunctionOptions options); default void waitForLoadState(LoadState state) { diff --git a/playwright/src/main/java/com/microsoft/playwright/JSHandle.java b/playwright/src/main/java/com/microsoft/playwright/JSHandle.java index 47504cb3..53fa115c 100644 --- a/playwright/src/main/java/com/microsoft/playwright/JSHandle.java +++ b/playwright/src/main/java/com/microsoft/playwright/JSHandle.java @@ -51,7 +51,7 @@ public interface JSHandle { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evaluate(String expression, Object arg); default JSHandle evaluateHandle(String expression) { @@ -72,7 +72,7 @@ public interface JSHandle { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ JSHandle evaluateHandle(String expression, Object arg); /** diff --git a/playwright/src/main/java/com/microsoft/playwright/Page.java b/playwright/src/main/java/com/microsoft/playwright/Page.java index f526eae1..e1e4df87 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Page.java +++ b/playwright/src/main/java/com/microsoft/playwright/Page.java @@ -1664,7 +1664,7 @@ public interface Page extends AutoCloseable { * @param selector A selector to query for. See [working with selectors](./selectors.md) for more details. * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evalOnSelector(String selector, String expression, Object arg); default Object evalOnSelectorAll(String selector, String expression) { @@ -1681,7 +1681,7 @@ public interface Page extends AutoCloseable { * @param selector A selector to query for. See [working with selectors](./selectors.md) for more details. * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evalOnSelectorAll(String selector, String expression, Object arg); default Object evaluate(String expression) { @@ -1707,7 +1707,7 @@ public interface Page extends AutoCloseable { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evaluate(String expression, Object arg); default JSHandle evaluateHandle(String expression) { @@ -1729,7 +1729,7 @@ public interface Page extends AutoCloseable { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ JSHandle evaluateHandle(String expression, Object arg); default void exposeBinding(String name, Binding callback) { @@ -2365,7 +2365,7 @@ public interface Page extends AutoCloseable { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ JSHandle waitForFunction(String expression, Object arg, WaitForFunctionOptions options); default void waitForLoadState(Frame.LoadState state) { diff --git a/playwright/src/main/java/com/microsoft/playwright/Request.java b/playwright/src/main/java/com/microsoft/playwright/Request.java index f3782d5c..ea59ad74 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Request.java +++ b/playwright/src/main/java/com/microsoft/playwright/Request.java @@ -22,10 +22,10 @@ import java.util.*; * Whenever the page sends a request for a network resource the following sequence of events are emitted by {@code Page}: * - [{@code event: Page.request}] emitted when the request is issued by the page. * - [{@code event: Page.response}] emitted when/if the response status and headers are received for the request. - * - [{@code event: Page.requestfinished}] emitted when the response body is downloaded and the request is complete. + * - [{@code event: Page.requestFinished}] emitted when the response body is downloaded and the request is complete. * *

If request fails at some point, then instead of {@code 'requestfinished'} event (and possibly instead of 'response' event), - * the [{@code event: Page.requestfailed}] event is emitted. + * the [{@code event: Page.requestFailed}] event is emitted. * *

NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will * complete with {@code 'requestfinished'} event. diff --git a/playwright/src/main/java/com/microsoft/playwright/Worker.java b/playwright/src/main/java/com/microsoft/playwright/Worker.java index 448ae2e5..6bf5bf27 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Worker.java +++ b/playwright/src/main/java/com/microsoft/playwright/Worker.java @@ -55,7 +55,7 @@ public interface Worker { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ Object evaluate(String expression, Object arg); default JSHandle evaluateHandle(String expression) { @@ -72,7 +72,7 @@ public interface Worker { * * @param expression JavaScript expression to be evaluated in the browser context. If it looks like a function declaration, it is interpreted * as a function. Otherwise, evaluated as an expression. - * @param arg Optional argument to pass to {@code expression} + * @param arg Optional argument to pass to {@code expression}. */ JSHandle evaluateHandle(String expression, Object arg); String url(); diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index e08b62b9..b103aa41 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.9.0-next-1612400196000 +1.9.0-next-1612463649000 diff --git a/tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java b/tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java index fdd4f9c7..2b10f39e 100644 --- a/tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java +++ b/tools/api-generator/src/main/java/com/microsoft/playwright/tools/ApiGenerator.java @@ -382,41 +382,6 @@ abstract class TypeDefinition extends Element { } class Event extends Element { - private static Map eventNames = new HashMap<>(); - static { - eventNames.put("Browser.disconnected", "Disconnected"); - - eventNames.put("BrowserContext.close", "Close"); - eventNames.put("BrowserContext.page", "Page"); - - eventNames.put("Page.close", "Close"); - eventNames.put("Page.console", "Console"); - eventNames.put("Page.crash", "Crash"); - eventNames.put("Page.dialog", "Dialog"); - eventNames.put("Page.domcontentloaded", "DOMContentLoaded"); - eventNames.put("Page.download", "Download"); - eventNames.put("Page.filechooser", "FileChooser"); - eventNames.put("Page.frameattached", "FrameAttached"); - eventNames.put("Page.framedetached", "FrameDetached"); - eventNames.put("Page.framenavigated", "FrameNavigated"); - eventNames.put("Page.load", "Load"); - eventNames.put("Page.pageerror", "PageError"); - eventNames.put("Page.popup", "Popup"); - eventNames.put("Page.request", "Request"); - eventNames.put("Page.requestfailed", "RequestFailed"); - eventNames.put("Page.requestfinished", "RequestFinished"); - eventNames.put("Page.response", "Response"); - eventNames.put("Page.websocket", "WebSocket"); - eventNames.put("Page.worker", "Worker"); - - eventNames.put("WebSocket.close", "Close"); - eventNames.put("WebSocket.framereceived", "FrameReceived"); - eventNames.put("WebSocket.framesent", "FrameSent"); - eventNames.put("WebSocket.socketerror", "SocketError"); - - eventNames.put("Worker.close", "Close"); - } - private static Set waitForEvents = new HashSet<>(); static { waitForEvents.add("BrowserContext.page"); @@ -424,22 +389,22 @@ class Event extends Element { waitForEvents.add("Page.close"); waitForEvents.add("Page.console"); waitForEvents.add("Page.download"); - waitForEvents.add("Page.filechooser"); - waitForEvents.add("Page.frameattached"); - waitForEvents.add("Page.framedetached"); - waitForEvents.add("Page.framenavigated"); - waitForEvents.add("Page.pageerror"); + waitForEvents.add("Page.fileChooser"); + waitForEvents.add("Page.frameAttached"); + waitForEvents.add("Page.frameDetached"); + waitForEvents.add("Page.frameNavigated"); + waitForEvents.add("Page.pageError"); waitForEvents.add("Page.popup"); waitForEvents.add("Page.request"); - waitForEvents.add("Page.requestfailed"); - waitForEvents.add("Page.requestfinished"); + waitForEvents.add("Page.requestFailed"); + waitForEvents.add("Page.requestFinished"); waitForEvents.add("Page.response"); - waitForEvents.add("Page.websocket"); + waitForEvents.add("Page.webSocket"); waitForEvents.add("Page.worker"); - waitForEvents.add("WebSocket.framereceived"); - waitForEvents.add("WebSocket.framesent"); - waitForEvents.add("WebSocket.socketerror"); + waitForEvents.add("WebSocket.frameReceived"); + waitForEvents.add("WebSocket.frameSent"); + waitForEvents.add("WebSocket.socketError"); waitForEvents.add("Worker.close"); } @@ -452,16 +417,8 @@ class Event extends Element { } void writeListenerMethods(List output, String offset) { - if (!eventNames.containsKey(jsonPath)) { - throw new RuntimeException("Unknown event: " + jsonPath); - } - String name = eventNames.get(jsonPath); - String paramType = type.toJava(); - // TODO: remove once fixed upstream - if (paramType.equals("void")) { - paramType = parent.jsonName; - } - String listenerType = "Consumer<" + paramType + ">"; + String name = toTitle(jsonName); + String listenerType = "Consumer<" + type.toJava() + ">"; output.add(offset + "void on" + name + "(" + listenerType + " handler);"); output.add(offset + "void off" + name + "(" + listenerType + " handler);"); } @@ -470,7 +427,7 @@ class Event extends Element { if (!waitForEvents.contains(jsonPath)) { return; } - String name = eventNames.get(jsonPath); + String name = toTitle(jsonName); String methodName = "waitFor" + name; // Skip events for which there is waitFor* method in the upstream API, that method will generate the code. if (Method.waitForMethods.contains(parent.jsonPath + "." + methodName)) { diff --git a/tools/api-generator/src/main/java/com/microsoft/playwright/tools/Types.java b/tools/api-generator/src/main/java/com/microsoft/playwright/tools/Types.java index 7f89feb3..dd78bbbd 100644 --- a/tools/api-generator/src/main/java/com/microsoft/playwright/tools/Types.java +++ b/tools/api-generator/src/main/java/com/microsoft/playwright/tools/Types.java @@ -130,8 +130,8 @@ class Types { // Return structures add("ConsoleMessage.location", "Object", "Location"); add("ElementHandle.boundingBox", "Object|null", "BoundingBox", new Empty()); - add("WebSocket.framereceived", "Object", "FrameData", new Empty()); - add("WebSocket.framesent", "Object", "FrameData", new Empty()); + add("WebSocket.frameReceived", "Object", "FrameData", new Empty()); + add("WebSocket.frameSent", "Object", "FrameData", new Empty()); // Custom options add("Page.pdf.options.margin.top", "float|string", "String");