Skip to content

Commit 46cef40

Browse files
committed
[java] Adding --allow-origins when starting GeckoDriver
Needed for Firefox 100 and above. GeckoDriver 0.31.0 or above is needed for this.
1 parent d5277ea commit 46cef40

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

java/src/org/openqa/selenium/firefox/GeckoDriverService.java

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

1818
package org.openqa.selenium.firefox;
1919

20-
import static java.util.Collections.unmodifiableList;
21-
import static java.util.concurrent.TimeUnit.MILLISECONDS;
22-
import static org.openqa.selenium.remote.Browser.FIREFOX;
23-
2420
import com.google.auto.service.AutoService;
2521
import com.google.common.io.ByteStreams;
2622

@@ -39,6 +35,10 @@
3935
import java.util.Map;
4036
import java.util.Optional;
4137

38+
import static java.util.Collections.unmodifiableList;
39+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
40+
import static org.openqa.selenium.remote.Browser.FIREFOX;
41+
4242
/**
4343
* Manages the life and death of an GeckoDriver aka 'wires'.
4444
*/
@@ -187,15 +187,18 @@ protected File findDefaultExecutable() {
187187
@Override
188188
protected List<String> createArgs() {
189189
List<String> args = new ArrayList<>();
190+
int wsPort = PortProber.findFreePort();
190191
args.add(String.format("--port=%d", getPort()));
191-
args.add(String.format("--websocket-port=%d", PortProber.findFreePort()));
192+
args.add(String.format("--websocket-port=%d", wsPort));
193+
args.add(String.format("--allow-origins=http://localhost:%d", wsPort));
192194
if (firefoxBinary != null) {
193195
args.add("-b");
194196
args.add(firefoxBinary.getPath());
195197
} else {
196198
// Read system property for Firefox binary and use those if they are set
197-
Optional<Executable> executable = Optional.ofNullable(FirefoxBinary.locateFirefoxBinaryFromSystemProperty());
198-
executable.ifPresent( e -> {
199+
Optional<Executable> executable =
200+
Optional.ofNullable(FirefoxBinary.locateFirefoxBinaryFromSystemProperty());
201+
executable.ifPresent(e -> {
199202
args.add("-b");
200203
args.add(e.getPath());
201204
});

0 commit comments

Comments
 (0)