Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs |
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs |
index 676ccd60d54122beef758373f0b33b61bb48ce3e..e63c56a1303f06cd3a75ee9e6f130af0871894fd 100644 |
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs |
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background_test.extjs |
@@ -74,6 +74,33 @@ BackgroundTest.prototype = { |
<iframe srcdoc="<button>Inside</button><h1>Inside</h1>"></iframe> |
<button>After</button> |
*/}, |
+ |
+ disappearingObjectDoc: function() {/*! |
+ <p>start</p> |
+ <article> |
+ <p>Before1</p> |
+ <p>Before2</p> |
+ <p>Before3</p> |
+ </article> |
+ <article> |
+ <p id="disappearing">Disappearing</p> |
+ </article> |
+ <article> |
+ <p>After1</p> |
+ <p>After2</p> |
+ <p>After3</p> |
+ </article> |
+ </div> |
+ <div id="live" aria-live="polite"></div> |
+ <div id="delete" role="button">Delete</div> |
+ <script> |
+ document.getElementById('delete').addEventListener('click', function() { |
+ var d = document.getElementById('disappearing'); |
+ d.parentElement.removeChild(d); |
+ document.getElementById('live').innerText = 'Deleted'; |
+ }); |
+ </script> |
+ */}, |
}; |
/** Tests that ChromeVox classic is in this context. */ |
@@ -239,7 +266,7 @@ TEST_F('BackgroundTest', 'AriaLabel', function() { |
var mockFeedback = this.createMockFeedback(); |
this.runWithLoadedTree('<a aria-label="foo" href="a">a</a>', |
function(rootNode) { |
- rootNode.find({role: 'link'}).focus(); |
+ rootNode.find({role: RoleType.link}).focus(); |
mockFeedback.expectSpeech('foo') |
.expectSpeech('Link') |
.expectBraille('foo lnk'); |
@@ -293,7 +320,7 @@ TEST_F('BackgroundTest', 'BrailleRouting', function() { |
*/}, |
function(rootNode) { |
var button1 = rootNode.find({role: RoleType.button, |
- name: 'Click me'}); |
+ attributes: { name: 'Click me' }}); |
var textField = rootNode.find( |
{role: RoleType.textField}); |
mockFeedback.expectBraille('start') |
@@ -450,7 +477,9 @@ TEST_F('BackgroundTest', 'ActiveOrInactive', function() { |
<input type="text"></input> |
*/}, |
function(rootNode) { |
- var focusButton = function() { rootNode.find({role: 'button'}).focus(); }; |
+ var focusButton = function() { |
+ rootNode.find({role: RoleType.button}).focus(); |
+ }; |
var on = function() { cvox.ChromeVox.isActive = true; }; |
var off = function() { cvox.ChromeVox.isActive = false; }; |
@@ -467,8 +496,10 @@ TEST_F('BackgroundTest', 'ActiveOrInactive', function() { |
mockFeedback.call(focusButton) |
.expectSpeech('b').expectSpeech('Button') |
.call(off) |
- .call(focusThen.bind(this, rootNode.find({ role: 'link' }), on)) |
- .call(focusThen.bind(this, rootNode.find({ role: 'textField' }))) |
+ .call(focusThen.bind(this, rootNode.find( |
+ { role: RoleType.link }), on)) |
+ .call(focusThen.bind(this, rootNode.find( |
+ { role: RoleType.textField }))) |
.expectNextSpeechUtteranceIsNot('a') |
.expectSpeech('Edit text'); |
@@ -541,8 +572,8 @@ TEST_F('BackgroundTest', 'FocusIframe', function() { |
<iframe tabindex=0 src="data:text/html,<p>Inside</p>"></iframe> |
<button>outside</button> |
*/}, function(root) { |
- var iframe = root.find({role: 'iframe'}); |
- var button = root.find({role: 'button'}); |
+ var iframe = root.find({role: RoleType.iframe}); |
+ var button = root.find({role: RoleType.button}); |
assertEquals('iframe', iframe.role); |
assertEquals('button', button.role); |
@@ -572,8 +603,8 @@ TEST_F('BackgroundTest', 'NoisySlider', function() { |
update(); |
</script> |
*/}, function(root) { |
- var go = root.find({role: 'button'}); |
- var slider = root.find({role: 'slider'}); |
+ var go = root.find({role: RoleType.button}); |
+ var slider = root.find({role: RoleType.slider}); |
var focusButton = go.focus.bind(go); |
var focusSlider = slider.focus.bind(slider); |
mockFeedback.call(focusButton) |
@@ -601,7 +632,7 @@ TEST_F('BackgroundTest', 'Checkbox', function() { |
}); |
</script> |
*/}, function(root) { |
- var cbx = root.find({role: 'checkBox'}); |
+ var cbx = root.find({role: RoleType.checkBox}); |
var click = cbx.doDefault.bind(cbx); |
mockFeedback.call(click) |
.expectSpeech('go') |
@@ -625,7 +656,7 @@ TEST_F('BackgroundTest', 'ForwardNavigationThroughIframeButtons', function() { |
return; |
// Return if the iframe hasn't loaded yet. |
- var iframe = rootNode.find({role: 'iframe'}); |
+ var iframe = rootNode.find({role: RoleType.iframe}); |
var childDoc = iframe.firstChild; |
if (!childDoc || childDoc.children.length == 0) |
return; |
@@ -716,7 +747,7 @@ TEST_F('BackgroundTest', 'SelectOptionSelected', function() { |
<option>grapefruit |
</select> |
*/}, function(root) { |
- var select = root.find({role: 'popUpButton'}); |
+ var select = root.find({role: RoleType.popUpButton}); |
var clickSelect = select.doDefault.bind(select); |
var lastOption = select.lastChild.lastChild; |
var selectLastOption = lastOption.doDefault.bind(lastOption); |
@@ -773,3 +804,38 @@ TEST_F('BackgroundTest', 'EditText', function() { |
.replay(); |
}); |
}); |
+ |
+/** Tests that navigation works when the current object disappears. */ |
+TEST_F('BackgroundTest', 'DisappearingObject', function() { |
+ var mockFeedback = this.createMockFeedback(); |
+ this.runWithLoadedTree(this.disappearingObjectDoc, function(rootNode) { |
+ var deleteButton = rootNode.find({role: RoleType.button, |
+ attributes: { name: 'Delete' }}); |
+ var pressDelete = deleteButton.doDefault.bind(deleteButton); |
+ var doCmd = this.doCmd.bind(this); |
David Tseng
2016/06/01 20:20:25
You don't need to bind; also, let's export this on
dmazzoni
2016/06/01 22:46:56
Done.
|
+ |
+ mockFeedback.expectSpeech('start').expectBraille('start'); |
+ |
+ mockFeedback.call(doCmd('nextObject')) |
+ .expectSpeech('Before1') |
+ .call(doCmd('nextObject')) |
+ .expectSpeech('Before2') |
+ .call(doCmd('nextObject')) |
+ .expectSpeech('Before3') |
+ .call(doCmd('nextObject')) |
+ .expectSpeech('Disappearing') |
+ .call(pressDelete) |
+ .expectSpeech('Deleted') |
+ .call(doCmd('nextObject')) |
+ .expectSpeech('After1') |
+ .call(doCmd('nextObject')) |
+ .expectSpeech('After2') |
+ .call(doCmd('previousObject')) |
+ .expectSpeech('After1') |
+ .call(doCmd('previousObject')) |
+ .expectSpeech('Before3'); |
+ |
+ mockFeedback.replay(); |
+ }); |
+}); |
+ |