diff --git a/src/core/session.js b/src/core/session.js
index 7bfb20ca2..b090c6e3f 100644
--- a/src/core/session.js
+++ b/src/core/session.js
@@ -98,8 +98,8 @@ export class Session {
const frameElement = options.frame ? document.getElementById(options.frame) : null
if (frameElement instanceof FrameElement) {
+ frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement)
frameElement.src = location.toString()
- frameElement.loaded
} else {
this.navigator.proposeVisit(expandURL(location), options)
}
diff --git a/src/tests/fixtures/frames.html b/src/tests/fixtures/frames.html
index d6a82d831..24c3272b9 100644
--- a/src/tests/fixtures/frames.html
+++ b/src/tests/fixtures/frames.html
@@ -27,7 +27,7 @@
Frames: #frame
-
+
Navigate #frame from within
Navigate #frame with ?key=value
Navigate #frame from within with a[data-turbo-action="advance"]
@@ -57,7 +57,7 @@ Frames: #frame
Frames: #hello
- Load #frame
+ Load #frame
diff --git a/src/tests/functional/frame_tests.js b/src/tests/functional/frame_tests.js
index b090aff8a..f1925908b 100644
--- a/src/tests/functional/frame_tests.js
+++ b/src/tests/functional/frame_tests.js
@@ -652,6 +652,39 @@ test("navigating turbo-frame[data-turbo-action=advance] from within pushes URL s
assert.equal(pathname(page.url()), "/src/tests/fixtures/frames/frame.html")
})
+test("navigating turbo-frame[data-turbo-action=advance] from outside with target pushes URL state", async ({ page }) => {
+ await page.click("#add-turbo-action-to-frame")
+ await page.click("#hello-link-frame")
+ await nextEventNamed(page, "turbo:load")
+
+ await expect(page.locator("h1")).toHaveText("Frames")
+ await expect(page.locator("#frame h2")).toHaveText("Frame: Loaded")
+ expect(pathname(page.url())).toEqual("/src/tests/fixtures/frames/frame.html")
+})
+
+test("navigating turbo-frame[data-turbo-action=advance] with Turbo.visit pushes URL state", async ({ page }) => {
+ const path = "/src/tests/fixtures/frames/frame.html"
+
+ await page.click("#add-turbo-action-to-frame")
+ await page.evaluate((path) => window.Turbo.visit(path, { frame: "frame" }), path)
+ await nextEventNamed(page, "turbo:load")
+
+ await expect(page.locator("h1")).toHaveText("Frames")
+ await expect(page.locator("#frame h2")).toHaveText("Frame: Loaded")
+ expect(pathname(page.url())).toEqual(path)
+})
+
+test("navigating turbo-frame without advance with Turbo.visit specifying advance pushes URL state", async ({ page }) => {
+ const path = "/src/tests/fixtures/frames/frame.html"
+
+ await page.evaluate((path) => window.Turbo.visit(path, { frame: "frame", action: "advance" }), path)
+ await nextEventNamed(page, "turbo:load")
+
+ await expect(page.locator("h1")).toHaveText("Frames")
+ await expect(page.locator("#frame h2")).toHaveText("Frame: Loaded")
+ expect(pathname(page.url())).toEqual(path)
+})
+
test("navigating turbo-frame[data-turbo-action=advance] to the same URL clears the [aria-busy] and [data-turbo-preview] state", async ({
page
}) => {