Bug 1105244 - avoid delete key removing the first special entry in the unified autocomplete popup. r=mossop

This commit is contained in:
Mark Hammond 2015-05-19 08:45:33 +10:00
Родитель c2599e18f5
Коммит fb79ba4b12
4 изменённых файлов: 78 добавлений и 1 удалений

Просмотреть файл

@ -427,6 +427,7 @@ skip-if = e10s # Bug 1100700 - test relies on unload event firing on closed tabs
[browser_urlHighlight.js]
[browser_urlbarAutoFillTrimURLs.js]
[browser_urlbarCopying.js]
[browser_urlbarDelete.js]
[browser_urlbarEnter.js]
[browser_urlbarEnterAfterMouseOver.js]
skip-if = os == "linux" || e10s # Bug 1073339 - Investigate autocomplete test unreliability on Linux/e10s

Просмотреть файл

@ -0,0 +1,53 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
add_task(function*() {
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/",
title: "test" });
registerCleanupFunction(function* () {
yield PlacesUtils.bookmarks.remove(bm);
});
// We do this test with both unifiedcomplete disabled and enabled.
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", false);
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, testDelete);
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, testDelete);
});
function sendHome() {
// unclear why VK_HOME doesn't work on Mac, but it doesn't...
if (Services.appinfo.OS == "Darwin") {
EventUtils.synthesizeKey("VK_LEFT", { altKey: true });
} else {
EventUtils.synthesizeKey("VK_HOME", {});
}
}
function sendDelete() {
EventUtils.synthesizeKey("VK_DELETE", {});
}
function* testDelete() {
yield promiseAutocompleteResultPopup("exam");
// move to the start.
sendHome();
// delete the first few chars - each delete should operate on the input field.
sendDelete();
Assert.equal(gURLBar.inputField.value, "xam");
yield promisePopupShown(gURLBar.popup);
sendDelete();
Assert.equal(gURLBar.inputField.value, "am");
}

Просмотреть файл

@ -866,6 +866,23 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
]]></body>
</method>
<method name="handleDelete">
<body><![CDATA[
// When UnifiedComplete is enabled, we arrange for the popup to
// always have a "special" first item that's always selected. The
// autocomplete controller's handleDelete() implementation will
// remove the selected entry from the popup in that case.
// So when our first special item is selected, we call handleText
// instead so it acts as a delete on the text value instead of
// removing that item.
if (Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete") &&
this.popup.selectedIndex == 0) {
return this.mController.handleText();
}
return this.mController.handleDelete();
]]></body>
</method>
</implementation>
<handlers>

Просмотреть файл

@ -485,7 +485,7 @@
case KeyEvent.DOM_VK_BACK_SPACE:
if (aEvent.shiftKey)
#endif
cancel = this.mController.handleDelete();
cancel = this.handleDelete();
break;
case KeyEvent.DOM_VK_DOWN:
case KeyEvent.DOM_VK_UP:
@ -514,6 +514,12 @@
]]></body>
</method>
<method name="handleDelete">
<body><![CDATA[
return this.mController.handleDelete();
]]></body>
</method>
<!-- ::::::::::::: miscellaneous ::::::::::::: -->
<method name="initSearchNames">