Skip to content

Commit

Permalink
Bug 1645521 - Part 3 - Port unifiedcomplete tests. r=adw
Browse files Browse the repository at this point in the history
  • Loading branch information
htwyford committed Jul 9, 2020
1 parent 86c7d10 commit a2379d0
Show file tree
Hide file tree
Showing 14 changed files with 571 additions and 580 deletions.
536 changes: 536 additions & 0 deletions browser/components/urlbar/tests/unit/test_providerHeuristicFallback.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions browser/components/urlbar/tests/unit/xpcshell.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ support-files =
data/engine-tail-suggestions.xml

[test_muxer.js]
[test_providerHeuristicFallback.js]
[test_providerOmnibox.js]
[test_providerOpenTabs.js]
[test_providersManager.js]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,14 @@ function addAutofillTasks(origins) {
}

// Enable actions. In the `origins` case, the failure to make an autofill
// match should not interrupt creating another type of heuristic match, in
// this case a search (for "ex"). In the `!origins` case, autofill should
// still happen since there's no threshold comparison.
// match means UnifiedComplete should not create a heuristic result. In the
// `!origins` case, autofill should still happen since there's no threshold
// comparison.
if (origins) {
await check_autocomplete({
search,
searchParam: "enable-actions",
matches: [
makeSearchMatch(search, { style: ["heuristic"] }),
{
value: "https://not-" + url,
comment: "test visit for https://not-" + url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,24 @@ async function check_autocomplete(test) {
if (matches.length) {
let firstIndexToCheck = 0;
if (test.searchParam && test.searchParam.includes("enable-actions")) {
firstIndexToCheck = 1;
info("Checking first match is first autocomplete entry");
let result = {
value: controller.getValueAt(0),
comment: controller.getCommentAt(0),
style: controller.getStyleAt(0),
image: controller.getImageAt(0),
};
info(`First match is "${result.value}", "${result.comment}"`);
Assert.ok(
await _check_autocomplete_matches(matches[0], result),
"first item is correct"
);
info("Checking rest of the matches");
// We only care about the positioning of the first result if it is
// heuristic.
if (result.style.includes("heuristic")) {
info("Checking first match is first autocomplete entry");
info(`First match is "${result.value}", "${result.comment}"`);
Assert.ok(
await _check_autocomplete_matches(matches[0], result),
"first item is correct"
);
info("Checking rest of the matches");
firstIndexToCheck = 1;
}
}

for (let i = firstIndexToCheck; i < controller.matchCount; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ add_task(async function test_javascript_match() {
search: "foo",
searchParam: "enable-actions",
matches: [
makeSearchMatch("foo", { heuristic: true }),
{ uri: uri1, title: "title" },
{ uri: uri2, title: "title", style: ["bookmark"] },
{ uri: uri3, title: "title" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,6 @@ add_task(async function test_keyword_search() {
],
});

info("Bug 420328: no-param keyword with a param");
await check_autocomplete({
search: "noparam foo",
searchParam: "enable-actions",
matches: [makeSearchMatch("noparam foo", { heuristic: true })],
});
await check_autocomplete({
search: "post_noparam foo",
searchParam: "enable-actions",
matches: [makeSearchMatch("post_noparam foo", { heuristic: true })],
});

info("escaping with default UTF-8 charset");
await check_autocomplete({
search: "encoded foé",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,6 @@ function makeRemoteTabMatch(url, deviceName, extra = {}) {
};
}

// The tests.
add_task(async function test_nomatch() {
// Nothing matches.
configureEngine({
guid_desktop: {
id: "desktop",
tabs: [
{
urlHistory: ["http://foo.com/"],
},
],
},
});

// No remote tabs match here, so we only expect search results.
await check_autocomplete({
search: "ex",
searchParam: "enable-actions",
matches: [makeSearchMatch("ex", { heuristic: true })],
});
});

add_task(async function test_minimal() {
// The minimal client and tabs info we can get away with.
configureEngine({
Expand All @@ -104,10 +82,7 @@ add_task(async function test_minimal() {
await check_autocomplete({
search: "ex",
searchParam: "enable-actions",
matches: [
makeSearchMatch("ex", { heuristic: true }),
makeRemoteTabMatch("http://example.com/", "My Desktop"),
],
matches: [makeRemoteTabMatch("http://example.com/", "My Desktop")],
});
});

Expand All @@ -130,7 +105,6 @@ add_task(async function test_maximal() {
search: "ex",
searchParam: "enable-actions",
matches: [
makeSearchMatch("ex", { heuristic: true }),
makeRemoteTabMatch("http://example.com/", "My Phone", {
title: "An Example",
icon: "moz-anno:favicon:http://favicon/",
Expand Down Expand Up @@ -158,7 +132,6 @@ add_task(async function test_noShowIcons() {
search: "ex",
searchParam: "enable-actions",
matches: [
makeSearchMatch("ex", { heuristic: true }),
makeRemoteTabMatch("http://example.com/", "My Phone", {
title: "An Example",
// expecting the default favicon due to that pref.
Expand Down Expand Up @@ -187,7 +160,7 @@ add_task(async function test_dontMatchSyncedTabs() {
await check_autocomplete({
search: "ex",
searchParam: "enable-actions",
matches: [makeSearchMatch("ex", { heuristic: true })],
matches: [],
});
Services.prefs.clearUserPref("services.sync.syncedTabs.showRemoteTabs");
});
Expand All @@ -210,7 +183,6 @@ add_task(async function test_matches_title() {
search: "ex",
searchParam: "enable-actions",
matches: [
makeSearchMatch("ex", { heuristic: true }),
makeRemoteTabMatch("http://foo.com/", "My Phone", {
title: "An Example",
}),
Expand Down Expand Up @@ -243,10 +215,7 @@ add_task(async function test_localtab_matches_override() {
await check_autocomplete({
search: "ex",
searchParam: "enable-actions",
matches: [
makeSearchMatch("ex", { heuristic: true }),
makeSwitchToTabMatch("http://foo.com/", { title: "An Example" }),
],
matches: [makeSwitchToTabMatch("http://foo.com/", { title: "An Example" })],
});
await removeOpenPages(uri, 1);
});
Expand Down Expand Up @@ -275,7 +244,6 @@ add_task(async function test_remotetab_matches_override() {
search: "rem",
searchParam: "enable-actions",
matches: [
makeSearchMatch("rem", { heuristic: true }),
makeRemoteTabMatch("http://foo.remote.com/", "My Phone", {
title: "An Example",
}),
Expand Down Expand Up @@ -312,7 +280,6 @@ add_task(async function test_many_remotetab_matches() {
searchParam: "enable-actions",
checkSorting: true,
matches: [
makeSearchMatch("rem", { heuristic: true }),
makeRemoteTabMatch("http://foo.remote.com/0", "My Phone", {
title: "A title",
}),
Expand Down Expand Up @@ -361,15 +328,12 @@ add_task(async function test_maxResults() {
},
});

// Set maxResults to 5 in our search. 5 results total should be returned: the
// heuristic followed by ceil(maxResults / 2) remote tabs, then two more
// remote tabs to round out the number of results to 5.
// Set maxResults to 4 in our search.
await check_autocomplete({
search: "rem",
searchParam: "enable-actions max-results:5",
searchParam: "enable-actions max-results:4",
checkSorting: true,
matches: [
makeSearchMatch("rem", { heuristic: true }),
makeRemoteTabMatch("http://foo.remote.com/0", "My Phone", {
title: "A title",
}),
Expand Down Expand Up @@ -409,15 +373,14 @@ add_task(async function test_restrictionCharacter() {
await PlacesTestUtils.addVisits([{ uri, title: "An Example" }]);
await addOpenPages(uri, 1);

// Set maxResults to 8 in our search. 8 results should be returned: the
// heuristic followed by (maxResults / 2) remote tabs, then the open tab, then
// 2 more remote tab results to get to 8 total.
// Set maxResults to 7 in our search. 7 results should be returned:
// ceil(maxResults / 2) remote tabs, then the open tab, then 2 more remote tab
// results to get to 7 total.
await check_autocomplete({
search: UrlbarTokenizer.RESTRICT.OPENPAGE,
searchParam: "enable-actions max-results:8",
searchParam: "enable-actions max-results:7",
checkSorting: true,
matches: [
makeSearchMatch(UrlbarTokenizer.RESTRICT.OPENPAGE, { heuristic: true }),
makeRemoteTabMatch("http://foo.remote.com/0", "My Phone", {
title: "A title",
}),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -111,30 +111,6 @@ add_task(async function basicGetAndPost() {
}),
],
});

// When a restriction token is used before the alias, the alias should *not*
// be recognized. It should be treated as part of the search string. Try
// all the restriction tokens to test that. We should get a single "search
// with" heuristic result without an alias.
for (let token of Object.values(UrlbarTokenizer.RESTRICT)) {
let search = `${token} ${alias} query string`;
let searchQuery =
token == UrlbarTokenizer.RESTRICT.SEARCH &&
search.startsWith(UrlbarTokenizer.RESTRICT.SEARCH)
? search.substring(2)
: search;
await check_autocomplete({
search,
searchParam: "enable-actions",
matches: [
makeSearchMatch(search, {
engineName: "MozSearch",
searchQuery,
heuristic: true,
}),
],
});
}
}
await cleanup();
});

This file was deleted.

Loading

0 comments on commit a2379d0

Please sign in to comment.