summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_async.js
blob: f00ba0275501f8a1edd79934211310354ab089d8 (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
32
33
34
35
36
37
38
39
40
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

add_task(async function setup() {
  await AddonTestUtils.promiseStartupManager();
  await SearchTestUtils.useTestEngines("simple-engines");
  Services.fog.initializeFOG();
});

add_task(async function test_async() {
  Assert.ok(!Services.search.isInitialized);

  let aStatus = await Services.search.init();
  Assert.ok(Components.isSuccessCode(aStatus));
  Assert.ok(Services.search.isInitialized);

  // test engines from dir are not loaded.
  let engines = await Services.search.getEngines();
  Assert.equal(engines.length, 2);

  // test jar engine is loaded ok.
  let engine = Services.search.getEngineByName("basic");
  Assert.notEqual(engine, null);
  Assert.ok(engine.isAppProvided, "Should be shown as an app-provided engine");

  engine = Services.search.getEngineByName("Simple Engine");
  Assert.notEqual(engine, null);
  Assert.ok(engine.isAppProvided, "Should be shown as an app-provided engine");

  // Check the hidden engine is not loaded.
  engine = Services.search.getEngineByName("hidden");
  Assert.equal(engine, null);

  // Check if there is a value for startup_time
  Assert.notEqual(
    await Glean.searchService.startupTime.testGetValue(),
    undefined,
    "Should have a value stored in startup_time"
  );
});