Commit 712add90 authored by fukino's avatar fukino Committed by Commit bot

Warn on executing command on unsupported elements.

Elements which don't have corresponding entries can be focused. (for example, when buttons are focused by <Tab>.)
When they are focused, canExecute of commands are called and warnings are emitted in CommandUtil.getCommandEntry().
This CL warn more specific (really suspicious) case. That is, a command executed on an element which doesn't have corresponding entry.

BUG=411790
TEST=manually tested

Review URL: https://codereview.chromium.org/550943003

Cr-Commit-Position: refs/heads/master@{#294125}
parent 06aaa078
...@@ -60,7 +60,6 @@ CommandUtil.getCommandEntry = function(element) { ...@@ -60,7 +60,6 @@ CommandUtil.getCommandEntry = function(element) {
// Check if it is Entry or not by checking for toURL(). // Check if it is Entry or not by checking for toURL().
return entry && 'toURL' in entry ? entry : null; return entry && 'toURL' in entry ? entry : null;
} else { } else {
console.warn('Unsupported element');
return null; return null;
} }
}; };
...@@ -329,8 +328,11 @@ CommandHandler.COMMANDS_['unmount'] = { ...@@ -329,8 +328,11 @@ CommandHandler.COMMANDS_['unmount'] = {
*/ */
execute: function(event, fileManager) { execute: function(event, fileManager) {
var root = CommandUtil.getCommandEntry(event.target); var root = CommandUtil.getCommandEntry(event.target);
if (!root) if (!root) {
console.warn('unmount command executed on an element which does not ' +
'have corresponding entry.');
return; return;
}
var errorCallback = function() { var errorCallback = function() {
fileManager.alert.showHtml('', str('UNMOUNT_FAILED')); fileManager.alert.showHtml('', str('UNMOUNT_FAILED'));
}; };
...@@ -806,8 +808,12 @@ CommandHandler.COMMANDS_['create-folder-shortcut'] = { ...@@ -806,8 +808,12 @@ CommandHandler.COMMANDS_['create-folder-shortcut'] = {
*/ */
execute: function(event, fileManager) { execute: function(event, fileManager) {
var entry = CommandUtil.getCommandEntry(event.target); var entry = CommandUtil.getCommandEntry(event.target);
if (entry) if (!entry) {
fileManager.createFolderShortcut(entry); console.warn('create-folder-shortcut command executed on an element ' +
'which does not have corresponding entry.');
return;
}
fileManager.createFolderShortcut(entry);
}, },
/** /**
...@@ -846,8 +852,12 @@ CommandHandler.COMMANDS_['remove-folder-shortcut'] = { ...@@ -846,8 +852,12 @@ CommandHandler.COMMANDS_['remove-folder-shortcut'] = {
*/ */
execute: function(event, fileManager) { execute: function(event, fileManager) {
var entry = CommandUtil.getCommandEntry(event.target); var entry = CommandUtil.getCommandEntry(event.target);
if (entry) if (!entry) {
fileManager.removeFolderShortcut(entry); console.warn('remove-folder-shortcut command executed on an element ' +
'which does not have corresponding entry.');
return;
}
fileManager.removeFolderShortcut(entry);
}, },
/** /**
......
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