| OLD | NEW |
| 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 /** | 5 /** |
| 6 * @fileoverview Library providing basic test framework functionality. | 6 * @fileoverview Library providing basic test framework functionality. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 // See assert.js for where this is used. | 9 // See assert.js for where this is used. |
| 10 this.traceAssertionsForTesting = true; | 10 this.traceAssertionsForTesting = true; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 /** | 162 /** |
| 163 * Configuration for the accessibility audit. | 163 * Configuration for the accessibility audit. |
| 164 * @type {axs.AuditConfiguration} | 164 * @type {axs.AuditConfiguration} |
| 165 */ | 165 */ |
| 166 accessibilityAuditConfig_: null, | 166 accessibilityAuditConfig_: null, |
| 167 | 167 |
| 168 /** | 168 /** |
| 169 * Returns the configuration for the accessibility audit, creating it | 169 * Returns the configuration for the accessibility audit, creating it |
| 170 * on-demand. | 170 * on-demand. |
| 171 * @return {axs.AuditConfiguration} | 171 * @return {!axs.AuditConfiguration} |
| 172 */ | 172 */ |
| 173 get accessibilityAuditConfig() { | 173 get accessibilityAuditConfig() { |
| 174 // The axs namespace is not available in chromevox tests. | 174 if (!this.accessibilityAuditConfig_) { |
| 175 // Further, 'window' is not available in unit tests, but since the | |
| 176 // accessibility audit library pulls in the closure library, | |
| 177 // 'goog.global' has to be present if axs is, so we use that here. | |
| 178 if (!this.accessibilityAuditConfig_ && | |
| 179 goog && goog.global && goog.global.axs) { | |
| 180 this.accessibilityAuditConfig_ = new axs.AuditConfiguration(); | 175 this.accessibilityAuditConfig_ = new axs.AuditConfiguration(); |
| 181 | 176 |
| 182 this.accessibilityAuditConfig_.showUnsupportedRulesWarning = false; | 177 this.accessibilityAuditConfig_.showUnsupportedRulesWarning = false; |
| 183 | 178 |
| 184 this.accessibilityAuditConfig_.auditRulesToIgnore = [ | 179 this.accessibilityAuditConfig_.auditRulesToIgnore = [ |
| 185 // The "elements with meaningful background image" accessibility | 180 // The "elements with meaningful background image" accessibility |
| 186 // audit (AX_IMAGE_01) does not apply, since Chrome doesn't | 181 // audit (AX_IMAGE_01) does not apply, since Chrome doesn't |
| 187 // disable background images in high-contrast mode like some | 182 // disable background images in high-contrast mode like some |
| 188 // browsers do. | 183 // browsers do. |
| 189 "elementsWithMeaningfulBackgroundImage", | 184 "elementsWithMeaningfulBackgroundImage", |
| 190 | 185 |
| 191 // Most WebUI pages are inside an IFrame, so the "web page should | 186 // Most WebUI pages are inside an IFrame, so the "web page should |
| 192 // have a title that describes topic or purpose" test (AX_TITLE_01) | 187 // have a title that describes topic or purpose" test (AX_TITLE_01) |
| 193 // generally does not apply. | 188 // generally does not apply. |
| 194 "pageWithoutTitle", | 189 "pageWithoutTitle", |
| 195 | 190 |
| 196 // TODO(aboxhall): re-enable when crbug.com/267035 is fixed. | 191 // TODO(aboxhall): re-enable when crbug.com/267035 is fixed. |
| 197 // Until then it's just noise. | 192 // Until then it's just noise. |
| 198 "lowContrastElements", | 193 "lowContrastElements", |
| 194 |
| 195 // TODO(apacible): re-enable when following issue is fixed. |
| 196 // github.com/GoogleChrome/accessibility-developer-tools/issues/251 |
| 197 "tableHasAppropriateHeaders", |
| 199 ]; | 198 ]; |
| 200 } | 199 } |
| 201 return this.accessibilityAuditConfig_; | 200 return this.accessibilityAuditConfig_; |
| 202 }, | 201 }, |
| 203 | 202 |
| 204 /** | 203 /** |
| 205 * Whether to treat accessibility issues (errors or warnings) as test | 204 * Whether to treat accessibility issues (errors or warnings) as test |
| 206 * failures. If true, any accessibility issues will cause the test to fail. | 205 * failures. If true, any accessibility issues will cause the test to fail. |
| 207 * If false, accessibility issues will cause a console.warn. | 206 * If false, accessibility issues will cause a console.warn. |
| 208 * Off by default to begin with; as we add the ability to suppress false | 207 * Off by default to begin with; as we add the ability to suppress false |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 * creating mocks and registering handlers). | 299 * creating mocks and registering handlers). |
| 301 * @type {Function} | 300 * @type {Function} |
| 302 */ | 301 */ |
| 303 preLoad: function() {}, | 302 preLoad: function() {}, |
| 304 | 303 |
| 305 /** | 304 /** |
| 306 * Override this method to perform tasks before running your test. | 305 * Override this method to perform tasks before running your test. |
| 307 * @type {Function} | 306 * @type {Function} |
| 308 */ | 307 */ |
| 309 setUp: function() { | 308 setUp: function() { |
| 310 var auditConfig = this.accessibilityAuditConfig; | 309 // These should be ignored in many of the web UI tests. |
| 311 if (auditConfig) { | 310 // user-image-stream and supervised-user-creation-image-stream are |
| 312 // These should be ignored in many of the web UI tests. | 311 // streaming video elements used for capturing a user image so they |
| 313 // user-image-stream and supervised-user-creation-image-stream are | 312 // won't have captions and should be ignored everywhere. |
| 314 // streaming video elements used for capturing a user image so they | 313 this.accessibilityAuditConfig.ignoreSelectors('videoWithoutCaptions', |
| 315 // won't have captions and should be ignored everywhere. | 314 '.user-image-stream'); |
| 316 auditConfig.ignoreSelectors('videoWithoutCaptions', | 315 this.accessibilityAuditConfig.ignoreSelectors( |
| 317 '.user-image-stream'); | 316 'videoWithoutCaptions', '.supervised-user-creation-image-stream'); |
| 318 auditConfig.ignoreSelectors( | |
| 319 'videoWithoutCaptions', '.supervised-user-creation-image-stream'); | |
| 320 } | |
| 321 }, | 317 }, |
| 322 | 318 |
| 323 /** | 319 /** |
| 324 * Override this method to perform tasks after running your test. If you | 320 * Override this method to perform tasks after running your test. If you |
| 325 * create a mock class, you must call Mock4JS.verifyAllMocks() in this | 321 * create a mock class, you must call Mock4JS.verifyAllMocks() in this |
| 326 * phase. | 322 * phase. |
| 327 * @type {Function} | 323 * @type {Function} |
| 328 */ | 324 */ |
| 329 tearDown: function() { | 325 tearDown: function() { |
| 330 if (typeof document != 'undefined') { | 326 if (typeof document != 'undefined') { |
| (...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1833 exports.TEST = TEST; | 1829 exports.TEST = TEST; |
| 1834 exports.TEST_F = TEST_F; | 1830 exports.TEST_F = TEST_F; |
| 1835 exports.RUNTIME_TEST_F = TEST_F; | 1831 exports.RUNTIME_TEST_F = TEST_F; |
| 1836 exports.GEN = GEN; | 1832 exports.GEN = GEN; |
| 1837 exports.GEN_INCLUDE = GEN_INCLUDE; | 1833 exports.GEN_INCLUDE = GEN_INCLUDE; |
| 1838 exports.WhenTestDone = WhenTestDone; | 1834 exports.WhenTestDone = WhenTestDone; |
| 1839 | 1835 |
| 1840 // Import the Mock4JS helpers. | 1836 // Import the Mock4JS helpers. |
| 1841 Mock4JS.addMockSupport(exports); | 1837 Mock4JS.addMockSupport(exports); |
| 1842 })(this); | 1838 })(this); |
| OLD | NEW |