Bug 190282 - A Document / Window should lose its browsing context as soon as its iframe is removed from the document
Summary: A Document / Window should lose its browsing context as soon as its iframe is...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on: 190320
Blocks:
  Show dependency treegraph
 
Reported: 2018-10-04 10:42 PDT by Chris Dumez
Modified: 2018-10-05 13:11 PDT (History)
8 users (show)

See Also:


Attachments
WIP Patch (24.79 KB, patch)
2018-10-04 12:16 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (32.20 KB, patch)
2018-10-04 12:25 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (32.39 KB, patch)
2018-10-04 12:28 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (32.55 KB, patch)
2018-10-04 13:28 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (32.46 KB, patch)
2018-10-04 14:17 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (31.01 KB, patch)
2018-10-04 16:40 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2018-10-04 10:42:02 PDT
A Document / Window should loose its browsing context (aka Frame) as soon as its iframe is removed from the document. Currently, in WebKit, a Document / Window's Frame only get nulled out when the frame gets destroyed, we happens later usually after a GC happens.
This is not consistent with the specification or other browsers (tested Chrome and Firefox).
Comment 1 Chris Dumez 2018-10-04 12:16:57 PDT
Created attachment 351611 [details]
WIP Patch
Comment 2 Chris Dumez 2018-10-04 12:25:31 PDT
Created attachment 351614 [details]
Patch
Comment 3 Chris Dumez 2018-10-04 12:28:21 PDT
Created attachment 351615 [details]
Patch
Comment 4 Alexey Proskuryakov 2018-10-04 13:02:40 PDT
Is there any provision in specs for reparenting?
Comment 5 Chris Dumez 2018-10-04 13:07:17 PDT
(In reply to Alexey Proskuryakov from comment #4)
> Is there any provision in specs for reparenting?

No sure what you mean. If you remove an iframe from a document and add it back to the document, then it will do a fresh load and you'll get a brand new document / window, as per HTML spec.
Comment 6 Chris Dumez 2018-10-04 13:07:57 PDT
(In reply to Chris Dumez from comment #5)
> (In reply to Alexey Proskuryakov from comment #4)
> > Is there any provision in specs for reparenting?
> 
> No sure what you mean. If you remove an iframe from a document and add it
> back to the document, then it will do a fresh load and you'll get a brand
> new document / window, as per HTML spec.

Once a window / document loose their frame, they do not normally get reattached later, expect in the PageCache case.
Comment 7 Chris Dumez 2018-10-04 13:28:38 PDT
Created attachment 351618 [details]
Patch
Comment 8 Chris Dumez 2018-10-04 14:17:17 PDT
Created attachment 351630 [details]
Patch
Comment 9 Ryosuke Niwa 2018-10-04 16:21:06 PDT
Comment on attachment 351630 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=351630&action=review

> LayoutTests/fast/dom/Window/resources/dom-access-from-closure-iframe-child.html:2
> +    p = parent; // Save parent as the window will be detached when accessFrame() is called.

Can we do const parent = window.parent instead?

> LayoutTests/fast/dom/Window/resources/dom-access-from-closure-window-child.html:2
> +    o = opener; // Save opener as the window will be detached when accessFrame() is called.

Ditto.

> LayoutTests/fast/parser/resources/set-parent-to-javascript-url.html:2
> +p = parent;

Ditto.
Comment 10 Chris Dumez 2018-10-04 16:40:01 PDT
Created attachment 351642 [details]
Patch
Comment 11 WebKit Commit Bot 2018-10-04 17:19:56 PDT
Comment on attachment 351642 [details]
Patch

Clearing flags on attachment: 351642

Committed r236862: <https://trac.webkit.org/changeset/236862>
Comment 12 WebKit Commit Bot 2018-10-04 17:19:58 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2018-10-04 17:20:35 PDT
<rdar://problem/45028073>