Call correct quit function and wait request sending.

This commit is contained in:
Brendan Dahl 2014-04-11 11:02:03 -07:00 committed by Yury Delendik
parent 70ce3a88a1
commit 339f8f0ac9

View File

@ -352,9 +352,16 @@ function snapshotCurrentPage(task, failure) {
}); });
} }
function sendQuitRequest() { function sendQuitRequest(cb) {
var r = new XMLHttpRequest(); var r = new XMLHttpRequest();
r.open('POST', '/tellMeToQuit?path=' + escape(appPath), false); r.open('POST', '/tellMeToQuit?path=' + escape(appPath), false);
r.onreadystatechange = function sendQuitRequestOnreadystatechange(e) {
if (r.readyState == 4) {
if (cb) {
cb();
}
}
};
r.send(null); r.send(null);
} }
@ -362,12 +369,13 @@ function quitApp() {
log('Done !'); log('Done !');
document.body.innerHTML = 'Tests are finished. <h1>CLOSE ME!</h1>' + document.body.innerHTML = 'Tests are finished. <h1>CLOSE ME!</h1>' +
document.body.innerHTML; document.body.innerHTML;
sendQuitRequest(function () {
if (window.SpecialPowers) { if (window.SpecialPowers) {
SpecialPowers.quitApplication(); SpecialPowers.quit();
} else { } else {
sendQuitRequest();
window.close(); window.close();
} }
});
} }
function done() { function done() {