Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A WindowClient close or terminate method perhaps? #1567

Open
jimmywarting opened this issue Feb 20, 2021 · 3 comments
Open

A WindowClient close or terminate method perhaps? #1567

jimmywarting opened this issue Feb 20, 2021 · 3 comments

Comments

@jimmywarting
Copy link

jimmywarting commented Feb 20, 2021

"You can close a window from the main thread, but only if it's open by another document" - message appears when trying to close a page by itself

What about those "go to your mail box and verify your code/identity" scenarios where a new page is open by another application? when i open up the new verification page from the mail client, then the previus old "go to your mail" pages becomes completely useless. I would like to close this tab.

Or a friend is calling you face to face - click on this desktop notification to answer (open) the conversation.
When the conversation ends you want to close the window. in that senario you would have wish you had open the window from another tab so the it has a opener and could be closed.
In this senario you have a opener (a desktop notification triggered by a service worker) but the service worker can't close the window on itself.

Could Service Worker have a more secure context and awareness of which window clients are open that it could circumvent the restriction of what window.close() has?

I know it could be bad to close the client if it where the last tab open, but what if browser instead open about:blank or the home screen in those scenarios so the browser itself would not closed down? child frames would switch to about:blank

maybe instead of a .close() there was a .terminate() method that could terminate both tabs and other web workers.

@jakearchibald
Copy link
Contributor

Right now (in Chrome at least) a window can close itself if it was opened with script (window.open) or from another page with target="_blank". It seems reasonable that this should work for service worker opened pages too.

Thanks for the use-cases!

@jakearchibald
Copy link
Contributor

TODO: Check the above happens in other browsers too.

@xxoo
Copy link

xxoo commented Apr 22, 2022

I think a serviceworker should be able to close any top-level window in its scope. Cause sometimes an application requires single instance to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants