summaryrefslogtreecommitdiffstats
path: root/browser/components/urlbar/tests/unit/test_encoded_urls.js
blob: 87a6015e868c62f1f12dd67129ca1e903668b71d (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
add_task(async function test_encoded() {
  info("Searching for over encoded url should not break it");
  let url = "https://www.mozilla.com/search/top/?q=%25%32%35";
  await PlacesTestUtils.addVisits({
    uri: Services.io.newURI(url),
    title: url,
  });
  let context = createContext(url, { isPrivate: false });
  await check_results({
    context,
    autofilled: url,
    completed: url,
    matches: [
      makeVisitResult(context, {
        uri: url,
        title: url,
        heuristic: true,
      }),
    ],
  });
  await cleanupPlaces();
});

add_task(async function test_encoded_trimmed() {
  info("Searching for over encoded url should not break it");
  let url = "https://www.mozilla.com/search/top/?q=%25%32%35";
  await PlacesTestUtils.addVisits({
    uri: Services.io.newURI(url),
    title: url,
  });
  let context = createContext("mozilla.com/search/top/?q=%25%32%35", {
    isPrivate: false,
  });
  await check_results({
    context,
    autofilled: "mozilla.com/search/top/?q=%25%32%35",
    completed: url,
    matches: [
      makeVisitResult(context, {
        uri: url,
        title: url,
        heuristic: true,
      }),
    ],
  });
  await cleanupPlaces();
});

add_task(async function test_encoded_partial() {
  info("Searching for over encoded url should not break it");
  let url = "https://www.mozilla.com/search/top/?q=%25%32%35";
  await PlacesTestUtils.addVisits({
    uri: Services.io.newURI(url),
    title: url,
  });
  let context = createContext("https://www.mozilla.com/search/top/?q=%25", {
    isPrivate: false,
  });
  await check_results({
    context,
    autofilled: url,
    completed: url,
    matches: [
      makeVisitResult(context, {
        uri: url,
        title: url,
        heuristic: true,
      }),
    ],
  });
  await cleanupPlaces();
});

add_task(async function test_encoded_path() {
  info("Searching for over encoded url should not break it");
  let url = "https://www.mozilla.com/%25%32%35/top/";
  await PlacesTestUtils.addVisits({
    uri: Services.io.newURI(url),
    title: url,
  });
  let context = createContext("https://www.mozilla.com/%25%32%35/t", {
    isPrivate: false,
  });
  await check_results({
    context,
    autofilled: url,
    completed: url,
    matches: [
      makeVisitResult(context, {
        uri: url,
        title: url,
        heuristic: true,
      }),
    ],
  });
  await cleanupPlaces();
});