Commit 6d08312c authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Local NTP, Realbox: fix [more] console errors

Pressing unmodified Delete is currently throwing.

R=mahmadi@chromium.org
Fixed: 1013833

Change-Id: Ia895d0977595562e8ea636a063a88bd663a0ebad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1861113
Auto-Submit: Dan Beam <dbeam@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Dan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705810}
parent 3a4bd179
...@@ -1246,9 +1246,9 @@ function onRealboxKeyDown(e) { ...@@ -1246,9 +1246,9 @@ function onRealboxKeyDown(e) {
return matchEl.classList.contains(CLASSES.SELECTED); return matchEl.classList.contains(CLASSES.SELECTED);
}); });
if (key === 'Delete' && e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { if (key === 'Delete') {
if (autocompleteMatches[selected].supportsDeletion) { if (e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey &&
matchElBeingDeleted = matchEls[selected]; autocompleteMatches[selected].supportsDeletion) {
window.chrome.embeddedSearch.searchBox.deleteAutocompleteMatch(selected); window.chrome.embeddedSearch.searchBox.deleteAutocompleteMatch(selected);
e.preventDefault(); e.preventDefault();
} }
......
...@@ -579,6 +579,24 @@ test.realbox.testSupportedDeletion = function() { ...@@ -579,6 +579,24 @@ test.realbox.testSupportedDeletion = function() {
assertEquals(newMatchesEl.children[0], document.activeElement); assertEquals(newMatchesEl.children[0], document.activeElement);
}; };
test.realbox.testNonShiftDelete = function() {
test.realbox.realboxEl.value = 'hello world';
test.realbox.realboxEl.dispatchEvent(new CustomEvent('input'));
chrome.embeddedSearch.searchBox.onqueryautocompletedone({
input: test.realbox.realboxEl.value,
matches: [test.realbox.getSearchMatch(), test.realbox.getUrlMatch()],
});
const deleteKey = new KeyboardEvent('keydown', {
bubbles: true,
cancelable: true,
key: 'Delete',
});
test.realbox.realboxEl.dispatchEvent(deleteKey); // Previously threw error.
assertFalse(deleteKey.defaultPrevented);
};
test.realbox.testRemoveIcon = function() { test.realbox.testRemoveIcon = function() {
test.realbox.realboxEl.value = 'hello world'; test.realbox.realboxEl.value = 'hello world';
test.realbox.realboxEl.dispatchEvent(new CustomEvent('input')); test.realbox.realboxEl.dispatchEvent(new CustomEvent('input'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment