From 3f3ee01fa02ae0d829f5666039e5d2c2178c8b88 Mon Sep 17 00:00:00 2001 From: David Rajchenbach-Teller Date: Wed, 14 May 2014 08:39:00 +0200 Subject: [PATCH] Bug 1010277 - Fixed uncaught async error in test_DownloadImport.js. r=paolo --- .../components/jsdownloads/test/unit/head.js | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/toolkit/components/jsdownloads/test/unit/head.js b/toolkit/components/jsdownloads/test/unit/head.js index 0b26d3198abc..7b8a2c16bad1 100644 --- a/toolkit/components/jsdownloads/test/unit/head.js +++ b/toolkit/components/jsdownloads/test/unit/head.js @@ -466,31 +466,6 @@ function promiseStartExternalHelperAppServiceDownload(aSourceUrl) { return deferred.promise; } -/** - * Waits for a download to finish, in case it has not finished already. - * - * @param aDownload - * The Download object to wait upon. - * - * @return {Promise} - * @resolves When the download has finished successfully. - * @rejects JavaScript exception if the download failed. - */ -function promiseDownloadStopped(aDownload) { - if (!aDownload.stopped) { - // The download is in progress, wait for the current attempt to finish and - // report any errors that may occur. - return aDownload.start(); - } - - if (aDownload.succeeded) { - return Promise.resolve(); - } - - // The download failed or was canceled. - return Promise.reject(aDownload.error || new Error("Download canceled.")); -} - /** * Waits for a download to reach half of its progress, in case it has not * reached the expected progress already. @@ -827,6 +802,10 @@ add_task(function test_common_initialize() DownloadIntegration._deferTestOpenFile = Promise.defer(); DownloadIntegration._deferTestShowDir = Promise.defer(); + // Avoid leaking uncaught promise errors + DownloadIntegration._deferTestOpenFile.promise.then(null, () => undefined); + DownloadIntegration._deferTestShowDir.promise.then(null, () => undefined); + // Get a reference to nsIComponentRegistrar, and ensure that is is freed // before the XPCOM shutdown. let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);