Bug 324706
| Summary: | [WebDriver][BiDi] browsingContext.contextDestroyed should report the destroyed subtree in a single event with a spec-shaped payload | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Timothy Olusanya <seunxplicit> |
| Component: | WebDriver | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | bburg, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=310157 https://bugs.webkit.org/show_bug.cgi?id=282981 https://bugs.webkit.org/show_bug.cgi?id=286790 https://bugs.webkit.org/show_bug.cgi?id=309502 |
||
| Bug Depends on: | |||
| Bug Blocks: | 288336 | ||
Timothy Olusanya
Split out of bug 288336 (browsingContext.contextDestroyed). The event is already emitted, but its payload does not follow "get the navigable info":
- `children` is always an empty array. The spec builds the payload with a null max depth, i.e. the whole child tree, and a destroyed navigable with descendants is reported once, with them inside. WPT: test_nested_iframes_delete_top_iframe and test_iframe_destroy_parent expect one event with children=1.
- `parent` and `originalOpener` are sent as the string "null" instead of JSON null, so every assert_browsing_context() with parent=None or original_opener=None fails.
- `clientWindow` differs from what browsingContext.getTree reports for the same context (covered separately by bug 303210).
- A frame's handle is discarded when the main frame finishes loading, even for frames of the new document, so the id announced by contextCreated no longer matches later ids, and the destroy event is dropped unless the client called getTree in between.
Cause of the missing subtree: WebCore detaches child frames before their parent (FrameLoader::detachFromParent() calls detachChildren() first), so by the time the UI process learns that a frame is gone, its subtree has already been torn down. Reporting the subtree needs a notification before the children are detached.
Proposed change:
1. A LocalFrameLoaderClient::willDetachFromParent() hook called before detachChildren(); WebKit sends FrameWillBeDetached to the UI process for automation-controlled pages.
2. The automation session builds the event from the UI-process frame tree (full depth), records the descendants so they do not emit again, and reports a closed page once with its whole tree.
3. JSON null for parent/originalOpener. Interim: those two event parameters are typed "any" until the protocol generator supports nullable event parameters (bug 310157).
4. Keep the handles of frames that are still attached when the main frame finishes loading.
Out of scope here, still tracked by bug 288336 and its dependencies: delivery to subscriptions scoped by context or by user context (bug 282981, bug 309502), contexts created inside a user context (bug 286790), and originalOpener coverage, which needs window.open() to create a browsing context under WebKitGTK automation.
Tests: imported/w3c/webdriver/tests/bidi/browsing_context/context_destroyed/context_destroyed.py
Tools/TestWebKitAPI/Tests/WebKitGLib/TestAutomationSession.cpp
Spec: https://w3c.github.io/webdriver-bidi/#event-browsingContext-contextDestroyed
https://w3c.github.io/webdriver-bidi/#get-the-navigable-info
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Timothy Olusanya
Pull request: https://github.com/WebKit/WebKit/pull/74498
Radar WebKit Bug Importer
<rdar://problem/188588833>