Skip to content

Instantly share code, notes, and snippets.

@zacc
Forked from bebef1987/kill_all.py
Last active January 3, 2016 10:38
Show Gist options
  • Save zacc/8450360 to your computer and use it in GitHub Desktop.
Save zacc/8450360 to your computer and use it in GitHub Desktop.
def kill_all(self):
self.marionette.switch_to_frame()
self.marionette.execute_async_script("""
// Kills all running apps, except the homescreen.
function killAll() {
let originsToClose = [];
let that = this;
let runningApps = window.wrappedJSObject.AppWindowManager.getRunningApps();
for (let origin in runningApps) {
if (origin.indexOf('homescreen') == -1) {
window.wrappedJSObject.AppWindowManager.kill(origin);
}
}
if (!originsToClose.length) {
marionetteScriptFinished(true);
return;
}
originsToClose.slice(0).forEach(function(origin) {
kill(origin, function() {});
});
};
killAll();
""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment