Commit 56aa5a78 authored by dpapad's avatar dpapad Committed by Commit Bot

Settings WebUI: Dismiss "reset profile" dialog on back navigation.

Bug: 822640
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I34936fa59d5f930250a12619674f4be1ee5c767c
Reviewed-on: https://chromium-review.googlesource.com/966996Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544213}
parent 6e824a20
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
'target_name': 'reset_page', 'target_name': 'reset_page',
'dependencies': [ 'dependencies': [
'../compiled_resources2.gyp:route', '../compiled_resources2.gyp:route',
'<(DEPTH)/ui/webui/resources/cr_elements/cr_lazy_render/compiled_resources2.gyp:cr_lazy_render',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
......
...@@ -57,11 +57,18 @@ Polymer({ ...@@ -57,11 +57,18 @@ Polymer({
* @protected * @protected
*/ */
currentRouteChanged: function(route) { currentRouteChanged: function(route) {
const lazyRender =
/** @type {!CrLazyRenderElement} */ (this.$.resetProfileDialog);
if (route == settings.routes.TRIGGERED_RESET_DIALOG || if (route == settings.routes.TRIGGERED_RESET_DIALOG ||
route == settings.routes.RESET_DIALOG) { route == settings.routes.RESET_DIALOG) {
/** @type {!SettingsResetProfileDialogElement} */ ( /** @type {!SettingsResetProfileDialogElement} */ (lazyRender.get())
this.$.resetProfileDialog.get())
.show(); .show();
} else {
const dialog = /** @type {?SettingsResetProfileDialogElement} */ (
lazyRender.getIfExists());
if (dialog)
dialog.cancel();
} }
}, },
......
...@@ -115,7 +115,12 @@ Polymer({ ...@@ -115,7 +115,12 @@ Polymer({
/** @private */ /** @private */
onCancelTap_: function() { onCancelTap_: function() {
this.$.dialog.cancel(); this.cancel();
},
cancel: function() {
if (this.$.dialog.open)
this.$.dialog.cancel();
}, },
/** @private */ /** @private */
......
...@@ -75,11 +75,16 @@ cr.define('settings_reset_page', function() { ...@@ -75,11 +75,16 @@ cr.define('settings_reset_page', function() {
return testOpenCloseResetProfileDialog(function(dialog) { return testOpenCloseResetProfileDialog(function(dialog) {
// Test case where the 'cancel' button is clicked. // Test case where the 'cancel' button is clicked.
MockInteractions.tap(dialog.$.cancel); MockInteractions.tap(dialog.$.cancel);
}).then(PolymerTest.flushTasks).then(function() { }).then(function() {
return testOpenCloseResetProfileDialog(function(dialog) { return testOpenCloseResetProfileDialog(function(dialog) {
// Test case where the 'close' button is clicked. // Test case where the 'close' button is clicked.
MockInteractions.tap(dialog.$.dialog.getCloseButton()); MockInteractions.tap(dialog.$.dialog.getCloseButton());
}); });
}).then(function() {
return testOpenCloseResetProfileDialog(function(dialog) {
// Test case where the browser's 'back' button is clicked.
resetPage.currentRouteChanged(settings.routes.BASIC);
});
}); });
}); });
......
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