Commit 419187a7 authored by Jeevan Shikaram's avatar Jeevan Shikaram Committed by Commit Bot

[App Management] Uninstalling an app now behaves correctly.

This CL fixes the errors that stopped the main page from being shown
when an app was uninstalled. dom-switch now detaches it's child when
the app-permission-view is not being displayed.

Bug: 1001710
Change-Id: Iefb2e19a3a1aa70d69bbafa9c5b347a030f8fa0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1799650
Commit-Queue: Jeevan Shikaram <jshikaram@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697449}
parent 1aca8b38
...@@ -30,11 +30,13 @@ Polymer({ ...@@ -30,11 +30,13 @@ Polymer({
}, },
/** /**
* @param {App} app
* @return {?string}
* @private * @private
*/ */
getSelectedRouteId_: function(app) { getSelectedRouteId_: function(app) {
if (!app) { if (!app) {
return; return null;
} }
const selectedAppType = app.type; const selectedAppType = app.type;
......
...@@ -101,13 +101,19 @@ Polymer({ ...@@ -101,13 +101,19 @@ Polymer({
}, },
/** /**
* @param {string} newRouteId * @param {?string} newRouteId
*/ */
onRouteChanged_: function(newRouteId) { onRouteChanged_: function(newRouteId) {
if (!this.instance_) { if (!this.instance_) {
return; return;
} }
if (newRouteId === null) {
this.parentNode.removeChild(this.selectedChild_);
this.selectedChild_ = null;
return;
}
const newSelectedChild = this.children_[newRouteId]; const newSelectedChild = this.children_[newRouteId];
assert( assert(
newSelectedChild, newSelectedChild,
......
...@@ -44,6 +44,9 @@ Polymer({ ...@@ -44,6 +44,9 @@ Polymer({
* @private * @private
*/ */
iconUrlFromId_: function(app) { iconUrlFromId_: function(app) {
if (!app) {
return '';
}
return app_management.util.getAppIcon(app); return app_management.util.getAppIcon(app);
}, },
......
...@@ -44,6 +44,11 @@ suite('<app-management-dom-switch>', function() { ...@@ -44,6 +44,11 @@ suite('<app-management-dom-switch>', function() {
domSwitch.route = '2'; domSwitch.route = '2';
assertFalse(!!document.getElementById('child1')); assertFalse(!!document.getElementById('child1'));
assertTrue(!!document.getElementById('child2')); assertTrue(!!document.getElementById('child2'));
// When no child is selected, the currently selected child is detached.
domSwitch.route = null;
assertFalse(!!document.getElementById('child1'));
assertFalse(!!document.getElementById('child2'));
}); });
test('binding to properties and paths works', function() { test('binding to properties and paths works', function() {
......
...@@ -171,6 +171,27 @@ const OSSettingsAppManagementBrowserTest = class extends OSSettingsBrowserTest { ...@@ -171,6 +171,27 @@ const OSSettingsAppManagementBrowserTest = class extends OSSettingsBrowserTest {
} }
}; };
// Text fixture for the app management dom switch element.
// eslint-disable-next-line no-var
var OSSettingsAppManagementDomSwitchTest =
class extends OSSettingsAppManagementBrowserTest {
/** @override */
get browsePreload() {
return super.browsePreload + 'app_management/dom_switch.html';
}
/** @override */
get extraLibraries() {
return super.extraLibraries.concat([
'app_management/dom_switch_test.js',
]);
}
};
TEST_F('OSSettingsAppManagementDomSwitchTest', 'All', function() {
mocha.run();
});
// Test fixture for the app management settings page. // Test fixture for the app management settings page.
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var OSSettingsAppManagementPageTest = var OSSettingsAppManagementPageTest =
......
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