diff --git a/src/bidiMapper/modules/context/NavigationTracker.spec.ts b/src/bidiMapper/modules/context/NavigationTracker.spec.ts index 54420e6a4..081a17ddf 100644 --- a/src/bidiMapper/modules/context/NavigationTracker.spec.ts +++ b/src/bidiMapper/modules/context/NavigationTracker.spec.ts @@ -310,7 +310,12 @@ describe('NavigationTracker', () => { navigationTracker.frameNavigated(YET_ANOTHER_URL, LOADER_ID); - assertNoNavigationEvents(); + assertNavigationEvent( + ChromiumBidi.BrowsingContext.EventNames.NavigationCommitted, + sinon.match.any, + YET_ANOTHER_URL, + ); + assert.equal(navigationTracker.url, YET_ANOTHER_URL); navigationTracker.loadPageEvent(LOADER_ID); diff --git a/src/bidiMapper/modules/context/NavigationTracker.ts b/src/bidiMapper/modules/context/NavigationTracker.ts index eb7ab5dab..028dbe93e 100644 --- a/src/bidiMapper/modules/context/NavigationTracker.ts +++ b/src/bidiMapper/modules/context/NavigationTracker.ts @@ -299,7 +299,6 @@ export class NavigationTracker { } const navigation = this.#getNavigationForFrameNavigated(url, loaderId); - navigation.frameNavigated(); if (navigation !== this.#currentNavigation) { this.#currentNavigation.fail( @@ -311,6 +310,7 @@ export class NavigationTracker { navigation.loaderId = loaderId; this.#loaderIdToNavigationsMap.set(loaderId, navigation); navigation.start(); + navigation.frameNavigated(); this.#currentNavigation = navigation; if (this.#pendingNavigation === navigation) { diff --git a/tests/browsing_context/__snapshots__/test_navigate_events.ambr b/tests/browsing_context/__snapshots__/test_navigate_events.ambr index 516cea5fe..d78eb4beb 100644 --- a/tests/browsing_context/__snapshots__/test_navigate_events.ambr +++ b/tests/browsing_context/__snapshots__/test_navigate_events.ambr @@ -323,7 +323,7 @@ 'type': 'event', }), dict({ - 'method': 'browsingContext.navigationCommitted', + 'method': 'browsingContext.navigationStarted', 'params': dict({ 'context': 'stable_0', 'navigation': 'stable_1', @@ -332,7 +332,7 @@ 'type': 'event', }), dict({ - 'method': 'browsingContext.navigationStarted', + 'method': 'browsingContext.navigationCommitted', 'params': dict({ 'context': 'stable_0', 'navigation': 'stable_1', @@ -575,20 +575,20 @@ 'type': 'event', }), dict({ - 'method': 'browsingContext.navigationCommitted', + 'method': 'browsingContext.navigationAborted', 'params': dict({ 'context': 'stable_0', - 'navigation': 'stable_3', - 'url': 'stable_4', + 'navigation': 'stable_1', + 'url': 'stable_2', }), 'type': 'event', }), dict({ - 'method': 'browsingContext.navigationAborted', + 'method': 'browsingContext.navigationCommitted', 'params': dict({ 'context': 'stable_0', - 'navigation': 'stable_1', - 'url': 'stable_2', + 'navigation': 'stable_3', + 'url': 'stable_4', }), 'type': 'event', }), diff --git a/tests/browsing_context/test_create.py b/tests/browsing_context/test_create.py index 4e87e69ec..adcbda4b0 100644 --- a/tests/browsing_context/test_create.py +++ b/tests/browsing_context/test_create.py @@ -112,7 +112,7 @@ async def test_browsingContext_windowOpen_nonBlank_eventsEmitted( }) events = await read_messages( - 4, + 5, # Filter out the command result, as it's order is not defined. filter_lambda=lambda m: 'id' not in m, keys_to_stabilize=['context', 'navigation'], @@ -140,6 +140,15 @@ async def test_browsingContext_windowOpen_nonBlank_eventsEmitted( 'url': url_example, }, 'type': 'event', + }, { + 'method': 'browsingContext.navigationCommitted', + 'params': { + 'context': 'stable_0', + 'navigation': 'stable_1', + 'timestamp': ANY_TIMESTAMP, + 'url': url_example, + }, + 'type': 'event', }, { 'method': 'browsingContext.domContentLoaded', 'params': { diff --git a/tests/browsing_context/test_navigate_events.py b/tests/browsing_context/test_navigate_events.py index 090477460..d86c5963d 100644 --- a/tests/browsing_context/test_navigate_events.py +++ b/tests/browsing_context/test_navigate_events.py @@ -83,7 +83,6 @@ async def test_window_open_url_checkEvents(websocket, context_id, url_example, read_messages, snapshot): await subscribe(websocket, ["browsingContext"]) - # Make same-document navigation. await send_JSON_command( websocket, { "method": "script.evaluate", @@ -110,7 +109,6 @@ async def test_window_open_aboutBlank_checkEvents(websocket, context_id, url, read_messages, snapshot): await subscribe(websocket, ["browsingContext"]) - # Make same-document navigation. await send_JSON_command( websocket, { "method": "script.evaluate",