Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
/* Any copyright is dedicated to the Public Domain.
"use strict";
/**
* Test deleting the start of urls works correctly.
*/
add_task(async function () {
// Add visits so that it can be autofilled.
await PlacesTestUtils.addVisits([
{
transition: PlacesUtils.history.TRANSITION_TYPED,
},
]);
await PlacesFrecencyRecalculator.recalculateAnyOutdatedFrecencies();
registerCleanupFunction(async function () {
await PlacesUtils.history.clear();
});
await BrowserTestUtils.withNewTab("about:blank", testDelete);
});
function sendHome() {
// unclear why VK_HOME doesn't work on Mac, but it doesn't...
if (AppConstants.platform == "macosx") {
EventUtils.synthesizeKey("KEY_ArrowLeft", { metaKey: true });
} else {
EventUtils.synthesizeKey("KEY_Home");
}
}
function sendDelete() {
EventUtils.synthesizeKey("KEY_Delete");
}
async function testDelete() {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
});
// move to the start.
sendHome();
// delete the first few chars - each delete should operate on the input field.
await UrlbarTestUtils.promisePopupOpen(window, sendDelete);
Assert.equal(gURLBar.value, "ug1105244.example.com/");
sendDelete();
Assert.equal(gURLBar.value, "g1105244.example.com/");
}