Skip to content

Commit

Permalink
Bug 1152454 - Made liveregions responsive to name/value change events…
Browse files Browse the repository at this point in the history
…. r=yzen

---
 accessible/jsat/EventManager.jsm                         | 12 ++++++++++++
 accessible/jsat/Presentation.jsm                         | 10 ++++++----
 .../tests/mochitest/jsat/doc_content_integration.html    | 15 +++++++++++++++
 accessible/tests/mochitest/jsat/jsatcommon.js            |  2 +-
 .../tests/mochitest/jsat/test_content_integration.html   | 16 +++++++++++++---
 5 files changed, 47 insertions(+), 8 deletions(-)
  • Loading branch information
funktr0n committed Apr 21, 2015
1 parent 8783283 commit 8cb7254
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
12 changes: 12 additions & 0 deletions accessible/jsat/EventManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ this.EventManager.prototype = {
let acc = aEvent.accessible;
if (acc === this.contentControl.vc.position) {
this.present(Presentation.nameChanged(acc));
} else {
let {liveRegion, isPolite} = this._handleLiveRegion(aEvent,
['text', 'all']);
if (liveRegion) {
this.present(Presentation.nameChanged(acc, isPolite));
}
}
break;
}
Expand Down Expand Up @@ -293,6 +299,12 @@ this.EventManager.prototype = {
if (position === target ||
Utils.getEmbeddedControl(position) === target) {
this.present(Presentation.valueChanged(target));
} else {
let {liveRegion, isPolite} = this._handleLiveRegion(aEvent,
['text', 'all']);
if (liveRegion) {
this.present(Presentation.valueChanged(target, isPolite));
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions accessible/jsat/Presentation.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,19 @@ B2GPresenter.prototype.pivotChanged =
};

B2GPresenter.prototype.nameChanged =
function B2GPresenter_nameChanged(aAccessible) {
function B2GPresenter_nameChanged(aAccessible, aIsPolite = true) {
return {
type: this.type,
details: {
eventType: 'name-change',
data: aAccessible.name
data: aAccessible.name,
options: {enqueue: aIsPolite}
}
};
};

B2GPresenter.prototype.valueChanged =
function B2GPresenter_valueChanged(aAccessible) {
function B2GPresenter_valueChanged(aAccessible, aIsPolite = true) {

// the editable value changes are handled in the text changed presenter
if (Utils.getState(aAccessible).contains(States.EDITABLE)) {
Expand All @@ -545,7 +546,8 @@ B2GPresenter.prototype.valueChanged =
type: this.type,
details: {
eventType: 'value-change',
data: aAccessible.value
data: aAccessible.value,
options: {enqueue: aIsPolite}
}
};
};
Expand Down
15 changes: 15 additions & 0 deletions accessible/tests/mochitest/jsat/doc_content_integration.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
document.getElementById('fruit').setAttribute('aria-label', 'banana');
}

function renameSlider() {
document.getElementById('slider').setAttribute(
'aria-label', 'mover');
}

function changeSliderValue() {
document.getElementById('slider').setAttribute('aria-valuenow', '5');
document.getElementById('slider').setAttribute(
'aria-valuetext', 'medium');
}

</script>
<style>
#windows {
Expand Down Expand Up @@ -89,5 +100,9 @@ <h1>This is an alert!</h1>
</div>
<button id="home">Home</button>
<button id="fruit" aria-label="apple"></button>
<div id="live" aria-live="polite" aria-label="live">
<div id="slider" role="slider" aria-label="slider" aria-valuemin="0"
aria-valuemax="10" aria-valuenow="0"></div>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion accessible/tests/mochitest/jsat/jsatcommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ ExpectedNameChange.prototype = Object.create(ExpectedPresent.prototype);
function ExpectedValueChange(aValue, aOptions) {
ExpectedPresent.call(this, {
eventType: 'value-change',
data: [aValue]
data: aValue
}, null, aOptions);
}

Expand Down
16 changes: 13 additions & 3 deletions accessible/tests/mochitest/jsat/test_content_integration.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@
new ExpectedCursorChange(['Home', {'string': 'pushbutton'}])],
[ContentMessages.simpleMoveNext,
new ExpectedCursorChange(['apple', {'string': 'pushbutton'}])],
[ContentMessages.simpleMoveNext,
new ExpectedCursorChange(['slider', '0', {'string': 'slider'}])],

// Simple traversal backward
[ContentMessages.simpleMovePrevious,
new ExpectedCursorChange(['apple', {'string': 'pushbutton'}])],
[ContentMessages.simpleMovePrevious,
new ExpectedCursorChange(['Home', {'string': 'pushbutton'}])],
[ContentMessages.simpleMovePrevious,
Expand Down Expand Up @@ -92,7 +96,7 @@
// Move from an inner frame to the last element in the parent doc
[ContentMessages.simpleMoveLast,
new ExpectedCursorChange(
['apple', {'string': 'pushbutton'}], { b2g_todo: true })],
['slider', '0', {'string': 'slider'}], { b2g_todo: true })],

[ContentMessages.clearCursor, 'AccessFu:CursorCleared'],

Expand Down Expand Up @@ -147,6 +151,12 @@
new ExpectedCursorChange(['apple', {'string': 'pushbutton'}])],
[doc.defaultView.renameFruit, new ExpectedNameChange('banana')],

// Name and value changes inside a live-region (no cursor present)
[doc.defaultView.renameSlider,
new ExpectedNameChange('mover')],
[doc.defaultView.changeSliderValue,
new ExpectedValueChange('medium')],

// Blur button and reset cursor
[ContentMessages.focusSelector('button#fruit', true), null],
[ContentMessages.clearCursor, 'AccessFu:CursorCleared'],
Expand Down Expand Up @@ -222,14 +232,14 @@

// Open dialog in outer doc, while cursor is also in outer doc
[ContentMessages.simpleMoveLast,
new ExpectedCursorChange(['banana', {'string': 'pushbutton'}])],
new ExpectedCursorChange(['mover'])],
[doc.defaultView.showAlert,
new ExpectedCursorChange(['This is an alert!',
{'string': 'headingLevel', 'args': [1]},
{'string': 'dialog'}])],

[doc.defaultView.hideAlert,
new ExpectedCursorChange(['banana', {'string': 'pushbutton'}])],
new ExpectedCursorChange(['mover'])],

[ContentMessages.clearCursor, 'AccessFu:CursorCleared'],

Expand Down

0 comments on commit 8cb7254

Please sign in to comment.