Commit bca45527 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

Turn off signin-allowed toggle after sign-out from dialog

When a sync user confirms to sign out after trying to turn
off the signin-allowed toggle, the toggle is now turned off.

Additional change:
 - The code related to the sign-out dialog in settings is
 extracted into its own element and refactored.

Bug: 892745
Change-Id: I9d638d8c77b1f4318fc592cc88f4be95e5eab7c8
Reviewed-on: https://chromium-review.googlesource.com/c/1280542Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600997}
parent b2ab63b3
......@@ -25,6 +25,7 @@ js_type_check("closure_compile") {
":profile_info_browser_proxy",
":setup_fingerprint_dialog",
":setup_pin_dialog",
":signout_dialog",
":sync_account_control",
":sync_browser_proxy",
":sync_page",
......@@ -174,6 +175,7 @@ js_library("people_page") {
":lock_screen",
":lock_state_behavior",
":profile_info_browser_proxy",
":signout_dialog",
":sync_browser_proxy",
"..:page_visibility",
"..:route",
......@@ -214,6 +216,19 @@ js_library("setup_pin_dialog") {
]
}
js_library("signout_dialog") {
deps = [
":profile_info_browser_proxy",
":sync_browser_proxy",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/cr_elements/cr_expand_button:cr_expand_button",
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:util",
"//ui/webui/resources/js:web_ui_listener_behavior",
]
}
js_library("sync_page") {
deps = [
":sync_browser_proxy",
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
......@@ -10,7 +7,6 @@
<link rel="import" href="chrome://resources/html/icon.html">
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
......@@ -27,6 +23,7 @@
<link rel="import" href="../passwords_and_forms_page/passwords_section.html">
<link rel="import" href="../passwords_and_forms_page/payments_section.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="signout_dialog.html">
<if expr="chromeos">
<link rel="import" href="account_manager.html">
......@@ -97,23 +94,6 @@
width: 40px;
}
#disconnectDialog [slot=footer] .settings-box {
--settings-box-row-padding: 0;
}
.delete-profile-warning {
padding-bottom: 10px;
padding-inline-end: var(--cr-section-padding);
/* In order to line up with the checkbox text. */
padding-inline-start: var(--cr-section-indent-padding);
padding-top: 10px;
}
#wideFooter {
/* Override the cr-dialog footer padding. */
padding: 16px 0;
}
<if expr="not chromeos">
#toast {
color: white;
......@@ -461,51 +441,10 @@
</if>
</settings-animated-pages>
<template is="dom-if" if="[[showDisconnectDialog_]]" restamp>
<cr-dialog id="disconnectDialog"
ignore-popstate ignore-enter-key
on-close="onDisconnectClosed_" close-text="$i18n{close}">
<div slot="title">$i18n{syncDisconnectTitle}</div>
<div slot="body">
<div inner-h-t-m-l="[[
getDisconnectExplanationHtml_(syncStatus.domain)]]">
</div>
</div>
<div slot="button-container">
<paper-button on-click="onDisconnectCancel_" class="cancel-button">
$i18n{cancel}
</paper-button>
<paper-button id="disconnectConfirm" class="action-button"
hidden="[[syncStatus.domain]]" on-click="onDisconnectConfirm_">
$i18n{syncDisconnect}
</paper-button>
<paper-button id="disconnectManagedProfileConfirm"
class="action-button" hidden="[[!syncStatus.domain]]"
on-click="onDisconnectConfirm_">
$i18n{syncDisconnectConfirm}
</paper-button>
</div>
<if expr="(not chromeos and is_posix) or is_win or is_macosx">
<template is="dom-if" if="[[!syncStatus.domain]]">
<div id="wideFooter" slot="footer">
<div class="settings-box first">
<cr-checkbox id="deleteProfile" class="start"
checked="{{deleteProfile_}}">
$i18n{syncDisconnectDeleteProfile}
</cr-checkbox>
<cr-expand-button expanded="{{deleteProfileWarningVisible_}}"
alt="$i18n{deleteProfileWarningExpandA11yLabel}">
</cr-expand-button>
</div>
<iron-collapse opened="[[deleteProfileWarningVisible_]]">
<div class="delete-profile-warning">
[[deleteProfileWarning_]]
</div>
</iron-collapse>
</div>
</template>
</if>
</cr-dialog>
<template is="dom-if" if="[[showSignoutDialog_]]" restamp>
<settings-signout-dialog sync-status="[[syncStatus]]"
on-close="onDisconnectDialogClosed_">
</settings-signout-dialog>
</template>
<template is="dom-if" if="[[showImportDataDialog_]]" restamp>
......
......@@ -86,26 +86,6 @@ Polymer({
*/
profileName_: String,
/**
* The profile deletion warning. The message indicates the number of
* profile stats that will be deleted if a non-zero count for the profile
* stats is returned from the browser.
* @private
*/
deleteProfileWarning_: String,
/**
* True if the profile deletion warning is visible.
* @private
*/
deleteProfileWarningVisible_: Boolean,
/**
* True if the checkbox to delete the profile has been checked.
* @private
*/
deleteProfile_: Boolean,
// <if expr="not chromeos">
/** @private */
showImportDataDialog_: {
......@@ -115,7 +95,7 @@ Polymer({
// </if>
/** @private */
showDisconnectDialog_: Boolean,
showSignoutDialog_: Boolean,
// <if expr="chromeos">
/**
......@@ -224,9 +204,6 @@ Polymer({
this.addWebUIListener(
'profile-info-changed', this.handleProfileInfo_.bind(this));
this.addWebUIListener(
'profile-stats-count-ready', this.handleProfileStatsCount_.bind(this));
this.syncBrowserProxy_ = settings.SyncBrowserProxyImpl.getInstance();
this.syncBrowserProxy_.getSyncStatus().then(
this.handleSyncStatus_.bind(this));
......@@ -245,22 +222,14 @@ Polymer({
settings.getCurrentRoute() == settings.routes.IMPORT_DATA;
if (settings.getCurrentRoute() == settings.routes.SIGN_OUT) {
// <if expr="not chromeos">
settings.ProfileInfoBrowserProxyImpl.getInstance().getProfileStatsCount();
// </if>
// If the sync status has not been fetched yet, optimistically display
// the disconnect dialog. There is another check when the sync status is
// fetched. The dialog will be closed then the user is not signed in.
// the sign-out dialog. There is another check when the sync status is
// fetched. The dialog will be closed when the user is not signed in.
if (this.syncStatus && !this.syncStatus.signedIn) {
settings.navigateToPreviousRoute();
} else {
this.showDisconnectDialog_ = true;
this.async(() => {
this.$$('#disconnectDialog').showModal();
});
this.showSignoutDialog_ = true;
}
} else if (this.showDisconnectDialog_) {
this.$$('#disconnectDialog').close();
}
},
......@@ -306,22 +275,6 @@ Polymer({
this.profileIconUrl_ = info.iconUrl;
},
/**
* Handler for when the profile stats count is pushed from the browser.
* @param {number} count
* @private
*/
handleProfileStatsCount_: function(count) {
const username = this.syncStatus.signedInUsername || '';
this.deleteProfileWarning_ = (count > 0) ?
(count == 1) ?
loadTimeData.getStringF(
'deleteProfileWarningWithCountsSingular', username) :
loadTimeData.getStringF(
'deleteProfileWarningWithCountsPlural', count, username) :
loadTimeData.getStringF('deleteProfileWarningWithoutCounts', username);
},
/**
* Handler for when the sync state is pushed from the browser.
* @param {?settings.SyncStatus} syncStatus
......@@ -334,9 +287,6 @@ Polymer({
const shouldRecordSigninImpression =
!this.syncStatus && syncStatus && this.showSignin_(syncStatus);
if (!syncStatus.signedIn && this.showDisconnectDialog_)
this.$$('#disconnectDialog').close();
this.syncStatus = syncStatus;
if (shouldRecordSigninImpression && !this.shouldShowSyncAccountControl_()) {
......@@ -388,8 +338,8 @@ Polymer({
},
/** @private */
onDisconnectClosed_: function() {
this.showDisconnectDialog_ = false;
onDisconnectDialogClosed_: function(e) {
this.showSignoutDialog_ = false;
// <if expr="not chromeos">
if (!this.diceEnabled_) {
// If DICE-enabled, this button won't exist here.
......@@ -403,7 +353,6 @@ Polymer({
if (settings.getCurrentRoute() == settings.routes.SIGN_OUT)
settings.navigateToPreviousRoute();
this.fire('signout-dialog-closed');
},
/** @private */
......@@ -411,27 +360,6 @@ Polymer({
settings.navigateTo(settings.routes.SIGN_OUT);
},
/** @private */
onDisconnectCancel_: function() {
this.$$('#disconnectDialog').close();
},
/** @private */
onDisconnectConfirm_: function() {
const deleteProfile = !!this.syncStatus.domain || this.deleteProfile_;
// Trigger the sign out event after the navigateToPreviousRoute().
// So that the navigation to the setting page could be finished before the
// sign out if navigateToPreviousRoute() returns synchronously even the
// browser is closed after the sign out. Otherwise, the navigation will be
// finished during session restore if the browser is closed before the async
// callback executed.
listenOnce(this, 'signout-dialog-closed', () => {
this.syncBrowserProxy_.signOut(deleteProfile);
});
this.$$('#disconnectDialog').close();
},
/** @private */
onSyncTap_: function() {
// When unified-consent is enabled, users can go to sync subpage regardless
......@@ -546,22 +474,6 @@ Polymer({
},
// </if>
/**
* @private
* @param {string} domain
* @return {string}
*/
getDisconnectExplanationHtml_: function(domain) {
// <if expr="not chromeos">
if (domain) {
return loadTimeData.getStringF(
'syncDisconnectManagedProfileExplanation',
'<span id="managed-by-domain-name">' + domain + '</span>');
}
// </if>
return loadTimeData.getString('syncDisconnectExplanation');
},
/**
* @private
* @param {?settings.SyncStatus} syncStatus
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="profile_info_browser_proxy.html">
<link rel="import" href="sync_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<dom-module id="settings-signout-dialog">
<template>
<style include="settings-shared">
#dialog [slot=footer] .settings-box {
--settings-box-row-padding: 0;
}
.delete-profile-warning {
padding-bottom: 10px;
padding-inline-end: var(--cr-section-padding);
/* In order to line up with the checkbox text. */
padding-inline-start: var(--cr-section-indent-padding);
padding-top: 10px;
}
#wideFooter {
/* Override the cr-dialog footer padding. */
padding: 16px 0;
}
</style>
<cr-dialog id="dialog" ignore-enter-key close-text="$i18n{close}">
<div slot="title">$i18n{syncDisconnectTitle}</div>
<div slot="body">
<div inner-h-t-m-l="[[
getDisconnectExplanationHtml_(syncStatus.domain)]]">
</div>
</div>
<div slot="button-container">
<paper-button id="disconnectCancel" class="cancel-button"
on-click="onDisconnectCancel_" >
$i18n{cancel}
</paper-button>
<paper-button id="disconnectConfirm" class="action-button"
hidden="[[syncStatus.domain]]" on-click="onDisconnectConfirm_">
$i18n{syncDisconnect}
</paper-button>
<paper-button id="disconnectManagedProfileConfirm"
class="action-button" hidden="[[!syncStatus.domain]]"
on-click="onDisconnectConfirm_">
$i18n{syncDisconnectConfirm}
</paper-button>
</div>
<if expr="(not chromeos and is_posix) or is_win or is_macosx">
<template is="dom-if" if="[[!syncStatus.domain]]">
<div id="wideFooter" slot="footer">
<div class="settings-box first">
<cr-checkbox id="deleteProfile" class="start"
checked="{{deleteProfile_}}">
$i18n{syncDisconnectDeleteProfile}
</cr-checkbox>
<cr-expand-button expanded="{{deleteProfileWarningVisible_}}"
alt="$i18n{deleteProfileWarningExpandA11yLabel}">
</cr-expand-button>
</div>
<iron-collapse opened="[[deleteProfileWarningVisible_]]">
<div class="delete-profile-warning">
[[deleteProfileWarning_]]
</div>
</iron-collapse>
</div>
</template>
</if>
</cr-dialog>
</template>
<script src="signout_dialog.js"></script>
</dom-module>
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview 'settings-signout-dialog' is a dialog that allows the
* user to turn off sync and sign out of Chromium.
*/
Polymer({
is: 'settings-signout-dialog',
behaviors: [WebUIListenerBehavior],
properties: {
/**
* The current sync status, supplied by the parent.
* @type {?settings.SyncStatus}
*/
syncStatus: {
type: Object,
observer: 'syncStatusChanged_',
},
/**
* True if the checkbox to delete the profile has been checked.
* @private
*/
deleteProfile_: Boolean,
/**
* True if the profile deletion warning is visible.
* @private
*/
deleteProfileWarningVisible_: Boolean,
/**
* The profile deletion warning. The message indicates the number of
* profile stats that will be deleted if a non-zero count for the profile
* stats is returned from the browser.
* @private
*/
deleteProfileWarning_: String,
},
/** @override */
attached: function() {
this.addWebUIListener(
'profile-stats-count-ready', this.handleProfileStatsCount_.bind(this));
// <if expr="not chromeos">
settings.ProfileInfoBrowserProxyImpl.getInstance().getProfileStatsCount();
// </if>
this.async(() => {
this.$.dialog.showModal();
});
},
/**
* Returns true when the user selected 'Confirm'.
* @return {boolean}
*/
wasConfirmed: function() {
return this.$.dialog.getNative().returnValue == 'success';
},
/**
* Handler for when the profile stats count is pushed from the browser.
* @param {number} count
* @private
*/
handleProfileStatsCount_: function(count) {
const username = this.syncStatus.signedInUsername || '';
if (count == 0) {
this.deleteProfileWarning_ = loadTimeData.getStringF(
'deleteProfileWarningWithoutCounts', username);
} else if (count == 1) {
this.deleteProfileWarning_ = loadTimeData.getStringF(
'deleteProfileWarningWithCountsSingular', username);
} else {
this.deleteProfileWarning_ = loadTimeData.getStringF(
'deleteProfileWarningWithCountsPlural', count, username);
}
},
/**
* Polymer observer for syncStatus.
* @private
*/
syncStatusChanged_: function() {
if (!this.syncStatus.signedIn && this.$.dialog.open)
this.$.dialog.close();
},
/**
* @private
* @param {string} domain
* @return {string}
*/
getDisconnectExplanationHtml_: function(domain) {
// <if expr="not chromeos">
if (domain) {
return loadTimeData.getStringF(
'syncDisconnectManagedProfileExplanation',
'<span id="managed-by-domain-name">' + domain + '</span>');
}
// </if>
return loadTimeData.getString('syncDisconnectExplanation');
},
/** @private */
onDisconnectCancel_: function() {
this.$.dialog.cancel();
},
/** @private */
onDisconnectConfirm_: function() {
this.$.dialog.close();
const deleteProfile = !!this.syncStatus.domain || this.deleteProfile_;
settings.SyncBrowserProxyImpl.getInstance().signOut(deleteProfile);
},
});
......@@ -37,6 +37,7 @@ js_library("privacy_page") {
"..:page_visibility",
"..:route",
"../controls:settings_toggle_button",
"../people_page:signout_dialog",
"../people_page:sync_browser_proxy",
"../settings_page:settings_animated_pages",
"../site_settings:constants",
......
......@@ -12,6 +12,7 @@
<link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="../lifetime_browser_proxy.html">
<link rel="import" href="../people_page/sync_browser_proxy.html">
<link rel="import" href="../people_page/signout_dialog.html">
<link rel="import" href="../route.html">
<link rel="import" href="../settings_page/settings_animated_pages.html">
<link rel="import" href="../settings_page/settings_subpage.html">
......@@ -581,6 +582,13 @@
</template>
</template>
</settings-animated-pages>
<template is="dom-if" if="[[showSignoutDialog_]]" restamp>
<settings-signout-dialog sync-status="[[syncStatus]]"
on-close="onSignoutDialogClosed_">
</settings-signout-dialog>
</template>
<if expr="not chromeos">
<cr-toast id="toast" open="[[showRestart_]]">
<div>$i18n{restartToApplyChanges}</div>
......
......@@ -166,6 +166,9 @@ Polymer({
/** @private */
showRestart_: Boolean,
// </if>
/** @private */
showSignoutDialog_: Boolean,
},
/** @override */
......@@ -369,9 +372,9 @@ Polymer({
/** @private */
onSigninAllowedChange_: function() {
if (this.syncStatus.signedIn && !this.$.signinAllowedToggle.checked) {
// Switch the toggle back on and route to people_page's disconnect dialog.
// Switch the toggle back on and show the signout dialog.
this.$.signinAllowedToggle.checked = true;
settings.navigateTo(settings.routes.SIGN_OUT);
this.showSignoutDialog_ = true;
} else {
/** @type {!SettingsToggleButtonElement} */ (this.$.signinAllowedToggle)
.sendPrefChange();
......@@ -379,6 +382,19 @@ Polymer({
}
},
/** @private */
onSignoutDialogClosed_: function() {
if (/** @type {!SettingsSignoutDialogElement} */ (
this.$$('settings-signout-dialog'))
.wasConfirmed()) {
this.$.signinAllowedToggle.checked = false;
/** @type {!SettingsToggleButtonElement} */ (this.$.signinAllowedToggle)
.sendPrefChange();
this.showRestart_ = true;
}
this.showSignoutDialog_ = false;
},
/**
* @param {!Event} e
* @private
......
......@@ -817,6 +817,14 @@
file="people_page/manage_profile_browser_proxy.js"
type="chrome_html" />
</if>
<structure name="IDR_SETTINGS_PEOPLE_PAGE_SIGNOUT_DIALOG_HTML"
file="people_page/signout_dialog.html"
type="chrome_html"
preprocess="true" />
<structure name="IDR_SETTINGS_PEOPLE_PAGE_SIGNOUT_DIALOG_JS"
file="people_page/signout_dialog.js"
type="chrome_html"
preprocess="true" />
<structure name="IDR_SETTINGS_PEOPLE_PAGE_PROFILE_INFO_BROWSER_PROXY_HTML"
file="people_page/profile_info_browser_proxy.html"
type="chrome_html" />
......
......@@ -133,20 +133,21 @@ cr.define('settings_people_page', function() {
Polymer.dom.flush();
disconnectButton = peoplePage.$$('#disconnectButton');
assertTrue(!!disconnectButton);
assertFalse(!!peoplePage.$$('#disconnectDialog'));
assertFalse(!!peoplePage.$$('settings-signout-dialog'));
disconnectButton.click();
Polymer.dom.flush();
})
.then(function() {
assertTrue(peoplePage.$$('#disconnectDialog').open);
assertFalse(peoplePage.$$('#deleteProfile').hidden);
const signoutDialog = peoplePage.$$('settings-signout-dialog');
assertTrue(signoutDialog.$$('#dialog').open);
assertFalse(signoutDialog.$$('#deleteProfile').hidden);
const deleteProfileCheckbox = peoplePage.$$('#deleteProfile');
const deleteProfileCheckbox = signoutDialog.$$('#deleteProfile');
assertTrue(!!deleteProfileCheckbox);
assertLT(0, deleteProfileCheckbox.clientHeight);
const disconnectConfirm = peoplePage.$$('#disconnectConfirm');
const disconnectConfirm = signoutDialog.$$('#disconnectConfirm');
assertTrue(!!disconnectConfirm);
assertFalse(disconnectConfirm.hidden);
......@@ -169,7 +170,7 @@ cr.define('settings_people_page', function() {
domain: 'example.com',
});
assertFalse(!!peoplePage.$$('#disconnectDialog'));
assertFalse(!!peoplePage.$$('#dialog'));
disconnectButton.click();
Polymer.dom.flush();
......@@ -178,11 +179,12 @@ cr.define('settings_people_page', function() {
});
})
.then(function() {
assertTrue(peoplePage.$$('#disconnectDialog').open);
assertFalse(!!peoplePage.$$('#deleteProfile'));
const signoutDialog = peoplePage.$$('settings-signout-dialog');
assertTrue(signoutDialog.$$('#dialog').open);
assertFalse(!!signoutDialog.$$('#deleteProfile'));
const disconnectManagedProfileConfirm =
peoplePage.$$('#disconnectManagedProfileConfirm');
signoutDialog.$$('#disconnectManagedProfileConfirm');
assertTrue(!!disconnectManagedProfileConfirm);
assertFalse(disconnectManagedProfileConfirm.hidden);
......@@ -218,10 +220,12 @@ cr.define('settings_people_page', function() {
})
.then(function() {
Polymer.dom.flush();
assertTrue(peoplePage.$$('#disconnectDialog').open);
const signoutDialog = peoplePage.$$('settings-signout-dialog');
assertTrue(signoutDialog.$$('#dialog').open);
// Assert the warning message is as expected.
const warningMessage = peoplePage.$$('.delete-profile-warning');
const warningMessage =
signoutDialog.$$('.delete-profile-warning');
cr.webUIListenerCallback('profile-stats-count-ready', 0);
assertEquals(
......@@ -243,7 +247,7 @@ cr.define('settings_people_page', function() {
warningMessage.textContent.trim());
// Close the disconnect dialog.
peoplePage.$$('#disconnectConfirm').click();
signoutDialog.$$('#disconnectConfirm').click();
return new Promise(function(resolve) {
listenOnce(window, 'popstate', resolve);
});
......@@ -258,7 +262,8 @@ cr.define('settings_people_page', function() {
peoplePage.async(resolve);
})
.then(function() {
assertTrue(peoplePage.$$('#disconnectDialog').open);
assertTrue(
peoplePage.$$('settings-signout-dialog').$$('#dialog').open);
return profileInfoBrowserProxy.whenCalled('getProfileStatsCount');
})
.then(function() {
......@@ -268,7 +273,9 @@ cr.define('settings_people_page', function() {
new settings.ProfileInfoBrowserProxyImpl().getProfileStatsCount();
// Close the disconnect dialog.
peoplePage.$$('#disconnectConfirm').click();
peoplePage.$$('settings-signout-dialog')
.$$('#disconnectConfirm')
.click();
})
.then(function() {
return new Promise(function(resolve) {
......@@ -286,7 +293,8 @@ cr.define('settings_people_page', function() {
});
})
.then(function() {
assertTrue(peoplePage.$$('#disconnectDialog').open);
assertTrue(
peoplePage.$$('settings-signout-dialog').$$('#dialog').open);
const popstatePromise = new Promise(function(resolve) {
listenOnce(window, 'popstate', resolve);
......
......@@ -183,12 +183,61 @@ cr.define('settings_privacy_page', function() {
page.syncStatus = {signedIn: true};
// When the user is signed in, clicking the toggle should open the
// sign-out dialog. The toggle should remain checked.
// sign-out dialog.
assertFalse(!!page.$$('settings-signout-dialog'));
toggle.click();
assertTrue(toggle.checked);
assertTrue(page.prefs.signin.allowed_on_next_startup.value);
assertFalse(page.$.toast.open);
assertEquals(settings.routes.SIGN_OUT, settings.getCurrentRoute());
return test_util.eventToPromise('cr-dialog-open', page)
.then(function() {
Polymer.dom.flush();
// The toggle remains on.
assertTrue(toggle.checked);
assertTrue(page.prefs.signin.allowed_on_next_startup.value);
assertFalse(page.$.toast.open);
const signoutDialog = page.$$('settings-signout-dialog');
assertTrue(!!signoutDialog);
assertTrue(signoutDialog.$$('#dialog').open);
// The user clicks cancel.
const cancel = signoutDialog.$$('#disconnectCancel');
cancel.click();
return test_util.eventToPromise('close', signoutDialog);
})
.then(function() {
Polymer.dom.flush();
assertFalse(!!page.$$('settings-signout-dialog'));
// After the dialog is closed, the toggle remains turned on.
assertTrue(toggle.checked);
assertTrue(page.prefs.signin.allowed_on_next_startup.value);
assertFalse(page.$.toast.open);
// The user clicks the toggle again.
toggle.click();
return test_util.eventToPromise('cr-dialog-open', page);
})
.then(function() {
Polymer.dom.flush();
const signoutDialog = page.$$('settings-signout-dialog');
assertTrue(!!signoutDialog);
assertTrue(signoutDialog.$$('#dialog').open);
// The user clicks confirm, which signs them out.
const disconnectConfirm =
signoutDialog.$$('#disconnectConfirm');
disconnectConfirm.click();
return test_util.eventToPromise('close', signoutDialog);
})
.then(function() {
Polymer.dom.flush();
// After the dialog is closed, the toggle is turned off and the
// toast is shown.
assertFalse(toggle.checked);
assertFalse(page.prefs.signin.allowed_on_next_startup.value);
assertTrue(page.$.toast.open);
});
});
}
});
......
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