summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_engine_alias.js
blob: 62c3c141c1c0f4a2c4ca2d107fd91fa7c5faa671 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

const NAME = "Test Alias Engine";

add_task(async function setup() {
  await AddonTestUtils.promiseStartupManager();
  let settingsFileWritten = promiseAfterSettings();
  await Services.search.init();
  await settingsFileWritten;
});

add_task(async function upgrade_with_configuration_change_test() {
  let settingsFileWritten = promiseAfterSettings();
  await SearchTestUtils.installSearchExtension({
    name: NAME,
    keyword: "testalias",
  });
  await settingsFileWritten;

  let engine = await Services.search.getEngineByAlias("testalias");
  Assert.equal(engine?.name, NAME, "Engine can be fetched by alias");

  // Restart the search service but not the AddonManager, we will
  // load the engines from settings.
  Services.search.wrappedJSObject.reset();
  await Services.search.init();

  engine = await Services.search.getEngineByAlias("testalias");
  Assert.equal(engine?.name, NAME, "Engine can be fetched by alias");
});