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