Bug 824785 - social toolbar buttons should have an aria-label. r=jaws

This commit is contained in:
Mark Hammond 2013-02-08 10:59:10 +11:00
parent ec93de981f
commit 56769ffba0
3 changed files with 14 additions and 2 deletions

View File

@ -908,8 +908,13 @@ var SocialToolbar = {
toolbarButton.setAttribute("tooltiptext", icon.label);
let badge = icon.counter || "";
if (toolbarButton.getAttribute("badge") != badge)
toolbarButton.setAttribute("badge", badge);
toolbarButton.setAttribute("badge", badge);
let ariaLabel = icon.label;
// if there is a badge value, we must use a localizable string to insert it.
if (badge)
ariaLabel = gNavigatorBundle.getFormattedString("social.aria.toolbarButtonBadgeText",
[ariaLabel, badge]);
toolbarButton.setAttribute("aria-label", ariaLabel);
}
let socialToolbarItem = document.getElementById("social-toolbar-item");
socialToolbarItem.appendChild(toolbarButtons);

View File

@ -110,11 +110,15 @@ var tests = {
}, function () {
let badge = statusIcon.getAttribute("badge");
is(badge, "42", "status value is correct");
// If there is a counter, the aria-label should reflect it.
is(statusIcon.getAttribute("aria-label"), "Test Ambient 1 \u2046 (42)");
ambience.counter = 0;
Social.provider.setAmbientNotification(ambience);
badge = statusIcon.getAttribute("badge");
is(badge, "", "status value is correct");
// If there is no counter, the aria-label should be the same as the label
is(statusIcon.getAttribute("aria-label"), "Test Ambient 1 \u2046");
// The menu bar isn't as easy to instrument on Mac.
if (navigator.platform.contains("Mac"))

View File

@ -399,6 +399,9 @@ social.error.ok.accesskey=O
social.error.closeSidebar.label=Close This Sidebar
social.error.closeSidebar.accesskey=C
# LOCALIZATION NOTE: %1$S is the label for the toolbar button, %2$S is the associated badge numbering that the social provider may provide.
social.aria.toolbarButtonBadgeText=%1$S (%2$S)
# Identity notifications popups
identity.termsOfService = Terms of Service
identity.privacyPolicy = Privacy Policy