Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5773)

Unified Diff: chrome/browser/resources/chromeos/chromevox/chromevox/injected/live_regions_test.unitjs

Issue 582123002: Port live region ChromeVox tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromevox_keyboard_tests_again
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/chromevox/injected/live_regions_test.unitjs
diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/injected/live_regions_test.unitjs b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/live_regions_test.unitjs
new file mode 100644
index 0000000000000000000000000000000000000000..1a6f4f755f495462fe13a2ff195c6ba0f91c756e
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/chromevox/injected/live_regions_test.unitjs
@@ -0,0 +1,254 @@
+// Copyright 2013 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.
+
+// Include test fixture.
+GEN_INCLUDE(['../../testing/chromevox_unittest_base.js']);
+
+/**
+ * Test fixture.
+ * @constructor
+ * @extends {ChromeVoxUnitTestBase}
+ */
+function CvoxLiveRegionsUnitTest() {}
+
+CvoxLiveRegionsUnitTest.prototype = {
+ __proto__: ChromeVoxUnitTestBase.prototype,
+
+ /** @override */
+ isAsync: true,
+
+ /** @override */
+ closureModuleDeps: [
+ 'cvox.ChromeVoxTester',
+ 'cvox.SpokenListBuilder',
+ ],
+
+ /** @override */
+ setUp: function() {
+ cvox.ChromeVoxTester.setUp(document);
+ }
+};
Peter Lundblad 2014/09/19 08:14:58 Do we want a tearDown that calls cvox.ChromeVoxTes
dmazzoni 2014/09/22 07:14:55 Done.
+
+TEST_F('CvoxLiveRegionsUnitTest', 'InsertNonLiveRegion', function() {
+ var region = document.createElement('div');
+ region.innerHTML = '<div role="button">Alpha</div>';
+ document.body.appendChild(region);
+
+ window.setTimeout(function() {
+ assertEquals(0, cvox.ChromeVoxTester.getUtteranceList().length);
+ testDone();
+ }, 300);
Peter Lundblad 2014/09/19 08:14:58 Yeah, let's not mention this to anyone... ;) To c
dmazzoni 2014/09/22 07:14:55 Good news, a bit more work and all setTimeouts are
+});
+
+
+/**
+ * Test inserting an 'alert' live region.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'InsertAlertLiveRegion', function() {
+ var region = document.createElement('div');
+ region.innerHTML = '<div role="alert">Alpha</div>';
+ document.body.appendChild(region);
+
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals('Alpha', utterances[0]);
+ assertEquals('Alert', utterances[1]);
+ testDone();
+ }, 300);
+});
+
+
+/**
+ * Test making text appear inside an 'alert' live region by setting its
+ * display to something other than 'none'.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'RevealAlertLiveRegion', function() {
+ this.loadDoc(function() {/*!
+ <div role="alert">
+ <style>
+ .invisible {
+ display: none;
+ }
+ </style>
+ <div id="mymessage" class="invisible">
+ I just appeared!
+ </div>
+ </div>
+ */});
+ $('mymessage').className = '';
+
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals('I just appeared!', utterances[0]);
+ testDone();
+ }, 300);
+});
+
+
+/**
+ * Test inserting a 'polite' live region.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'InsertPoliteLiveRegion', function() {
+ var region = document.createElement('div');
+ region.innerHTML = '<div aria-live="polite">Beta</div>';
+ document.body.appendChild(region);
+
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals('Beta', utterances[0]);
+ testDone();
+ }, 300);
+});
+
+
+/**
+ * Test modifying an existing status live region.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'ModifyStatusLiveRegion', function() {
+ var region = document.createElement('div');
+ region.innerHTML = '<div id="status" role="status">Gamma</div>';
+ document.body.appendChild(region);
+
+ window.setTimeout(function() {
+ $('status').innerText = 'Delta';
+ // Wait for this to make it through the event queue and
+ // trigger the live region change announcement.
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals('Delta', utterances[utterances.length - 1]);
+ testDone();
+ }, 300);
+ }, 300);
+});
+
+
+/**
+ * Test adding element to a atomic and non-atomic live regions.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'AddToLiveRegion', function() {
+ this.loadDoc(function() {/*!
+ <div>
+ <div id="non_atomic_buddylist" aria-live="polite">
+ <div>Larry</div>
+ <div>Sergey</div>
+ </div>
+ <div id="atomic_buddylist" aria-live="polite" aria-atomic="true">
+ <div>Larry</div>
+ <div>Sergey</div>
+ </div>
+ </div>
+ */});
+
+ window.setTimeout(function() {
+ var eric1 = document.createElement('div');
+ eric1.innerHTML = 'Eric';
+ $('non_atomic_buddylist').appendChild(eric1);
+ var eric2 = document.createElement('div');
+ eric2.innerHTML = 'Eric';
+ $('atomic_buddylist').appendChild(eric2);
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals('Eric', utterances[utterances.length - 2]);
+ assertEquals('Larry Sergey Eric', utterances[utterances.length - 1]);
+ testDone();
+ }, 300);
+ }, 300);
+});
+
+/**
+ * Test removing elements from live regions.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'RemoveFromLiveRegion', function() {
+ this.loadDoc(function() {/*!
+ <div>
+ <div id="buddylist2" aria-relevant="removals">
+ <div id="jack">Jack</div>
+ <div id="janet">Janet</div>
+ <div id="chrissy">Chrissy</div>
+ </div>
+ </div>
+ */});
+
+ $('buddylist2').setAttribute('aria-live', 'polite');
+ $('buddylist2').removeChild($('jack'));
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals(3, utterances.length);
+ assertEquals('removed:', utterances[0]);
+ assertEquals('', utterances[1]);
+ assertEquals('Jack', utterances[2]);
+ testDone();
+ }, 300);
+});
+
+
+/**
+ * Test live region that's a progress bar through the event watcher.
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'ProgressBarLiveRegionEvents', function() {
+ this.loadDoc(function() {/*!
+ <div id="progress" role="progressbar" aria-live="polite" aria-valuenow="1">
+ <div id="ptext">
+ 1% complete.
+ </div>
+ </div>
+ */});
+
+ $('progress').setAttribute('aria-valuenow', '2');
+ $('ptext').innerText = '2% complete';
+ window.setTimeout(function() {
+ var utterances = cvox.ChromeVoxTester.getUtteranceList();
+ assertEquals('Progress bar 2', utterances[utterances.length - 1]);
+ testDone();
+ }, 300);
+});
+
+
+/**
+ * Test 'alert' live region inserted as a result of focus change, like
+ * when there's an error message when filling out a form.
+ * @export
+ */
+TEST_F('CvoxLiveRegionsUnitTest', 'FocusTriggeredAlertLiveRegion', function() {
+ this.loadDoc(function() {/*!
+ <form id="form">
+ <label>
+ Name
+ <input id="name">
+ </label>
+ <label>
+ Address
+ <input id="address">
+ </label>
+ </form>
+ */});
+
+ // Suppress EventWatcher's artificial limit on the number of DOM subtree
+ // modified events that can happen in a row.
+ cvox.ChromeVoxEventWatcher.SUBTREE_MODIFIED_BURST_COUNT_LIMIT_ = 999;
+
+ var form = $('form');
+ var name = $('name');
+ var address = $('address');
+
+ name.addEventListener(
+ 'blur',
+ function() {
+ var region = document.createElement('div');
+ region.innerHTML = '<div role="alert">Not a valid name!</div>';
+ form.appendChild(region);
+ }, false);
+
+ this.waitForCalm_(function() { name.focus(); })
+ .waitForCalm_(function() { address.focus(); })
+ .waitForCalm_(this.assertSpokenList_,
+ new cvox.SpokenListBuilder()
+ .categoryFlush('Name')
+ .queue('Edit text')
+ .categoryFlush('Address')
+ .queue('Edit text')
+ .categoryFlush('Not a valid name!')
+ .queue('Alert'))
+ .waitForCalm_(testDone);
+});

Powered by Google App Engine
This is Rietveld 408576698