Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / webui / extensions / extension_settings_browsertest.js
blob9f1b86756ae5586369cfbfdc861291ad541839e9
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
3 // found in the LICENSE file.
5 // TODO(dbeam): test for loading upacked extensions?
7 GEN('#include "chrome/browser/ui/webui/extensions/' +
8 'extension_settings_browsertest.h"');
10 // chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by
11 // ExtensionSettingsUIBrowserTest::InstallGoodExtension() in some of the tests.
12 var GOOD_CRX_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf';
14 /**
15 * Test C++ fixture for settings WebUI testing.
16 * @constructor
17 * @extends {testing.Test}
19 function ExtensionSettingsUIBrowserTest() {}
21 /**
22 * TestFixture for extension settings WebUI testing.
23 * @extends {testing.Test}
24 * @constructor
26 function ExtensionSettingsWebUITest() {}
28 ExtensionSettingsWebUITest.prototype = {
29 __proto__: testing.Test.prototype,
31 /** @override */
32 runAccessibilityChecks: true,
34 /** @override */
35 accessibilityIssuesAreErrors: true,
37 /**
38 * A URL to load before starting each test.
39 * @type {string}
40 * @const
42 browsePreload: 'chrome://extensions-frame/',
44 /** @override */
45 typedefCppFixture: 'ExtensionSettingsUIBrowserTest',
48 TEST_F('ExtensionSettingsWebUITest', 'testChromeSendHandled', function() {
49 assertEquals(this.browsePreload, document.location.href);
51 // This dialog should be hidden at first.
52 assertFalse($('pack-extension-overlay').classList.contains('showing'));
54 // Show the dialog, which triggers a chrome.send() for metrics purposes.
55 cr.dispatchSimpleEvent($('pack-extension'), 'click');
56 assertTrue($('pack-extension-overlay').classList.contains('showing'));
57 });
59 function AsyncExtensionSettingsWebUITest() {}
61 AsyncExtensionSettingsWebUITest.prototype = {
62 __proto__: ExtensionSettingsWebUITest.prototype,
64 /** @override */
65 isAsync: true,
67 /** @override */
68 testGenPreamble: function() {
69 GEN(' InstallGoodExtension();');
70 GEN(' InstallErrorsExtension();');
73 enableDeveloperMode: function(callback) {
74 var devControls = $('dev-controls');
76 // Make sure developer controls are hidden before checkbox is clicked.
77 assertEquals(0, devControls.offsetHeight);
78 $('toggle-dev-on').click();
80 document.addEventListener('webkitTransitionEnd', function f(e) {
81 if (e.target == devControls) {
82 // Make sure developer controls are not hidden after checkbox is
83 // clicked.
84 assertGT(devControls.offsetHeight, 0);
86 document.removeEventListener(f, 'webkitTransitionEnd');
87 callback();
89 });
90 ensureTransitionEndEvent(devControls, 4000);
94 TEST_F('AsyncExtensionSettingsWebUITest', 'testDeveloperModeA11y', function() {
95 this.enableDeveloperMode(testDone);
96 });
98 // Often times out on all platforms: http://crbug.com/467528
99 TEST_F('AsyncExtensionSettingsWebUITest',
100 'DISABLED_testErrorListButtonVisibility',
101 function() {
102 this.enableDeveloperMode(function() {
103 // 2 extensions are loaded:
104 // The 'good' extension will have 0 errors wich means no error list
105 // buttons.
106 // The 'bad' extension will have >3 manifest errors and <3 runtime errors.
107 // This means 2 buttons: 1 visible and 1 hidden.
108 var visibleButtons = document.querySelectorAll(
109 '.extension-error-list-show-more > a:not([hidden])');
110 assertEquals(1, visibleButtons.length);
111 // Visible buttons must be part of the focusRow.
112 assertTrue(visibleButtons[0].hasAttribute('column-type'));
114 var hiddenButtons = document.querySelectorAll(
115 '.extension-error-list-show-more > a[hidden]');
116 assertEquals(1, hiddenButtons.length);
117 // Hidden buttons must NOT be part of the focusRow.
118 assertFalse(hiddenButtons[0].hasAttribute('column-type'));
120 testDone();
125 * TestFixture for extension settings WebUI testing (commands config edition).
126 * @extends {testing.Test}
127 * @constructor
129 function ExtensionSettingsCommandsConfigWebUITest() {}
131 ExtensionSettingsCommandsConfigWebUITest.prototype = {
132 __proto__: testing.Test.prototype,
134 /** @override */
135 runAccessibilityChecks: true,
137 /** @override */
138 accessibilityIssuesAreErrors: true,
141 * A URL to load before starting each test.
142 * @type {string}
143 * @const
145 browsePreload: 'chrome://extensions-frame/configureCommands',
148 TEST_F('ExtensionSettingsCommandsConfigWebUITest', 'testChromeSendHandler',
149 function() {
150 // Just navigating to the page should trigger the chrome.send().
151 assertEquals(this.browsePreload, document.location.href);
152 assertTrue($('extension-commands-overlay').classList.contains('showing'));
156 * @constructor
157 * @extends {ExtensionSettingsWebUITest}
159 function InstalledExtensionSettingsWebUITest() {}
161 InstalledExtensionSettingsWebUITest.prototype = {
162 __proto__: ExtensionSettingsWebUITest.prototype,
164 /** @override */
165 typedefCppFixture: 'ExtensionSettingsUIBrowserTest',
167 /** @override */
168 testGenPreamble: function() {
169 GEN(' InstallGoodExtension();');
173 /** @this {InstalledExtensionSettingsWebUITest} */
174 function runAudit() {
175 assertEquals(this.browsePreload, document.location.href);
176 this.runAccessibilityAudit();
179 TEST_F('InstalledExtensionSettingsWebUITest', 'baseAccessibilityOk', runAudit);
182 * @constructor
183 * @extends {InstalledExtensionSettingsWebUITest}
185 function AsyncInstalledExtensionSettingsWebUITest() {}
187 AsyncInstalledExtensionSettingsWebUITest.prototype = {
188 __proto__: InstalledExtensionSettingsWebUITest.prototype,
190 /** @override */
191 isAsync: true,
194 TEST_F('AsyncInstalledExtensionSettingsWebUITest', 'showOptions', function() {
195 var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance();
196 optionsOverlay.setExtensionAndShowOverlay(GOOD_CRX_ID, 'GOOD!', '', testDone);
198 // Preferred size changes don't happen in browser tests. Just fake it.
199 var size = {width: 500, height: 500};
200 document.querySelector('extensionoptions').onpreferredsizechanged(size);
204 * @constructor
205 * @extends {InstalledExtensionSettingsWebUITest}
207 function ManagedExtensionSettingsWebUITest() {}
209 ManagedExtensionSettingsWebUITest.prototype = {
210 __proto__: InstalledExtensionSettingsWebUITest.prototype,
212 /** @override */
213 testGenPreamble: function() {
214 GEN(' AddManagedPolicyProvider();');
215 InstalledExtensionSettingsWebUITest.prototype.testGenPreamble.call(this);
219 TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', runAudit);
222 * @constructor
223 * @extends {InstalledExtensionSettingsWebUITest}
225 function ExtensionOptionsDialogWebUITest() {}
227 ExtensionOptionsDialogWebUITest.prototype = {
228 __proto__: InstalledExtensionSettingsWebUITest.prototype,
230 /** @override */
231 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload +
232 '?options=' + GOOD_CRX_ID,
235 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit);