Skip to content

Commit

Permalink
fix: handle max depth property (#3027)
Browse files Browse the repository at this point in the history
According to the spec, max depth in browsingContext.contextDestroyed
event should always be null.

---------

Co-authored-by: browser-automation-bot <133232582+browser-automation-bot@users.noreply.github.com>
  • Loading branch information
OrKoN and browser-automation-bot authored Jan 24, 2025
1 parent 4b48379 commit 1393215
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 78 deletions.
14 changes: 10 additions & 4 deletions src/bidiMapper/modules/context/BrowsingContextImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class BrowsingContextImpl {
{
type: 'event',
method: ChromiumBidi.BrowsingContext.EventNames.ContextDestroyed,
params: this.serializeToBidiValue(),
params: this.serializeToBidiValue(null),
},
this.id,
);
Expand Down Expand Up @@ -361,8 +361,11 @@ export class BrowsingContextImpl {
return maybeSandboxes[0]!;
}

/**
* Implements https://w3c.github.io/webdriver-bidi/#get-the-navigable-info.
*/
serializeToBidiValue(
maxDepth = 0,
maxDepth: number | null = 0,
addParentField = true,
): BrowsingContext.Info {
return {
Expand All @@ -373,9 +376,12 @@ export class BrowsingContextImpl {
// TODO(#2646): Implement Client Window correctly
clientWindow: '',
children:
maxDepth > 0
maxDepth === null || maxDepth > 0
? this.directChildren.map((c) =>
c.serializeToBidiValue(maxDepth - 1, false),
c.serializeToBidiValue(
maxDepth === null ? maxDepth : maxDepth - 1,
false,
),
)
: null,
...(addParentField ? {parent: this.#parentId} : {}),
Expand Down
4 changes: 2 additions & 2 deletions tests/browsing_context/test_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def test_browsingContext_close(websocket, context_id):
"context": context_id,
"parent": None,
"url": "about:blank",
"children": None,
"children": [],
"userContext": "default"
}
})
Expand Down Expand Up @@ -139,7 +139,7 @@ async def test_browsingContext_close_prompt(websocket, context_id, html,
'method': 'browsingContext.contextDestroyed',
'params': {
'context': context_id,
'children': None,
'children': [],
'originalOpener': None,
'clientWindow': ANY_STR,
'parent': None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
[context_destroyed.py]
[test_new_context[tab\]]
expected: FAIL

[test_new_context[window\]]
expected: FAIL

[test_navigate_iframe[same_origin\]]
expected: FAIL

[test_navigate_iframe[cross_origin\]]
expected: FAIL

[test_delete_iframe]
expected: FAIL

[test_nested_iframes_delete_top_iframe]
expected: FAIL

[test_nested_iframes_delete_deepest_iframe]
expected: FAIL

[test_iframe_destroy_parent]
expected: FAIL

[test_new_user_context[tab\]]
expected: FAIL

[test_new_user_context[window\]]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
[context_destroyed.py]
[test_new_context[tab\]]
expected: FAIL

[test_new_context[window\]]
expected: FAIL

[test_navigate_iframe[same_origin\]]
expected: FAIL

[test_navigate_iframe[cross_origin\]]
expected: FAIL

[test_delete_iframe]
expected: FAIL

[test_nested_iframes_delete_top_iframe]
expected: FAIL

[test_nested_iframes_delete_deepest_iframe]
expected: FAIL

[test_iframe_destroy_parent]
expected: FAIL

[test_new_user_context[tab\]]
expected: FAIL

[test_new_user_context[window\]]
expected: FAIL
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
[context_destroyed.py]
[test_new_context[tab\]]
expected: FAIL

[test_new_context[window\]]
expected: FAIL

[test_navigate_iframe[same_origin\]]
expected: FAIL

[test_navigate_iframe[cross_origin\]]
expected: FAIL

[test_delete_iframe]
expected: FAIL

[test_nested_iframes_delete_top_iframe]
expected: FAIL

[test_nested_iframes_delete_deepest_iframe]
expected: FAIL

[test_iframe_destroy_parent]
expected: FAIL

[test_new_user_context[tab\]]
expected: FAIL

[test_new_user_context[window\]]
expected: FAIL

0 comments on commit 1393215

Please sign in to comment.