Commit 55d87411 authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

Reland: A11y: Label "delete word" button in setting's custom dictionary.

Bug: 1008556
Change-Id: If6cdaa711a8fd498652edf980395383b9318abe2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841656
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703894}
parent e43e5d68
......@@ -2880,6 +2880,9 @@
<message name="IDS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD_LENGTH_ERROR" desc="Error message displayed to the user when the word is too long in the text input used to add a new word to the custom spell check dictionary.">
Cannot exceed 99 letters
</message>
<message name="IDS_SETTINGS_LANGUAGES_DELETE_DICTIONARY_WORD_BUTTON" desc="Message shown over the button to delete a custom word.">
Delete word
</message>
<message name="IDS_SETTINGS_LANGUAGES_DICTIONARY_WORDS" desc="Header for the list of custom dictionary words used for spell check.">
Custom words
</message>
......
......@@ -56,9 +56,12 @@
scroll-target="[[subpageScrollTarget]]">
<template>
<div class="list-item">
<div class="word text-elide">[[item]]</div>
<div id$="word[[index]]" class="word text-elide">[[item]]</div>
<cr-icon-button class="icon-clear" on-click="onRemoveWordTap_"
tabindex$="[[tabIndex]]"></cr-icon-button>
tabindex$="[[tabIndex]]"
title="$i18n{deleteDictionaryWordButton}"
aria-describedby$="word[[index]]">
</cr-icon-button>
</div>
</template>
</iron-list>
......
......@@ -1614,6 +1614,8 @@ void AddLanguagesStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD_DUPLICATE_ERROR},
{"addDictionaryWordLengthError",
IDS_SETTINGS_LANGUAGES_ADD_DICTIONARY_WORD_LENGTH_ERROR},
{"deleteDictionaryWordButton",
IDS_SETTINGS_LANGUAGES_DELETE_DICTIONARY_WORD_BUTTON},
{"customDictionaryWords", IDS_SETTINGS_LANGUAGES_DICTIONARY_WORDS},
{"noCustomDictionaryWordsFound",
IDS_SETTINGS_LANGUAGES_DICTIONARY_WORDS_NONE},
......
......@@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Define accessibility tests for the EDIT_DICTIONARY route.
*/
/** @fileoverview Define accessibility tests for the EDIT_DICTIONARY route. */
// Disable since the EDIT_DICTIONARY route does not exist on Mac.
GEN('#if !defined(OS_MACOSX)');
......@@ -14,18 +12,49 @@ GEN_INCLUDE([
'settings_accessibility_test.js',
]);
AccessibilityTest.define('SettingsAccessibilityTest', {
// eslint-disable-next-line no-var
var EditDictionaryA11yTest = class extends SettingsAccessibilityTest {
/** @override */
name: 'EDIT_DICTIONARY',
/** @override */
axeOptions: SettingsAccessibilityTest.axeOptions,
get extraLibraries() {
return super.extraLibraries.concat([
'../../fake_chrome_event.js',
'../../test_browser_proxy.js',
'../../test_util.js',
'../fake_language_settings_private.js',
'../fake_settings_private.js',
]);
}
};
function getDictionaryPage() {
const settingsUI = document.querySelector('settings-ui');
assertTrue(!!settingsUI);
const settingsMain = settingsUI.$.main;
assertTrue(!!settingsMain);
const settingsBasicPage = settingsMain.$$('settings-basic-page');
assertTrue(!!settingsBasicPage);
const languagesPage = settingsBasicPage.$$('settings-languages-page');
assertTrue(!!languagesPage);
const dictionaryPage = languagesPage.$$('settings-edit-dictionary-page');
assertTrue(!!dictionaryPage);
return dictionaryPage;
}
AccessibilityTest.define('EditDictionaryA11yTest', {
/** @override */
setup: function() {
settings.navigateTo(settings.routes.EDIT_DICTIONARY);
Polymer.dom.flush();
},
name: 'EDIT_DICTIONARY',
/** @override */
tests: {'Accessible with No Changes': function() {}},
axeOptions: Object.assign({}, SettingsAccessibilityTest.axeOptions, {
'rules': Object.assign({}, SettingsAccessibilityTest.axeOptions.rules, {
// TODO(crbug.com/1012370): Disable because of timeout in CFI build.
'hidden-content': {enabled: false},
}),
}),
/** @type {settings.FakeLanguageSettingsPrivate} */
languageSettingsPrivate_: null,
/** @override */
violationFilter:
Object.assign({}, SettingsAccessibilityTest.violationFilter, {
......@@ -39,7 +68,39 @@ AccessibilityTest.define('SettingsAccessibilityTest', {
// TODO(crbug.com/808276): remove this exception when bug is fixed.
return nodeResult.element.getAttribute('tabindex') == '0';
},
})
}),
/** @override */
setup: async function() {
// Don't replace b/c each test case needs to use the same fake.
if (!this.languageSettingsPrivate_) {
this.languageSettingsPrivate_ =
new settings.FakeLanguageSettingsPrivate(),
settings.languageSettingsPrivateApiForTest =
this.languageSettingsPrivate_;
}
settings.navigateTo(settings.routes.EDIT_DICTIONARY);
Polymer.dom.flush();
await test_util.flushTasks();
},
/** @override */
tests: {
'Accessible with No Changes': function() {
const dictionaryPage = getDictionaryPage();
assertFalse(!!dictionaryPage.$$('#list'));
},
'Load data to list': function() {
const dictionaryPage = getDictionaryPage();
this.languageSettingsPrivate_.addSpellcheckWord('one');
assertTrue(!!dictionaryPage.$$('#list'));
assertEquals(1, dictionaryPage.$$('#list').items.length);
},
},
});
GEN('#endif // !defined(OS_MACOSX)');
GEN('#endif // !defined(OS_MACOSX)');
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