Commit 256aade4 authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Just refresh the focus index when navigating chrome://media-app.

This will need more intelligence later to allow nearby files to preload.
For now it's enough to only validate the file being navigated to.

Bug: b/159757240
Change-Id: I2edfe421af38163afcea9d8bc38b138e75d11f9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2262093
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarBugs Nash <bugsnash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781739}
parent 62c133e3
......@@ -306,17 +306,25 @@ async function sendFilesToGuest() {
*/
async function sendSnapshotToGuest(
snapshot, localLaunchNumber, extraFiles = false) {
const focusIndex = entryIndex;
// On first launch, files are opened to determine navigation candidates. Don't
// reopen in that case. Otherwise, attempt to reopen here. Some files may be
// assigned null, e.g., if they have been moved to a different folder.
await Promise.all(snapshot.map(refreshFile));
// reopen in that case. Otherwise, attempt to reopen the focus file only. In
// future we might also open "nearby" files for preloading. However, reopening
// *all* files on every navigation attempt to verify they can still be
// navigated to adds noticeable lag in large directories.
if (focusIndex >= 0 && focusIndex < snapshot.length) {
await refreshFile(snapshot[focusIndex]);
} else if (snapshot.length !== 0) {
await refreshFile(snapshot[0]);
}
if (localLaunchNumber !== globalLaunchNumber) {
return;
}
/** @type {!LoadFilesMessage} */
const loadFilesMessage = {
writableFileIndex: entryIndex,
writableFileIndex: focusIndex,
// Handle can't be passed through a message pipe.
files: snapshot.map(fd => ({
token: fd.token,
......
......@@ -372,8 +372,11 @@ TEST_F('MediaAppUIBrowserTest', 'NavigateWithUnopenableSibling', async () => {
assertEquals(currentFiles.length, 3);
// The error stays on the third, now unopenable. But, since we've advanced,
// it has now rotated into the second slot.
assertEquals(await getFileErrors(), ',NotAllowedError,');
// it has now rotated into the second slot. But! Also we don't validate it
// until it rotates into the first slot, so the error won't be present yet.
// If we implement pre-loading, this expectation can change to
// ',NotAllowedError,'.
assertEquals(await getFileErrors(), ',,');
// Navigate to the unopenable file and expect a graceful error.
await advance(1);
......@@ -382,7 +385,8 @@ TEST_F('MediaAppUIBrowserTest', 'NavigateWithUnopenableSibling', async () => {
assertEquals(currentFiles.length, 3);
assertEquals(await getFileErrors(), 'NotAllowedError,,');
// Navigating back to an openable file should still work.
// Navigating back to an openable file should still work, and the error should
// "stick".
await advance(1);
result = await waitForImageAndGetWidth('1.png');
assertEquals(result, '111');
......
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