Skip to content

Commit c8da7c2

Browse files
committed
[java] Making sure "loggingPrefs" only affects Chrome
Fixes #10222
1 parent 3334607 commit c8da7c2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

java/src/org/openqa/selenium/remote/session/ChromeFilter.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@
1717

1818
package org.openqa.selenium.remote.session;
1919

20-
import org.openqa.selenium.remote.CapabilityType;
21-
2220
import java.util.Map;
2321
import java.util.Objects;
2422
import java.util.TreeMap;
2523
import java.util.stream.Collectors;
2624

2725
import static org.openqa.selenium.remote.Browser.CHROME;
26+
import static org.openqa.selenium.remote.CapabilityType.BROWSER_NAME;
2827

2928
public class ChromeFilter implements CapabilitiesFilter {
3029
@Override
3130
public Map<String, Object> apply(Map<String, Object> unmodifiedCaps) {
31+
String browserName = (String) unmodifiedCaps.getOrDefault(BROWSER_NAME, "");
3232
Map<String, Object> caps = unmodifiedCaps.entrySet().parallelStream()
3333
.filter(
3434
entry ->
35-
(CapabilityType.BROWSER_NAME.equals(entry.getKey()) && CHROME.is(String.valueOf(entry.getValue()))) ||
35+
(BROWSER_NAME.equals(entry.getKey()) && CHROME.is(String.valueOf(entry.getValue()))) ||
3636
entry.getKey().startsWith("goog:") ||
3737
"chromeOptions".equals(entry.getKey()) ||
38-
"loggingPrefs".equals(entry.getKey()))
38+
("loggingPrefs".equals(entry.getKey()) && CHROME.is(browserName)))
3939
.filter(entry -> Objects.nonNull(entry.getValue()))
4040
.distinct()
4141
.collect(Collectors.toMap(
@@ -45,11 +45,13 @@ public Map<String, Object> apply(Map<String, Object> unmodifiedCaps) {
4545
TreeMap::new));
4646

4747
// We may need to map the chromeoptions to the new form
48-
if (caps.containsKey("chromeOptions") && !caps.containsKey("goog:chromeOptions")) {
48+
if (caps.containsKey("chromeOptions") && !caps.containsKey("goog:chromeOptions")
49+
&& CHROME.is(browserName)) {
4950
caps.put("goog:chromeOptions", caps.get("chromeOptions"));
5051
}
5152

52-
if (caps.containsKey("loggingPrefs") && !caps.containsKey("goog:loggingPrefs")) {
53+
if (caps.containsKey("loggingPrefs") && !caps.containsKey("goog:loggingPrefs")
54+
&& CHROME.is(browserName)) {
5355
caps.put("goog:loggingPrefs", caps.get("loggingPrefs"));
5456
}
5557

0 commit comments

Comments
 (0)