Commit d2d014a7 authored by Jordy Greenblatt's avatar Jordy Greenblatt Committed by Commit Bot

[CrOS MultiDevice] Block false Settings error from ambiguous listener.

The settings-multidevice-setup-page listens for the event 'close'
as a proxy for the password prompt being confirmed. However, the
event type 'close' is ubiquitous to cr-dialog so it also fires when
the forget device dialog is closed on the subpage, which causes the
assertion "assert(this.featureToBeEnabledOnceAuthenticated_ !== null)"
in SettingsMultidevicePageElement.onPasswordPromptDialogClose() to
fail.

This CL only calls onPasswordPromptDialogClose_ if the close event came
from the MultiDevice page's password prompt and stops the event's
propagation.

Bug: 887160
Change-Id: I5740061c8f9e08ee5ba9e8d99862bcec6b0a6677
Reviewed-on: https://chromium-review.googlesource.com/1235321
Commit-Queue: Jordy Greenblatt <jordynass@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592908}
parent 703664dc
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<div class$= <div class$=
"[[getMultiDeviceItemLabelBlockCssClass_(pageContentData)]]"> "[[getMultiDeviceItemLabelBlockCssClass_(pageContentData)]]">
<div id="multidevice-label">[[getLabelText_(pageContentData)]]</div> <div id="multidevice-label">[[getLabelText_(pageContentData)]]</div>
<div id="mutltideviceSubLabel" class="secondary" <div id="multideviceSubLabel" class="secondary"
inner-h-t-m-l="[[getSubLabelInnerHtml_(pageContentData)]]"> inner-h-t-m-l="[[getSubLabelInnerHtml_(pageContentData)]]">
</div> </div>
</div> </div>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
restamp> restamp>
<paper-icon-button-light class="subpage-arrow"> <paper-icon-button-light class="subpage-arrow">
<button aria-labelledby="multidevice-label" <button aria-labelledby="multidevice-label"
aria-describedby="mutltideviceSubLabel"></button> aria-describedby="multideviceSubLabel"></button>
</paper-icon-button-light> </paper-icon-button-light>
</template> </template>
<div class="separator"></div> <div class="separator"></div>
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
</template> </template>
</settings-animated-pages> </settings-animated-pages>
<template is="dom-if" if="[[showPasswordPromptDialog_]]" restamp> <template is="dom-if" if="[[showPasswordPromptDialog_]]" restamp>
<settings-password-prompt-dialog id="passwordPrompt"> <settings-password-prompt-dialog id="multidevicePasswordPrompt">
</settings-password-prompt-dialog> </settings-password-prompt-dialog>
</template> </template>
</template> </template>
......
...@@ -63,7 +63,7 @@ Polymer({ ...@@ -63,7 +63,7 @@ Polymer({
listeners: { listeners: {
'auth-token-changed': 'onAuthTokenChanged_', 'auth-token-changed': 'onAuthTokenChanged_',
'close': 'onPasswordPromptDialogClose_', 'close': 'onDialogClose_',
'feature-toggle-clicked': 'onFeatureToggleClicked_', 'feature-toggle-clicked': 'onFeatureToggleClicked_',
'forget-device-requested': 'onForgetDeviceRequested_', 'forget-device-requested': 'onForgetDeviceRequested_',
}, },
...@@ -204,6 +204,12 @@ Polymer({ ...@@ -204,6 +204,12 @@ Polymer({
this.showPasswordPromptDialog_ = true; this.showPasswordPromptDialog_ = true;
}, },
onDialogClose_: function(event) {
event.stopPropagation();
if (event.path.some(element => element.id === 'multidevicePasswordPrompt'))
this.onPasswordPromptDialogClose_();
},
/** @private */ /** @private */
onPasswordPromptDialogClose_: function() { onPasswordPromptDialogClose_: function() {
// The password prompt should only be shown when there is a feature waiting // The password prompt should only be shown when there is a feature waiting
......
...@@ -87,7 +87,8 @@ suite('Multidevice', function() { ...@@ -87,7 +87,8 @@ suite('Multidevice', function() {
assertTrue(multidevicePage.showPasswordPromptDialog_); assertTrue(multidevicePage.showPasswordPromptDialog_);
// Simulate the user entering a valid password, then closing the dialog. // Simulate the user entering a valid password, then closing the dialog.
multidevicePage.fire('auth-token-changed', {value: 'validAuthToken'}); multidevicePage.fire('auth-token-changed', {value: 'validAuthToken'});
multidevicePage.fire('close'); // Simulate closing the password prompt dialog
multidevicePage.$$('#multidevicePasswordPrompt').fire('close');
Polymer.dom.flush(); Polymer.dom.flush();
} else { } else {
assertFalse(multidevicePage.showPasswordPromptDialog_); assertFalse(multidevicePage.showPasswordPromptDialog_);
......
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