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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs

Issue 1457683009: Complete live region support in ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed last feedback Created 5 years 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/cvox2/background/live_regions_test.extjs
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs
new file mode 100644
index 0000000000000000000000000000000000000000..3a06754bcfc724b7433df14a22bb3a944aac2bf7
--- /dev/null
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/live_regions_test.extjs
@@ -0,0 +1,216 @@
+// Copyright 2015 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_next_e2e_test_base.js',
+ '../../testing/assert_additions.js']);
+
+GEN_INCLUDE(['../../testing/mock_feedback.js']);
+
+/**
+ * Test fixture for Live Regions.
+ * @constructor
+ * @extends {ChromeVoxNextE2ETest}
+ */
+function LiveRegionsTest() {
+ ChromeVoxNextE2ETest.call(this);
+}
+
+LiveRegionsTest.prototype = {
+ __proto__: ChromeVoxNextE2ETest.prototype,
+
+ /** @override */
+ setUp: function() {
+ global.backgroundObj.forceChromeVoxNextActive();
+ window.RoleType = chrome.automation.RoleType;
+ },
+
+ /**
+ * @return {!MockFeedback}
+ */
+ createMockFeedback: function() {
+ var mockFeedback = new MockFeedback(this.newCallback(),
+ this.newCallback.bind(this));
+ mockFeedback.install();
+ return mockFeedback;
+ },
+
+ /**
+ * Create a function which performs the command |cmd|.
+ * @param {string} cmd
+ * @return {function() : void}
+ */
+ doCmd: function(cmd) {
+ return function() {
+ global.backgroundObj.onGotCommand(cmd);
+ };
+ },
+};
+
+TEST_F('LiveRegionsTest', 'LiveRegionAddElement', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <h1>Document with live region</h1>
+ <p id="live" aria-live="polite"></p>
+ <button id="go">Go</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('live').innerHTML = 'Hello, world';
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ mockFeedback.call(go.doDefault.bind(go))
+ .expectCategoryFlushSpeech('Hello, world');
+ mockFeedback.replay();
+ });
+});
+
+TEST_F('LiveRegionsTest', 'LiveRegionRemoveElement', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <h1>Document with live region</h1>
+ <p id="live" aria-live="polite" aria-relevant="removals">Hello, world</p>
+ <button id="go">Go</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('live').innerHTML = '';
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ go.doDefault();
+ mockFeedback.expectCategoryFlushSpeech('removed:')
+ .expectQueuedSpeech('Hello, world');
+ mockFeedback.replay();
+ });
+});
+
+TEST_F('LiveRegionsTest', 'LiveRegionChangeAtomic', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <div id="live" aria-live="polite" aria-atomic="true">
+ <div id="a"></div><div id="b">Bravo</div><div id="c"></div>
+ </div>
+ <button id="go">Go</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('c').textContent = 'Charlie';
+ document.getElementById('a').textContent = 'Alpha';
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ mockFeedback.call(go.doDefault.bind(go))
+ .expectQueuedSpeech('Alpha')
+ .expectQueuedSpeech('Bravo')
+ .expectQueuedSpeech('Charlie');
+ mockFeedback.replay();
+ });
+});
+
+TEST_F('LiveRegionsTest', 'LiveRegionChangeImageAlt', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <div id="live" aria-live="polite">
+ <img id="img" src="#" alt="Before">
+ </div>
+ <button id="go">Go</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('img').setAttribute('alt', 'After');
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ mockFeedback.call(go.doDefault.bind(go))
+ .expectCategoryFlushSpeech('After')
+ .expectQueuedSpeech('Image');
+ mockFeedback.replay();
+ });
+});
+
+TEST_F('LiveRegionsTest', 'LiveRegionThenFocus', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <div id="live" aria-live="polite"></div>
+ <button id="go">Go</button>
+ <button id="focus">Focus</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('live').textContent = 'Live';
+ window.setTimeout(function() {
+ document.getElementById('focus').focus();
+ }, 50);
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ mockFeedback.call(go.doDefault.bind(go))
+ .expectCategoryFlushSpeech('Live')
+ .expectQueuedSpeech('Focus');
+ mockFeedback.replay();
+ });
+});
+
+TEST_F('LiveRegionsTest', 'FocusThenLiveRegion', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <div id="live" aria-live="polite"></div>
+ <button id="go">Go</button>
+ <button id="focus">Focus</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('focus').focus();
+ window.setTimeout(function() {
+ document.getElementById('live').textContent = 'Live';
+ }, 50);
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ mockFeedback.call(go.doDefault.bind(go))
+ .expectQueuedSpeech('Focus')
+ .expectCategoryFlushSpeech('Live');
+ mockFeedback.replay();
+ });
+});
+
+TEST_F('LiveRegionsTest', 'LiveRegionCategoryFlush', function() {
+ var mockFeedback = this.createMockFeedback();
+ this.runWithLoadedTree(
+ function() {/*!
+ <div id="live1" aria-live="polite"></div>
+ <div id="live2" aria-live="polite"></div>
+ <button id="go">Go</button>
+ <button id="focus">Focus</button>
+ <script>
+ document.getElementById('go').addEventListener('click', function() {
+ document.getElementById('live1').textContent = 'Live1';
+ window.setTimeout(function() {
+ document.getElementById('live2').textContent = 'Live2';
+ }, 1000);
+ }, false);
+ </script>
+ */},
+ function(rootNode) {
+ var go = rootNode.find({ role: RoleType.button });
+ mockFeedback.call(go.doDefault.bind(go))
+ .expectCategoryFlushSpeech('Live1')
+ .expectCategoryFlushSpeech('Live2');
+ mockFeedback.replay();
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698