diff --git a/src/core/drive/visit.js b/src/core/drive/visit.js index d1929b03e..6cf1b52c7 100644 --- a/src/core/drive/visit.js +++ b/src/core/drive/visit.js @@ -154,10 +154,10 @@ export class Visit { } } - issueRequest() { + async issueRequest() { if (this.hasPreloadedResponse()) { this.simulateRequest() - } else if (this.shouldIssueRequest() && !this.request) { + } else if (!this.request && await this.shouldIssueRequest()) { this.request = new FetchRequest(this, FetchMethod.get, this.location) this.request.perform() } @@ -231,14 +231,14 @@ export class Visit { } } - hasCachedSnapshot() { - return this.getCachedSnapshot() != null + async hasCachedSnapshot() { + return (await this.getCachedSnapshot()) != null } async loadCachedSnapshot() { const snapshot = await this.getCachedSnapshot() if (snapshot) { - const isPreview = this.shouldIssueRequest() + const isPreview = await this.shouldIssueRequest() this.render(async () => { this.cacheSnapshot() if (this.isSamePage) { @@ -391,11 +391,11 @@ export class Visit { return typeof this.response == "object" } - shouldIssueRequest() { + async shouldIssueRequest() { if (this.isSamePage) { return false - } else if (this.action == "restore") { - return !this.hasCachedSnapshot() + } else if (this.action === "restore") { + return !(await this.hasCachedSnapshot()) } else { return this.willRender } diff --git a/src/core/native/browser_adapter.js b/src/core/native/browser_adapter.js index 7505d7f8f..c3f1086de 100644 --- a/src/core/native/browser_adapter.js +++ b/src/core/native/browser_adapter.js @@ -22,11 +22,7 @@ export class BrowserAdapter { visitRequestStarted(visit) { this.progressBar.setValue(0) - if (visit.hasCachedSnapshot() || visit.action != "restore") { - this.showVisitProgressBarAfterDelay() - } else { - this.showProgressBar() - } + this.showVisitProgressBarAfterDelay() } visitRequestCompleted(visit) { diff --git a/src/tests/functional/navigation_tests.js b/src/tests/functional/navigation_tests.js index f18a7ea1e..c4263d0f3 100644 --- a/src/tests/functional/navigation_tests.js +++ b/src/tests/functional/navigation_tests.js @@ -195,7 +195,13 @@ test("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")) })