Skip to content

Commit 7fb2ff3

Browse files
authored
cherry-pick(1.11.1): fix: wait for video to finish even if page was closed (#447) (#448)
1 parent 0585e0d commit 7fb2ff3

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

playwright/src/test/java/com/microsoft/playwright/TestScreencast.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import org.junit.jupiter.api.Test;
2020
import org.junit.jupiter.api.io.TempDir;
2121

22+
import java.io.IOException;
2223
import java.nio.file.Files;
2324
import java.nio.file.Path;
25+
import java.util.List;
26+
import java.util.stream.Collectors;
2427

2528
import static org.junit.jupiter.api.Assertions.*;
2629

@@ -101,4 +104,25 @@ void shouldDeleteVideo(@TempDir Path videosDir) {
101104
Path videoPath = page.video().path();
102105
assertFalse(Files.exists(videoPath));
103106
}
107+
108+
@Test
109+
void shouldWaitForVideoFinishWhenPageIsClosed(@TempDir Path videosDir) throws IOException {
110+
try (Browser browser = browserType.launch(createLaunchOptions())) {
111+
BrowserContext context = browser.newContext(
112+
new Browser.NewContextOptions()
113+
.setRecordVideoDir(videosDir)
114+
.setRecordVideoSize(320, 240)
115+
.setViewportSize(320, 240));
116+
Page page = context.newPage();
117+
page.evaluate("() => document.body.style.backgroundColor = 'red'");
118+
page.waitForTimeout(500);
119+
// First close page manually.
120+
page.close();
121+
context.close();
122+
}
123+
List<Path> files = Files.list(videosDir).collect(Collectors.toList());
124+
assertEquals(1, files.size());
125+
assertTrue(Files.exists(files.get(0)));
126+
assertTrue(Files.size(files.get(0)) > 0);
127+
}
104128
}

scripts/CLI_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.11.0-1620331022000
1+
1.11.0-1621402998000

0 commit comments

Comments
 (0)