Skip to content

Commit

Permalink
Revert "Fix back navigation after POST form submission (#1014)"
Browse files Browse the repository at this point in the history
This reverts commit c207f5b.
  • Loading branch information
afcapel committed Nov 13, 2023
1 parent 60de74a commit 2655842
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/core/drive/visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ export class Visit {
}
}

async issueRequest() {
issueRequest() {
if (this.hasPreloadedResponse()) {
this.simulateRequest()
} else if (!this.request && await this.shouldIssueRequest()) {
} else if (this.shouldIssueRequest() && !this.request) {
this.request = new FetchRequest(this, FetchMethod.get, this.location)
this.request.perform()
}
Expand Down Expand Up @@ -231,14 +231,14 @@ export class Visit {
}
}

async hasCachedSnapshot() {
return (await this.getCachedSnapshot()) != null
hasCachedSnapshot() {
return this.getCachedSnapshot() != null
}

async loadCachedSnapshot() {
const snapshot = await this.getCachedSnapshot()
if (snapshot) {
const isPreview = await this.shouldIssueRequest()
const isPreview = this.shouldIssueRequest()
this.render(async () => {
this.cacheSnapshot()
if (this.isSamePage) {
Expand Down Expand Up @@ -391,11 +391,11 @@ export class Visit {
return typeof this.response == "object"
}

async shouldIssueRequest() {
shouldIssueRequest() {
if (this.isSamePage) {
return false
} else if (this.action === "restore") {
return !(await this.hasCachedSnapshot())
} else if (this.action == "restore") {
return !this.hasCachedSnapshot()
} else {
return this.willRender
}
Expand Down
6 changes: 5 additions & 1 deletion src/core/native/browser_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export class BrowserAdapter {

visitRequestStarted(visit) {
this.progressBar.setValue(0)
this.showVisitProgressBarAfterDelay()
if (visit.hasCachedSnapshot() || visit.action != "restore") {
this.showVisitProgressBarAfterDelay()
} else {
this.showProgressBar()
}
}

visitRequestCompleted(visit) {
Expand Down
6 changes: 0 additions & 6 deletions src/tests/functional/navigation_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,7 @@ test("following a POST form clears cache", async ({ page }) => {
await page.click("#form-post-submit")
await nextBeat() // 301 redirect response
await nextBeat() // 200 response

assert.equal(await page.textContent("h1"), "One")

await page.goBack()
await nextBeat()

assert.equal(await page.textContent("h1"), "Navigation")
assert.notOk(await hasSelector(page, "some-cached-element"))
})

Expand Down

0 comments on commit 2655842

Please sign in to comment.