From 8d8d6feabfde22c0e8e25f8c71602e5a45cc6364 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Tue, 9 Jan 2018 18:54:58 -0500 Subject: [PATCH] Bug 888784 - Make satchel tests wait for FormHistory to be clear when shutting down. r=mak MozReview-Commit-ID: 9rxyT48VnNj --HG-- extra : rebase_source : b4b0dd42bdda44182bd83baf8715fbe6813e00a5 --- toolkit/components/satchel/test/parent_utils.js | 10 +++++++--- toolkit/components/satchel/test/satchel_common.js | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/toolkit/components/satchel/test/parent_utils.js b/toolkit/components/satchel/test/parent_utils.js index 513dc7103ff6..e8f841c1a50a 100644 --- a/toolkit/components/satchel/test/parent_utils.js +++ b/toolkit/components/satchel/test/parent_utils.js @@ -23,8 +23,10 @@ var ParentUtils = { return entries; }, - cleanUpFormHist() { - FormHistory.update({ op: "remove" }); + cleanUpFormHist(callback) { + FormHistory.update({ op: "remove" }, { + handleCompletion: callback, + }); }, updateFormHistory(changes) { @@ -116,7 +118,9 @@ var ParentUtils = { cleanup() { gAutocompletePopup.removeEventListener("popupshown", this._popupshownListener); - this.cleanUpFormHist(); + this.cleanUpFormHist(() => { + sendAsyncMessage("cleanup-done"); + }); }, }; diff --git a/toolkit/components/satchel/test/satchel_common.js b/toolkit/components/satchel/test/satchel_common.js index 623d46735700..ef621f3b6a81 100644 --- a/toolkit/components/satchel/test/satchel_common.js +++ b/toolkit/components/satchel/test/satchel_common.js @@ -281,7 +281,13 @@ function satchelCommonSetup() { SimpleTest.registerCleanupFunction(() => { gChromeScript.sendAsyncMessage("cleanup"); - gChromeScript.destroy(); + return new Promise(resolve => { + gChromeScript.addMessageListener("cleanup-done", function done() { + gChromeScript.removeMessageListener("cleanup-done", done); + gChromeScript.destroy(); + resolve(); + }); + }); }); }