0

My project has single-sign-on to multiple apps and once signed on, people may be clicking bookmarks or links in notification emails to open tabs to our various and sundry applications. HOWEVER, when they sign out, this means all that stuff is open, even though the session it connects to on the server is dead.

Analysis has requested that we be able to close all browser tabs going to our app when the user hits logout. I have told them that I don't think we can, but was sufficiently unsure that I am being asked to research it. After all, people do some bonkers stuff in javascript nowadays.

So my questions are, in Chrome, Edge, and IE 11, and without adding extensions, can we:

  1. Detect what windows are open to our domain?
  2. Close said windows forcibly?

I of course know that I could collect window handles for each window opened from our portal page, but as indicated above, I can't depend on all of them having been opened by my portal.

Entropy
  • 1,219
  • 6
  • 21
  • 45

1 Answers1

0

-- Get and close browser tabs that match my domain on logout

-- Detect what windows are open to our domain?

-- Close said windows forcibly?

By using JavaScript, we could only close the tab/window that your code performed window.open() on. also if the window/tab navigates, the window handle is no longer valid and you can’t close it. You could check this thread.

Besides, we could also use selenium webdriver to loop through the tabs and close it. But using this method, we have to use the Edge webdriver, Internet Explorer webdriver and Chrome WebDriver. here are some related threads, you could refer to them:

Is there a way to close a tab in WebDriver or Protractor?

Python and Selenium - Close all tabs without closing the browser

Generally, after login success via SSO, we will get an access token. It contain login user information and the access information, and it also has the start time and expired time. Then, use session or cookie to store this token. After user logout, we should clear the session and cookie, and make the token expired, so next time when user click the website, need to enter user account again. So, in my opinion, I think there is no need to close the related tabs, you could use this method.

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30