From 32640e20198ea02c2be5a950031e86a74cdffc40 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 19 Aug 2026 14:44:36 -0400 Subject: [PATCH] Wait for test success file to be written before quitting The write is asynchronous, and on Windows the app quit before it finished, making passing test runs report failure. --- test/content/runtests.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/content/runtests.js b/test/content/runtests.js index aef4a991e3..758eaf1b2b 100644 --- a/test/content/runtests.js +++ b/test/content/runtests.js @@ -10,15 +10,20 @@ chai.config.truncateThreshold = 0 function quit(failed) { // Quit with exit status + var promise = Promise.resolve(); if(!failed) { - IOUtils.write(PathUtils.join(FileUtils.getDir("ProfD", []).path, "success"), new Uint8Array(0)); + // Wait for the write, which the runner uses to detect success, to finish before + // quitting -- on Windows, quitting could otherwise beat it + promise = IOUtils.write(PathUtils.join(FileUtils.getDir("ProfD", []).path, "success"), new Uint8Array(0)); } if(!TestOptions.noquit) { - setTimeout(function () { - Components.classes['@mozilla.org/toolkit/app-startup;1'] - .getService(Components.interfaces.nsIAppStartup) - .quit(Components.interfaces.nsIAppStartup.eForceQuit); - }, 250); + promise.then(function () { + setTimeout(function () { + Components.classes['@mozilla.org/toolkit/app-startup;1'] + .getService(Components.interfaces.nsIAppStartup) + .quit(Components.interfaces.nsIAppStartup.eForceQuit); + }, 250); + }); } }