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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 assertEquals(this.browsePreload, document.location.href); | 49 assertEquals(this.browsePreload, document.location.href); |
50 | 50 |
51 // This dialog should be hidden at first. | 51 // This dialog should be hidden at first. |
52 assertFalse($('pack-extension-overlay').classList.contains('showing')); | 52 assertFalse($('pack-extension-overlay').classList.contains('showing')); |
53 | 53 |
54 // Show the dialog, which triggers a chrome.send() for metrics purposes. | 54 // Show the dialog, which triggers a chrome.send() for metrics purposes. |
55 cr.dispatchSimpleEvent($('pack-extension'), 'click'); | 55 cr.dispatchSimpleEvent($('pack-extension'), 'click'); |
56 assertTrue($('pack-extension-overlay').classList.contains('showing')); | 56 assertTrue($('pack-extension-overlay').classList.contains('showing')); |
57 }); | 57 }); |
58 | 58 |
| 59 function BasicExtensionSettingsWebUITest() {} |
| 60 |
| 61 BasicExtensionSettingsWebUITest.prototype = { |
| 62 __proto__: ExtensionSettingsWebUITest.prototype, |
| 63 |
| 64 /** @override */ |
| 65 isAsync: true, |
| 66 |
| 67 /** @override */ |
| 68 testGenPreamble: function() { |
| 69 // Install multiple types of extensions to ensure we handle each type. |
| 70 // TODO(devlin): There are more types to add here. |
| 71 GEN(' InstallGoodExtension();'); |
| 72 GEN(' InstallErrorsExtension();'); |
| 73 GEN(' InstallSharedModule();'); |
| 74 GEN(' InstallPackagedApp();'); |
| 75 |
| 76 GEN(' SetAutoConfirmUninstall();'); |
| 77 }, |
| 78 |
| 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 /** |
| 95 * A silly hack because we re-fetch extension data after every event, which is |
| 96 * asynchronous. This will be unneeded once we transition to observing events |
| 97 * on the developerPrivate API. |
| 98 * @param {Function} after The function to run after the pending requests. |
| 99 * @protected |
| 100 */ |
| 101 runPendingRequests: function(after) { |
| 102 window.setTimeout(function() { |
| 103 chrome.developerPrivate.getExtensionsInfo(after); |
| 104 }, 0); |
| 105 }, |
| 106 |
| 107 /** @protected */ |
| 108 verifyDisabledWorks: function() { |
| 109 chrome.management.setEnabled(GOOD_CRX_ID, false, |
| 110 this.runPendingRequests.bind(this, function() { |
| 111 var node = getRequiredElement(GOOD_CRX_ID); |
| 112 assertTrue(node.classList.contains('inactive-extension')); |
| 113 this.nextStep(); |
| 114 }.bind(this))); |
| 115 }, |
| 116 |
| 117 /** @protected */ |
| 118 verifyEnabledWorks: function() { |
| 119 chrome.management.setEnabled(GOOD_CRX_ID, true, |
| 120 this.runPendingRequests.bind(this, function() { |
| 121 var node = getRequiredElement(GOOD_CRX_ID); |
| 122 assertFalse(node.classList.contains('inactive-extension')); |
| 123 this.nextStep(); |
| 124 }.bind(this))); |
| 125 }, |
| 126 |
| 127 /** @protected */ |
| 128 verifyUninstallWorks: function() { |
| 129 chrome.test.runWithUserGesture(function() { |
| 130 chrome.management.uninstall(GOOD_CRX_ID, |
| 131 this.runPendingRequests.bind(this, function() { |
| 132 assertEquals(null, $(GOOD_CRX_ID)); |
| 133 this.nextStep(); |
| 134 }.bind(this))); |
| 135 }.bind(this)); |
| 136 }, |
| 137 }; |
| 138 |
| 139 TEST_F('BasicExtensionSettingsWebUITest', 'testDisable', function() { |
| 140 this.steps = [this.waitForPageLoad, |
| 141 this.verifyDisabledWorks, |
| 142 testDone]; |
| 143 this.nextStep(); |
| 144 }); |
| 145 |
| 146 TEST_F('BasicExtensionSettingsWebUITest', 'testEnable', function() { |
| 147 this.steps = [this.waitForPageLoad, |
| 148 this.verifyDisabledWorks, |
| 149 this.verifyEnabledWorks, |
| 150 testDone]; |
| 151 this.nextStep(); |
| 152 }); |
| 153 |
| 154 TEST_F('BasicExtensionSettingsWebUITest', 'testUninstall', function() { |
| 155 this.steps = [this.waitForPageLoad, |
| 156 this.verifyUninstallWorks, |
| 157 testDone]; |
| 158 this.nextStep(); |
| 159 }); |
| 160 |
59 function AsyncExtensionSettingsWebUITest() {} | 161 function AsyncExtensionSettingsWebUITest() {} |
60 | 162 |
61 AsyncExtensionSettingsWebUITest.prototype = { | 163 AsyncExtensionSettingsWebUITest.prototype = { |
62 __proto__: ExtensionSettingsWebUITest.prototype, | 164 __proto__: ExtensionSettingsWebUITest.prototype, |
63 | 165 |
64 /** @override */ | 166 /** @override */ |
65 isAsync: true, | 167 isAsync: true, |
66 | 168 |
67 /** @override */ | 169 /** @override */ |
68 testGenPreamble: function() { | 170 testGenPreamble: function() { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 328 |
227 ExtensionOptionsDialogWebUITest.prototype = { | 329 ExtensionOptionsDialogWebUITest.prototype = { |
228 __proto__: InstalledExtensionSettingsWebUITest.prototype, | 330 __proto__: InstalledExtensionSettingsWebUITest.prototype, |
229 | 331 |
230 /** @override */ | 332 /** @override */ |
231 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + | 333 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + |
232 '?options=' + GOOD_CRX_ID, | 334 '?options=' + GOOD_CRX_ID, |
233 }; | 335 }; |
234 | 336 |
235 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit); | 337 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit); |
OLD | NEW |