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

Side by Side Diff: chrome/browser/ui/webui/options/options_browsertest.js

Issue 646853004: Enable a11y audit for chrome://settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 GEN('#include "chrome/browser/ui/webui/options/options_browsertest.h"'); 5 GEN('#include "chrome/browser/ui/webui/options/options_browsertest.h"');
6 6
7 /** @const */ var SUPERVISED_USERS_PREF = 'profile.managed_users'; 7 /** @const */ var SUPERVISED_USERS_PREF = 'profile.managed_users';
8 8
9 /** 9 /**
10 * Wait for the method specified by |methodName|, on the |object| object, to be 10 * Wait for the method specified by |methodName|, on the |object| object, to be
(...skipping 28 matching lines...) Expand all
39 * TestFixture for OptionsPage WebUI testing. 39 * TestFixture for OptionsPage WebUI testing.
40 * @extends {testing.Test} 40 * @extends {testing.Test}
41 * @constructor 41 * @constructor
42 */ 42 */
43 function OptionsWebUITest() {} 43 function OptionsWebUITest() {}
44 44
45 OptionsWebUITest.prototype = { 45 OptionsWebUITest.prototype = {
46 __proto__: testing.Test.prototype, 46 __proto__: testing.Test.prototype,
47 47
48 /** @override */ 48 /** @override */
49 runAccessibilityChecks: true,
50
51 /** @override */
49 accessibilityIssuesAreErrors: true, 52 accessibilityIssuesAreErrors: true,
50 53
51 /** @override */ 54 /** @override */
52 setUp: function() { 55 setUp: function() {
53 // user-image-stream is a streaming video element used for capturing a 56 // user-image-stream is a streaming video element used for capturing a
54 // user image during OOBE. 57 // user image during OOBE.
55 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions', 58 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions',
56 '.user-image-stream'); 59 '.user-image-stream');
57 }, 60 },
58 61
59 /** 62 /**
60 * Browse to the options page & call our preLoad(). 63 * Browse to the options page & call our preLoad().
64 * @override
61 */ 65 */
62 browsePreload: 'chrome://settings-frame', 66 browsePreload: 'chrome://settings-frame',
63 67
68 /** @override */
64 isAsync: true, 69 isAsync: true,
65 70
66 /** 71 /**
67 * Register a mock handler to ensure expectations are met and options pages 72 * Register a mock handler to ensure expectations are met and options pages
68 * behave correctly. 73 * behave correctly.
69 */ 74 */
70 preLoad: function() { 75 preLoad: function() {
71 this.makeAndRegisterMockHandler( 76 this.makeAndRegisterMockHandler(
72 ['defaultZoomFactorAction', 77 ['defaultZoomFactorAction',
73 'fetchPrefs', 78 'fetchPrefs',
74 'observePrefs', 79 'observePrefs',
75 'setBooleanPref', 80 'setBooleanPref',
76 'setIntegerPref', 81 'setIntegerPref',
77 'setDoublePref', 82 'setDoublePref',
78 'setStringPref', 83 'setStringPref',
79 'setObjectPref', 84 'setObjectPref',
80 'clearPref', 85 'clearPref',
81 'coreOptionsUserMetricsAction', 86 'coreOptionsUserMetricsAction',
82 ]); 87 ]);
83 88
84 // Register stubs for methods expected to be called before/during tests. 89 // Register stubs for methods expected to be called before/during tests.
85 // Specific expectations can be made in the tests themselves. 90 // Specific expectations can be made in the tests themselves.
86 this.mockHandler.stubs().fetchPrefs(ANYTHING); 91 this.mockHandler.stubs().fetchPrefs(ANYTHING);
87 this.mockHandler.stubs().observePrefs(ANYTHING); 92 this.mockHandler.stubs().observePrefs(ANYTHING);
88 this.mockHandler.stubs().coreOptionsUserMetricsAction(ANYTHING); 93 this.mockHandler.stubs().coreOptionsUserMetricsAction(ANYTHING);
89 }, 94 },
90 }; 95 };
91 96
97 /**
98 * Wait for overlay-container-1 and overlay-container-2 to be hidden.
99 */
100 function waitForOverlaysToHide() {
101 var overlayCount = 0;
102
103 /**
104 * Finsh the test once all overlays that were visible are hidden.
105 */
106 function transitionEndOverlayHidden() {
107 if (--overlayCount == 0) {
Dan Beam 2014/11/07 05:43:20 no curlies
108 testDone();
109 }
110 }
111
112 /**
113 * Wait for an overlay to hide and do nothing if it's already hidden.
114 * @param {string} overlayId is the element id of the overlay to watch.
115 */
116 function waitForTransitionEnd(overlayId) {
Dan Beam 2014/11/07 05:43:20 this generally seems a bit much for 2 overlays...
117 var overlay = $(overlayId);
118
119 if (!overlayId.hidden) {
120 ++overlayCount;
121 document.addEventListener('webkitTransitionEnd', function f(e) {
122 if (e.target.id == overlayId) {
123 if (overlay.hidden) {
Dan Beam 2014/11/07 05:43:20 nit: if (!(e.target.id == overlayId && overlay.
124 document.removeEventListener(f, 'webkitTransitionEnd');
125 transitionEndOverlayHidden();
126 }
127 }
128 });
129
130 // Make sure that there is a transition end event. The overlays will not
131 // be set as hidden Withouth an end transition.
132 ensureTransitionEndEvent(overlay, 500);
133 }
134 }
135
136 waitForTransitionEnd('overlay-container-1');
137 waitForTransitionEnd('overlay-container-2');
138 }
139
92 // Crashes on Mac only. See http://crbug.com/79181 140 // Crashes on Mac only. See http://crbug.com/79181
93 GEN('#if defined(OS_MACOSX)'); 141 GEN('#if defined(OS_MACOSX)');
94 GEN('#define MAYBE_testSetBooleanPrefTriggers ' + 142 GEN('#define MAYBE_testSetBooleanPrefTriggers ' +
95 'DISABLED_testSetBooleanPrefTriggers'); 143 'DISABLED_testSetBooleanPrefTriggers');
96 GEN('#else'); 144 GEN('#else');
97 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers'); 145 GEN('#define MAYBE_testSetBooleanPrefTriggers testSetBooleanPrefTriggers');
98 GEN('#endif // defined(OS_MACOSX)'); 146 GEN('#endif // defined(OS_MACOSX)');
99 147
100 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() { 148 TEST_F('OptionsWebUITest', 'MAYBE_testSetBooleanPrefTriggers', function() {
101 // TODO(dtseng): make generic to click all buttons. 149 // TODO(dtseng): make generic to click all buttons.
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 /** 404 /**
357 * TestFixture for OptionsPage WebUI testing including tab history and support 405 * TestFixture for OptionsPage WebUI testing including tab history and support
358 * for preference manipulation. If you don't need the features in the C++ 406 * for preference manipulation. If you don't need the features in the C++
359 * fixture, use the simpler OptionsWebUITest (above) instead. 407 * fixture, use the simpler OptionsWebUITest (above) instead.
360 * @extends {testing.Test} 408 * @extends {testing.Test}
361 * @constructor 409 * @constructor
362 */ 410 */
363 function OptionsWebUIExtendedTest() {} 411 function OptionsWebUIExtendedTest() {}
364 412
365 OptionsWebUIExtendedTest.prototype = { 413 OptionsWebUIExtendedTest.prototype = {
366 __proto__: testing.Test.prototype, 414 __proto__: OptionsWebUITest.prototype,
367
368 /** @override */
369 browsePreload: 'chrome://settings-frame',
370 415
371 /** @override */ 416 /** @override */
372 typedefCppFixture: 'OptionsBrowserTest', 417 typedefCppFixture: 'OptionsBrowserTest',
373 418
374 testGenPreamble: function() { 419 testGenPreamble: function() {
375 // Start with no supervised users managed by this profile. 420 // Start with no supervised users managed by this profile.
376 GEN(' ClearPref("' + SUPERVISED_USERS_PREF + '");'); 421 GEN(' ClearPref("' + SUPERVISED_USERS_PREF + '");');
377 }, 422 },
378 423
379 /** @override */
380 isAsync: true,
381
382 /** @override */
383 setUp: function() {
384 // user-image-stream is a streaming video element used for capturing a
385 // user image during OOBE.
386 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions',
387 '.user-image-stream');
388 },
389
390 /** 424 /**
391 * Asserts that two non-nested arrays are equal. The arrays must contain only 425 * Asserts that two non-nested arrays are equal. The arrays must contain only
392 * plain data types, no nested arrays or other objects. 426 * plain data types, no nested arrays or other objects.
393 * @param {Array} expected An array of expected values. 427 * @param {Array} expected An array of expected values.
394 * @param {Array} result An array of actual values. 428 * @param {Array} result An array of actual values.
395 * @param {boolean} doSort If true, the arrays will be sorted before being 429 * @param {boolean} doSort If true, the arrays will be sorted before being
396 * compared. 430 * compared.
397 * @param {string} description A brief description for the array of actual 431 * @param {string} description A brief description for the array of actual
398 * values, to use in an error message if the arrays differ. 432 * values, to use in an error message if the arrays differ.
399 * @private 433 * @private
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 PageManager.closeOverlay(); 703 PageManager.closeOverlay();
670 self.verifyOpenPages_(['settings', 'languages']); 704 self.verifyOpenPages_(['settings', 'languages']);
671 self.verifyHistory_( 705 self.verifyHistory_(
672 ['', 'languages', 'addLanguage', 'languages'], 706 ['', 'languages', 'addLanguage', 'languages'],
673 function() { 707 function() {
674 // Close the layer-1 overlay. 708 // Close the layer-1 overlay.
675 PageManager.closeOverlay(); 709 PageManager.closeOverlay();
676 self.verifyOpenPages_(['settings'], ''); 710 self.verifyOpenPages_(['settings'], '');
677 self.verifyHistory_( 711 self.verifyHistory_(
678 ['', 'languages', 'addLanguage', 'languages', ''], 712 ['', 'languages', 'addLanguage', 'languages', ''],
679 testDone); 713 waitForOverlaysToHide);
680 }); 714 });
681 }); 715 });
682 }); 716 });
683 717
684 // Hashes are maintained separately for each page and are preserved when 718 // Hashes are maintained separately for each page and are preserved when
685 // overlays close. 719 // overlays close.
686 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayWithHashes', function() { 720 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayWithHashes', function() {
687 // Open an overlay on top of the search page. 721 // Open an overlay on top of the search page.
688 PageManager.showPageByName('search', true, {hash: '#1'}); 722 PageManager.showPageByName('search', true, {hash: '#1'});
689 this.verifyOpenPages_(['settings', 'search'], 'search#1'); 723 this.verifyOpenPages_(['settings', 'search'], 'search#1');
(...skipping 11 matching lines...) Expand all
701 this.verifyOpenPages_(['settings', 'search', 'languages'], 'languages#2'); 735 this.verifyOpenPages_(['settings', 'search', 'languages'], 'languages#2');
702 this.verifyHistory_( 736 this.verifyHistory_(
703 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2'], 737 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2'],
704 function() { 738 function() {
705 // Close the layer-1 overlay. 739 // Close the layer-1 overlay.
706 PageManager.closeOverlay(); 740 PageManager.closeOverlay();
707 this.verifyOpenPages_(['settings', 'search'], 'search#1'); 741 this.verifyOpenPages_(['settings', 'search'], 'search#1');
708 this.verifyHistory_( 742 this.verifyHistory_(
709 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2', 743 ['', 'search#1', 'languages#2', 'addLanguage#3', 'languages#2',
710 'search#1'], 744 'search#1'],
711 testDone); 745 waitForOverlaysToHide);
712 }.bind(this)); 746 }.bind(this));
713 }.bind(this)); 747 }.bind(this));
714 }); 748 });
715 749
716 // Test that closing an overlay that did not push history when opening does not 750 // Test that closing an overlay that did not push history when opening does not
717 // again push history. 751 // again push history.
718 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() { 752 TEST_F('OptionsWebUIExtendedTest', 'CloseOverlayNoHistory', function() {
719 // Open the do not track confirmation prompt. 753 // Open the do not track confirmation prompt.
720 PageManager.showPageByName('doNotTrackConfirm', false); 754 PageManager.showPageByName('doNotTrackConfirm', false);
721 755
722 // Opening the prompt does not add to the history. 756 // Opening the prompt does not add to the history.
723 this.verifyHistory_([''], function() { 757 this.verifyHistory_([''], function() {
724 // Close the overlay. 758 // Close the overlay.
725 PageManager.closeOverlay(); 759 PageManager.closeOverlay();
726 // Still no history changes. 760 // Still no history changes.
727 this.verifyHistory_([''], testDone); 761 this.verifyHistory_([''], waitForOverlaysToHide);
728 }.bind(this)); 762 }.bind(this));
729 }); 763 });
730 764
731 // Make sure an overlay isn't closed (even temporarily) when another overlay is 765 // Make sure an overlay isn't closed (even temporarily) when another overlay is
732 // opened on top. 766 // opened on top.
733 TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() { 767 TEST_F('OptionsWebUIExtendedTest', 'OverlayAboveNoReset', function() {
734 // Open a layer-1 overlay. 768 // Open a layer-1 overlay.
735 PageManager.showPageByName('languages', true); 769 PageManager.showPageByName('languages', true);
736 this.verifyOpenPages_(['settings', 'languages']); 770 this.verifyOpenPages_(['settings', 'languages']);
737 771
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 __proto__: OptionsWebUIExtendedTest.prototype, 907 __proto__: OptionsWebUIExtendedTest.prototype,
874 908
875 /** @override */ 909 /** @override */
876 browsePreload: 'chrome://settings-frame/nonexistantPage', 910 browsePreload: 'chrome://settings-frame/nonexistantPage',
877 }; 911 };
878 912
879 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() { 913 TEST_F('OptionsWebUIRedirectTest', 'TestURL', function() {
880 assertEquals('chrome://settings-frame/', document.location.href); 914 assertEquals('chrome://settings-frame/', document.location.href);
881 this.verifyHistory_([''], testDone); 915 this.verifyHistory_([''], testDone);
882 }); 916 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698