Skip to content

Commit

Permalink
feat: emit browsingContext.navigationCommitted
Browse files Browse the repository at this point in the history
  • Loading branch information
sadym-chromium committed Jan 31, 2025
1 parent 04816f3 commit 4057428
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/bidiMapper/modules/context/NavigationTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ export class NavigationState {

frameNavigated() {
this.#navigated = true;
if (!this.#isInitial) {
this.#eventManager.registerEvent(
{
type: 'event',
method: ChromiumBidi.BrowsingContext.EventNames.NavigationCommitted,
params: this.navigationInfo(),
},
this.#browsingContextId,
);
}
}

fragmentNavigated() {
Expand Down Expand Up @@ -257,7 +267,7 @@ export class NavigationTracker {

if (
this.#pendingNavigation !== undefined &&
this.#pendingNavigation?.loaderId === undefined
this.#pendingNavigation.loaderId === undefined
) {
// This can be a pending navigation to `about:blank` created by a command. Use the
// pending navigation in this case.
Expand Down
108 changes: 108 additions & 0 deletions tests/browsing_context/__snapshots__/test_navigate_events.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -88,6 +97,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -152,6 +170,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -242,6 +269,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_6',
'url': 'stable_7',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -286,6 +322,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationStarted',
'params': dict({
Expand Down Expand Up @@ -359,6 +404,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -423,6 +477,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -493,6 +556,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationStarted',
'params': dict({
Expand All @@ -502,6 +574,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_3',
'url': 'stable_4',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationAborted',
'params': dict({
Expand Down Expand Up @@ -542,6 +623,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.domContentLoaded',
'params': dict({
Expand Down Expand Up @@ -573,6 +663,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.fragmentNavigated',
'params': dict({
Expand Down Expand Up @@ -613,6 +712,15 @@
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.navigationCommitted',
'params': dict({
'context': 'stable_0',
'navigation': 'stable_1',
'url': 'stable_2',
}),
'type': 'event',
}),
dict({
'method': 'browsingContext.fragmentNavigated',
'params': dict({
Expand Down
22 changes: 11 additions & 11 deletions tests/browsing_context/test_navigate_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def test_navigate_checkEvents(websocket, context_id, url_base,
}
})

messages = await read_messages(6,
messages = await read_messages(7,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand Down Expand Up @@ -97,7 +97,7 @@ async def test_navigate_aboutBlank_checkEvents(websocket, context_id, url_base,
}
})

messages = await read_messages(5,
messages = await read_messages(6,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand Down Expand Up @@ -125,7 +125,7 @@ async def test_navigate_dataUrl_checkEvents(websocket, context_id, url_base,
}
})

messages = await read_messages(6,
messages = await read_messages(7,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand Down Expand Up @@ -167,7 +167,7 @@ async def test_navigate_hang_navigate_again_checkEvents(
}
})

messages = await read_messages(9,
messages = await read_messages(10,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand All @@ -192,7 +192,7 @@ async def test_scriptNavigate_checkEvents(websocket, context_id, url_example,
})

messages = await read_messages(
5,
7,
# Filter out command result, as it can be
# racy with other events.
filter_lambda=lambda x: 'id' not in x,
Expand Down Expand Up @@ -257,7 +257,7 @@ async def test_scriptNavigate_dataUrl_checkEvents(websocket, context_id,
})

messages = await read_messages(
3,
4,
# Filter out command result, as it can be
# racy with other events.
filter_lambda=lambda x: 'id' not in x,
Expand Down Expand Up @@ -286,7 +286,7 @@ async def test_scriptNavigate_fragment_checkEvents(websocket, context_id,
})

messages = await read_messages(
4,
5,
# Filter out command result, as it can be
# racy with other events.
filter_lambda=lambda x: 'id' not in x,
Expand Down Expand Up @@ -314,7 +314,7 @@ async def test_scriptNavigate_fragment_nested_checkEvents(
})

messages = await read_messages(
4,
5,
# Filter out command result, as it can be
# racy with other events.
filter_lambda=lambda x: 'id' not in x,
Expand Down Expand Up @@ -343,7 +343,7 @@ async def test_reload_checkEvents(websocket, context_id, url_example, html,
}
})

messages = await read_messages(6,
messages = await read_messages(7,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand Down Expand Up @@ -371,7 +371,7 @@ async def test_reload_aboutBlank_checkEvents(websocket, context_id, html,
}
})

messages = await read_messages(5,
messages = await read_messages(6,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand All @@ -398,7 +398,7 @@ async def test_reload_dataUrl_checkEvents(websocket, context_id, html,
}
})

messages = await read_messages(6,
messages = await read_messages(7,
keys_to_stabilize=KEYS_TO_STABILIZE,
check_no_other_messages=True,
sort=False)
Expand Down

0 comments on commit 4057428

Please sign in to comment.