<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>169467</bug_id>
          
          <creation_ts>2017-03-10 07:44:43 -0800</creation_ts>
          <short_desc>iframe `window.parent` should return null when iframe element removed</short_desc>
          <delta_ts>2024-01-10 13:38:25 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Frames</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.11</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Lyza Gardner">lyza</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>dbates</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1285803</commentid>
    <comment_count>0</comment_count>
      <attachid>304043</attachid>
    <who name="Lyza Gardner">lyza</who>
    <bug_when>2017-03-10 07:44:43 -0800</bug_when>
    <thetext>Created attachment 304043
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&apos;s active document&apos;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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2004197</commentid>
    <comment_count>1</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-10 13:38:25 -0800</bug_when>
    <thetext>All browsers (Safari 17.2.1, Chrome Canary 122 and Firefox Nightly 123) show &apos;true&apos;, &apos;true&apos; in console.

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

Marking this as &apos;RESOLVED CONFIGURATION CHANGED&apos;.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>304043</attachid>
            <date>2017-03-10 07:44:43 -0800</date>
            <delta_ts>2017-03-10 07:44:43 -0800</delta_ts>
            <desc>window.parent should be null after iframe removed</desc>
            <filename>window-parent-null.html</filename>
            <type>text/html</type>
            <size>544</size>
            <attacher name="Lyza Gardner">lyza</attacher>
            
              <data encoding="base64">PCFkb2N0eXBlIGh0bWw+CjxodG1sPgo8aGVhZD4KPG1ldGEgY2hhcnNldD0idXRmLTgiPgo8dGl0
bGU+d2luZG93LnBhcmVudDwvdGl0bGU+CjxzY3JpcHQ+CmZ1bmN0aW9uIHdpbmRvd1BhcmVudCgp
IHsKICB2YXIgaWZyYW1lID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnaWZyYW1lJyk7CgogIGlm
cmFtZS5vbmxvYWQgPSBmdW5jdGlvbiAoKSB7CiAgICB2YXIgaVdpbmRvdyA9IGlmcmFtZS5jb250
ZW50V2luZG93OwogICAgY29uc29sZS5sb2coaVdpbmRvdy5wYXJlbnQgPT09IHdpbmRvdyk7IC8v
IFNob3VsZCBiZSBgdHJ1ZWAKICAgIGRvY3VtZW50LmJvZHkucmVtb3ZlQ2hpbGQoaWZyYW1lKTsK
ICAgIGNvbnNvbGUubG9nKGlXaW5kb3cucGFyZW50ID09PSBudWxsKTsgLy8gU2hvdWxkIGJlIGB0
cnVlYAogIH07CgogIGRvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQoaWZyYW1lKTsKfQo8L3Njcmlw
dD4KPC9oZWFkPgo8Ym9keSBvbmxvYWQ9IndpbmRvd1BhcmVudCgpIj4KICA8aDE+d2luZG93LnBh
cmVudCB0ZXN0PC9oMT4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>