summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/unit/test_dont_autofill_cases.js
blob: fefdd68452711e3c5615906858ba32b1a9ca6479 (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
52
53
54
55
56
57
58
59
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
 * Tests some cases where autofill should not happen.
 */

testEngine_setup();

add_task(async function test_prefix_space_noautofill() {
  await PlacesTestUtils.addVisits({
    uri: Services.io.newURI("http://moz.org/test/"),
  });

  info("Should not try to autoFill if search string contains a space");
  let context = createContext(" mo", { isPrivate: false });
  await check_results({
    context,
    matches: [
      makeSearchResult(context, {
        engineName: SUGGESTIONS_ENGINE_NAME,
        query: " mo",
        heuristic: true,
      }),
      makeVisitResult(context, {
        uri: "http://moz.org/test/",
        title: "test visit for http://moz.org/test/",
      }),
    ],
  });

  await cleanupPlaces();
});

add_task(async function test_trailing_space_noautofill() {
  await PlacesTestUtils.addVisits({
    uri: Services.io.newURI("http://moz.org/test/"),
  });

  info("Should not try to autoFill if search string contains a space");
  let context = createContext("mo ", { isPrivate: false });
  await check_results({
    context,
    matches: [
      makeSearchResult(context, {
        engineName: SUGGESTIONS_ENGINE_NAME,
        query: "mo ",
        heuristic: true,
      }),
      makeVisitResult(context, {
        uri: "http://moz.org/test/",
        title: "test visit for http://moz.org/test/",
      }),
    ],
  });

  await cleanupPlaces();
});