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';
15 * Test C++ fixture for settings WebUI testing.
17 * @extends {testing.Test}
19 function ExtensionSettingsUIBrowserTest() {}
22 * TestFixture for extension settings WebUI testing.
23 * @extends {testing.Test}
26 function ExtensionSettingsWebUITest() {}
28 ExtensionSettingsWebUITest
.prototype = {
29 __proto__
: testing
.Test
.prototype,
32 runAccessibilityChecks
: true,
35 accessibilityIssuesAreErrors
: true,
38 * A URL to load before starting each test.
42 browsePreload
: 'chrome://extensions-frame/',
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'));
59 function AsyncExtensionSettingsWebUITest() {}
61 AsyncExtensionSettingsWebUITest
.prototype = {
62 __proto__
: ExtensionSettingsWebUITest
.prototype,
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
84 assertGT(devControls
.offsetHeight
, 0);
86 document
.removeEventListener(f
, 'webkitTransitionEnd');
90 ensureTransitionEndEvent(devControls
, 4000);
94 TEST_F('AsyncExtensionSettingsWebUITest', 'testDeveloperModeA11y', function() {
95 this.enableDeveloperMode(testDone
);
98 // Often times out on all platforms: http://crbug.com/467528
99 TEST_F('AsyncExtensionSettingsWebUITest',
100 'DISABLED_testErrorListButtonVisibility',
102 this.enableDeveloperMode(function() {
103 // 2 extensions are loaded:
104 // The 'good' extension will have 0 errors wich means no error list
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'));
125 * TestFixture for extension settings WebUI testing (commands config edition).
126 * @extends {testing.Test}
129 function ExtensionSettingsCommandsConfigWebUITest() {}
131 ExtensionSettingsCommandsConfigWebUITest
.prototype = {
132 __proto__
: testing
.Test
.prototype,
135 runAccessibilityChecks
: true,
138 accessibilityIssuesAreErrors
: true,
141 * A URL to load before starting each test.
145 browsePreload
: 'chrome://extensions-frame/configureCommands',
148 TEST_F('ExtensionSettingsCommandsConfigWebUITest', 'testChromeSendHandler',
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'));
157 * @extends {ExtensionSettingsWebUITest}
159 function InstalledExtensionSettingsWebUITest() {}
161 InstalledExtensionSettingsWebUITest
.prototype = {
162 __proto__
: ExtensionSettingsWebUITest
.prototype,
165 typedefCppFixture
: 'ExtensionSettingsUIBrowserTest',
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
);
183 * @extends {InstalledExtensionSettingsWebUITest}
185 function AsyncInstalledExtensionSettingsWebUITest() {}
187 AsyncInstalledExtensionSettingsWebUITest
.prototype = {
188 __proto__
: InstalledExtensionSettingsWebUITest
.prototype,
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
);
205 * @extends {InstalledExtensionSettingsWebUITest}
207 function ManagedExtensionSettingsWebUITest() {}
209 ManagedExtensionSettingsWebUITest
.prototype = {
210 __proto__
: InstalledExtensionSettingsWebUITest
.prototype,
213 testGenPreamble: function() {
214 GEN(' AddManagedPolicyProvider();');
215 InstalledExtensionSettingsWebUITest
.prototype.testGenPreamble
.call(this);
219 TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', runAudit
);
223 * @extends {InstalledExtensionSettingsWebUITest}
225 function ExtensionOptionsDialogWebUITest() {}
227 ExtensionOptionsDialogWebUITest
.prototype = {
228 __proto__
: InstalledExtensionSettingsWebUITest
.prototype,
231 browsePreload
: ExtensionSettingsWebUITest
.prototype.browsePreload
+
232 '?options=' + GOOD_CRX_ID
,
235 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit
);