Skip to content

Commit

Permalink
[bidi][java] Add browsing context reload methods implemented by the b…
Browse files Browse the repository at this point in the history
…rowsers
  • Loading branch information
pujagani committed Sep 20, 2023
1 parent 3a126ba commit 79f73c4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,36 @@ public List<BrowsingContextInfo> getTopLevelContexts() {
new Command<>("browsingContext.getTree", new HashMap<>(), browsingContextInfoListMapper));
}

// Yet to be implemented by browser vendors
private void reload() {
this.bidi.send(new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id)));
public NavigationResult reload() {
return this.bidi.send(new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id), navigationInfoMapper));
}

// Yet to be implemented by browser vendors
private void reload(boolean ignoreCache) {
this.bidi.send(new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id, "ignoreCache", ignoreCache)));
private NavigationResult reload(boolean ignoreCache) {
return this.bidi.send(new Command<>(
RELOAD,
ImmutableMap.of(CONTEXT, id, "ignoreCache", ignoreCache),
navigationInfoMapper));
}

// Yet to be implemented by browser vendors
private void reload(ReadinessState readinessState) {
this.bidi.send(
new Command<>(RELOAD, ImmutableMap.of(CONTEXT, id, "wait", readinessState.toString())));
// TODO: Handle timeouts in case of Readiness state "interactive" and "complete".
// Refer https://github.com/w3c/webdriver-bidi/issues/188
public NavigationResult reload(ReadinessState readinessState) {
return this.bidi.send(
new Command<>(
RELOAD,
ImmutableMap.of(CONTEXT, id, "wait", readinessState.toString()),
navigationInfoMapper));
}

// Yet to be implemented by browser vendors
private void reload(boolean ignoreCache, ReadinessState readinessState) {
this.bidi.send(
private NavigationResult reload(boolean ignoreCache, ReadinessState readinessState) {
return this.bidi.send(
new Command<>(
RELOAD,
ImmutableMap.of(
CONTEXT, id, "ignoreCache", ignoreCache, "wait", readinessState.toString())));
CONTEXT, id, "ignoreCache", ignoreCache, "wait", readinessState.toString()),
navigationInfoMapper));
}

// Yet to be implemented by browser vendors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,36 @@ void canCloseATab() {
// TODO: Add a test for closing the last tab once the behavior is finalized
// Refer: https://github.com/w3c/webdriver-bidi/issues/187

@Test
@NotYetImplemented(SAFARI)
@NotYetImplemented(IE)
void canReloadABrowsingContext() {
BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB);

String url = server.whereIs("/bidi/logEntryAdded.html");
browsingContext.navigate(url, ReadinessState.COMPLETE);

NavigationResult reloadInfo = browsingContext.reload();

assertThat(reloadInfo.getNavigationId()).isNotNull();
assertThat(reloadInfo.getUrl()).contains("/bidi/logEntryAdded.html");
}

@Test
@NotYetImplemented(SAFARI)
@NotYetImplemented(IE)
void canReloadWithReadinessState() {
BrowsingContext browsingContext = new BrowsingContext(driver, WindowType.TAB);

String url = server.whereIs("/bidi/logEntryAdded.html");
browsingContext.navigate(url, ReadinessState.COMPLETE);

NavigationResult reloadInfo = browsingContext.reload(ReadinessState.COMPLETE);

assertThat(reloadInfo.getNavigationId()).isNotNull();
assertThat(reloadInfo.getUrl()).contains("/bidi/logEntryAdded.html");
}

@AfterEach
public void quitDriver() {
if (driver != null) {
Expand Down

0 comments on commit 79f73c4

Please sign in to comment.