From 3e1f97d6740481505bd12fce24d03c494eb8a231 Mon Sep 17 00:00:00 2001 From: Paul Shippy Date: Wed, 19 Jun 2024 14:06:45 -0700 Subject: [PATCH 1/4] Reproduce issue by removing script tag on target page --- src/tests/fixtures/tabs/three.html | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tests/fixtures/tabs/three.html b/src/tests/fixtures/tabs/three.html index 517d0dc2b..90e869918 100644 --- a/src/tests/fixtures/tabs/three.html +++ b/src/tests/fixtures/tabs/three.html @@ -3,7 +3,6 @@ Frame - From 438588d362dc18ffc4e4b11b0c3147a1eb5475e5 Mon Sep 17 00:00:00 2001 From: Paul Shippy Date: Wed, 19 Jun 2024 15:04:28 -0700 Subject: [PATCH 2/4] Fix by setting last rendered location even if !trackedElementsAreIdentical --- src/core/frames/frame_controller.js | 2 ++ src/core/session.js | 6 +++++- src/core/view.js | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/frames/frame_controller.js b/src/core/frames/frame_controller.js index 07764fc86..25e747f4e 100644 --- a/src/core/frames/frame_controller.js +++ b/src/core/frames/frame_controller.js @@ -270,6 +270,8 @@ export class FrameController { viewRenderedSnapshot(_snapshot, _isPreview, _renderMethod) {} + setLastRenderedLocation() {} + preloadOnLoadLinksForView(element) { session.preloadOnLoadLinksForView(element) } diff --git a/src/core/session.js b/src/core/session.js index cdb978348..56eb37fbf 100644 --- a/src/core/session.js +++ b/src/core/session.js @@ -327,10 +327,14 @@ export class Session { } viewRenderedSnapshot(_snapshot, _isPreview, renderMethod) { - this.view.lastRenderedLocation = this.history.location + this.setLastRenderedLocation() this.notifyApplicationAfterRender(renderMethod) } + setLastRenderedLocation() { + this.view.lastRenderedLocation = this.history.location + } + preloadOnLoadLinksForView(element) { this.preloader.preloadOnLoadLinksForView(element) } diff --git a/src/core/view.js b/src/core/view.js index 7b562563d..f20607dc5 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -84,6 +84,8 @@ export class View { } } else if (shouldInvalidate) { this.invalidate(renderer.reloadReason) + } else { + this.delegate.setLastRenderedLocation(); } } From 0c7841d4d0e6e4fcf660d327a85bc6185ff64f1a Mon Sep 17 00:00:00 2001 From: Paul Shippy Date: Sat, 22 Jun 2024 14:18:23 -0700 Subject: [PATCH 3/4] Remove semicolon to match existing style --- src/core/view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/view.js b/src/core/view.js index f20607dc5..5f09e9f28 100644 --- a/src/core/view.js +++ b/src/core/view.js @@ -85,7 +85,7 @@ export class View { } else if (shouldInvalidate) { this.invalidate(renderer.reloadReason) } else { - this.delegate.setLastRenderedLocation(); + this.delegate.setLastRenderedLocation() } } From 69f4fcd0f1722b7e36657a22f5733b6a029336b7 Mon Sep 17 00:00:00 2001 From: Paul Shippy Date: Sat, 22 Jun 2024 14:20:41 -0700 Subject: [PATCH 4/4] Switch to @tleish's testing approach --- src/tests/fixtures/tabs/three.html | 1 + src/tests/functional/frame_navigation_tests.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tests/fixtures/tabs/three.html b/src/tests/fixtures/tabs/three.html index 90e869918..517d0dc2b 100644 --- a/src/tests/fixtures/tabs/three.html +++ b/src/tests/fixtures/tabs/three.html @@ -3,6 +3,7 @@ Frame + diff --git a/src/tests/functional/frame_navigation_tests.js b/src/tests/functional/frame_navigation_tests.js index 9927aec87..f0c3b3901 100644 --- a/src/tests/functional/frame_navigation_tests.js +++ b/src/tests/functional/frame_navigation_tests.js @@ -36,12 +36,19 @@ test("frame navigation with data-turbo-action", async ({ page }) => { await nextBeat() await nextEventOnTarget(page, "empty-head", "turbo:frame-load") + assert.equal(pathname(page.url()), "/src/tests/fixtures/frames/empty_head.html") - const frameText = await page.textContent("#empty-head h2") + let frameText = await page.textContent("#empty-head h2") assert.equal(frameText, "Frame updated") const titleText = await page.textContent("h1") assert.equal(titleText, "Frame navigation tests") + + await page.goBack() + await nextEventNamed(page, "turbo:load") + assert.equal(pathname(page.url()), "/src/tests/fixtures/frame_navigation.html") + frameText = await page.textContent("#empty-head #link-to-frame-with-empty-head") + assert.equal(frameText, 'About (a link with data-turbo-action="advance")') }) test("frame navigation emits fetch-request-error event when offline", async ({ page }) => {