webdriver icon indicating copy to clipboard operation
webdriver copied to clipboard

What happens when the last window is closed through JS?

Open gsnedders opened this issue 5 years ago • 2 comments

What should the behaviour be given:

wd = new Session();
wd.execute("window.close()");

As far as I can tell the spec fails to account for this at all. The session is still open but we have no current browsing which as far as I can tell is a state the spec doesn't believe exists.

gsnedders avatar Aug 05 '20 15:08 gsnedders

Beside MacOS where the browser process still exists, the process is gone on Linux and Windows. As such I would suggest we handle it similar like the Close Window command.

Note that we can run into the same situation with Element Click and Element Send Keys.

whimboo avatar Aug 13 '20 08:08 whimboo

We should probably generally specify what happens when the last window closes, rather than trying to do it for each and every command. But maybe we do need to do it for each command to make it clear how they act… Though esp. anything that triggers JS could asynchronously close the window which means you could be at any point in an algorithm when the spec says to do something involving the current browsing context and then you'd find there are no windows left (which is in some ways comparable to #1308).

Beside MacOS where the browser process still exists, the process is gone on Linux and Windows. As such I would suggest we handle it similar like the Close Window command.

Note that that is in principle this is browser-controlled behaviour (and I believe Chrome for example keeps running in the background by default on Windows at least).

gsnedders avatar Aug 18 '20 19:08 gsnedders