summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/unifiedcomplete/test_search_engine_alias.js
blob: f35242e2108c578248187c411c5ebb44c8e8d09c (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
41
42
43
44
45
46
47
48
49
50
51
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */


add_task(function*() {
  // Note that head_autocomplete.js has already added a MozSearch engine.
  // Here we add another engine with a search alias.
  Services.search.addEngineWithDetails("AliasedGETMozSearch", "", "get", "",
                                       "GET", "http://s.example.com/search");
  Services.search.addEngineWithDetails("AliasedPOSTMozSearch", "", "post", "",
                                       "POST", "http://s.example.com/search");

  for (let alias of ["get", "post"]) {
    yield check_autocomplete({
      search: alias,
      searchParam: "enable-actions",
      matches: [ makeSearchMatch(alias, { engineName: `Aliased${alias.toUpperCase()}MozSearch`,
                                          searchQuery: "", alias, heuristic: true }) ]
    });

    yield check_autocomplete({
      search: `${alias} `,
      searchParam: "enable-actions",
      matches: [ makeSearchMatch(`${alias} `, { engineName: `Aliased${alias.toUpperCase()}MozSearch`,
                                                searchQuery: "", alias, heuristic: true }) ]
    });

    yield check_autocomplete({
      search: `${alias} mozilla`,
      searchParam: "enable-actions",
          matches: [ makeSearchMatch(`${alias} mozilla`, { engineName: `Aliased${alias.toUpperCase()}MozSearch`,
                                                           searchQuery: "mozilla", alias, heuristic: true }) ]
    });

    yield check_autocomplete({
      search: `${alias} MoZiLlA`,
      searchParam: "enable-actions",
          matches: [ makeSearchMatch(`${alias} MoZiLlA`, { engineName: `Aliased${alias.toUpperCase()}MozSearch`,
                                                           searchQuery: "MoZiLlA", alias, heuristic: true }) ]
    });

    yield check_autocomplete({
      search: `${alias} mozzarella mozilla`,
      searchParam: "enable-actions",
          matches: [ makeSearchMatch(`${alias} mozzarella mozilla`, { engineName: `Aliased${alias.toUpperCase()}MozSearch`,
                                                                      searchQuery: "mozzarella mozilla", alias, heuristic: true }) ]
    });
  }

  yield cleanup();
});