fix: unflake exposeBindingHandleShouldNotThrowDuringNavigation (#37)

This commit is contained in:
Yury Semikhatsky 2020-10-23 12:18:40 -07:00 committed by GitHub
parent 5f578aae41
commit f9fc50b6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 49 deletions

View File

@ -187,14 +187,18 @@ public class PageImpl extends ChannelOwner implements Page {
@Override
public void addListener(EventType type, Listener<EventType> listener) {
willAddFileChooserListener();
if (type == EventType.FILECHOOSER) {
willAddFileChooserListener();
}
listeners.add(type, listener);
}
@Override
public void removeListener(EventType type, Listener<EventType> listener) {
listeners.remove(type, listener);
didRemoveFileChooserListener();
if (type == EventType.FILECHOOSER) {
didRemoveFileChooserListener();
}
}
@Override

View File

@ -24,56 +24,61 @@ import org.junit.jupiter.api.BeforeEach;
import java.io.IOException;
public class TestBase {
static Server server;
static Server httpsServer;
static BrowserType browserType;
static Playwright playwright;
static Browser browser;
static boolean isChromium;
static boolean isWebKit;
static boolean isFirefox;
static boolean headful;
Page page;
BrowserContext context;
static Server server;
static Server httpsServer;
static BrowserType browserType;
static Playwright playwright;
static Browser browser;
static boolean isChromium;
static boolean isWebKit;
static boolean isFirefox;
static boolean headful;
Page page;
BrowserContext context;
@BeforeAll
static void launchBrowser() {
playwright = Playwright.create();
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
browserType = playwright.chromium();
browser = browserType.launch(options);
isChromium = true;
isWebKit = false;
headful = false;
}
@BeforeAll
static void launchBrowser() {
playwright = Playwright.create();
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
browserType = playwright.chromium();
browser = browserType.launch(options);
isChromium = true;
isWebKit = false;
headful = false;
}
@BeforeAll
static void startServer() throws IOException {
server = Server.createHttp(8907);
httpsServer = Server.createHttps(8908);
}
@AfterAll
static void closeBrowser() {
browser.close();
browser = null;
}
@AfterAll
static void stopServer() throws IOException {
browser.close();
server.stop();
server = null;
httpsServer.stop();
httpsServer = null;
}
@BeforeAll
static void startServer() throws IOException {
server = Server.createHttp(8907);
httpsServer = Server.createHttps(8908);
}
@BeforeEach
void setUp() {
server.reset();
httpsServer.reset();
context = browser.newContext();
page = context.newPage();
}
@AfterAll
static void stopServer() throws IOException {
server.stop();
server = null;
httpsServer.stop();
httpsServer = null;
}
@AfterEach
void tearDown() {
context.close();
context = null;
page = null;
}
@BeforeEach
void createContextAndPage() {
server.reset();
httpsServer.reset();
context = browser.newContext();
page = context.newPage();
}
@AfterEach
void closeContext() {
context.close();
context = null;
page = null;
}
}