Commit 349d2557 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Settings: Fix erroneous hyphens shown in import data dialog.

A <span hidden> within an <option> tag does not work as normally
does, since <span> is not a valid child for a <select>, which was
the reason for the incorrect behavior.

Fixed: 1061324
Change-Id: Ib7e3e6a67f1471d578c0b82ec689825e6be7e147
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2103444
Commit-Queue: John Lee <johntlee@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750642}
parent f8b33e24
...@@ -65,10 +65,7 @@ ...@@ -65,10 +65,7 @@
on-change="onBrowserProfileSelectionChange_"> on-change="onBrowserProfileSelectionChange_">
<template is="dom-repeat" items="[[browserProfiles_]]"> <template is="dom-repeat" items="[[browserProfiles_]]">
<option value="[[item.index]]"> <option value="[[item.index]]">
[[item.name]] [[getProfileDisplayName_(item.name, item.profileName)]]
<span hidden$="[[!item.profileName]]">
- [[item.profileName]]
</span>
</option> </option>
</template> </template>
</select> </select>
......
...@@ -70,6 +70,16 @@ Polymer({ ...@@ -70,6 +70,16 @@ Polymer({
}); });
}, },
/**
* @param {string} name
* @param {string} profileName
* @return {string}
* @private
*/
getProfileDisplayName_(name, profileName) {
return profileName ? `${name} - ${profileName}` : name;
},
/** @private */ /** @private */
prefsChanged_() { prefsChanged_() {
if (this.selected_ == undefined || this.prefs == undefined) { if (this.selected_ == undefined || this.prefs == undefined) {
......
...@@ -49,11 +49,21 @@ suite('ImportDataDialog', function() { ...@@ -49,11 +49,21 @@ suite('ImportDataDialog', function() {
passwords: true, passwords: true,
search: true search: true
}, },
{
autofillFormData: true,
favorites: true,
history: true,
index: 1,
name: 'Mozilla Firefox',
passwords: true,
profileName: 'My profile',
search: true
},
{ {
autofillFormData: false, autofillFormData: false,
favorites: true, favorites: true,
history: false, history: false,
index: 1, index: 2,
name: 'Bookmarks HTML File', name: 'Bookmarks HTML File',
passwords: false, passwords: false,
search: false search: false
...@@ -104,6 +114,18 @@ suite('ImportDataDialog', function() { ...@@ -104,6 +114,18 @@ suite('ImportDataDialog', function() {
assertFalse(dialog.$.cancel.disabled); assertFalse(dialog.$.cancel.disabled);
assertTrue(dialog.$.done.hidden); assertTrue(dialog.$.done.hidden);
assertTrue(dialog.$.successIcon.parentElement.hidden); assertTrue(dialog.$.successIcon.parentElement.hidden);
// Check that the displayed text correctly combines browser name and profile
// name (if any).
const expectedText = [
'Mozilla Firefox',
'Mozilla Firefox - My profile',
'Bookmarks HTML File',
];
Array.from(dialog.$.browserSelect.options).forEach((option, i) => {
assertEquals(expectedText[i], option.textContent.trim());
});
}); });
test('ImportButton', function() { test('ImportButton', function() {
...@@ -116,7 +138,7 @@ suite('ImportDataDialog', function() { ...@@ -116,7 +138,7 @@ suite('ImportDataDialog', function() {
assertTrue(dialog.$.import.disabled); assertTrue(dialog.$.import.disabled);
// Change browser selection to "Import from Bookmarks HTML file". // Change browser selection to "Import from Bookmarks HTML file".
simulateBrowserProfileChange(1); simulateBrowserProfileChange(2);
assertTrue(dialog.$.import.disabled); assertTrue(dialog.$.import.disabled);
// Ensure everything except |import_dialog_bookmarks| is ignored. // Ensure everything except |import_dialog_bookmarks| is ignored.
...@@ -151,7 +173,7 @@ suite('ImportDataDialog', function() { ...@@ -151,7 +173,7 @@ suite('ImportDataDialog', function() {
} }
test('ImportFromBookmarksFile', function() { test('ImportFromBookmarksFile', function() {
simulateBrowserProfileChange(1); simulateBrowserProfileChange(2);
dialog.$.import.click(); dialog.$.import.click();
return browserProxy.whenCalled('importFromBookmarksFile').then(function() { return browserProxy.whenCalled('importFromBookmarksFile').then(function() {
simulateImportStatusChange(settings.ImportDataStatus.IN_PROGRESS); simulateImportStatusChange(settings.ImportDataStatus.IN_PROGRESS);
......
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