ProfilePolicyConnectorFactory: Refactoring from Profile to BrowserContext.
[chromium-blink-merge.git] / chrome / browser / ui / webui / extensions / extension_settings_browsertest.js
blob449fe4bfdceca12bf9ed74702f136e24bdcc3139
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,
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');
81 testDone();
83 });
84 ensureTransitionEndEvent(devControls, 4000);
85 });
87 /**
88 * TestFixture for extension settings WebUI testing (commands config edition).
89 * @extends {testing.Test}
90 * @constructor
92 function ExtensionSettingsCommandsConfigWebUITest() {}
94 ExtensionSettingsCommandsConfigWebUITest.prototype = {
95 __proto__: testing.Test.prototype,
97 /** @override */
98 runAccessibilityChecks: true,
100 /** @override */
101 accessibilityIssuesAreErrors: true,
104 * A URL to load before starting each test.
105 * @type {string}
106 * @const
108 browsePreload: 'chrome://extensions-frame/configureCommands',
111 TEST_F('ExtensionSettingsCommandsConfigWebUITest', 'testChromeSendHandler',
112 function() {
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'));
119 * @constructor
120 * @extends {ExtensionSettingsWebUITest}
122 function InstalledExtensionSettingsWebUITest() {}
124 InstalledExtensionSettingsWebUITest.prototype = {
125 __proto__: ExtensionSettingsWebUITest.prototype,
127 /** @override */
128 typedefCppFixture: 'ExtensionSettingsUIBrowserTest',
130 /** @override */
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);
145 * @constructor
146 * @extends {InstalledExtensionSettingsWebUITest}
148 function AsyncInstalledExtensionSettingsWebUITest() {}
150 AsyncInstalledExtensionSettingsWebUITest.prototype = {
151 __proto__: InstalledExtensionSettingsWebUITest.prototype,
153 /** @override */
154 isAsync: true,
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);
167 * @constructor
168 * @extends {InstalledExtensionSettingsWebUITest}
170 function ManagedExtensionSettingsWebUITest() {}
172 ManagedExtensionSettingsWebUITest.prototype = {
173 __proto__: InstalledExtensionSettingsWebUITest.prototype,
175 /** @override */
176 testGenPreamble: function() {
177 GEN(' AddManagedPolicyProvider();');
178 InstalledExtensionSettingsWebUITest.prototype.testGenPreamble.call(this);
182 TEST_F('ManagedExtensionSettingsWebUITest', 'testAccessibility', runAudit);
185 * @constructor
186 * @extends {InstalledExtensionSettingsWebUITest}
188 function ExtensionOptionsDialogWebUITest() {}
190 ExtensionOptionsDialogWebUITest.prototype = {
191 __proto__: InstalledExtensionSettingsWebUITest.prototype,
193 /** @override */
194 browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload +
195 '?options=' + GOOD_CRX_ID,
198 TEST_F('ExtensionOptionsDialogWebUITest', 'testAccessibility', runAudit);