WebDriver: fix return value of close window command
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2017 11:38:22 +0000 (11:38 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2017 11:38:22 +0000 (11:38 +0000)
commit9f22fb4acc1b385217f9d99f78978ae1af4c18e9
treef97815392cddd59b7691a9774456913d70a3b16d
parenta04aca1d79a934752cecbfabb893053e1e09d52a
WebDriver: fix return value of close window command
https://bugs.webkit.org/show_bug.cgi?id=174861

Reviewed by Brian Burg.

We are currently returning null, but we should return the list of window handles, and try to close the session
if there aren't more window handles.

10.2 Close Window
https://w3c.github.io/webdriver/webdriver-spec.html#close-window

3. If there are no more open top-level browsing contexts, then try to close the session.
4. Return the result of running the remote end steps for the Get Window Handles command.

* Session.cpp:
(WebDriver::Session::closeAllToplevelBrowsingContexts): Helper function to close the given toplevel browsing
context and the next one if there are more.
(WebDriver::Session::close): Call closeAllToplevelBrowsingContexts() to delete all toplevel browsing contexts of
the session.
(WebDriver::Session::closeTopLevelBrowsingContext): Close the given toplevel browsing context and call
getWindowHandles() when done.
(WebDriver::Session::closeWindow): Call closeTopLevelBrowsingContext() passing the current toplevel browsing context.
(WebDriver::Session::getWindowHandles): Remove the early return, this command doesn't depend on a current
toplevel browsing context.
* Session.h:
* SessionHost.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::run): Disconnect the server when main loop quits.
(WebDriver::WebDriverService::deleteSession): Do not fail if the given session is not active.
(WebDriver::WebDriverService::closeWindow): Remove the session if the closed window was the last one.
* WebDriverService.h: Remove unused quit() method.
* glib/SessionHostGlib.cpp:
(WebDriver::SessionHost::isConnected): Return whether host is connected to a browser instance.
(WebDriver::SessionHost::dbusConnectionClosedCallback): Delete m_browser.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebDriver/ChangeLog
Source/WebDriver/Session.cpp
Source/WebDriver/Session.h
Source/WebDriver/SessionHost.cpp
Source/WebDriver/SessionHost.h
Source/WebDriver/WebDriverService.cpp
Source/WebDriver/WebDriverService.h
Source/WebDriver/glib/SessionHostGlib.cpp