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 TEST_F('AsyncExtensionSettingsWebUITest', 'testDeveloperModeA11y', function() {
69 var devControls
= $('dev-controls');
71 // Make sure developer controls are hidden before checkbox is clicked.
72 assertEquals(0, devControls
.offsetHeight
);
73 $('toggle-dev-on').click();
75 document
.addEventListener('webkitTransitionEnd', function f(e
) {
76 if (e
.target
== devControls
) {
77 // Make sure developer controls are not hidden after checkbox is clicked.
78 assertGT(devControls
.offsetHeight
, 0);
80 document
.removeEventListener(f
, 'webkitTransitionEnd');
84 ensureTransitionEndEvent(devControls
, 4000);
88 * TestFixture for extension settings WebUI testing (commands config edition).
89 * @extends {testing.Test}
92 function ExtensionSettingsCommandsConfigWebUITest() {}
94 ExtensionSettingsCommandsConfigWebUITest
.prototype = {
95 __proto__
: testing
.Test
.prototype,
98 runAccessibilityChecks
: true,
101 accessibilityIssuesAreErrors
: true,
104 * A URL to load before starting each test.
108 browsePreload
: 'chrome://extensions-frame/configureCommands',
111 TEST_F('ExtensionSettingsCommandsConfigWebUITest', 'testChromeSendHandler',
113 // Just navigating to the page should trigger the chrome.send().
114 assertEquals(this.browsePreload
, document
.location
.href
);
115 assertTrue($('extension-commands-overlay').classList
.contains('showing'));
120 * @extends {ExtensionSettingsWebUITest}
122 function InstalledExtensionSettingsWebUITest() {}
124 InstalledExtensionSettingsWebUITest
.prototype = {
125 __proto__
: ExtensionSettingsWebUITest
.prototype,
128 typedefCppFixture
: 'ExtensionSettingsUIBrowserTest',
131 testGenPreamble: function() {
132 GEN(' InstallGoodExtension();');
136 /** @this {InstalledExtensionSettingsWebUITest} */
137 function runAudit() {
138 assertEquals(this.browsePreload
, document
.location
.href
);
139 this.runAccessibilityAudit();
142 TEST_F('InstalledExtensionSettingsWebUITest', 'baseAccessibilityOk', runAudit
);
146 * @extends {InstalledExtensionSettingsWebUITest}
148 function AsyncInstalledExtensionSettingsWebUITest() {}
150 AsyncInstalledExtensionSettingsWebUITest
.prototype = {
151 __proto__
: InstalledExtensionSettingsWebUITest
.prototype,
157 TEST_F('AsyncInstalledExtensionSettingsWebUITest', 'showOptions', function() {
158 var optionsOverlay
= extensions
.ExtensionOptionsOverlay
.getInstance();
159 optionsOverlay
.setExtensionAndShowOverlay(GOOD_CRX_ID
, 'GOOD!', '', testDone
);
161 // Preferred size changes don't happen in browser tests. Just fake it.
162 var size
= {width
: 500, height
: 500};
163 document
.querySelector('extensionoptions').onpreferredsizechanged(size
);
168 * @extends {InstalledExtensionSettingsWebUITest}
170 function ManagedExtensionSettingsWebUITest() {}
172 ManagedExtensionSettingsWebUITest
.prototype = {
173 __proto__
: InstalledExtensionSettingsWebUITest
.prototype,
176 testGenPreamble: function() {
177 GEN(' AddManagedPolicyProvider();');
178 InstalledExtensionSettingsWebUITest
.prototype.testGenPreamble
.call(this);
182 TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', runAudit
);
186 * @extends {InstalledExtensionSettingsWebUITest}
188 function ExtensionOptionsDialogWebUITest() {}
190 ExtensionOptionsDialogWebUITest
.prototype = {
191 __proto__
: InstalledExtensionSettingsWebUITest
.prototype,
194 browsePreload
: ExtensionSettingsWebUITest
.prototype.browsePreload
+
195 '?options=' + GOOD_CRX_ID
,
198 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit
);