Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: browser/components/urlbar/tests/unit/xpcshell.toml
/* 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
/**
*
* site subdomains.
*/
testEngine_setup();
add_task(async function test_swap_protocol() {
await PlacesTestUtils.addVisits([
{ uri: uri8, title: "title" },
{ uri: uri7, title: "title" },
{ uri: uri6, title: "title" },
{ uri: uri5, title: "title" },
{ uri: uri4, title: "title" },
{ uri: uri3, title: "title" },
{ uri: uri2, title: "title" },
{ uri: uri1, title: "title" },
]);
// Disable autoFill to avoid handling the first result.
Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
Services.prefs.setBoolPref("browser.urlbar.suggest.searches", false);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.urlbar.suggest.searches");
});
let context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
title: "title",
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
title: "title",
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
heuristic: true,
}),
makeVisitResult(context, { uri: uri3.spec, title: "title" }),
makeVisitResult(context, { uri: uri4.spec, title: "title" }),
makeVisitResult(context, { uri: uri6.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri3.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri3.spec, title: "title" }),
makeVisitResult(context, { uri: uri4.spec, title: "title" }),
makeVisitResult(context, { uri: uri6.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri3.spec, title: "title" }),
makeVisitResult(context, { uri: uri4.spec, title: "title" }),
makeVisitResult(context, { uri: uri6.spec, title: "title" }),
],
});
info("www.site matches 'www.site' pages");
searchString = "www.site";
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
title: "title",
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
],
});
info("w matches 'w' pages, including 'www'");
context = createContext("w", { isPrivate: false });
await check_results({
context,
matches: [
makeSearchResult(context, {
engineName: SUGGESTIONS_ENGINE_NAME,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
makeVisitResult(context, { uri: uri7.spec, title: "title" }),
makeVisitResult(context, { uri: uri8.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
makeVisitResult(context, { uri: uri7.spec, title: "title" }),
makeVisitResult(context, { uri: uri8.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
],
});
info("ww matches no 'ww' pages, including 'www'");
context = createContext("ww", { isPrivate: false });
await check_results({
context,
matches: [
makeSearchResult(context, {
engineName: SUGGESTIONS_ENGINE_NAME,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
makeVisitResult(context, { uri: uri8.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
makeVisitResult(context, { uri: uri8.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
],
});
info("www matches 'www' pages");
context = createContext("www", { isPrivate: false });
await check_results({
context,
matches: [
makeSearchResult(context, {
engineName: SUGGESTIONS_ENGINE_NAME,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
makeVisitResult(context, { uri: uri8.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
makeVisitResult(context, { uri: uri5.spec, title: "title" }),
makeVisitResult(context, { uri: uri8.spec, title: "title" }),
],
});
context = createContext(searchString, { isPrivate: false });
await check_results({
context,
matches: [
makeVisitResult(context, {
uri: `${searchString}/`,
fallbackTitle: `${searchString}/`,
source: UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
heuristic: true,
}),
],
});
await cleanupPlaces();
});