зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1521702 - Hook up autofill with URL canonization. r=dao
Differential Revision: https://phabricator.services.mozilla.com/D18620 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a8e8126805
Коммит
43bf9e7c8a
|
@ -310,8 +310,15 @@ class UrlbarInput {
|
|||
allowInheritPrincipal: false,
|
||||
};
|
||||
|
||||
// TODO bug 1521702: Call _maybeCanonizeURL for autofilled results with the
|
||||
// typed string (not the autofilled one).
|
||||
if (result.autofill) {
|
||||
// For autofilled results, the value that should be canonized is not the
|
||||
// autofilled value but the value that the user typed.
|
||||
let canonizedUrl = this._maybeCanonizeURL(event, this._lastSearchString);
|
||||
if (canonizedUrl) {
|
||||
this._loadURL(canonizedUrl, where, openParams);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (result.type) {
|
||||
case UrlbarUtils.RESULT_TYPE.TAB_SWITCH: {
|
||||
|
|
|
@ -80,3 +80,55 @@ add_task(async function checkPrefTurnsOffCanonize() {
|
|||
gBrowser.removeTab(t);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function autofill() {
|
||||
// Re-enable autofill and canonization.
|
||||
await SpecialPowers.pushPrefEnv({set: [
|
||||
["browser.urlbar.autoFill", true],
|
||||
["browser.urlbar.ctrlCanonizesURLs", true],
|
||||
]});
|
||||
|
||||
// Quantumbar automatically disables autofill when the old search string
|
||||
// starts with the new search string, so to make sure that doesn't happen and
|
||||
// that earlier tests don't conflict with this one, start a new search for
|
||||
// some other string.
|
||||
gURLBar.focus();
|
||||
EventUtils.sendString("blah");
|
||||
|
||||
// Add a visit that will be autofilled.
|
||||
await PlacesUtils.history.clear();
|
||||
await PlacesTestUtils.addVisits([{
|
||||
uri: "http://example.com/",
|
||||
}]);
|
||||
|
||||
let testcases = [
|
||||
["ex", "http://www.ex.com/", { ctrlKey: true }],
|
||||
// Check that a direct load is not overwritten by a previous canonization.
|
||||
["ex", "http://example.com/", {}],
|
||||
// search alias
|
||||
["@goo", "http://www%2E@goo.com/", { ctrlKey: true }],
|
||||
];
|
||||
|
||||
function promiseAutofill() {
|
||||
return BrowserTestUtils.waitForEvent(gURLBar.inputField, "select");
|
||||
}
|
||||
|
||||
for (let [inputValue, expectedURL, options] of testcases) {
|
||||
let promiseLoad =
|
||||
BrowserTestUtils.waitForDocLoadAndStopIt(expectedURL, gBrowser.selectedBrowser);
|
||||
gURLBar.focus();
|
||||
gURLBar.inputField.value = inputValue.slice(0, -1);
|
||||
let autofillPromise = promiseAutofill();
|
||||
EventUtils.sendString(inputValue.slice(-1));
|
||||
await autofillPromise;
|
||||
EventUtils.synthesizeKey("KEY_Enter", options);
|
||||
await promiseLoad;
|
||||
|
||||
// Here again, make sure autofill isn't disabled for the next search. See
|
||||
// the comment above.
|
||||
gURLBar.focus();
|
||||
EventUtils.sendString("blah");
|
||||
}
|
||||
|
||||
await PlacesUtils.history.clear();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче