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
This commit is contained in:
Mark Banner 2020-07-09 08:04:47 +00:00
Родитель 7ffb8f8c90
Коммит 8fd10a1111
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -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");