diff --git a/src/core/drive/visit.js b/src/core/drive/visit.js index d1929b03e..d770860cc 100644 --- a/src/core/drive/visit.js +++ b/src/core/drive/visit.js @@ -128,12 +128,9 @@ export class Visit { if (this.state == VisitState.started) { this.recordTimingMetric(TimingMetric.visitEnd) this.state = VisitState.completed - this.followRedirect() - if (!this.followedRedirect) { - this.adapter.visitCompleted(this) - this.delegate.visitCompleted(this) - } + this.adapter.visitCompleted(this) + this.delegate.visitCompleted(this) } } @@ -147,6 +144,7 @@ export class Visit { changeHistory() { if (!this.historyChanged && this.updateHistory) { + this.followRedirect() const actionForHistory = this.location.href === this.referrer?.href ? "replace" : this.action const method = getHistoryMethodForAction(actionForHistory) this.history.update(method, this.location, this.restorationIdentifier) @@ -259,12 +257,7 @@ export class Visit { followRedirect() { if (this.redirectedToLocation && !this.followedRedirect && this.response?.redirected) { - this.adapter.visitProposedToLocation(this.redirectedToLocation, { - action: "replace", - response: this.response, - shouldCacheSnapshot: false, - willRender: false - }) + this.location = this.redirectedToLocation this.followedRedirect = true } } diff --git a/src/tests/functional/navigation_tests.js b/src/tests/functional/navigation_tests.js index f18a7ea1e..e96ae5cbb 100644 --- a/src/tests/functional/navigation_tests.js +++ b/src/tests/functional/navigation_tests.js @@ -361,7 +361,7 @@ test("test following a redirection", async ({ page }) => { await page.click("#redirection-link") await nextBody(page) assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html") - assert.equal(await visitAction(page), "replace") + assert.equal(await visitAction(page), "advance") }) test("test clicking the back button after redirection", async ({ page }) => {