Commit d80d69dc authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Local NTP, Realbox: fix Shift+Enter opening 2 windows

Fixed: 1013832
Change-Id: I5563e500d7c5371fb61ce07b1336e9e5446cd052
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857785
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@{#705720}
parent ca985233
......@@ -1269,6 +1269,7 @@ function onRealboxKeyDown(e) {
// this forwards key modifiers. This enables Shift+Enter to open a match
// in a new window, for example.
matchEls[selected].dispatchEvent(new MouseEvent('click', e));
e.preventDefault();
}
return;
}
......
......@@ -623,3 +623,30 @@ test.realbox.testRemoveIcon = function() {
assertEquals(0, $(test.realbox.IDS.REALBOX_MATCHES).children.length);
};
test.realbox.testPressEnterOnResult = function() {
test.realbox.realboxEl.value = 'hello world';
test.realbox.realboxEl.dispatchEvent(new CustomEvent('input'));
const matches = [test.realbox.getSearchMatch({supportsDeletion: true})];
chrome.embeddedSearch.searchBox.onqueryautocompletedone(
{input: test.realbox.realboxEl.value, matches});
const matchEls = $(test.realbox.IDS.REALBOX_MATCHES).children;
assertEquals(1, matchEls.length);
let clicked = false;
matchEls[0].onclick = () => clicked = true;
const shiftEnter = new KeyboardEvent('keydown', {
bubbles: true,
cancelable: true,
key: 'Enter',
target: matchEls[0],
shiftKey: true,
});
test.realbox.realboxEl.dispatchEvent(shiftEnter);
assertTrue(shiftEnter.defaultPrevented);
assertTrue(clicked);
};
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