chore: roll to 1.11.0-next-1617387566000 (#384)

This commit is contained in:
Yury Semikhatsky 2021-04-02 14:10:43 -07:00 committed by GitHub
parent 1ff5671b12
commit 5cd00cc4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 21 deletions

View File

@ -70,7 +70,7 @@ public interface BrowserType {
public List<String> args;
/**
* Browser distribution channel. Read more about using <a
* href="https://playwright.dev/java/docs/browsers#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
* href="https://playwright.dev/java/docs/browsers/#google-chrome--microsoft-edge">Google Chrome and Microsoft Edge</a>.
*/
public BrowserChannel channel;
/**

View File

@ -61,7 +61,7 @@ public interface Download {
String failure();
/**
* Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if
* necessary. The method throws when connected remotely via {@link BrowserType#connect BrowserType.connect()}.
* necessary. The method throws when connected remotely.
*/
Path path();
/**

View File

@ -41,11 +41,11 @@ import java.util.*;
*/
public interface Playwright extends AutoCloseable {
/**
* This object can be used to launch or connect to Chromium, returning instances of {@code ChromiumBrowser}.
* This object can be used to launch or connect to Chromium, returning instances of {@code Browser}.
*/
BrowserType chromium();
/**
* This object can be used to launch or connect to Firefox, returning instances of {@code FirefoxBrowser}.
* This object can be used to launch or connect to Firefox, returning instances of {@code Browser}.
*/
BrowserType firefox();
/**
@ -54,7 +54,7 @@ public interface Playwright extends AutoCloseable {
*/
Selectors selectors();
/**
* This object can be used to launch or connect to WebKit, returning instances of {@code WebKitBrowser}.
* This object can be used to launch or connect to WebKit, returning instances of {@code Browser}.
*/
BrowserType webkit();
/**

View File

@ -32,8 +32,7 @@ public interface Video {
void delete();
/**
* Returns the file system path this video will be recorded to. The video is guaranteed to be written to the filesystem
* upon closing the browser context. This method throws when connected remotely via {@link BrowserType#connect
* BrowserType.connect()}.
* upon closing the browser context. This method throws when connected remotely.
*/
Path path();
/**

View File

@ -395,8 +395,11 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
}
} else if ("page".equals(event)) {
PageImpl page = connection.getExistingObject(params.getAsJsonObject("page").get("guid").getAsString());
listeners.notify(EventType.PAGE, page);
pages.add(page);
listeners.notify(EventType.PAGE, page);
if (page.opener() != null && !page.opener().isClosed()) {
page.opener().notifyPopup(page);
}
} else if ("bindingCall".equals(event)) {
BindingCall bindingCall = connection.getExistingObject(params.getAsJsonObject("binding").get("guid").getAsString());
BindingCallback binding = bindings.get(bindingCall.name());

View File

@ -71,6 +71,7 @@ public class PageImpl extends ChannelOwner implements Page {
final Set<Worker> workers = new HashSet<>();
private final TimeoutSettings timeoutSettings;
private VideoImpl video;
private final PageImpl opener;
enum EventType {
CLOSE,
@ -109,6 +110,11 @@ public class PageImpl extends ChannelOwner implements Page {
frames.add(mainFrame);
timeoutSettings = new TimeoutSettings(browserContext.timeoutSettings);
waitableClosedOrCrashed = createWaitForCloseHelper();
if (initializer.has("opener")) {
opener = connection.getExistingObject(initializer.getAsJsonObject("opener").get("guid").getAsString());
} else {
opener = null;
}
}
@Override
@ -121,10 +127,6 @@ public class PageImpl extends ChannelOwner implements Page {
} else {
dialog.dismiss();
}
} else if ("popup".equals(event)) {
String guid = params.getAsJsonObject("page").get("guid").getAsString();
PageImpl popup = connection.getExistingObject(guid);
listeners.notify(EventType.POPUP, popup);
} else if ("worker".equals(event)) {
String guid = params.getAsJsonObject("worker").get("guid").getAsString();
WorkerImpl worker = connection.getExistingObject(guid);
@ -235,6 +237,10 @@ public class PageImpl extends ChannelOwner implements Page {
}
}
void notifyPopup(PageImpl popup) {
listeners.notify(EventType.POPUP, popup);
}
void didClose() {
isClosed = true;
browserContext.pages.remove(this);
@ -849,14 +855,11 @@ public class PageImpl extends ChannelOwner implements Page {
}
@Override
public Page opener() {
return withLogging("Page.opener", () -> {
JsonObject result = sendMessage("opener").getAsJsonObject();
if (!result.has("page")) {
return null;
}
return connection.getExistingObject(result.getAsJsonObject("page").get("guid").getAsString());
});
public PageImpl opener() {
if (opener == null || opener.isClosed()) {
return null;
}
return opener;
}
@Override

View File

@ -1 +1 @@
1.11.0-next-1617218236000
1.11.0-next-1617387566000