diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 3b37ec9409d3..a4054f3f90a7 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -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 diff --git a/browser/base/content/test/general/browser_urlbarDelete.js b/browser/base/content/test/general/browser_urlbarDelete.js new file mode 100644 index 000000000000..22d5c0965afc --- /dev/null +++ b/browser/base/content/test/general/browser_urlbarDelete.js @@ -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"); +} diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 56694f5b1a9e..18b754999e76 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -866,6 +866,23 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. ]]> + + + + diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index f2dc24677f02..529023e12e11 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -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 @@ ]]> + + + +