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 @@
<div class$=
"[[getMultiDeviceItemLabelBlockCssClass_(pageContentData)]]">
<div id="multidevice-label">[[getLabelText_(pageContentData)]]</div>
<div id="mutltideviceSubLabel" class="secondary"
<div id="multideviceSubLabel" class="secondary"
inner-h-t-m-l="[[getSubLabelInnerHtml_(pageContentData)]]">
</div>
</div>
......@@ -64,7 +64,7 @@
restamp>
<paper-icon-button-light class="subpage-arrow">
<button aria-labelledby="multidevice-label"
aria-describedby="mutltideviceSubLabel"></button>
aria-describedby="multideviceSubLabel"></button>
</paper-icon-button-light>
</template>
<div class="separator"></div>
......@@ -97,7 +97,7 @@
</template>
</settings-animated-pages>
<template is="dom-if" if="[[showPasswordPromptDialog_]]" restamp>
<settings-password-prompt-dialog id="passwordPrompt">
<settings-password-prompt-dialog id="multidevicePasswordPrompt">
</settings-password-prompt-dialog>
</template>
</template>
......
......@@ -63,7 +63,7 @@ Polymer({
listeners: {
'auth-token-changed': 'onAuthTokenChanged_',
'close': 'onPasswordPromptDialogClose_',
'close': 'onDialogClose_',
'feature-toggle-clicked': 'onFeatureToggleClicked_',
'forget-device-requested': 'onForgetDeviceRequested_',
},
......@@ -204,6 +204,12 @@ Polymer({
this.showPasswordPromptDialog_ = true;
},
onDialogClose_: function(event) {
event.stopPropagation();
if (event.path.some(element => element.id === 'multidevicePasswordPrompt'))
this.onPasswordPromptDialogClose_();
},
/** @private */
onPasswordPromptDialogClose_: function() {
// The password prompt should only be shown when there is a feature waiting
......
......@@ -87,7 +87,8 @@ suite('Multidevice', function() {
assertTrue(multidevicePage.showPasswordPromptDialog_);
// Simulate the user entering a valid password, then closing the dialog.
multidevicePage.fire('auth-token-changed', {value: 'validAuthToken'});
multidevicePage.fire('close');
// Simulate closing the password prompt dialog
multidevicePage.$$('#multidevicePasswordPrompt').fire('close');
Polymer.dom.flush();
} else {
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