Commit 3b9772b4 authored by David's avatar David Committed by Commit Bot

Update renamed file in the untrusted context for chrome://media-app.

Prior we re-launched upon a successful rename so the file was
reloaded with the correct name. crrev/c/2352586 changes that but we
forgot to update it in the untrusted context.

Also adds tests for it.

Bug: b/165431994
Change-Id: I3b17c88b40ed563e043be7bb0b70c3dc098caeaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362169
Commit-Queue: David Lei <dlei@google.com>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799495}
parent cab8d3f2
...@@ -77,6 +77,9 @@ class ReceivedFile { ...@@ -77,6 +77,9 @@ class ReceivedFile {
const renameResponse = const renameResponse =
/** @type {!RenameFileResponse} */ (await parentMessagePipe.sendMessage( /** @type {!RenameFileResponse} */ (await parentMessagePipe.sendMessage(
Message.RENAME_FILE, {token: this.token, newFilename: newName})); Message.RENAME_FILE, {token: this.token, newFilename: newName}));
if (renameResponse.renameResult === RenameResult.SUCCESS) {
this.name = newName;
}
return renameResponse.renameResult; return renameResponse.renameResult;
} }
......
...@@ -16,6 +16,7 @@ let TestMessageResponseData; ...@@ -16,6 +16,7 @@ let TestMessageResponseData;
* @typedef {{ * @typedef {{
* deleteLastFile: (boolean|undefined), * deleteLastFile: (boolean|undefined),
* getFileErrors: (boolean|undefined), * getFileErrors: (boolean|undefined),
* getLastFileName: (boolean|undefined),
* navigate: (string|undefined), * navigate: (string|undefined),
* overwriteLastFile: (string|undefined), * overwriteLastFile: (string|undefined),
* pathToRoot: (!Array<string>|undefined), * pathToRoot: (!Array<string>|undefined),
......
...@@ -125,6 +125,8 @@ async function runTestQuery(data) { ...@@ -125,6 +125,8 @@ async function runTestQuery(data) {
assertCast(lastReceivedFileList).files.map(file => file.error).join(); assertCast(lastReceivedFileList).files.map(file => file.error).join();
} else if (data.openFile) { } else if (data.openFile) {
await DELEGATE.openFile(); await DELEGATE.openFile();
} else if (data.getLastFileName) {
result = firstReceivedItem().name;
} }
return {testQueryResult: result, testQueryResultData: extraResultData}; return {testQueryResult: result, testQueryResultData: extraResultData};
} }
......
...@@ -783,8 +783,14 @@ TEST_F('MediaAppUIBrowserTest', 'RenameOriginalIPC', async () => { ...@@ -783,8 +783,14 @@ TEST_F('MediaAppUIBrowserTest', 'RenameOriginalIPC', async () => {
testResponse.testQueryResult, 'renameOriginalFile resolved success'); testResponse.testQueryResult, 'renameOriginalFile resolved success');
// The original file that was renamed got deleted. // The original file that was renamed got deleted.
assertEquals(file2Handle, directory.lastDeleted); assertEquals(file2Handle, directory.lastDeleted);
// The new file has the right name in the trusted context.
assertEquals(directory.files.length, 2); assertEquals(directory.files.length, 2);
assertEquals(directory.files[entryIndex].name, 'new_file_name.png'); assertEquals(directory.files[entryIndex].name, 'new_file_name.png');
assertEquals(currentFiles[entryIndex].handle.name, 'new_file_name.png');
assertEquals(currentFiles[entryIndex].file.name, 'new_file_name.png');
// The new file has the right name in the untrusted context.
testResponse = await sendTestMessage({getLastFileName: true});
assertEquals(testResponse.testQueryResult, 'new_file_name.png');
// The new file uses the same token as the old file. // The new file uses the same token as the old file.
assertEquals(currentFiles[entryIndex].token, file2Token); assertEquals(currentFiles[entryIndex].token, file2Token);
// Check the new file written has the correct data. // Check the new file written has the correct data.
......
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