chore(driver): roll to 1.62.0 (#1954)
This commit is contained in:
@@ -12,7 +12,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Chromium <!-- GEN:chromium-version -->151.0.7922.34<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| WebKit <!-- GEN:webkit-version -->26.5<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
||||
| Firefox <!-- GEN:firefox-version -->152.0.4<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Firefox <!-- GEN:firefox-version -->153.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
## Documentation
|
||||
|
||||
|
||||
@@ -363,13 +363,6 @@ public interface BrowserContext extends AutoCloseable {
|
||||
}
|
||||
}
|
||||
class RouteFromHAROptions {
|
||||
/**
|
||||
* If set to {@code true}, requests made via {@code APIRequestContext} (such as {@link
|
||||
* com.microsoft.playwright.BrowserContext#request BrowserContext.request()} or {@link
|
||||
* com.microsoft.playwright.Page#request Page.request()}) are also served from the HAR file. By default these requests are
|
||||
* sent to the network, matching the behavior prior to v1.62. Defaults to {@code false} for backward compatibility.
|
||||
*/
|
||||
public Boolean interceptAPIRequests;
|
||||
/**
|
||||
* <ul>
|
||||
* <li> If set to 'abort' any request not found in the HAR file will be aborted.</li>
|
||||
@@ -401,16 +394,6 @@ public interface BrowserContext extends AutoCloseable {
|
||||
*/
|
||||
public Object url;
|
||||
|
||||
/**
|
||||
* If set to {@code true}, requests made via {@code APIRequestContext} (such as {@link
|
||||
* com.microsoft.playwright.BrowserContext#request BrowserContext.request()} or {@link
|
||||
* com.microsoft.playwright.Page#request Page.request()}) are also served from the HAR file. By default these requests are
|
||||
* sent to the network, matching the behavior prior to v1.62. Defaults to {@code false} for backward compatibility.
|
||||
*/
|
||||
public RouteFromHAROptions setInterceptAPIRequests(boolean interceptAPIRequests) {
|
||||
this.interceptAPIRequests = interceptAPIRequests;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* <ul>
|
||||
* <li> If set to 'abort' any request not found in the HAR file will be aborted.</li>
|
||||
|
||||
@@ -547,9 +547,6 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
|
||||
HARRouter harRouter = new HARRouter(connection.localUtils, har, options.notFound);
|
||||
onClose(context -> harRouter.dispose());
|
||||
route(matcher, route -> harRouter.handle(route), null);
|
||||
if (options.interceptAPIRequests != null && options.interceptAPIRequests) {
|
||||
harRouter.addAPIRequestRoute(this, options.url);
|
||||
}
|
||||
}
|
||||
|
||||
private void route(UrlMatcher matcher, Consumer<Route> handler, RouteOptions options) {
|
||||
|
||||
@@ -25,23 +25,18 @@ import com.microsoft.playwright.Route;
|
||||
import com.microsoft.playwright.options.HarNotFound;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.microsoft.playwright.impl.ChannelOwner.NO_TIMEOUT;
|
||||
import static com.microsoft.playwright.impl.LoggingSupport.*;
|
||||
import static com.microsoft.playwright.impl.Serialization.fromNameValues;
|
||||
import static com.microsoft.playwright.impl.Serialization.gson;
|
||||
import static com.microsoft.playwright.impl.Utils.toJsRegexFlags;
|
||||
|
||||
public class HARRouter {
|
||||
private final LocalUtils localUtils;
|
||||
private final HarNotFound defaultAction;
|
||||
private final String harId;
|
||||
private final List<Map.Entry<BrowserContextImpl, String>> apiRequestRegistrations = new ArrayList<>();
|
||||
|
||||
HARRouter(LocalUtils localUtils, Path harFile, HarNotFound defaultAction) {
|
||||
this.localUtils = localUtils;
|
||||
@@ -56,21 +51,6 @@ public class HARRouter {
|
||||
harId = json.get("harId").getAsString();
|
||||
}
|
||||
|
||||
void addAPIRequestRoute(BrowserContextImpl context, Object url) {
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("harId", harId);
|
||||
if (url instanceof String) {
|
||||
params.addProperty("urlGlob", (String) url);
|
||||
} else if (url instanceof Pattern) {
|
||||
Pattern pattern = (Pattern) url;
|
||||
params.addProperty("urlRegexSource", pattern.pattern());
|
||||
params.addProperty("urlRegexFlags", toJsRegexFlags(pattern));
|
||||
}
|
||||
params.addProperty("notFound", defaultAction == HarNotFound.FALLBACK ? "fallback" : "abort");
|
||||
JsonObject result = context.sendMessage("routeAPIRequestsFromHar", params, NO_TIMEOUT).getAsJsonObject();
|
||||
apiRequestRegistrations.add(new java.util.AbstractMap.SimpleEntry<>(context, result.get("registrationId").getAsString()));
|
||||
}
|
||||
|
||||
void handle(Route route) {
|
||||
Request request = route.request();
|
||||
|
||||
@@ -147,12 +127,6 @@ public class HARRouter {
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
for (Map.Entry<BrowserContextImpl, String> registration : apiRequestRegistrations) {
|
||||
JsonObject unrouteParams = new JsonObject();
|
||||
unrouteParams.addProperty("registrationId", registration.getValue());
|
||||
registration.getKey().sendMessageAsync("unrouteAPIRequestsFromHar", unrouteParams);
|
||||
}
|
||||
apiRequestRegistrations.clear();
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty("harId", harId);
|
||||
localUtils.sendMessageAsync("harClose", params);
|
||||
|
||||
@@ -514,31 +514,6 @@ public class TestBrowserContextHar extends TestBase {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFulfillAPIRequestContextRequestsFromHAR(@TempDir Path tmpDir) {
|
||||
setJsonRoute("/api/data", "{\"hello\": \"live\"}");
|
||||
Path harPath = tmpDir.resolve("api.har");
|
||||
try (BrowserContext context1 = browser.newContext()) {
|
||||
context1.routeFromHAR(harPath, new BrowserContext.RouteFromHAROptions().setUpdate(true));
|
||||
Page page1 = context1.newPage();
|
||||
page1.navigate(server.EMPTY_PAGE);
|
||||
APIResponse recorded = page1.request().get(server.PREFIX + "/api/data");
|
||||
assertEquals("{\"hello\": \"live\"}", recorded.text());
|
||||
}
|
||||
|
||||
// Now stop serving on the network side - the request must come from the HAR.
|
||||
setJsonRoute("/api/data", "NOT_FROM_HAR");
|
||||
try (BrowserContext context2 = browser.newContext()) {
|
||||
context2.routeFromHAR(harPath, new BrowserContext.RouteFromHAROptions().setInterceptAPIRequests(true));
|
||||
Page page2 = context2.newPage();
|
||||
APIResponse replayed = page2.request().get(server.PREFIX + "/api/data");
|
||||
assertEquals("{\"hello\": \"live\"}", replayed.text());
|
||||
Timing timing = replayed.timing();
|
||||
assertEquals(-1, timing.startTime);
|
||||
assertEquals(-1, timing.responseEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotInterceptAPIRequestContextRequestsByDefault(@TempDir Path tmpDir) {
|
||||
setJsonRoute("/api/data", "{\"hello\": \"live\"}");
|
||||
|
||||
@@ -193,9 +193,7 @@ public class TestWorkers extends TestBase {
|
||||
page.navigate(server.EMPTY_PAGE);
|
||||
Worker worker = page.waitForWorker(() -> page.evaluate(
|
||||
"() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))"));
|
||||
// https://github.com/microsoft/playwright/issues/38919
|
||||
String expected = isFirefox() ? "10,000.2" : "10\u00A0000,2";
|
||||
assertEquals(expected, worker.evaluate("() => (10000.20).toLocaleString()"));
|
||||
assertEquals("10\u00A0000,2", worker.evaluate("() => (10000.20).toLocaleString()"));
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.62.0-alpha-2026-07-22
|
||||
1.62.0
|
||||
|
||||
Reference in New Issue
Block a user