Skip to content

Commit 3f755a7

Browse files
committed
fix getBrowserGeolocation
1 parent 3adb987 commit 3f755a7

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

java/test/org/openqa/selenium/bidi/emulation/EmulationTest.java

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,10 @@ class EmulationTest extends JupiterTestBase {
4848
Object getBrowserGeolocation(WebDriver driver, String userContext) {
4949
JavascriptExecutor executor = (JavascriptExecutor) driver;
5050

51-
BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle());
52-
String url = appServer.whereIs("blank.html");
53-
context.navigate(url, ReadinessState.COMPLETE);
54-
driver.switchTo().window(context.getId());
51+
String originValue = (String) executor.executeScript("return window.location.origin;");
5552

5653
Permission permission = new Permission(driver);
57-
Script script = new Script(driver);
58-
EvaluateResult origin =
59-
script.callFunctionInBrowsingContext(
60-
context.getId(),
61-
"() => {return window.location.origin;}",
62-
true,
63-
Optional.empty(),
64-
Optional.empty(),
65-
Optional.empty());
66-
67-
String originValue = (String) ((EvaluateResultSuccess) origin).getResult().getValue().get();
68-
69-
permission.setPermission(Map.of("name", "geolocation"), PermissionState.GRANTED, originValue);
70-
71-
EvaluateResult result =
72-
script.callFunctionInBrowsingContext(
73-
context.getId(),
74-
GET_GEOLOCATION_PERMISSION,
75-
true,
76-
Optional.empty(),
77-
Optional.empty(),
78-
Optional.empty());
79-
80-
String resultValue = (String) ((EvaluateResultSuccess) result).getResult().getValue().get();
81-
System.out.println(resultValue);
54+
permission.setPermission(Map.of("name", "geolocation"), PermissionState.GRANTED, originValue, userContext);
8255

8356
return executor.executeAsyncScript(
8457
"const callback = arguments[arguments.length - 1];\n"

0 commit comments

Comments
 (0)