Bug 169467 - iframe `window.parent` should return null when iframe element removed
Summary: iframe `window.parent` should return null when iframe element removed
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac OS X 10.11
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-10 07:44 PST by Lyza Gardner
Modified: 2024-01-10 13:38 PST (History)
4 users (show)

See Also:


Attachments
window.parent should be null after iframe removed (544 bytes, text/html)
2017-03-10 07:44 PST, Lyza Gardner
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lyza Gardner 2017-03-10 07:44:43 PST
Created attachment 304043 [details]
window.parent should be null after iframe removed

While working on some web-platform-tests regarding `window.parent` and `window.top` for nested browsing contexts[1], I happened on some unexpected behavior in Safari/Webkit regarding `window.parent`.

When an `iframe` element is removed from a document, its associated browsing context should be discarded. For a nested browsing container to be the parent or child of another browsing context, both parties need to be connected and active.[2][3]

Expected behavior: When an iframe is removed from a document, its previous browsing context (window) should return `null` for `window.parent`.

Actual behavior: When an iframe is removed from a document, Webkit/Safari continues to return the prior-associated `parent` browsing context.

Steps to reproduce:

1. Append an iframe `iframe` to top-level browsing context's active document's `body`
2. Let `iframeWindow` be the current value of `iframe.contentWindow`.
3. Remove `iframe` from `document`
4. Observe the returned value of `iframeWindow.parent` (it should be `null`)

(Test case attached).

Behavior observed in
* Safari 10.0.3 (11602.4.8.0.1)
* Webkit Nightly 10.0.3 (11602.4.8.0.1, r213646)

[1]: https://github.com/w3c/web-platform-tests/pull/5105
[2]: https://html.spec.whatwg.org/#nested-browsing-contexts
[3]: https://html.spec.whatwg.org/#the-iframe-element
Comment 1 Ahmad Saleem 2024-01-10 13:38:25 PST
All browsers (Safari 17.2.1, Chrome Canary 122 and Firefox Nightly 123) show 'true', 'true' in console.

Plus Safari Technology Preview 185 passes all tests: https://wpt.fyi/results/html/browsers/windows/nested-browsing-contexts?label=master&label=experimental&aligned=

Marking this as 'RESOLVED CONFIGURATION CHANGED'.