Chromium Code Reviews| 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 // The id of the extension from |InstallGoodExtension|. |
| 11 // ExtensionSettingsUIBrowserTest::InstallGoodExtension() in some of the tests. | 11 var GOOD_EXTENSION_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf'; |
|
Dan Beam
2015/05/12 01:34:13
\n
hcarmona
2015/05/12 17:20:13
Done.
| |
| 12 var GOOD_CRX_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf'; | 12 // The id of the extension from |InstallErrorsExtension|. |
| 13 var ERROR_EXTENSION_ID = 'pdlpifnclfacjobnmbpngemkalkjamnf'; | |
| 13 | 14 |
| 14 /** | 15 /** |
| 15 * Test C++ fixture for settings WebUI testing. | 16 * Test C++ fixture for settings WebUI testing. |
| 16 * @constructor | 17 * @constructor |
| 17 * @extends {testing.Test} | 18 * @extends {testing.Test} |
| 18 */ | 19 */ |
| 19 function ExtensionSettingsUIBrowserTest() {} | 20 function ExtensionSettingsUIBrowserTest() {} |
| 20 | 21 |
| 21 /** | 22 /** |
| 22 * TestFixture for extension settings WebUI testing. | 23 * TestFixture for extension settings WebUI testing. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 GEN(' InstallPackagedApp();'); | 193 GEN(' InstallPackagedApp();'); |
| 193 | 194 |
| 194 GEN(' SetAutoConfirmUninstall();'); | 195 GEN(' SetAutoConfirmUninstall();'); |
| 195 }, | 196 }, |
| 196 | 197 |
| 197 /** @protected */ | 198 /** @protected */ |
| 198 verifyDisabledWorks: function() { | 199 verifyDisabledWorks: function() { |
| 199 var listener = new UpdateListener( | 200 var listener = new UpdateListener( |
| 200 chrome.developerPrivate.EventType.UNLOADED, | 201 chrome.developerPrivate.EventType.UNLOADED, |
| 201 function() { | 202 function() { |
| 202 var node = getRequiredElement(GOOD_CRX_ID); | 203 var node = getRequiredElement(GOOD_EXTENSION_ID); |
| 203 assertTrue(node.classList.contains('inactive-extension')); | 204 assertTrue(node.classList.contains('inactive-extension')); |
| 204 this.nextStep(); | 205 this.nextStep(); |
| 205 }.bind(this)); | 206 }.bind(this)); |
| 206 chrome.management.setEnabled(GOOD_CRX_ID, false); | 207 chrome.management.setEnabled(GOOD_EXTENSION_ID, false); |
| 207 }, | 208 }, |
| 208 | 209 |
| 209 /** @protected */ | 210 /** @protected */ |
| 210 verifyEnabledWorks: function() { | 211 verifyEnabledWorks: function() { |
| 211 var listener = new UpdateListener( | 212 var listener = new UpdateListener( |
| 212 chrome.developerPrivate.EventType.LOADED, | 213 chrome.developerPrivate.EventType.LOADED, |
| 213 function() { | 214 function() { |
| 214 var node = getRequiredElement(GOOD_CRX_ID); | 215 var node = getRequiredElement(GOOD_EXTENSION_ID); |
| 215 assertFalse(node.classList.contains('inactive-extension')); | 216 assertFalse(node.classList.contains('inactive-extension')); |
| 216 this.nextStep(); | 217 this.nextStep(); |
| 217 }.bind(this)); | 218 }.bind(this)); |
| 218 chrome.management.setEnabled(GOOD_CRX_ID, true); | 219 chrome.management.setEnabled(GOOD_EXTENSION_ID, true); |
| 219 }, | 220 }, |
| 220 | 221 |
| 221 /** @protected */ | 222 /** @protected */ |
| 222 verifyUninstallWorks: function() { | 223 verifyUninstallWorks: function() { |
| 223 var listener = new UpdateListener( | 224 var listener = new UpdateListener( |
| 224 chrome.developerPrivate.EventType.UNINSTALLED, | 225 chrome.developerPrivate.EventType.UNINSTALLED, |
| 225 function() { | 226 function() { |
| 226 assertEquals(null, $(GOOD_CRX_ID)); | 227 assertEquals(null, $(GOOD_EXTENSION_ID)); |
| 227 this.nextStep(); | 228 this.nextStep(); |
| 228 }.bind(this)); | 229 }.bind(this)); |
| 229 chrome.test.runWithUserGesture(function() { | 230 chrome.test.runWithUserGesture(function() { |
| 230 chrome.management.uninstall(GOOD_CRX_ID); | 231 chrome.management.uninstall(GOOD_EXTENSION_ID); |
| 231 }); | 232 }); |
| 232 }, | 233 }, |
| 233 }; | 234 }; |
| 234 | 235 |
| 235 // Verify that developer mode doesn't change behavior when the number of | 236 // Verify that developer mode doesn't change behavior when the number of |
| 236 // extensions changes. | 237 // extensions changes. |
| 237 TEST_F('BasicExtensionSettingsWebUITest', 'testDeveloperModeManyExtensions', | 238 TEST_F('BasicExtensionSettingsWebUITest', 'testDeveloperModeManyExtensions', |
| 238 function() { | 239 function() { |
| 239 this.testDeveloperMode(); | 240 this.testDeveloperMode(); |
| 240 }); | 241 }); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 264 assertFalse($('extension-list-wrapper').hidden); | 265 assertFalse($('extension-list-wrapper').hidden); |
| 265 assertTrue($('no-extensions').hidden); | 266 assertTrue($('no-extensions').hidden); |
| 266 assertGT($('extension-settings-list').childNodes.length, 0); | 267 assertGT($('extension-settings-list').childNodes.length, 0); |
| 267 this.nextStep(); | 268 this.nextStep(); |
| 268 }; | 269 }; |
| 269 | 270 |
| 270 this.steps = [this.waitForPageLoad, verifyListIsNotHiddenAndEmpty, testDone]; | 271 this.steps = [this.waitForPageLoad, verifyListIsNotHiddenAndEmpty, testDone]; |
| 271 this.nextStep(); | 272 this.nextStep(); |
| 272 }); | 273 }); |
| 273 | 274 |
| 274 function AsyncExtensionSettingsWebUITest() {} | 275 function ErrorConsoleExtensionSettingsWebUITest() {} |
| 275 | 276 |
| 276 AsyncExtensionSettingsWebUITest.prototype = { | 277 ErrorConsoleExtensionSettingsWebUITest.prototype = { |
| 277 __proto__: ExtensionSettingsWebUITest.prototype, | 278 __proto__: ExtensionSettingsWebUITest.prototype, |
| 278 | 279 |
| 279 /** @override */ | 280 /** @override */ |
| 280 testGenPreamble: function() { | 281 testGenPreamble: function() { |
| 282 GEN(' EnableErrorConsole();'); | |
| 283 | |
|
Dan Beam
2015/05/12 01:34:13
why the \n?
hcarmona
2015/05/12 17:20:13
It was to separate enabling the error console and
| |
| 281 GEN(' InstallGoodExtension();'); | 284 GEN(' InstallGoodExtension();'); |
| 282 GEN(' InstallErrorsExtension();'); | 285 GEN(' InstallErrorsExtension();'); |
| 283 }, | 286 }, |
| 284 }; | 287 }; |
| 285 | 288 |
| 286 // Still fails on CrWinClang tester. BUG=463245 | 289 TEST_F('ErrorConsoleExtensionSettingsWebUITest', |
| 287 TEST_F('AsyncExtensionSettingsWebUITest', | 290 'testErrorListButtonVisibility', function() { |
| 288 'DISABLED_testErrorListButtonVisibility', | |
| 289 function() { | |
| 290 var testButtonVisibility = function() { | 291 var testButtonVisibility = function() { |
| 291 var extensionList = $('extension-list-wrapper'); | 292 var extensionList = $('extension-list-wrapper'); |
| 292 | 293 |
| 293 // 2 extensions are loaded: | |
| 294 // The 'good' extension will have 0 errors wich means no error button. | |
| 295 // The 'bad' extension will have >3 manifest errors and <3 runtime errors. | |
| 296 // This means there will be a single error button. | |
| 297 var visibleButtons = extensionList.querySelectorAll( | 294 var visibleButtons = extensionList.querySelectorAll( |
| 298 '.errors-link:not([hidden])'); | 295 '.errors-link:not([hidden])'); |
| 299 expectEquals(1, visibleButtons.length); | 296 expectEquals(1, visibleButtons.length); |
| 300 | 297 |
| 298 if (visibleButtons.length > 0) { | |
| 299 var errorLink = $(ERROR_EXTENSION_ID).querySelector('.errors-link'); | |
| 300 expectEquals(visibleButtons[0], errorLink); | |
| 301 | |
| 302 var errorIcon = errorLink.querySelector('img'); | |
| 303 expectTrue(errorIcon.classList.contains('extension-error-warning-icon')); | |
| 304 } | |
| 305 | |
| 301 var hiddenButtons = extensionList.querySelectorAll('.errors-link[hidden]'); | 306 var hiddenButtons = extensionList.querySelectorAll('.errors-link[hidden]'); |
| 302 expectEquals(1, hiddenButtons.length); | 307 expectEquals(1, hiddenButtons.length); |
| 303 | 308 |
| 304 this.nextStep(); | 309 this.nextStep(); |
| 305 }; | 310 }; |
| 306 | 311 |
| 307 this.steps = [this.waitForPageLoad, | 312 this.steps = [this.waitForPageLoad, |
| 308 this.enableDeveloperMode, | 313 this.enableDeveloperMode, |
| 309 testButtonVisibility, | 314 testButtonVisibility, |
| 310 testDone]; | 315 testDone]; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 }; | 367 }; |
| 363 | 368 |
| 364 TEST_F('InstallGoodExtensionSettingsWebUITest', 'testAccessibility', | 369 TEST_F('InstallGoodExtensionSettingsWebUITest', 'testAccessibility', |
| 365 function() { | 370 function() { |
| 366 this.emptyTestForAccessibility(); | 371 this.emptyTestForAccessibility(); |
| 367 }); | 372 }); |
| 368 | 373 |
| 369 TEST_F('InstallGoodExtensionSettingsWebUITest', 'showOptions', function() { | 374 TEST_F('InstallGoodExtensionSettingsWebUITest', 'showOptions', function() { |
| 370 var showExtensionOptions = function() { | 375 var showExtensionOptions = function() { |
| 371 var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance(); | 376 var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance(); |
| 372 optionsOverlay.setExtensionAndShow(GOOD_CRX_ID, 'GOOD!', '', | 377 optionsOverlay.setExtensionAndShow(GOOD_EXTENSION_ID, 'GOOD!', '', |
| 373 this.nextStep.bind(this)); | 378 this.nextStep.bind(this)); |
| 374 | 379 |
| 375 // Preferred size changes don't happen in browser tests. Just fake it. | 380 // Preferred size changes don't happen in browser tests. Just fake it. |
| 376 document.querySelector('extensionoptions').onpreferredsizechanged( | 381 document.querySelector('extensionoptions').onpreferredsizechanged( |
| 377 {width: 500, height: 500}); | 382 {width: 500, height: 500}); |
| 378 }; | 383 }; |
| 379 | 384 |
| 380 this.steps = [this.waitForPageLoad, showExtensionOptions, testDone]; | 385 this.steps = [this.waitForPageLoad, showExtensionOptions, testDone]; |
| 381 this.nextStep(); | 386 this.nextStep(); |
| 382 }); | 387 }); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 405 * @constructor | 410 * @constructor |
| 406 * @extends {InstallGoodExtensionSettingsWebUITest} | 411 * @extends {InstallGoodExtensionSettingsWebUITest} |
| 407 */ | 412 */ |
| 408 function OptionsDialogExtensionSettingsWebUITest() {} | 413 function OptionsDialogExtensionSettingsWebUITest() {} |
| 409 | 414 |
| 410 OptionsDialogExtensionSettingsWebUITest.prototype = { | 415 OptionsDialogExtensionSettingsWebUITest.prototype = { |
| 411 __proto__: InstallGoodExtensionSettingsWebUITest.prototype, | 416 __proto__: InstallGoodExtensionSettingsWebUITest.prototype, |
| 412 | 417 |
| 413 /** @override */ | 418 /** @override */ |
| 414 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + | 419 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + |
| 415 '?options=' + GOOD_CRX_ID, | 420 '?options=' + GOOD_EXTENSION_ID, |
| 416 }; | 421 }; |
| 417 | 422 |
| 418 TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility', | 423 TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility', |
| 419 function() { | 424 function() { |
| 420 this.emptyTestForAccessibility(); | 425 this.emptyTestForAccessibility(); |
| 421 }); | 426 }); |
| OLD | NEW |