chore(1.43): roll 1.43-beta driver (#1539)
This commit is contained in:
@@ -11,7 +11,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Chromium <!-- GEN:chromium-version -->124.0.6367.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Chromium <!-- GEN:chromium-version -->124.0.6367.8<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
||||
| Firefox <!-- GEN:firefox-version -->124.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
|
||||
@@ -44,23 +44,6 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public interface BrowserContext extends AutoCloseable {
|
||||
|
||||
/**
|
||||
* <strong>NOTE:</strong> Only works with Chromium browser's persistent context.
|
||||
*
|
||||
* <p> Emitted when new background page is created in the context.
|
||||
* <pre>{@code
|
||||
* Page backgroundPage = context.waitForBackgroundPage(() -> {
|
||||
* page.getByText("activate extension").click();
|
||||
* });
|
||||
* System.out.println(backgroundPage.evaluate("location.href"));
|
||||
* }</pre>
|
||||
*/
|
||||
void onBackgroundPage(Consumer<Page> handler);
|
||||
/**
|
||||
* Removes handler that was previously added with {@link #onBackgroundPage onBackgroundPage(handler)}.
|
||||
*/
|
||||
void offBackgroundPage(Consumer<Page> handler);
|
||||
|
||||
/**
|
||||
* Emitted when Browser context gets closed. This might happen because of one of the following:
|
||||
* <ul>
|
||||
@@ -568,14 +551,6 @@ public interface BrowserContext extends AutoCloseable {
|
||||
* @since v1.8
|
||||
*/
|
||||
void addInitScript(Path script);
|
||||
/**
|
||||
* <strong>NOTE:</strong> Background pages are only supported on Chromium-based browsers.
|
||||
*
|
||||
* <p> All existing background pages in the context.
|
||||
*
|
||||
* @since v1.11
|
||||
*/
|
||||
List<Page> backgroundPages();
|
||||
/**
|
||||
* Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
|
||||
*
|
||||
|
||||
@@ -47,7 +47,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
private final TracingImpl tracing;
|
||||
private final APIRequestContextImpl request;
|
||||
final List<PageImpl> pages = new ArrayList<>();
|
||||
final List<PageImpl> backgroundPages = new ArrayList<>();
|
||||
|
||||
final Router routes = new Router();
|
||||
private boolean closeWasCalled;
|
||||
@@ -83,7 +82,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
}
|
||||
|
||||
enum EventType {
|
||||
BACKGROUNDPAGE,
|
||||
CLOSE,
|
||||
CONSOLE,
|
||||
DIALOG,
|
||||
@@ -131,16 +129,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackgroundPage(Consumer<Page> handler) {
|
||||
listeners.add(EventType.BACKGROUNDPAGE, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offBackgroundPage(Consumer<Page> handler) {
|
||||
listeners.remove(EventType.BACKGROUNDPAGE, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(Consumer<BrowserContext> handler) {
|
||||
listeners.add(EventType.CLOSE, handler);
|
||||
@@ -337,11 +325,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Page> backgroundPages() {
|
||||
return new ArrayList<>(backgroundPages);
|
||||
}
|
||||
|
||||
private void addInitScriptImpl(String script) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("source", script);
|
||||
@@ -730,10 +713,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
if (page.opener() != null && !page.opener().isClosed()) {
|
||||
page.opener().notifyPopup(page);
|
||||
}
|
||||
} else if ("backgroundPage".equals(event)) {
|
||||
PageImpl page = connection.getExistingObject(params.getAsJsonObject("page").get("guid").getAsString());
|
||||
backgroundPages.add(page);
|
||||
listeners.notify(EventType.BACKGROUNDPAGE, page);
|
||||
} else if ("bindingCall".equals(event)) {
|
||||
BindingCall bindingCall = connection.getExistingObject(params.getAsJsonObject("binding").get("guid").getAsString());
|
||||
BindingCallback binding = bindings.get(bindingCall.name());
|
||||
|
||||
@@ -203,7 +203,6 @@ public class PageImpl extends ChannelOwner implements Page {
|
||||
void didClose() {
|
||||
isClosed = true;
|
||||
browserContext.pages.remove(this);
|
||||
browserContext.backgroundPages.remove(this);
|
||||
listeners.notify(EventType.CLOSE, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,30 +59,4 @@ public class TestLaunch extends TestBase {
|
||||
public static boolean canRunExtensionTest() {
|
||||
return canRunHeaded() && isChromium();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf(value="com.microsoft.playwright.TestLaunch#canRunExtensionTest", disabledReason="Only Chromium Headed")
|
||||
void shouldReturnBackgroundPages(@TempDir Path tmpDir) throws IOException {
|
||||
Path profileDir = tmpDir.resolve("profile");
|
||||
Files.createDirectories(profileDir);
|
||||
String extensionPath = Paths.get("src/test/resources/simple-extension").toAbsolutePath().toString();
|
||||
initBrowserType();
|
||||
BrowserContext context = browserType.launchPersistentContext(profileDir, new BrowserType.LaunchPersistentContextOptions()
|
||||
.setHeadless(false)
|
||||
.setArgs(asList(
|
||||
"--disable-extensions-except=" + extensionPath,
|
||||
"--load-extension=" + extensionPath
|
||||
)));
|
||||
List<Page> backgroundPages = context.backgroundPages();
|
||||
context.onBackgroundPage(page1 -> backgroundPages.add(page1));
|
||||
context.waitForCondition(() -> !backgroundPages.isEmpty(),
|
||||
new BrowserContext.WaitForConditionOptions().setTimeout(10_000));
|
||||
Page backgroundPage = backgroundPages.get(0);
|
||||
assertNotNull(backgroundPage);
|
||||
assertTrue(context.backgroundPages().contains(backgroundPage));
|
||||
assertFalse(context.pages().contains(backgroundPage));
|
||||
context.close();
|
||||
assertEquals(0, context.pages().size());
|
||||
assertEquals(0, context.backgroundPages().size());
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.44.0-alpha-2024-04-02
|
||||
1.43.0-beta-1712173949000
|
||||
|
||||
Reference in New Issue
Block a user