Commit e2b0ae2f authored by May Lippert's avatar May Lippert Committed by Commit Bot

Expose regulatory info to the screen reader.

The img tag for the regulatory info contains role="presentation" which
makes the screen reader skip the alt tag. This tag was originally added
because the a11y tests were failing
(https://chromium-review.googlesource.com/c/chromium/src/+/1345127).

The original issue of test failures was actually because regulatory
info is asynchronously filled in, so when the page is loaded,
regulatoryInfo_.text which is used as the alt tag is empty. This makes
the a11y tests fail since it expects a non empty string as the value.

This change fixes the tests by setting the regulatory info text through
the fake browser proxy, and removes the role="presentation" tag since
it's not needed anymore to make the tests pass.

BUG=950842

Change-Id: I136456fab06c15b9d13f0d7827f251062d242c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1653085Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Commit-Queue: May Lippert <maybelle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668468}
parent a071cc59
......@@ -269,8 +269,7 @@
</div>
</if>
<img src="[[regulatoryInfo_.url]]" alt="[[regulatoryInfo_.text]]"
hidden$="[[!shouldShowRegulatoryInfo_(regulatoryInfo_)]]"
role="presentation">
hidden$="[[!shouldShowRegulatoryInfo_(regulatoryInfo_)]]">
</div>
</if>
</settings-section>
......
......@@ -11,16 +11,48 @@ GEN_INCLUDE([
'settings_accessibility_test.js',
]);
AccessibilityTest.define('SettingsAccessibilityTest', {
/**
* Test fixture for ABOUT
* @constructor
* @extends {PolymerTest}
*/
function SettingsA11yAbout() {}
SettingsA11yAbout.prototype = {
__proto__: SettingsAccessibilityTest.prototype,
extraLibraries: SettingsAccessibilityTest.prototype.extraLibraries.concat([
'../../test_browser_proxy.js',
'../test_about_page_browser_proxy.js',
]),
};
AccessibilityTest.define('SettingsA11yAbout', {
/** @override */
name: 'ABOUT',
/** @override */
axeOptions: SettingsAccessibilityTest.axeOptions,
/** @override */
setup: function() {
settings.router.navigateTo(settings.routes.ABOUT);
Polymer.dom.flush();
// Reset to a blank page.
PolymerTest.clearBody();
// Set the URL to be that of specific route to load upon injecting
// settings-ui. Simply calling settings.navigateTo(route) prevents
// use of mock APIs for fake data.
window.history.pushState(
'object or string', 'Test', settings.routes.ABOUT.path);
if (AccessibilityTest.isChromeOS) {
let aboutPageProxy = new TestAboutPageBrowserProxy();
// Regulatory info is added when the image is loaded async.
// Add a fake string to mimic the image text.
aboutPageProxy.setRegulatoryInfo('This is fake regulatory info');
}
const settingsUi = document.createElement('settings-ui');
document.body.appendChild(settingsUi);
},
/** @override */
tests: {'Accessible with No Changes': function() {}},
/** @override */
......
......@@ -3,185 +3,6 @@
// found in the LICENSE file.
cr.define('settings_about_page', function() {
/** @implements {settings.AboutPageBrowserProxy} */
class TestAboutPageBrowserProxy extends TestBrowserProxy {
constructor() {
const methodNames = [
'pageReady',
'refreshUpdateStatus',
'openHelpPage',
'openFeedbackDialog',
];
if (cr.isChromeOS) {
methodNames.push(
'getChannelInfo', 'getVersionInfo', 'getRegulatoryInfo',
'getHasEndOfLife', 'refreshTPMFirmwareUpdateStatus', 'setChannel');
}
if (cr.isMac) {
methodNames.push('promoteUpdater');
}
super(methodNames);
/** @private {!UpdateStatus} */
this.updateStatus_ = UpdateStatus.UPDATED;
if (cr.isChromeOS) {
/** @private {!VersionInfo} */
this.versionInfo_ = {
arcVersion: '',
osFirmware: '',
osVersion: '',
};
/** @private {!ChannelInfo} */
this.channelInfo_ = {
currentChannel: BrowserChannel.BETA,
targetChannel: BrowserChannel.BETA,
canChangeChannel: true,
};
/** @private {?RegulatoryInfo} */
this.regulatoryInfo_ = null;
/** @private {!TPMFirmwareUpdateStatus} */
this.tpmFirmwareUpdateStatus_ = {
updateAvailable: false,
};
/** @private {boolean|Promise} */
this.hasEndOfLife_ = false;
}
}
/** @param {!UpdateStatus} updateStatus */
setUpdateStatus(updateStatus) {
this.updateStatus_ = updateStatus;
}
sendStatusNoInternet() {
cr.webUIListenerCallback('update-status-changed', {
progress: 0,
status: UpdateStatus.FAILED,
message: 'offline',
connectionTypes: 'no internet',
});
}
/** @override */
pageReady() {
this.methodCalled('pageReady');
}
/** @override */
refreshUpdateStatus() {
cr.webUIListenerCallback('update-status-changed', {
progress: 1,
status: this.updateStatus_,
});
this.methodCalled('refreshUpdateStatus');
}
/** @override */
openFeedbackDialog() {
this.methodCalled('openFeedbackDialog');
}
/** @override */
openHelpPage() {
this.methodCalled('openHelpPage');
}
}
if (cr.isMac) {
/** @override */
TestAboutPageBrowserProxy.prototype.promoteUpdater = function() {
this.methodCalled('promoteUpdater');
};
}
if (cr.isChromeOS) {
/** @param {!VersionInfo} */
TestAboutPageBrowserProxy.prototype.setVersionInfo = function(versionInfo) {
this.versionInfo_ = versionInfo;
};
/** @param {boolean} canChangeChannel */
TestAboutPageBrowserProxy.prototype.setCanChangeChannel = function(
canChangeChannel) {
this.channelInfo_.canChangeChannel = canChangeChannel;
};
/**
* @param {!BrowserChannel} current
* @param {!BrowserChannel} target
*/
TestAboutPageBrowserProxy.prototype.setChannels = function(
current, target) {
this.channelInfo_.currentChannel = current;
this.channelInfo_.targetChannel = target;
};
/** @param {?RegulatoryInfo} regulatoryInfo */
TestAboutPageBrowserProxy.prototype.setRegulatoryInfo = function(
regulatoryInfo) {
this.regulatoryInfo_ = regulatoryInfo;
};
/** @param {boolean|Promise} hasEndOfLife */
TestAboutPageBrowserProxy.prototype.setHasEndOfLife = function(
hasEndOfLife) {
this.hasEndOfLife_ = hasEndOfLife;
};
/** @override */
TestAboutPageBrowserProxy.prototype.getChannelInfo = function() {
this.methodCalled('getChannelInfo');
return Promise.resolve(this.channelInfo_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.getVersionInfo = function() {
this.methodCalled('getVersionInfo');
return Promise.resolve(this.versionInfo_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.getRegulatoryInfo = function() {
this.methodCalled('getRegulatoryInfo');
return Promise.resolve(this.regulatoryInfo_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.getHasEndOfLife = function() {
this.methodCalled('getHasEndOfLife');
return Promise.resolve(this.hasEndOfLife_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.setChannel = function(
channel, isPowerwashAllowed) {
this.methodCalled('setChannel', [channel, isPowerwashAllowed]);
};
/** @param {!TPMFirmwareUpdateStatus} status */
TestAboutPageBrowserProxy.prototype.setTPMFirmwareUpdateStatus = function(
status) {
this.tpmFirmwareUpdateStatus_ = status;
};
/** @override */
TestAboutPageBrowserProxy.prototype.refreshTPMFirmwareUpdateStatus =
function() {
this.methodCalled('refreshTPMFirmwareUpdateStatus');
cr.webUIListenerCallback(
'tpm-firmware-update-status-changed', this.tpmFirmwareUpdateStatus_);
};
}
function registerAboutPageTests() {
/**
* @param {!UpdateStatus} status
......
......@@ -209,6 +209,7 @@ CrSettingsAboutPageTest.prototype = {
'test_util.js',
'../test_browser_proxy.js',
'test_lifetime_browser_proxy.js',
'test_about_page_browser_proxy.js',
'about_page_tests.js',
]),
};
......
// Copyright 2019 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.
/** @implements {settings.AboutPageBrowserProxy} */
class TestAboutPageBrowserProxy extends TestBrowserProxy {
constructor() {
const methodNames = [
'pageReady',
'refreshUpdateStatus',
'openHelpPage',
'openFeedbackDialog',
];
if (cr.isChromeOS) {
methodNames.push(
'getChannelInfo', 'getVersionInfo', 'getRegulatoryInfo',
'getHasEndOfLife', 'refreshTPMFirmwareUpdateStatus', 'setChannel');
}
if (cr.isMac) {
methodNames.push('promoteUpdater');
}
super(methodNames);
/** @private {!UpdateStatus} */
this.updateStatus_ = UpdateStatus.UPDATED;
if (cr.isChromeOS) {
/** @private {!VersionInfo} */
this.versionInfo_ = {
arcVersion: '',
osFirmware: '',
osVersion: '',
};
/** @private {!ChannelInfo} */
this.channelInfo_ = {
currentChannel: BrowserChannel.BETA,
targetChannel: BrowserChannel.BETA,
canChangeChannel: true,
};
/** @private {?RegulatoryInfo} */
this.regulatoryInfo_ = null;
/** @private {!TPMFirmwareUpdateStatus} */
this.tpmFirmwareUpdateStatus_ = {
updateAvailable: false,
};
/** @private {boolean|Promise} */
this.hasEndOfLife_ = false;
}
}
/** @param {!UpdateStatus} updateStatus */
setUpdateStatus(updateStatus) {
this.updateStatus_ = updateStatus;
}
sendStatusNoInternet() {
cr.webUIListenerCallback('update-status-changed', {
progress: 0,
status: UpdateStatus.FAILED,
message: 'offline',
connectionTypes: 'no internet',
});
}
/** @override */
pageReady() {
this.methodCalled('pageReady');
}
/** @override */
refreshUpdateStatus() {
cr.webUIListenerCallback('update-status-changed', {
progress: 1,
status: this.updateStatus_,
});
this.methodCalled('refreshUpdateStatus');
}
/** @override */
openFeedbackDialog() {
this.methodCalled('openFeedbackDialog');
}
/** @override */
openHelpPage() {
this.methodCalled('openHelpPage');
}
}
if (cr.isMac) {
/** @override */
TestAboutPageBrowserProxy.prototype.promoteUpdater = function() {
this.methodCalled('promoteUpdater');
};
}
if (cr.isChromeOS) {
/** @param {!VersionInfo} */
TestAboutPageBrowserProxy.prototype.setVersionInfo = function(versionInfo) {
this.versionInfo_ = versionInfo;
};
/** @param {boolean} canChangeChannel */
TestAboutPageBrowserProxy.prototype.setCanChangeChannel = function(
canChangeChannel) {
this.channelInfo_.canChangeChannel = canChangeChannel;
};
/**
* @param {!BrowserChannel} current
* @param {!BrowserChannel} target
*/
TestAboutPageBrowserProxy.prototype.setChannels = function(current, target) {
this.channelInfo_.currentChannel = current;
this.channelInfo_.targetChannel = target;
};
/** @param {?RegulatoryInfo} regulatoryInfo */
TestAboutPageBrowserProxy.prototype.setRegulatoryInfo = function(
regulatoryInfo) {
this.regulatoryInfo_ = regulatoryInfo;
};
/** @param {boolean|Promise} hasEndOfLife */
TestAboutPageBrowserProxy.prototype.setHasEndOfLife = function(hasEndOfLife) {
this.hasEndOfLife_ = hasEndOfLife;
};
/** @override */
TestAboutPageBrowserProxy.prototype.getChannelInfo = function() {
this.methodCalled('getChannelInfo');
return Promise.resolve(this.channelInfo_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.getVersionInfo = function() {
this.methodCalled('getVersionInfo');
return Promise.resolve(this.versionInfo_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.getRegulatoryInfo = function() {
this.methodCalled('getRegulatoryInfo');
return Promise.resolve(this.regulatoryInfo_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.getHasEndOfLife = function() {
this.methodCalled('getHasEndOfLife');
return Promise.resolve(this.hasEndOfLife_);
};
/** @override */
TestAboutPageBrowserProxy.prototype.setChannel = function(
channel, isPowerwashAllowed) {
this.methodCalled('setChannel', [channel, isPowerwashAllowed]);
};
/** @param {!TPMFirmwareUpdateStatus} status */
TestAboutPageBrowserProxy.prototype.setTPMFirmwareUpdateStatus = function(
status) {
this.tpmFirmwareUpdateStatus_ = status;
};
/** @override */
TestAboutPageBrowserProxy.prototype.refreshTPMFirmwareUpdateStatus =
function() {
this.methodCalled('refreshTPMFirmwareUpdateStatus');
cr.webUIListenerCallback(
'tpm-firmware-update-status-changed', this.tpmFirmwareUpdateStatus_);
};
}
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