summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/unit/test_dupe_urls.js
blob: 9707233279be6fc68401804a00239d76944baaa3 (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
60
61
62
63
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Ensure inline autocomplete doesn't return zero frecency pages.

add_task(async function setup() {
  registerCleanupFunction(async () => {
    Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
  });

  Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
});

add_task(async function test_dupe_urls() {
  info("Searching for urls with dupes should only show one");
  await PlacesTestUtils.addVisits(
    {
      uri: Services.io.newURI("http://mozilla.org/"),
    },
    {
      uri: Services.io.newURI("http://mozilla.org/?"),
    }
  );
  let context = createContext("moz", { isPrivate: false });
  await check_results({
    context,
    autofilled: "mozilla.org/",
    completed: "http://mozilla.org/",
    matches: [
      makeVisitResult(context, {
        uri: "http://mozilla.org/",
        title: "mozilla.org",
        heuristic: true,
      }),
    ],
  });
  await cleanupPlaces();
});

add_task(async function test_dupe_secure_urls() {
  await PlacesTestUtils.addVisits(
    {
      uri: Services.io.newURI("https://example.org/"),
    },
    {
      uri: Services.io.newURI("https://example.org/?"),
    }
  );
  let context = createContext("exam", { isPrivate: false });
  await check_results({
    context,
    autofilled: "example.org/",
    completed: "https://example.org/",
    matches: [
      makeVisitResult(context, {
        uri: "https://example.org/",
        title: "https://example.org",
        heuristic: true,
      }),
    ],
  });
  await cleanupPlaces();
});