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 // TODO(dbeam): test for loading upacked extensions? | 5 // TODO(dbeam): test for loading upacked extensions? |
6 | 6 |
7 GEN('#include "chrome/browser/ui/webui/extensions/' + | 7 GEN('#include "chrome/browser/ui/webui/extensions/' + |
8 'extension_settings_browsertest.h"'); | 8 'extension_settings_browsertest.h"'); |
9 | 9 |
10 // chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by | 10 // chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 * @type {string} | 42 * @type {string} |
43 * @const | 43 * @const |
44 */ | 44 */ |
45 browsePreload: 'chrome://extensions-frame/', | 45 browsePreload: 'chrome://extensions-frame/', |
46 | 46 |
47 /** @override */ | 47 /** @override */ |
48 typedefCppFixture: 'ExtensionSettingsUIBrowserTest', | 48 typedefCppFixture: 'ExtensionSettingsUIBrowserTest', |
49 | 49 |
50 /** @override */ | 50 /** @override */ |
51 setUp: function() { | 51 setUp: function() { |
52 // Make all transitions take 0ms for testing purposes. | 52 testing.Test.disableAnimationsAndTransitions(); |
53 var noTransitionStyle = document.createElement('style'); | |
54 noTransitionStyle.textContent = | |
55 '* {' + | |
56 ' -webkit-transition-duration: 0ms !important;' + | |
57 ' -webkit-transition-delay: 0ms !important;' + | |
58 '}'; | |
59 document.querySelector('head').appendChild(noTransitionStyle); | |
60 }, | 53 }, |
61 | 54 |
62 /** | 55 /** |
63 * Holds an array of steps that should happen in order during a test. | 56 * Holds an array of steps that should happen in order during a test. |
64 * The last step should be |testDone|. | 57 * The last step should be |testDone|. |
65 * @protected {Array<!Function>} | 58 * @protected {Array<!Function>} |
66 * */ | 59 * */ |
67 steps: [], | 60 steps: [], |
68 | 61 |
69 /** | 62 /** |
(...skipping 10 matching lines...) Expand all Loading... |
80 * the first step in every test. | 73 * the first step in every test. |
81 * @protected | 74 * @protected |
82 * */ | 75 * */ |
83 waitForPageLoad: function() { | 76 waitForPageLoad: function() { |
84 assertEquals(this.browsePreload, document.location.href); | 77 assertEquals(this.browsePreload, document.location.href); |
85 var extensionList = getRequiredElement('extension-settings-list'); | 78 var extensionList = getRequiredElement('extension-settings-list'); |
86 extensionList.loadFinished.then(this.nextStep.bind(this)); | 79 extensionList.loadFinished.then(this.nextStep.bind(this)); |
87 }, | 80 }, |
88 | 81 |
89 /** @protected */ | 82 /** @protected */ |
90 verifyDeveloperModeWorks: function() { | 83 enableDeveloperMode: function() { |
91 this.ignoreDevModeA11yFailures(); | 84 var next = this.nextStep.bind(this); |
| 85 extensions.ExtensionSettings.getInstance().testingDeveloperModeCallback = |
| 86 function() { |
| 87 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { |
| 88 assertTrue(extensionSettings.classList.contains('dev-mode')); |
| 89 assertTrue(profileInfo.inDeveloperMode); |
| 90 next(); |
| 91 |
| 92 // This event isn't thrown because transitions are disabled. |
| 93 // Ensure transition here so that any dependent code does not break. |
| 94 ensureTransitionEndEvent($('dev-controls'), 0); |
| 95 }); |
| 96 }; |
| 97 |
92 var extensionSettings = getRequiredElement('extension-settings'); | 98 var extensionSettings = getRequiredElement('extension-settings'); |
93 assertFalse(extensionSettings.classList.contains('dev-mode')); | 99 assertFalse(extensionSettings.classList.contains('dev-mode')); |
94 $('toggle-dev-on').click(); | 100 $('toggle-dev-on').click(); |
95 assertTrue(extensionSettings.classList.contains('dev-mode')); | |
96 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { | |
97 assertTrue(profileInfo.inDeveloperMode); | |
98 | |
99 // A 0ms timeout is necessary so that all the transitions can finish. | |
100 window.setTimeout(this.nextStep.bind(this), 0); | |
101 }.bind(this)); | |
102 }, | 101 }, |
103 | 102 |
104 /** @protected */ | 103 /** @protected */ |
105 testDeveloperMode: function() { | 104 testDeveloperMode: function() { |
106 var next = this.nextStep.bind(this); | 105 var next = this.nextStep.bind(this); |
107 var checkDevModeIsOff = function() { | 106 var checkDevModeIsOff = function() { |
108 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { | 107 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { |
109 assertFalse(profileInfo.inDeveloperMode); | 108 assertFalse(profileInfo.inDeveloperMode); |
110 next(); | 109 next(); |
111 }); | 110 }); |
112 }; | 111 }; |
113 this.steps = [this.waitForPageLoad, | 112 this.steps = [this.waitForPageLoad, |
114 checkDevModeIsOff, | 113 checkDevModeIsOff, |
115 this.verifyDeveloperModeWorks, | 114 this.enableDeveloperMode, |
116 testDone]; | 115 testDone]; |
117 this.nextStep(); | 116 this.nextStep(); |
118 }, | 117 }, |
119 | |
120 /** | |
121 * TODO(hcarmona): Remove this as part of fixing crbug.com/463245. | |
122 * Will ignore accessibility failures caused by the transition when developer | |
123 * mode is enabled. | |
124 * @protected | |
125 */ | |
126 ignoreDevModeA11yFailures: function() { | |
127 this.accessibilityAuditConfig.ignoreSelectors( | |
128 'focusableElementNotVisibleAndNotAriaHidden', | |
129 '#load-unpacked'); | |
130 this.accessibilityAuditConfig.ignoreSelectors( | |
131 'focusableElementNotVisibleAndNotAriaHidden', | |
132 '#pack-extension'); | |
133 this.accessibilityAuditConfig.ignoreSelectors( | |
134 'focusableElementNotVisibleAndNotAriaHidden', | |
135 '#update-extensions-now'); | |
136 }, | |
137 }; | 118 }; |
138 | 119 |
139 // Verify that developer mode doesn't change behavior when the number of | 120 // Verify that developer mode doesn't change behavior when the number of |
140 // extensions changes. | 121 // extensions changes. |
141 TEST_F('ExtensionSettingsWebUITest', 'testDeveloperModeNoExtensions', | 122 TEST_F('ExtensionSettingsWebUITest', 'testDeveloperModeNoExtensions', |
142 function() { | 123 function() { |
143 this.testDeveloperMode(); | 124 this.testDeveloperMode(); |
144 }); | 125 }); |
145 | 126 |
146 TEST_F('ExtensionSettingsWebUITest', 'testEmptyExtensionList', function() { | 127 TEST_F('ExtensionSettingsWebUITest', 'testEmptyExtensionList', function() { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 this.steps = [this.waitForPageLoad, this.verifyUninstallWorks, testDone]; | 257 this.steps = [this.waitForPageLoad, this.verifyUninstallWorks, testDone]; |
277 this.nextStep(); | 258 this.nextStep(); |
278 }); | 259 }); |
279 | 260 |
280 TEST_F('BasicExtensionSettingsWebUITest', 'testNonEmptyExtensionList', | 261 TEST_F('BasicExtensionSettingsWebUITest', 'testNonEmptyExtensionList', |
281 function() { | 262 function() { |
282 var verifyListIsNotHiddenAndEmpty = function() { | 263 var verifyListIsNotHiddenAndEmpty = function() { |
283 assertFalse($('extension-list-wrapper').hidden); | 264 assertFalse($('extension-list-wrapper').hidden); |
284 assertTrue($('no-extensions').hidden); | 265 assertTrue($('no-extensions').hidden); |
285 assertGT($('extension-settings-list').childNodes.length, 0); | 266 assertGT($('extension-settings-list').childNodes.length, 0); |
286 | |
287 this.nextStep(); | 267 this.nextStep(); |
288 }; | 268 }; |
289 | 269 |
290 this.steps = [this.waitForPageLoad, verifyListIsNotHiddenAndEmpty, testDone]; | 270 this.steps = [this.waitForPageLoad, verifyListIsNotHiddenAndEmpty, testDone]; |
291 this.nextStep(); | 271 this.nextStep(); |
292 }); | 272 }); |
293 | 273 |
294 function AsyncExtensionSettingsWebUITest() {} | 274 function AsyncExtensionSettingsWebUITest() {} |
295 | 275 |
296 AsyncExtensionSettingsWebUITest.prototype = { | 276 AsyncExtensionSettingsWebUITest.prototype = { |
297 __proto__: ExtensionSettingsWebUITest.prototype, | 277 __proto__: ExtensionSettingsWebUITest.prototype, |
298 | 278 |
299 /** @override */ | 279 /** @override */ |
300 testGenPreamble: function() { | 280 testGenPreamble: function() { |
301 GEN(' InstallGoodExtension();'); | 281 GEN(' InstallGoodExtension();'); |
302 GEN(' InstallErrorsExtension();'); | 282 GEN(' InstallErrorsExtension();'); |
303 }, | 283 }, |
304 }; | 284 }; |
305 | 285 |
306 // Often times out on all platforms: http://crbug.com/467528 | 286 TEST_F('AsyncExtensionSettingsWebUITest', 'testErrorListButtonVisibility', |
307 TEST_F('AsyncExtensionSettingsWebUITest', | |
308 'DISABLED_testErrorListButtonVisibility', | |
309 function() { | 287 function() { |
310 var testButtonVisibility = function() { | 288 var testButtonVisibility = function() { |
| 289 var extensionList = $('extension-list-wrapper'); |
| 290 |
311 // 2 extensions are loaded: | 291 // 2 extensions are loaded: |
312 // The 'good' extension will have 0 errors wich means no error list | 292 // The 'good' extension will have 0 errors wich means no error button. |
313 // buttons. | |
314 // The 'bad' extension will have >3 manifest errors and <3 runtime errors. | 293 // The 'bad' extension will have >3 manifest errors and <3 runtime errors. |
315 // This means 2 buttons: 1 visible and 1 hidden. | 294 // This means there will be a single error button. |
316 var visibleButtons = document.querySelectorAll( | 295 var visibleButtons = extensionList.querySelectorAll( |
317 '.extension-error-list-show-more > a:not([hidden])'); | 296 '.errors-link:not([hidden])'); |
318 assertEquals(1, visibleButtons.length); | 297 expectEquals(1, visibleButtons.length); |
319 // Visible buttons must be part of the focusRow. | |
320 assertTrue(visibleButtons[0].hasAttribute('column-type')); | |
321 | 298 |
322 var hiddenButtons = document.querySelectorAll( | 299 var hiddenButtons = extensionList.querySelectorAll('.errors-link[hidden]'); |
323 '.extension-error-list-show-more > a[hidden]'); | 300 expectEquals(1, hiddenButtons.length); |
324 assertEquals(1, hiddenButtons.length); | |
325 // Hidden buttons must NOT be part of the focusRow. | |
326 assertFalse(hiddenButtons[0].hasAttribute('column-type')); | |
327 | 301 |
328 this.nextStep(); | 302 this.nextStep(); |
329 }; | 303 }; |
330 | 304 |
331 this.steps = [this.waitForPageLoad, | 305 this.steps = [this.waitForPageLoad, |
332 this.verifyDeveloperModeWorks, | 306 this.enableDeveloperMode, |
333 testButtonVisibility, | 307 testButtonVisibility, |
334 testDone]; | 308 testDone]; |
335 this.nextStep(); | 309 this.nextStep(); |
336 }); | 310 }); |
337 | 311 |
338 /** | 312 /** |
339 * TestFixture for extension settings WebUI testing (commands config edition). | 313 * TestFixture for extension settings WebUI testing (commands config edition). |
340 * @extends {testing.Test} | 314 * @extends {testing.Test} |
341 * @constructor | 315 * @constructor |
342 */ | 316 */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 410 |
437 /** @override */ | 411 /** @override */ |
438 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + | 412 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + |
439 '?options=' + GOOD_CRX_ID, | 413 '?options=' + GOOD_CRX_ID, |
440 }; | 414 }; |
441 | 415 |
442 TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility', | 416 TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility', |
443 function() { | 417 function() { |
444 this.emptyTestForAccessibility(); | 418 this.emptyTestForAccessibility(); |
445 }); | 419 }); |
OLD | NEW |