Commit d4239fb5 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Disable "Install new service" button when offline

The button currently does nothing when offline, so disable it to avoid
confusion.

Bug: 925272
Change-Id: I5577285e58ecf8c6ce3362db54b96b0bb83f6b8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570964Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654799}
parent baeb053a
......@@ -908,7 +908,9 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("requestMountSourceFile"),
TestCase("requestMountSourceFile").DisableNativeSmb(),
TestCase("providerEject"),
TestCase("providerEject").DisableNativeSmb()));
TestCase("providerEject").DisableNativeSmb(),
TestCase("installNewServiceOnline"),
TestCase("installNewServiceOffline").Offline()));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
GearMenu, /* gear_menu.js */
......
......@@ -2313,8 +2313,9 @@ CommandHandler.COMMANDS_['install-new-extension'] = /** @type {Command} */ ({
});
},
canExecute: function(event, fileManager) {
event.canExecute = fileManager.dialogType === DialogType.FULL_PAGE;
event.command.setHidden(!event.canExecute);
const isFullPage = fileManager.dialogType === DialogType.FULL_PAGE;
event.canExecute = isFullPage && navigator.onLine;
event.command.setHidden(!isFullPage);
}
});
......
......@@ -275,4 +275,32 @@
// ejected.
return IGNORE_APP_ERRORS;
};
/**
* Tests that when online, the install new service button is enabled.
*/
testcase.installNewServiceOnline = async () => {
const appId = await setUpProvider('manifest.json');
await showProvidersMenu(appId);
const selector = '#add-new-services-menu:not([hidden]) ' +
'cr-menu-item[command="#install-new-extension"]:not([disabled])';
const element = await remoteCall.waitForElement(appId, selector);
chrome.test.assertEq('Install new service', element.text);
chrome.test.assertFalse(element.hidden);
};
/**
* Tests that when offline, the install new service button is disabled.
*/
testcase.installNewServiceOffline = async () => {
const appId = await setUpProvider('manifest.json');
await showProvidersMenu(appId);
const selector = '#add-new-services-menu:not([hidden]) ' +
'cr-menu-item[command="#install-new-extension"][disabled]';
const element = await remoteCall.waitForElement(appId, selector);
chrome.test.assertEq('Install new service', element.text);
chrome.test.assertFalse(element.hidden);
};
})();
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