diff --git a/src/core/frames/frame_controller.ts b/src/core/frames/frame_controller.ts index 6815bc349..e251eee6d 100644 --- a/src/core/frames/frame_controller.ts +++ b/src/core/frames/frame_controller.ts @@ -175,8 +175,12 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest } async requestSucceededWithResponse(request: FetchRequest, response: FetchResponse) { - await this.loadResponse(response) - this.resolveVisitPromise() + if (response.redirected && response.header("Turbo-Frame") == "_top") { + session.visit(response.location) + } else { + await this.loadResponse(response) + this.resolveVisitPromise() + } } requestFailedWithResponse(request: FetchRequest, response: FetchResponse) { @@ -201,8 +205,13 @@ export class FrameController implements AppearanceObserverDelegate, FetchRequest } formSubmissionSucceededWithResponse(formSubmission: FormSubmission, response: FetchResponse) { - const frame = this.findFrameElement(formSubmission.formElement, formSubmission.submitter) - frame.delegate.loadResponse(response) + if (response.redirected && response.header("Turbo-Frame") == "_top") { + session.view.clearSnapshotCache() + session.visit(response.location) + } else { + const frame = this.findFrameElement(formSubmission.formElement, formSubmission.submitter) + frame.delegate.loadResponse(response) + } } formSubmissionFailedWithResponse(formSubmission: FormSubmission, fetchResponse: FetchResponse) { diff --git a/src/tests/fixtures/form.html b/src/tests/fixtures/form.html index 1729d7a70..d34a96007 100644 --- a/src/tests/fixtures/form.html +++ b/src/tests/fixtures/form.html @@ -163,6 +163,11 @@