RESOLVED FIXED 181505
Setting Window.opener to null should disown its opener
https://bugs.webkit.org/show_bug.cgi?id=181505
Summary Setting Window.opener to null should disown its opener
Chris Dumez
Reported 2018-01-10 16:34:45 PST
Setting Window.opener to null to disown the window's opener: - https://html.spec.whatwg.org/#dom-opener This seems to be impacting Gmail.
Attachments
WIP Patch (2.65 KB, patch)
2018-01-10 17:02 PST, Chris Dumez
no flags
Archive of layout-test-results from ews106 for mac-sierra-wk2 (2.73 MB, application/zip)
2018-01-10 21:42 PST, EWS Watchlist
no flags
Patch (9.10 KB, patch)
2018-01-11 10:53 PST, Chris Dumez
no flags
Archive of layout-test-results from ews112 for mac-sierra (3.02 MB, application/zip)
2018-01-11 12:33 PST, EWS Watchlist
no flags
Patch (9.22 KB, patch)
2018-01-11 12:40 PST, Chris Dumez
no flags
Patch (9.18 KB, patch)
2018-01-11 19:56 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2018-01-10 17:02:31 PST
Created attachment 330990 [details] WIP Patch
Chris Dumez
Comment 2 2018-01-10 17:02:57 PST
Will work on a test tomorrow.
EWS Watchlist
Comment 3 2018-01-10 21:42:55 PST
Comment on attachment 330990 [details] WIP Patch Attachment 330990 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/6029767 New failing tests: webgl/1.0.2/conformance/uniforms/uniform-default-values.html
EWS Watchlist
Comment 4 2018-01-10 21:42:57 PST
Created attachment 331026 [details] Archive of layout-test-results from ews106 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
Chris Dumez
Comment 5 2018-01-11 10:17:35 PST
Comment on attachment 331026 [details] Archive of layout-test-results from ews106 for mac-sierra-wk2 Not related.
Radar WebKit Bug Importer
Comment 6 2018-01-11 10:50:44 PST
Chris Dumez
Comment 7 2018-01-11 10:53:04 PST
John Wilander
Comment 8 2018-01-11 11:03:09 PST
Looks good to me. This was the thing I think Mike West was talking about — disowning the opener.
John Wilander
Comment 9 2018-01-11 11:05:29 PST
Is there a way to test that disowning the opener makes WebKit not keep the pages in the same web process?
Chris Dumez
Comment 10 2018-01-11 12:10:30 PST
(In reply to John Wilander from comment #9) > Is there a way to test that disowning the opener makes WebKit not keep the > pages in the same web process? Well, but it does currently :P
Chris Dumez
Comment 11 2018-01-11 12:10:50 PST
(In reply to Chris Dumez from comment #10) > (In reply to John Wilander from comment #9) > > Is there a way to test that disowning the opener makes WebKit not keep the > > pages in the same web process? > > Well, but it does currently :P That's another issue we have to fix.
EWS Watchlist
Comment 12 2018-01-11 12:33:20 PST
Comment on attachment 331074 [details] Patch Attachment 331074 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/6037592 New failing tests: fast/dom/Window/window-opener-set-to-null.html
EWS Watchlist
Comment 13 2018-01-11 12:33:21 PST
Created attachment 331096 [details] Archive of layout-test-results from ews112 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-sierra Platform: Mac OS X 10.12.6
Chris Dumez
Comment 14 2018-01-11 12:40:01 PST
Ryosuke Niwa
Comment 15 2018-01-11 16:45:40 PST
Comment on attachment 331098 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=331098&action=review > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:478 > + replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("opener"), strlen("opener")), value); Why not just Identifier::fromString(&state.vm(), "opener")?
Chris Dumez
Comment 16 2018-01-11 16:46:33 PST
Comment on attachment 331098 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=331098&action=review >> Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:478 >> + replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("opener"), strlen("opener")), value); > > Why not just Identifier::fromString(&state.vm(), "opener")? Hmm, I copy/pasted the code from the bindings generator. I'll look into it so see if there is a good reason.
Chris Dumez
Comment 17 2018-01-11 19:56:41 PST
WebKit Commit Bot
Comment 18 2018-01-11 20:47:35 PST
Comment on attachment 331161 [details] Patch Clearing flags on attachment: 331161 Committed r226842: <https://trac.webkit.org/changeset/226842>
WebKit Commit Bot
Comment 19 2018-01-11 20:47:37 PST
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 20 2018-01-13 12:38:56 PST
Comment on attachment 331161 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=331161&action=review > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:478 > + if (value.isNull()) { > + wrapped().disownOpener(); > + return; > + } > + replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "opener"), value); I don’t see test coverage for the case where we first have opener reflecting the real opening, then set it to "foo" and then set it to null. Will this do the right thing in that case, or will "foo" still be left behind in the static property slot?
Chris Dumez
Comment 21 2018-01-13 19:55:09 PST
(In reply to Darin Adler from comment #20) > Comment on attachment 331161 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=331161&action=review > > > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:478 > > + if (value.isNull()) { > > + wrapped().disownOpener(); > > + return; > > + } > > + replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "opener"), value); > > I don’t see test coverage for the case where we first have opener reflecting > the real opening, then set it to "foo" and then set it to null. Will this do > the right thing in that case, or will "foo" still be left behind in the > static property slot? I will add testing and check other browsers. My current implementation would disown the opener and keep "foo" expando property. This seems correct to me based on my interpretation of the specification: """ On setting, if the new value is null then the current browsing context must disown its opener; if the new value is anything else then the user agent must call the [[DefineOwnProperty]] internal method of the Window object, passing the property name "opener" as the property key, and the Property Descriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true } as the property descriptor, where value is the new value. """
Chris Dumez
Comment 22 2018-01-13 20:04:50 PST
(In reply to Chris Dumez from comment #21) > (In reply to Darin Adler from comment #20) > > Comment on attachment 331161 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=331161&action=review > > > > > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:478 > > > + if (value.isNull()) { > > > + wrapped().disownOpener(); > > > + return; > > > + } > > > + replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "opener"), value); > > > > I don’t see test coverage for the case where we first have opener reflecting > > the real opening, then set it to "foo" and then set it to null. Will this do > > the right thing in that case, or will "foo" still be left behind in the > > static property slot? > > I will add testing and check other browsers. My current implementation would > disown the opener and keep "foo" expando property. This seems correct to me > based on my interpretation of the specification: > """ > On setting, if the new value is null then the current browsing context must > disown its opener; if the new value is anything else then the user agent > must call the [[DefineOwnProperty]] internal method of the Window object, > passing the property name "opener" as the property key, and the Property > Descriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, > [[Configurable]]: true } as the property descriptor, where value is the new > value. > """ Firefox and chrome seem to return null and not "foo" which means we are not interoperable unfortunately. I filed a bug against the spec (https://github.com/whatwg/html/issues/3351) and will align WebKit with other browser engines.
Chris Dumez
Comment 23 2018-01-13 21:12:06 PST
(In reply to Chris Dumez from comment #22) > (In reply to Chris Dumez from comment #21) > > (In reply to Darin Adler from comment #20) > > > Comment on attachment 331161 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=331161&action=review > > > > > > > Source/WebCore/bindings/js/JSDOMWindowCustom.cpp:478 > > > > + if (value.isNull()) { > > > > + wrapped().disownOpener(); > > > > + return; > > > > + } > > > > + replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "opener"), value); > > > > > > I don’t see test coverage for the case where we first have opener reflecting > > > the real opening, then set it to "foo" and then set it to null. Will this do > > > the right thing in that case, or will "foo" still be left behind in the > > > static property slot? > > > > I will add testing and check other browsers. My current implementation would > > disown the opener and keep "foo" expando property. This seems correct to me > > based on my interpretation of the specification: > > """ > > On setting, if the new value is null then the current browsing context must > > disown its opener; if the new value is anything else then the user agent > > must call the [[DefineOwnProperty]] internal method of the Window object, > > passing the property name "opener" as the property key, and the Property > > Descriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, > > [[Configurable]]: true } as the property descriptor, where value is the new > > value. > > """ > > Firefox and chrome seem to return null and not "foo" which means we are not > interoperable unfortunately. I filed a bug against the spec > (https://github.com/whatwg/html/issues/3351) and will align WebKit with > other browser engines. As it turns out, the spec and our implementation is correct. I am extending testing via Bug 181634. When you set it to "foo", it calls [DefineOwnProperty] which overrides our "native" property. When you then set to null, it merely updates the descriptor's value to null, it does not call our native setter.
Note You need to log in before you can comment on or make changes to this bug.