Bug 23634 - Synchronize window.close() policy with HTML 5
Summary: Synchronize window.close() policy with HTML 5
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2009-01-29 18:57 PST by Adam Barth
Modified: 2022-09-14 01:42 PDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2009-01-29 18:57:48 PST
Spun off from Bug 20661.  We should match HTML5's policy for window.close():

"The close() method on Window objects should, if the corresponding browsing context A is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), and if the browsing context of the script that invokes the method is allowed to navigate the browsing context A, close the browsing context A (and may discard it too)."

http://www.whatwg.org/specs/web-apps/current-work/#dom-window-close

Here is Firefox's implementation:

http://mxr.mozilla.org/mozilla-central/source/dom/src/base/nsGlobalWindow.cpp#5348

Here is our implementation:

http://trac.webkit.org/browser/trunk/WebCore/page/DOMWindow.cpp#L447

The main goofy thing we do is that we allow window.close() if 

        || m_frame->loader()->getHistoryLength() <= 1
Comment 1 Ahmad Saleem 2022-08-09 14:35:30 PDT
It seems that it was updated in this commit:

https://github.com/WebKit/WebKit/commit/ad05b3b957d598dd2fc12542d6f93c6b3dca046f#diff-a906690109f28a0283c513d9f09976d4bf6f53b99569113eb2fda779cff23b39R876

I don't know whether it have fixed the issue but we also pass tests in WPT:

https://wpt.fyi/results/html/browsers/the-window-object?label=master&label=experimental&aligned&view=subtest&q=window%20close

For close-method.window.html & closed-attribute.window.html and latter do cover - auxiliary browsing context:

closed/close() and cross-site auxiliary browsing context.

rniwa@webkit.org - Is this needed anymore? Thanks!
Comment 2 Ryosuke Niwa 2022-08-10 00:07:50 PDT
I'm pretty sure this bug still exists.
Comment 3 Radar WebKit Bug Importer 2022-08-10 10:54:25 PDT
<rdar://problem/98459982>
Comment 4 Woody Lee 2022-09-14 01:18:30 PDT
Still cannot close tab via window.close in iPhone/iPad Safari 15.6/16.
It works well in MacOS Safari.
Comment 5 Woody Lee 2022-09-14 01:42:04 PDT
#c4
Sorry for error information. It's another issue https://bugs.webkit.org/show_bug.cgi?id=245171