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 // chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 * TestFixture for extension settings WebUI testing. | 22 * TestFixture for extension settings WebUI testing. |
| 23 * @extends {testing.Test} | 23 * @extends {testing.Test} |
| 24 * @constructor | 24 * @constructor |
| 25 */ | 25 */ |
| 26 function ExtensionSettingsWebUITest() {} | 26 function ExtensionSettingsWebUITest() {} |
| 27 | 27 |
| 28 ExtensionSettingsWebUITest.prototype = { | 28 ExtensionSettingsWebUITest.prototype = { |
| 29 __proto__: testing.Test.prototype, | 29 __proto__: testing.Test.prototype, |
| 30 | 30 |
| 31 /** @override */ | 31 /** @override */ |
| 32 isAsync: true, | |
| 33 | |
| 34 /** @override */ | |
| 32 runAccessibilityChecks: true, | 35 runAccessibilityChecks: true, |
| 33 | 36 |
| 34 /** @override */ | 37 /** @override */ |
| 35 accessibilityIssuesAreErrors: true, | 38 accessibilityIssuesAreErrors: true, |
| 36 | 39 |
| 37 /** | 40 /** |
| 38 * A URL to load before starting each test. | 41 * A URL to load before starting each test. |
| 39 * @type {string} | 42 * @type {string} |
| 40 * @const | 43 * @const |
| 41 */ | 44 */ |
| 42 browsePreload: 'chrome://extensions-frame/', | 45 browsePreload: 'chrome://extensions-frame/', |
| 43 | 46 |
| 44 /** @override */ | 47 /** @override */ |
| 45 typedefCppFixture: 'ExtensionSettingsUIBrowserTest', | 48 typedefCppFixture: 'ExtensionSettingsUIBrowserTest', |
| 49 | |
| 50 /** @override */ | |
| 51 setUp: function() { | |
| 52 // Make all transitions take 0ms for testing purposes. | |
| 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 }, | |
| 61 | |
| 62 /** | |
| 63 * Holds an array of steps that should happen in order during a test. | |
| 64 * The last step should be |testDone|. | |
| 65 * @protected {Array<!Function>} | |
| 66 * */ | |
| 67 steps: [], | |
| 68 | |
| 69 /** | |
| 70 * Advances to the next step in the test. Every step should call this. | |
| 71 * @protected | |
| 72 * */ | |
| 73 nextStep: function() { | |
| 74 assertTrue(this.steps.length > 0); | |
| 75 this.steps.shift().call(this); | |
| 76 }, | |
| 77 | |
| 78 /** | |
| 79 * Will wait for the page to load before calling the next step. This should be | |
| 80 * the first step in every test. | |
| 81 * @protected | |
| 82 * */ | |
| 83 waitForPageLoad: function() { | |
| 84 assertEquals(this.browsePreload, document.location.href); | |
| 85 var extensionList = getRequiredElement('extension-settings-list'); | |
| 86 extensionList.loadFinished.then(this.nextStep.bind(this)); | |
| 87 }, | |
| 88 | |
| 89 /** @protected */ | |
| 90 verifyDeveloperModeWorks: function() { | |
| 91 var extensionSettings = getRequiredElement('extension-settings'); | |
| 92 assertFalse(extensionSettings.classList.contains('dev-mode')); | |
| 93 $('toggle-dev-on').click(); | |
| 94 assertTrue(extensionSettings.classList.contains('dev-mode')); | |
| 95 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { | |
| 96 assertTrue(profileInfo.inDeveloperMode); | |
| 97 | |
| 98 // A 0ms timeout is necessary so that all the transitions can finish. | |
| 99 window.setTimeout(function() { | |
|
Dan Beam
2015/04/22 18:44:55
nit:
window.setTimeout(this.nextSetup.bind(this)
hcarmona
2015/04/22 20:44:45
Done.
| |
| 100 this.nextStep(this); | |
|
Dan Beam
2015/04/22 18:44:55
this.nextStep();
hcarmona
2015/04/22 20:44:45
Acknowledged.
| |
| 101 }.bind(this), 0); | |
| 102 }.bind(this)); | |
| 103 }, | |
| 104 | |
| 105 /** @protected */ | |
| 106 testDeveloperMode: function() { | |
| 107 var next = this.nextStep.bind(this); | |
| 108 var checkDevModeIsOff = function() { | |
| 109 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { | |
| 110 assertFalse(profileInfo.inDeveloperMode); | |
| 111 next(); | |
| 112 }); | |
| 113 }; | |
| 114 this.steps = [this.waitForPageLoad, | |
| 115 checkDevModeIsOff, | |
| 116 this.verifyDeveloperModeWorks, | |
| 117 testDone]; | |
| 118 this.nextStep(); | |
| 119 } | |
| 46 }; | 120 }; |
| 47 | 121 |
| 122 // Verify that developer mode doesn't change behavior when the number of | |
| 123 // extensions changes. | |
| 124 TEST_F('ExtensionSettingsWebUITest', 'testDeveloperModeNoExtensions', | |
| 125 function() { | |
| 126 this.testDeveloperMode(); | |
| 127 }); | |
| 128 | |
| 129 TEST_F('ExtensionSettingsWebUITest', 'testEmptyExtensionList', function() { | |
| 130 var verifyListIsHiddenAndEmpty = function() { | |
| 131 var listWrapper = $('extension-list-wrapper'); | |
| 132 var noExtensionMessage = $('no-extensions'); | |
| 133 var list = $('extension-settings-list'); | |
| 134 | |
| 135 assertTrue(listWrapper.hidden); | |
|
Dan Beam
2015/04/22 18:44:54
nit: inline variables only used once, e.g.
asse
hcarmona
2015/04/22 20:44:45
Done.
| |
| 136 assertFalse(noExtensionMessage.hidden); | |
| 137 assertEquals(0, list.childNodes.length); | |
| 138 this.nextStep(); | |
| 139 }; | |
| 140 | |
| 141 this.steps = [this.waitForPageLoad, | |
| 142 verifyListIsHiddenAndEmpty, | |
| 143 testDone]; | |
| 144 this.nextStep(); | |
| 145 }); | |
| 146 | |
| 48 TEST_F('ExtensionSettingsWebUITest', 'testChromeSendHandled', function() { | 147 TEST_F('ExtensionSettingsWebUITest', 'testChromeSendHandled', function() { |
| 49 assertEquals(this.browsePreload, document.location.href); | 148 var testPackExtenion = function() { |
| 149 // This dialog should be hidden at first. | |
| 150 assertFalse($('pack-extension-overlay').classList.contains('showing')); | |
| 50 | 151 |
| 51 // This dialog should be hidden at first. | 152 // Show the dialog, which triggers a chrome.send() for metrics purposes. |
| 52 assertFalse($('pack-extension-overlay').classList.contains('showing')); | 153 cr.dispatchSimpleEvent($('pack-extension'), 'click'); |
| 154 assertTrue($('pack-extension-overlay').classList.contains('showing')); | |
| 155 this.nextStep(); | |
| 156 }; | |
| 53 | 157 |
| 54 // Show the dialog, which triggers a chrome.send() for metrics purposes. | 158 this.steps = [this.waitForPageLoad, |
| 55 cr.dispatchSimpleEvent($('pack-extension'), 'click'); | 159 testPackExtenion, |
| 56 assertTrue($('pack-extension-overlay').classList.contains('showing')); | 160 testDone]; |
| 161 this.nextStep(); | |
| 57 }); | 162 }); |
| 58 | 163 |
| 59 function BasicExtensionSettingsWebUITest() {} | 164 function BasicExtensionSettingsWebUITest() {} |
| 60 | 165 |
| 61 BasicExtensionSettingsWebUITest.prototype = { | 166 BasicExtensionSettingsWebUITest.prototype = { |
| 62 __proto__: ExtensionSettingsWebUITest.prototype, | 167 __proto__: ExtensionSettingsWebUITest.prototype, |
| 63 | 168 |
| 64 /** @override */ | 169 /** @override */ |
| 65 isAsync: true, | |
| 66 | |
| 67 /** @override */ | |
| 68 testGenPreamble: function() { | 170 testGenPreamble: function() { |
| 69 // Install multiple types of extensions to ensure we handle each type. | 171 // Install multiple types of extensions to ensure we handle each type. |
| 70 // TODO(devlin): There are more types to add here. | 172 // TODO(devlin): There are more types to add here. |
| 71 GEN(' InstallGoodExtension();'); | 173 GEN(' InstallGoodExtension();'); |
| 72 GEN(' InstallErrorsExtension();'); | 174 GEN(' InstallErrorsExtension();'); |
| 73 GEN(' InstallSharedModule();'); | 175 GEN(' InstallSharedModule();'); |
| 74 GEN(' InstallPackagedApp();'); | 176 GEN(' InstallPackagedApp();'); |
| 75 | 177 |
| 76 GEN(' SetAutoConfirmUninstall();'); | 178 GEN(' SetAutoConfirmUninstall();'); |
| 77 }, | 179 }, |
| 78 | 180 |
| 79 /** @protected {Array<!Function>} */ | |
| 80 steps: [], | |
| 81 | |
| 82 /** @protected */ | |
| 83 nextStep: function() { | |
| 84 assertTrue(this.steps.length > 0); | |
| 85 this.steps.shift().call(this); | |
| 86 }, | |
| 87 | |
| 88 /** @protected */ | |
| 89 waitForPageLoad: function() { | |
| 90 var extensionList = getRequiredElement('extension-settings-list'); | |
| 91 extensionList.extensionsUpdated_.then(this.nextStep.bind(this)); | |
| 92 }, | |
| 93 | |
| 94 /** @protected */ | 181 /** @protected */ |
| 95 verifyDisabledWorks: function() { | 182 verifyDisabledWorks: function() { |
| 96 chrome.management.setEnabled(GOOD_CRX_ID, false, function() { | 183 chrome.management.setEnabled(GOOD_CRX_ID, false, function() { |
| 97 var node = getRequiredElement(GOOD_CRX_ID); | 184 var node = getRequiredElement(GOOD_CRX_ID); |
| 98 assertTrue(node.classList.contains('inactive-extension')); | 185 assertTrue(node.classList.contains('inactive-extension')); |
| 99 this.nextStep(); | 186 this.nextStep(); |
| 100 }.bind(this)); | 187 }.bind(this)); |
| 101 }, | 188 }, |
| 102 | 189 |
| 103 /** @protected */ | 190 /** @protected */ |
| 104 verifyEnabledWorks: function() { | 191 verifyEnabledWorks: function() { |
| 105 chrome.management.setEnabled(GOOD_CRX_ID, true, function() { | 192 chrome.management.setEnabled(GOOD_CRX_ID, true, function() { |
| 106 var node = getRequiredElement(GOOD_CRX_ID); | 193 var node = getRequiredElement(GOOD_CRX_ID); |
| 107 assertFalse(node.classList.contains('inactive-extension')); | 194 assertFalse(node.classList.contains('inactive-extension')); |
| 108 this.nextStep(); | 195 this.nextStep(); |
| 109 }.bind(this)); | 196 }.bind(this)); |
| 110 }, | 197 }, |
| 111 | 198 |
| 112 /** @protected */ | 199 /** @protected */ |
| 113 verifyUninstallWorks: function() { | 200 verifyUninstallWorks: function() { |
| 114 var next = this.nextStep.bind(this); | 201 var next = this.nextStep.bind(this); |
| 115 chrome.test.runWithUserGesture(function() { | 202 chrome.test.runWithUserGesture(function() { |
| 116 chrome.management.uninstall(GOOD_CRX_ID, function() { | 203 chrome.management.uninstall(GOOD_CRX_ID, function() { |
| 117 assertEquals(null, $(GOOD_CRX_ID)); | 204 assertEquals(null, $(GOOD_CRX_ID)); |
| 118 next(); | 205 next(); |
| 119 }); | 206 }); |
| 120 }); | 207 }); |
| 121 }, | 208 }, |
| 209 }; | |
| 122 | 210 |
| 123 /** @protected */ | 211 // Verify that developer mode doesn't change behavior when the number of |
| 124 verifyDeveloperModeWorks: function() { | 212 // extensions changes. |
| 125 var extensionSettings = getRequiredElement('extension-settings'); | 213 TEST_F('BasicExtensionSettingsWebUITest', 'testDeveloperModeManyExtensions', |
| 126 assertFalse(extensionSettings.classList.contains('dev-mode')); | 214 function() { |
| 127 $('toggle-dev-on').click(); | 215 this.testDeveloperMode(); |
| 128 assertTrue(extensionSettings.classList.contains('dev-mode')); | 216 }); |
| 129 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { | 217 |
| 130 assertTrue(profileInfo.inDeveloperMode); | |
| 131 this.nextStep(); | |
| 132 }.bind(this)); | |
| 133 }, | |
| 134 }; | |
| 135 | 218 |
| 136 TEST_F('BasicExtensionSettingsWebUITest', 'testDisable', function() { | 219 TEST_F('BasicExtensionSettingsWebUITest', 'testDisable', function() { |
| 137 this.steps = [this.waitForPageLoad, | 220 this.steps = [this.waitForPageLoad, |
| 138 this.verifyDisabledWorks, | 221 this.verifyDisabledWorks, |
| 139 testDone]; | 222 testDone]; |
| 140 this.nextStep(); | 223 this.nextStep(); |
| 141 }); | 224 }); |
| 142 | 225 |
| 143 TEST_F('BasicExtensionSettingsWebUITest', 'testEnable', function() { | 226 TEST_F('BasicExtensionSettingsWebUITest', 'testEnable', function() { |
| 144 this.steps = [this.waitForPageLoad, | 227 this.steps = [this.waitForPageLoad, |
| 145 this.verifyDisabledWorks, | 228 this.verifyDisabledWorks, |
| 146 this.verifyEnabledWorks, | 229 this.verifyEnabledWorks, |
| 147 testDone]; | 230 testDone]; |
| 148 this.nextStep(); | 231 this.nextStep(); |
| 149 }); | 232 }); |
| 150 | 233 |
| 151 TEST_F('BasicExtensionSettingsWebUITest', 'testUninstall', function() { | 234 TEST_F('BasicExtensionSettingsWebUITest', 'testUninstall', function() { |
| 152 this.steps = [this.waitForPageLoad, | 235 this.steps = [this.waitForPageLoad, |
| 153 this.verifyUninstallWorks, | 236 this.verifyUninstallWorks, |
| 154 testDone]; | 237 testDone]; |
| 155 this.nextStep(); | 238 this.nextStep(); |
| 156 }); | 239 }); |
| 157 | 240 |
| 158 TEST_F('BasicExtensionSettingsWebUITest', 'testDeveloperMode', function() { | 241 TEST_F('BasicExtensionSettingsWebUITest', 'testNonEmptyExtensionList', |
| 159 var next = this.nextStep.bind(this); | 242 function() { |
| 160 var checkDevModeIsOff = function() { | 243 var verifyListIsNotHiddenAndEmpty = function() { |
| 161 chrome.developerPrivate.getProfileConfiguration(function(profileInfo) { | 244 var listWrapper = $('extension-list-wrapper'); |
| 162 assertFalse(profileInfo.inDeveloperMode); | 245 var noExtensionMessage = $('no-extensions'); |
| 163 next(); | 246 var list = $('extension-settings-list'); |
| 164 }); | 247 |
| 248 assertFalse(listWrapper.hidden); | |
| 249 assertTrue(noExtensionMessage.hidden); | |
| 250 assertGT(list.childNodes.length, 0); | |
|
Dan Beam
2015/04/22 18:44:54
same nits re: inline vars
hcarmona
2015/04/22 20:44:45
Done.
| |
| 251 | |
| 252 this.nextStep(); | |
| 165 }; | 253 }; |
| 166 this.steps = [checkDevModeIsOff, | 254 |
| 167 this.waitForPageLoad, | 255 this.steps = [this.waitForPageLoad, |
| 168 this.verifyDeveloperModeWorks, | 256 verifyListIsNotHiddenAndEmpty, |
| 169 testDone]; | 257 testDone]; |
| 170 this.nextStep(); | 258 this.nextStep(); |
| 171 }); | 259 }); |
| 172 | 260 |
| 173 function AsyncExtensionSettingsWebUITest() {} | 261 function AsyncExtensionSettingsWebUITest() {} |
| 174 | 262 |
| 175 AsyncExtensionSettingsWebUITest.prototype = { | 263 AsyncExtensionSettingsWebUITest.prototype = { |
| 176 __proto__: ExtensionSettingsWebUITest.prototype, | 264 __proto__: ExtensionSettingsWebUITest.prototype, |
| 177 | 265 |
| 178 /** @override */ | 266 /** @override */ |
| 179 isAsync: true, | |
| 180 | |
| 181 /** @override */ | |
| 182 testGenPreamble: function() { | 267 testGenPreamble: function() { |
| 183 GEN(' InstallGoodExtension();'); | 268 GEN(' InstallGoodExtension();'); |
| 184 GEN(' InstallErrorsExtension();'); | 269 GEN(' InstallErrorsExtension();'); |
| 185 }, | 270 }, |
| 186 | |
| 187 enableDeveloperMode: function(callback) { | |
| 188 var devControls = $('dev-controls'); | |
| 189 | |
| 190 // Make sure developer controls are hidden before checkbox is clicked. | |
| 191 assertEquals(0, devControls.offsetHeight); | |
| 192 $('toggle-dev-on').click(); | |
| 193 | |
| 194 document.addEventListener('webkitTransitionEnd', function f(e) { | |
| 195 if (e.target == devControls) { | |
| 196 // Make sure developer controls are not hidden after checkbox is | |
| 197 // clicked. | |
| 198 assertGT(devControls.offsetHeight, 0); | |
| 199 | |
| 200 document.removeEventListener(f, 'webkitTransitionEnd'); | |
| 201 callback(); | |
| 202 } | |
| 203 }); | |
| 204 ensureTransitionEndEvent(devControls, 4000); | |
| 205 }, | |
| 206 }; | 271 }; |
| 207 | 272 |
| 208 TEST_F('AsyncExtensionSettingsWebUITest', 'testDeveloperModeA11y', function() { | |
| 209 this.enableDeveloperMode(testDone); | |
| 210 }); | |
| 211 | |
| 212 // Often times out on all platforms: http://crbug.com/467528 | 273 // Often times out on all platforms: http://crbug.com/467528 |
| 213 TEST_F('AsyncExtensionSettingsWebUITest', | 274 TEST_F('AsyncExtensionSettingsWebUITest', |
| 214 'DISABLED_testErrorListButtonVisibility', | 275 'DISABLED_testErrorListButtonVisibility', |
| 215 function() { | 276 function() { |
| 216 this.enableDeveloperMode(function() { | 277 var testButtonVisibility = function() { |
| 217 // 2 extensions are loaded: | 278 // 2 extensions are loaded: |
| 218 // The 'good' extension will have 0 errors wich means no error list | 279 // The 'good' extension will have 0 errors wich means no error list |
| 219 // buttons. | 280 // buttons. |
| 220 // The 'bad' extension will have >3 manifest errors and <3 runtime errors. | 281 // The 'bad' extension will have >3 manifest errors and <3 runtime errors. |
| 221 // This means 2 buttons: 1 visible and 1 hidden. | 282 // This means 2 buttons: 1 visible and 1 hidden. |
| 222 var visibleButtons = document.querySelectorAll( | 283 var visibleButtons = document.querySelectorAll( |
| 223 '.extension-error-list-show-more > a:not([hidden])'); | 284 '.extension-error-list-show-more > a:not([hidden])'); |
| 224 assertEquals(1, visibleButtons.length); | 285 assertEquals(1, visibleButtons.length); |
| 225 // Visible buttons must be part of the focusRow. | 286 // Visible buttons must be part of the focusRow. |
| 226 assertTrue(visibleButtons[0].hasAttribute('column-type')); | 287 assertTrue(visibleButtons[0].hasAttribute('column-type')); |
| 227 | 288 |
| 228 var hiddenButtons = document.querySelectorAll( | 289 var hiddenButtons = document.querySelectorAll( |
| 229 '.extension-error-list-show-more > a[hidden]'); | 290 '.extension-error-list-show-more > a[hidden]'); |
| 230 assertEquals(1, hiddenButtons.length); | 291 assertEquals(1, hiddenButtons.length); |
| 231 // Hidden buttons must NOT be part of the focusRow. | 292 // Hidden buttons must NOT be part of the focusRow. |
| 232 assertFalse(hiddenButtons[0].hasAttribute('column-type')); | 293 assertFalse(hiddenButtons[0].hasAttribute('column-type')); |
| 233 | 294 |
| 234 testDone(); | 295 this.nextStep(); |
| 235 }); | 296 }; |
| 297 | |
| 298 this.steps = [this.waitForPageLoad, | |
| 299 this.verifyDeveloperModeWorks, | |
| 300 testButtonVisibility, | |
| 301 testDone]; | |
| 302 this.nextStep(); | |
| 236 }); | 303 }); |
| 237 | 304 |
| 238 /** | 305 /** |
| 239 * TestFixture for extension settings WebUI testing (commands config edition). | 306 * TestFixture for extension settings WebUI testing (commands config edition). |
| 240 * @extends {testing.Test} | 307 * @extends {testing.Test} |
| 241 * @constructor | 308 * @constructor |
| 242 */ | 309 */ |
| 243 function ExtensionSettingsCommandsConfigWebUITest() {} | 310 function SettingsCommandsExtensionSettingsWebUITest() {} |
| 244 | 311 |
| 245 ExtensionSettingsCommandsConfigWebUITest.prototype = { | 312 SettingsCommandsExtensionSettingsWebUITest.prototype = { |
| 246 __proto__: testing.Test.prototype, | 313 __proto__: ExtensionSettingsWebUITest.prototype, |
| 247 | |
| 248 /** @override */ | |
| 249 runAccessibilityChecks: true, | |
| 250 | |
| 251 /** @override */ | |
| 252 accessibilityIssuesAreErrors: true, | |
| 253 | 314 |
| 254 /** | 315 /** |
| 255 * A URL to load before starting each test. | 316 * A URL to load before starting each test. |
| 256 * @type {string} | 317 * @type {string} |
| 257 * @const | 318 * @const |
| 258 */ | 319 */ |
| 259 browsePreload: 'chrome://extensions-frame/configureCommands', | 320 browsePreload: 'chrome://extensions-frame/configureCommands', |
| 260 }; | 321 }; |
| 261 | 322 |
| 262 TEST_F('ExtensionSettingsCommandsConfigWebUITest', 'testChromeSendHandler', | 323 TEST_F('SettingsCommandsExtensionSettingsWebUITest', 'testChromeSendHandler', |
| 263 function() { | 324 function() { |
| 264 // Just navigating to the page should trigger the chrome.send(). | 325 // Just navigating to the page should trigger the chrome.send(). |
| 265 assertEquals(this.browsePreload, document.location.href); | 326 var assertOverlayVisible = function() { |
| 266 assertTrue($('extension-commands-overlay').classList.contains('showing')); | 327 assertTrue($('extension-commands-overlay').classList.contains('showing')); |
| 328 this.nextStep(); | |
| 329 }; | |
| 330 | |
| 331 this.steps = [this.waitForPageLoad, | |
| 332 assertOverlayVisible, | |
| 333 testDone]; | |
| 334 this.nextStep(); | |
| 267 }); | 335 }); |
| 268 | 336 |
| 269 /** | 337 /** |
| 270 * @constructor | 338 * @constructor |
| 271 * @extends {ExtensionSettingsWebUITest} | 339 * @extends {ExtensionSettingsWebUITest} |
| 272 */ | 340 */ |
| 273 function InstalledExtensionSettingsWebUITest() {} | 341 function InstallGoodExtensionSettingsWebUITest() {} |
| 274 | 342 |
| 275 InstalledExtensionSettingsWebUITest.prototype = { | 343 InstallGoodExtensionSettingsWebUITest.prototype = { |
| 276 __proto__: ExtensionSettingsWebUITest.prototype, | 344 __proto__: ExtensionSettingsWebUITest.prototype, |
| 277 | 345 |
| 278 /** @override */ | 346 /** @override */ |
| 279 typedefCppFixture: 'ExtensionSettingsUIBrowserTest', | |
| 280 | |
| 281 /** @override */ | |
| 282 testGenPreamble: function() { | 347 testGenPreamble: function() { |
| 283 GEN(' InstallGoodExtension();'); | 348 GEN(' InstallGoodExtension();'); |
| 284 }, | 349 }, |
| 350 | |
| 351 emptyTestForAccessibility() { | |
| 352 this.steps = [this.waitForPageLoad, | |
| 353 testDone]; | |
|
Dan Beam
2015/04/22 18:44:54
some of these fit in one line, e.g.
this.steps
hcarmona
2015/04/22 20:44:45
Done.
| |
| 354 this.nextStep(); | |
| 355 }, | |
| 285 }; | 356 }; |
| 286 | 357 |
| 287 /** @this {InstalledExtensionSettingsWebUITest} */ | 358 TEST_F('InstallGoodExtensionSettingsWebUITest', 'testAccessibility', |
| 288 function runAudit() { | 359 function() { |
| 289 assertEquals(this.browsePreload, document.location.href); | 360 this.emptyTestForAccessibility(); |
| 290 this.runAccessibilityAudit(); | 361 }); |
| 291 } | |
| 292 | 362 |
| 293 TEST_F('InstalledExtensionSettingsWebUITest', 'baseAccessibilityOk', runAudit); | 363 TEST_F('InstallGoodExtensionSettingsWebUITest', 'showOptions', function() { |
| 364 var showExtensionOptions = function() { | |
| 365 var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance(); | |
| 366 optionsOverlay.setExtensionAndShowOverlay(GOOD_CRX_ID, 'GOOD!', '', | |
| 367 this.nextStep.bind(this)); | |
| 294 | 368 |
| 295 /** | 369 // Preferred size changes don't happen in browser tests. Just fake it. |
| 296 * @constructor | 370 var size = {width: 500, height: 500}; |
| 297 * @extends {InstalledExtensionSettingsWebUITest} | 371 document.querySelector('extensionoptions').onpreferredsizechanged(size); |
|
Dan Beam
2015/04/22 21:09:45
nit: this is the same number of lines but more is
| |
| 298 */ | 372 }; |
| 299 function AsyncInstalledExtensionSettingsWebUITest() {} | |
| 300 | 373 |
| 301 AsyncInstalledExtensionSettingsWebUITest.prototype = { | 374 this.steps = [this.waitForPageLoad, |
| 302 __proto__: InstalledExtensionSettingsWebUITest.prototype, | 375 showExtensionOptions, |
| 303 | 376 testDone]; |
| 304 /** @override */ | 377 this.nextStep(); |
| 305 isAsync: true, | |
| 306 }; | |
| 307 | |
| 308 TEST_F('AsyncInstalledExtensionSettingsWebUITest', 'showOptions', function() { | |
| 309 var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance(); | |
| 310 optionsOverlay.setExtensionAndShowOverlay(GOOD_CRX_ID, 'GOOD!', '', testDone); | |
| 311 | |
| 312 // Preferred size changes don't happen in browser tests. Just fake it. | |
| 313 var size = {width: 500, height: 500}; | |
| 314 document.querySelector('extensionoptions').onpreferredsizechanged(size); | |
| 315 }); | 378 }); |
| 316 | 379 |
| 317 /** | 380 /** |
| 318 * @constructor | 381 * @constructor |
| 319 * @extends {InstalledExtensionSettingsWebUITest} | 382 * @extends {InstallGoodExtensionSettingsWebUITest} |
| 320 */ | 383 */ |
| 321 function ManagedExtensionSettingsWebUITest() {} | 384 function ManagedExtensionSettingsWebUITest() {} |
| 322 | 385 |
| 323 ManagedExtensionSettingsWebUITest.prototype = { | 386 ManagedExtensionSettingsWebUITest.prototype = { |
| 324 __proto__: InstalledExtensionSettingsWebUITest.prototype, | 387 __proto__: InstallGoodExtensionSettingsWebUITest.prototype, |
| 325 | 388 |
| 326 /** @override */ | 389 /** @override */ |
| 327 testGenPreamble: function() { | 390 testGenPreamble: function() { |
| 328 GEN(' AddManagedPolicyProvider();'); | 391 GEN(' AddManagedPolicyProvider();'); |
| 329 InstalledExtensionSettingsWebUITest.prototype.testGenPreamble.call(this); | 392 InstallGoodExtensionSettingsWebUITest.prototype.testGenPreamble.call(this); |
| 330 }, | 393 }, |
| 331 }; | 394 }; |
| 332 | 395 |
| 333 TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', runAudit); | 396 TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', function() { |
| 397 this.emptyTestForAccessibility(); | |
| 398 }); | |
| 334 | 399 |
| 335 /** | 400 /** |
| 336 * @constructor | 401 * @constructor |
| 337 * @extends {InstalledExtensionSettingsWebUITest} | 402 * @extends {InstallGoodExtensionSettingsWebUITest} |
| 338 */ | 403 */ |
| 339 function ExtensionOptionsDialogWebUITest() {} | 404 function OptionsDialogExtensionSettingsWebUITest() {} |
| 340 | 405 |
| 341 ExtensionOptionsDialogWebUITest.prototype = { | 406 OptionsDialogExtensionSettingsWebUITest.prototype = { |
| 342 __proto__: InstalledExtensionSettingsWebUITest.prototype, | 407 __proto__: InstallGoodExtensionSettingsWebUITest.prototype, |
| 343 | 408 |
| 344 /** @override */ | 409 /** @override */ |
| 345 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + | 410 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + |
| 346 '?options=' + GOOD_CRX_ID, | 411 '?options=' + GOOD_CRX_ID, |
| 347 }; | 412 }; |
| 348 | 413 |
| 349 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit); | 414 TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility', |
| 415 function() { | |
| 416 this.emptyTestForAccessibility(); | |
| 417 }); | |
| OLD | NEW |