New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 767806 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Feature



Sign in to add a comment

Feature request: window.close() for PWA's

Reported by chem...@gmail.com, Sep 22 2017

Issue description

Steps to reproduce the problem:
Right now, there is no way for a PWA to close itself like native Android apps can. I think it would make sense to allow PWA's to call window.close().

Use case: To override the back button behavior on Android, I push items to the browser's history stack (and a list for my own use since I can't pop things from the history) any time the user navigates to a new screen. When the back button is pressed, I simply prevent the browser from navigating away from the page and show the previous screen. However, when the user reaches the 'top' of the app, I can't close the window. This is behavior that the user expects.

What is the expected behavior?
PWA should be able to close itself

What went wrong?
Window.close is not allowed because the 'window' was not opened through javascript.

Did this work before? No 

Does this work in other browsers? N/A

Chrome version: Any  Channel: stable
OS Version: Any
Flash Version:
 
Cc: msrchandra@chromium.org rbasuvula@chromium.org nyerramilli@chromium.org ligim...@chromium.org sandeepkumars@chromium.org
Components: UI>Browser>WebAppInstalls
Labels: Needs-triage-Mobile Triaged-Mobile
Labels: -Triaged-Mobile
Labels: -Type-Bug Type-Feature

Comment 4 by chem...@gmail.com, Jan 29 2018

Any word on this? Would also be useful when PWA's replace Chrome Apps :)
Status: Untriaged (was: Unconfirmed)
*** Bulk edit ***

Setting Feature Requests as: Untriaged 

Comment 6 by donnd@google.com, Apr 24 2018

Labels: -Needs-triage-Mobile
Owner: yus...@chromium.org
Status: Assigned (was: Untriaged)
yusufo@, please reassign as needed.

Comment 7 by ortuno@chromium.org, Apr 25 2018

This seems like a pattern specific to Android. I'm not sure why we would do something like this on Desktop.

Comment 8 by chem...@gmail.com, Apr 26 2018

Well since PWA's are going to replace Chrome Apps I assume that that will deprecate the chrome.* Api at some point, too? Then apps won't be able to close themselves.

And yes, it would make a lot of sense of Android so I think that could be worth it in any case (imho 😉)

Comment 9 by yus...@chromium.org, Apr 26 2018

Cc: bauerb@chromium.org rbyers@chromium.org yfried...@chromium.org
Adding relevant people working on web platform, WebAPKs and TWAs. I do remember this being discussed at some point. What would be the recommendation for developers wanting to close their Activity in Android with window.close()?
Hm, at least for the Trusted Web Activity case, this seems similar to the feature request to allow closing the tab from the Android side. (And possibly one could be implemented using the other?) If we do allow this from Javascript, I would probably want to require a user gesture or something.
Cc: mgiuca@chromium.org
Want Matt's opinion as surely he's thought about it :)
I haven't tried this, but I'm surprised that window.close() doesn't work in PWA windows. window.move() and other APIs work (at least on Desktop). Is this a mobile-only issue?

Would definitely expect PWA windows to be able to close themselves. Web tabs can do so.
Urr, when I try running window.close() in about:blank on desktop, I get the messsage "Scripts may close only the windows that were opened by it.".
Hmm, apparently you can't close yourself.

This doesn't seem right to me; I can't imagine an abuse case you can get from a website being able to close itself, especially if it required a user gesture. But seems like a fairly uphill battle to change HTML in that regard.

If we can't globally change window.close() to allow a site to close itself, I would be in support of allowing installed PWA windows to close themselves. Not sure how this would look in a spec.
Any news? Pwas have made it onto the desktop (windows) by now ;)

Sign in to add a comment