appium/appium — pull request #1472 by snevesbarros (2013-11-14 11:28:54+00:00)
Title: Added ability to close tabs in safari when using safariLauncher 

By changing the window.close() javascript call we can now close tabs for mobile safari on physical devices as well. This solution bypasses the rule that javascript can only close a tab opened by javascript.

In addition we automatically connect to the latest window (rather than the first) as this is the one opened by SafariLauncher.

Tested this on Sim (iOS6 and iOS7) with:
mocha -t 60000 -R spec test/functional/safari -g "findElement"

And on physical iOS6 (iPhone) and iOS7 iPad and I was able to close tabs and run safari tests.