1
0
mirror of synced 2026-05-23 19:23:20 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Yury Semikhatsky dfd62f06b5 chore(release-1.11.1): roll to 1.11.1-1621490832000 (#451) 2021-05-20 09:44:00 -07:00
Yury Semikhatsky 7fb2ff34c0 cherry-pick(1.11.1): fix: wait for video to finish even if page was closed (#447) (#448) 2021-05-19 09:08:09 -07:00
Yury Semikhatsky 0585e0d108 chore(release): update version to 1.11.1 (#442) 2021-05-12 16:38:22 -07:00
Yury Semikhatsky 48d95a6543 Revert "fix: manually pipe messages from child process sdtout/stderr (#426)" (#440) (#441) 2021-05-12 16:27:55 -07:00
Yury Semikhatsky 74bf6637f3 fix: remove stray logging (#435) 2021-05-07 16:30:12 -07:00
Yury Semikhatsky 7f3ecd83b9 chore(release): set version to 1.11.0 (#431) 2021-05-07 11:17:54 -07:00
15 changed files with 37 additions and 95 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
</parent>
<artifactId>driver-bundle</artifactId>
@@ -17,7 +17,6 @@
package com.microsoft.playwright;
import com.microsoft.playwright.impl.Driver;
import com.microsoft.playwright.impl.StreamRedirectThread;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
@@ -37,13 +36,11 @@ public class TestInstall {
assertTrue(Files.exists(cli));
ProcessBuilder pb = new ProcessBuilder(cli.toString(), "install");
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
Process p = pb.start();
StreamRedirectThread stdoutThread = new StreamRedirectThread(p.getInputStream(), System.out);
StreamRedirectThread stderrThread = new StreamRedirectThread(p.getErrorStream(), System.err);
boolean result = p.waitFor(1, TimeUnit.MINUTES);
assertTrue(result, "Timed out waiting for browsers to install");
stderrThread.terminateAndJoin();
stdoutThread.terminateAndJoin();
} catch (Exception e) {
e.printStackTrace();
assertNull(e);
+1 -1
View File
@@ -6,7 +6,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
</parent>
<artifactId>driver</artifactId>
@@ -1,69 +0,0 @@
/*
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.playwright.impl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
// We manually copy stderr and stdout from child process as INHERIT for err/out streams
// doesn't work well in Java Enterprise, see
// https://github.com/microsoft/playwright-java/issues/418#issuecomment-832650650
public class StreamRedirectThread extends Thread {
private final InputStream from;
private final OutputStream to;
private volatile boolean terminated;
public StreamRedirectThread(InputStream from, OutputStream to) {
this.from = from;
this.to = to;
start();
}
@Override
public void run() {
byte[] buffer = new byte[1<<14];
try {
while (true) {
while (from.available() != 0) {
int len = from.read(buffer);
if (len != -1) {
to.write(buffer);
}
}
if (terminated) {
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
public void terminateAndJoin() {
terminated = true;
try {
join();
} catch (InterruptedException e) {
e.printStackTrace(System.err);
}
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>org.example</groupId>
<artifactId>examples</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
<name>Playwright Client Examples</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
</parent>
<artifactId>playwright</artifactId>
@@ -27,29 +27,21 @@ import java.util.concurrent.TimeUnit;
public class PlaywrightImpl extends ChannelOwner implements Playwright {
private Process driverProcess;
private StreamRedirectThread stderrThread;
public static PlaywrightImpl create() {
StreamRedirectThread stderrThread = null;
try {
Path driver = Driver.ensureDriverInstalled();
ProcessBuilder pb = new ProcessBuilder(driver.toString(), "run-driver");
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
// pb.environment().put("DEBUG", "pw:pro*");
Process p = pb.start();
stderrThread = new StreamRedirectThread(p.getErrorStream(), System.err);
Connection connection = new Connection(new PipeTransport(p.getInputStream(), p.getOutputStream()));
PlaywrightImpl result = (PlaywrightImpl) connection.waitForObjectWithKnownName("Playwright");
result.driverProcess = p;
result.stderrThread = stderrThread;
stderrThread = null;
result.initSharedSelectors(null);
return result;
} catch (IOException e) {
throw new PlaywrightException("Failed to launch driver", e);
} finally {
if (stderrThread != null) {
stderrThread.terminateAndJoin();
}
}
}
@@ -111,7 +103,6 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
if (!didClose) {
System.err.println("WARNING: Timed out while waiting for driver process to exit");
}
stderrThread.terminateAndJoin();
} catch (IOException e) {
throw new PlaywrightException("Failed to terminate", e);
} catch (InterruptedException e) {
@@ -38,7 +38,6 @@ class Utils {
.registerTypeAdapter(Optional.class, new OptionalSerializer())
.create();
String json = gson.toJson(f);
System.err.println("json = " + json);
return gson.fromJson(json, t);
}
@@ -19,8 +19,11 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.*;
@@ -101,4 +104,25 @@ public class TestScreencast extends TestBase {
Path videoPath = page.video().path();
assertFalse(Files.exists(videoPath));
}
@Test
void shouldWaitForVideoFinishWhenPageIsClosed(@TempDir Path videosDir) throws IOException {
try (Browser browser = browserType.launch(createLaunchOptions())) {
BrowserContext context = browser.newContext(
new Browser.NewContextOptions()
.setRecordVideoDir(videosDir)
.setRecordVideoSize(320, 240)
.setViewportSize(320, 240));
Page page = context.newPage();
page.evaluate("() => document.body.style.backgroundColor = 'red'");
page.waitForTimeout(500);
// First close page manually.
page.close();
context.close();
}
List<Path> files = Files.list(videosDir).collect(Collectors.toList());
assertEquals(1, files.size());
assertTrue(Files.exists(files.get(0)));
assertTrue(Files.size(files.get(0)) > 0);
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>parent-pom</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
<packaging>pom</packaging>
<name>Playwright Parent Project</name>
<description>Java library to automate Chromium, Firefox and WebKit with a single API.
+1 -1
View File
@@ -1 +1 @@
1.11.0-1620331022000
1.11.1-1621490832000
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>api-generator</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
<name>Playwright - API Generator</name>
<description>
This is an internal module used to generate Java API from the upstream Playwright
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-local-installation</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
<name>Test local installation</name>
<description>Runs Playwright test suite (copied from playwright module) against locally cached Playwright</description>
<properties>
+1 -1
View File
@@ -9,7 +9,7 @@
</parent>
<groupId>com.microsoft.playwright</groupId>
<artifactId>test-spring-boot-starter</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
<name>Test Playwright With Spring Boot</name>
<properties>
<spring.version>2.4.3</spring.version>
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>com.microsoft.playwright</groupId>
<artifactId>update-version</artifactId>
<version>1.11.0-SNAPSHOT</version>
<version>1.11.1</version>
<name>Playwright - Update Version in Documentation</name>
<description>
This is an internal module used to update versions in the documentation based on