<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - iframe `window.parent` should return null when iframe element removed"
href="https://bugs.webkit.org/show_bug.cgi?id=169467">169467</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>iframe `window.parent` should return null when iframe element removed
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Nightly Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>OS X 10.11
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>Frames
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lyza@lyza.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=304043" name="attach_304043" title="window.parent should be null after iframe removed">attachment 304043</a> <a href="attachment.cgi?id=304043&action=edit" title="window.parent should be null after iframe removed">[details]</a></span>
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]: <a href="https://github.com/w3c/web-platform-tests/pull/5105">https://github.com/w3c/web-platform-tests/pull/5105</a>
[2]: <a href="https://html.spec.whatwg.org/#nested-browsing-contexts">https://html.spec.whatwg.org/#nested-browsing-contexts</a>
[3]: <a href="https://html.spec.whatwg.org/#the-iframe-element">https://html.spec.whatwg.org/#the-iframe-element</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>