diff --git a/java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java b/java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java index 86d954967a856..702bd9651a96d 100644 --- a/java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java +++ b/java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java @@ -229,8 +229,8 @@ public FirefoxDriver(GeckoDriverService driverService, Capabilities desiredCapab private FirefoxDriver(CommandExecutor executor, Capabilities desiredCapabilities, Capabilities requiredCapabilities) { super(executor, - dropCapabilities(desiredCapabilities, BINARY, PROFILE), - dropCapabilities(requiredCapabilities, BINARY, PROFILE)); + dropCapabilities(desiredCapabilities), + dropCapabilities(requiredCapabilities)); } private static final CommandExecutor createCommandExecutor(Capabilities desiredCapabilities, @@ -351,16 +351,23 @@ protected void stopClient(Capabilities desiredCapabilities, Capabilities require * Used for capabilities which aren't BeanToJson-convertable, and are only used by the local * launcher. */ - private static Capabilities dropCapabilities(Capabilities capabilities, String... keysToRemove) { + private static Capabilities dropCapabilities(Capabilities capabilities) { if (capabilities == null) { return new DesiredCapabilities(); } - final Set toRemove = Sets.newHashSet(keysToRemove); - DesiredCapabilities caps = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate() { - public boolean apply(String key) { - return !toRemove.contains(key); - } - })); + + DesiredCapabilities caps; + + if (isLegacy(capabilities)) { + final Set toRemove = Sets.newHashSet(BINARY, PROFILE); + caps = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate() { + public boolean apply(String key) { + return !toRemove.contains(key); + } + })); + } else { + caps = new DesiredCapabilities(capabilities); + } // Ensure that the proxy is in a state fit to be sent to the extension Proxy proxy = Proxy.extractFrom(capabilities);