Skip to content

Commit fdec32c

Browse files
authored
chore: simplify handler result (#959)
1 parent 7e285ff commit fdec32c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ private void maybeDisableNetworkInterception() {
481481

482482
void handleRoute(RouteImpl route) {
483483
Router.HandleResult handled = routes.handle(route);
484-
if (handled != Router.HandleResult.NoMatchingHandler) {
484+
if (handled == Router.HandleResult.FoundMatchingHandler) {
485485
maybeDisableNetworkInterception();
486486
}
487-
if (handled != Router.HandleResult.Handled){
487+
if (!route.isHandled()){
488488
route.resume();
489489
}
490490
}

playwright/src/main/java/com/microsoft/playwright/impl/PageImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ protected void handleEvent(String event, JsonObject params) {
196196
} else if ("route".equals(event)) {
197197
RouteImpl route = connection.getExistingObject(params.getAsJsonObject("route").get("guid").getAsString());
198198
Router.HandleResult handled = routes.handle(route);
199-
if (handled != Router.HandleResult.NoMatchingHandler) {
199+
if (handled == Router.HandleResult.FoundMatchingHandler) {
200200
maybeDisableNetworkInterception();
201201
}
202-
if (handled != Router.HandleResult.Handled) {
202+
if (!route.isHandled()) {
203203
browserContext.handleRoute(route);
204204
}
205205
} else if ("video".equals(event)) {

playwright/src/main/java/com/microsoft/playwright/impl/Router.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ int size() {
7171
return routes.size();
7272
}
7373

74-
enum HandleResult { NoMatchingHandler, MatchedHandlerButNotHandled, Handled }
74+
enum HandleResult { NoMatchingHandler, FoundMatchingHandler}
7575
HandleResult handle(RouteImpl route) {
7676
HandleResult result = HandleResult.NoMatchingHandler;
7777
for (Iterator<RouteInfo> it = routes.iterator(); it.hasNext();) {
7878
RouteInfo info = it.next();
7979
if (info.handle(route)) {
80+
result = HandleResult.FoundMatchingHandler;
8081
if (info.isDone()) {
8182
it.remove();
8283
}
8384
if (route.isHandled()) {
84-
return HandleResult.Handled;
85+
break;
8586
}
86-
result = HandleResult.MatchedHandlerButNotHandled;
8787
}
8888
}
8989
return result;

0 commit comments

Comments
 (0)