From 8fd10a11116a6a9cfea9f716f90cfbd7fbf19c66 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Thu, 9 Jul 2020 08:04:47 +0000 Subject: [PATCH] Bug 1649493 - Fix intermittent failure in test_remove_profile_engine.js - ensure we correctly wait for the cache to save. r=daleharvey Differential Revision: https://phabricator.services.mozilla.com/D82228 --- .../tests/xpcshell/test_remove_profile_engine.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js b/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js index d47ea69e4bd2..efebc8edae40 100644 --- a/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js +++ b/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js @@ -1,6 +1,9 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +// This test is to ensure that we remove xml files from searchplugins/ in the +// profile directory when a user removes the actual engine from their profile. + add_task(async function run_test() { // Copy an engine to [profile]/searchplugin/ let dir = do_get_profile().clone(); @@ -15,14 +18,16 @@ add_task(async function run_test() { Assert.ok(file.exists()); await AddonTestUtils.promiseStartupManager(); + let cacheWrittenPromise = promiseAfterCache(); await Services.search.init(); + await cacheWrittenPromise; // Install the same engine through a supported way. useHttpServer(); + cacheWrittenPromise = promiseAfterCache(); await addTestEngines([{ name: "basic", xmlFileName: "engine-override.xml" }]); - await promiseAfterCache(); + await cacheWrittenPromise; let data = await promiseCacheData(); - // Put the filePath inside the cache file, to simulate what a pre-58 version // of Firefox would have done. for (let engine of data.engines) { @@ -33,7 +38,9 @@ add_task(async function run_test() { await promiseSaveCacheData(data); + cacheWrittenPromise = promiseAfterCache(); await asyncReInit(); + await cacheWrittenPromise; // test the engine is loaded ok. let engine = Services.search.getEngineByName("basic");