Commit 07528460 authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Merge text from all changes to the same live region into one utterance.

The problem was that if there were two objects that both changed in the
same live region, like 'apple' and 'orange', they should really be
spoken in sequence, but there was no way to enforce that - another
utterance can be inserted in-between them. Until we have a way to enforce it,
combining the text is a better user experience.

To match other screen readers, read text and control values, but not
roles and states.

BUG=408821

Review URL: https://codereview.chromium.org/522433002

Cr-Commit-Position: refs/heads/master@{#296070}
parent d64a4dd2
...@@ -412,6 +412,30 @@ cvox.LiveRegions.announceChange = function( ...@@ -412,6 +412,30 @@ cvox.LiveRegions.announceChange = function(
} }
}); });
// TODO(dmazzoni): http://crbug.com/415679 Temporary design decision;
// until we have a way to tell the speech queue to group the nav
// descriptions together, collapse them into one.
// Otherwise, one nav description could be spoken, then something unrelated,
// then the rest.
if (navDescriptions.length > 1) {
var allStrings = [];
navDescriptions.forEach(function(desc) {
if (desc.context) {
allStrings.push(desc.context);
}
if (desc.text) {
allStrings.push(desc.text);
}
if (desc.userValue) {
allStrings.push(desc.userValue);
}
});
navDescriptions = [new cvox.NavDescription({
text: allStrings.join(', '),
category: 'live'
})];
}
handler(assertive, navDescriptions); handler(assertive, navDescriptions);
}; };
......
...@@ -179,10 +179,8 @@ TEST_F('CvoxLiveRegionsUnitTest', 'RemoveFromLiveRegion', function() { ...@@ -179,10 +179,8 @@ TEST_F('CvoxLiveRegionsUnitTest', 'RemoveFromLiveRegion', function() {
$('buddylist2').removeChild($('jack')); $('buddylist2').removeChild($('jack'));
this.waitForCalm(function() { this.waitForCalm(function() {
var utterances = cvox.ChromeVoxTester.getUtteranceList(); var utterances = cvox.ChromeVoxTester.getUtteranceList();
assertEquals(3, utterances.length); assertEquals(1, utterances.length);
assertEquals('removed:', utterances[0]); assertEquals('removed:, Jack', utterances[0]);
assertEquals('', utterances[1]);
assertEquals('Jack', utterances[2]);
testDone(); testDone();
}); });
}); });
...@@ -213,7 +211,6 @@ TEST_F('CvoxLiveRegionsUnitTest', 'ProgressBarLiveRegionEvents', function() { ...@@ -213,7 +211,6 @@ TEST_F('CvoxLiveRegionsUnitTest', 'ProgressBarLiveRegionEvents', function() {
/** /**
* Test 'alert' live region inserted as a result of focus change, like * Test 'alert' live region inserted as a result of focus change, like
* when there's an error message when filling out a form. * when there's an error message when filling out a form.
* @export
*/ */
TEST_F('CvoxLiveRegionsUnitTest', 'FocusTriggeredAlertLiveRegion', function() { TEST_F('CvoxLiveRegionsUnitTest', 'FocusTriggeredAlertLiveRegion', function() {
this.loadDoc(function() {/*! this.loadDoc(function() {/*!
...@@ -257,3 +254,69 @@ TEST_F('CvoxLiveRegionsUnitTest', 'FocusTriggeredAlertLiveRegion', function() { ...@@ -257,3 +254,69 @@ TEST_F('CvoxLiveRegionsUnitTest', 'FocusTriggeredAlertLiveRegion', function() {
.queue('Alert')) .queue('Alert'))
.waitForCalm(testDone); .waitForCalm(testDone);
}); });
/**
* Test focus followed by live region change, make sure both are spoken.
*/
TEST_F('CvoxLiveRegionsUnitTest', 'FocusThenLiveRegion', function() {
this.loadDoc(function() {/*!
<button id="button_to_focus">Button To Focus</button>
<div id="live" aria-live="polite"></div>
*/});
$('button_to_focus').focus();
$('live').innerText = 'Live region text';
this.waitForCalm(this.assertSpokenList,
new cvox.SpokenListBuilder()
.categoryFlush('Button To Focus')
.queue('Button')
.categoryFlush('Live region text'))
.waitForCalm(testDone);
});
/**
* Test live region change followed by focus, make sure both are spoken.
*/
TEST_F('CvoxLiveRegionsUnitTest', 'LiveRegionThenFocus', function() {
this.loadDoc(function() {/*!
<button id="button_to_focus">Button To Focus</button>
<div id="live" aria-live="polite"></div>
*/});
$('live').innerText = 'Live region text';
this.waitForCalm(function() {
$('button_to_focus').focus();
})
.waitForCalm(this.assertSpokenList,
new cvox.SpokenListBuilder()
.categoryFlush('Live region text')
.categoryFlush('Button To Focus')
.queue('Button'))
.waitForCalm(testDone);
});
/**
* Two elements inside a live region. These are all combined into
* one utterance until this bug is fixed: http://crbug.com/415679
*/
TEST_F('CvoxLiveRegionsUnitTest', 'TwoElementsInLiveRegion', function() {
this.loadDoc(function() {/*!
<div id="live" aria-live="polite">
<div id="hidden" style="display:none">
<button>L1</button>
<button>L2</button>
</div>
</div>
*/});
$('hidden').style.display = 'block';
this.waitForCalm(this.assertSpokenList,
new cvox.SpokenListBuilder()
.categoryFlush('L1, L2'))
.waitForCalm(testDone);
});
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