Commit 622075a4 authored by Zain Afzal's avatar Zain Afzal Committed by Commit Bot

Focus the sandboxed iframe when chrome://media-app loads.

Currently the host frame is focused, which means keyboard shortcuts
installed on 'window' in the sandboxed iframe will not see events until
the iframe is clicked on or otherwise interacted with.

Bug: b/158707819
Change-Id: I866776c41b90faaa2e2cb7814fc3f714c4e81725
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2239140
Commit-Queue: Zain Afzal <zafzal@google.com>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777275}
parent 8ba027e4
......@@ -536,3 +536,11 @@ function installLaunchHandler() {
}
installLaunchHandler();
// Make sure the guest frame has focus.
/** @type {!Element} */
const guest = assertCast(
document.querySelector('iframe[src^="chrome-untrusted://media-app"]'));
guest.addEventListener('load', () => {
guest.focus();
});
......@@ -731,6 +731,16 @@ TEST_F('MediaAppUIBrowserTest', 'RelatedFiles', async () => {
testDone();
});
// Tests that the guest gets focus automatically on start up.
TEST_F('MediaAppUIBrowserTest', 'GuestHasFocus', async () => {
const guest = document.querySelector('iframe');
// By the time this tests runs the iframe should already have been loaded.
assertEquals(document.activeElement, guest);
testDone();
});
// Test cases injected into the guest context.
// See implementations in media_app_guest_ui_browsertest.js.
......
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