Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/test/data/webui/plugins_browsertest.js

Issue 2563743002: Fix PluginsTest.Plugins race condition and re-enable. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview Tests for chrome://plugins 6 * @fileoverview Tests for chrome://plugins
7 */ 7 */
8 8
9 /** @const {string} Path to source root. */ 9 /** @const {string} Path to source root. */
10 var ROOT_PATH = '../../../../'; 10 var ROOT_PATH = '../../../../';
11 11
12 /** 12 /**
13 * Test fixture for testing async methods of cr.js. 13 * Test fixture for testing async methods of cr.js.
14 * @constructor 14 * @constructor
15 * @extends testing.Test 15 * @extends testing.Test
16 */ 16 */
17 function PluginsTest() { 17 function PluginsTest() {
18 this.browserProxy = null; 18 this.browserProxy = null;
19 this.setupFnResolver = new PromiseResolver();
19 } 20 }
20 21
21 PluginsTest.prototype = { 22 PluginsTest.prototype = {
22 __proto__: testing.Test.prototype, 23 __proto__: testing.Test.prototype,
23 24
24 /** @override */ 25 /** @override */
25 browsePreload: 'chrome://plugins', 26 browsePreload: 'chrome://plugins',
26 27
27 /** @override */ 28 /** @override */
28 isAsync: true, 29 isAsync: true,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 saveShowDetailsToPrefs: function(expanded) { 82 saveShowDetailsToPrefs: function(expanded) {
82 this.methodCalled('saveShowDetailsToPrefs', expanded); 83 this.methodCalled('saveShowDetailsToPrefs', expanded);
83 }, 84 },
84 85
85 setClientPage: function() { 86 setClientPage: function() {
86 // Nothing to do here. 87 // Nothing to do here.
87 }, 88 },
88 }; 89 };
89 90
91 this.browserProxy = new TestBrowserProxy();
92
90 // A function that is called from chrome://plugins to allow this test to 93 // A function that is called from chrome://plugins to allow this test to
91 // replace the real Mojo browser proxy with a fake one, before any other 94 // replace the real Mojo browser proxy with a fake one, before any other
92 // code runs. 95 // code runs.
93 window.setupFn = function() { 96 window.setupFn = function() {
94 return importModules([ 97 return importModules([
95 'mojo/public/js/bindings', 98 'mojo/public/js/bindings',
96 'mojo/public/js/connection', 99 'mojo/public/js/connection',
97 'chrome/browser/ui/webui/plugins/plugins.mojom', 100 'chrome/browser/ui/webui/plugins/plugins.mojom',
98 'content/public/renderer/frame_interfaces', 101 'content/public/renderer/frame_interfaces',
99 ]).then(function(modules) { 102 ]).then(function(modules) {
100 var bindings = modules[0]; 103 var bindings = modules[0];
101 var connection = modules[1]; 104 var connection = modules[1];
102 var pluginsMojom = modules[2]; 105 var pluginsMojom = modules[2];
103 var frameInterfaces = modules[3]; 106 var frameInterfaces = modules[3];
104 107
105 frameInterfaces.addInterfaceOverrideForTesting( 108 frameInterfaces.addInterfaceOverrideForTesting(
106 pluginsMojom.PluginsPageHandler.name, function(handle) { 109 pluginsMojom.PluginsPageHandler.name, function(handle) {
107 var stub = connection.bindHandleToStub( 110 var stub = connection.bindHandleToStub(
108 handle, pluginsMojom.PluginsPageHandler); 111 handle, pluginsMojom.PluginsPageHandler);
109 this.browserProxy = new TestBrowserProxy();
110 bindings.StubBindings(stub).delegate = this.browserProxy; 112 bindings.StubBindings(stub).delegate = this.browserProxy;
111 }.bind(this)); 113 }.bind(this));
114 return this.setupFnResolver.promise;
112 }.bind(this)); 115 }.bind(this));
113 }.bind(this); 116 }.bind(this);
114 }, 117 },
115 }; 118 };
116 119
117 TEST_F('PluginsTest', 'DISABLED_Plugins', function() { 120 TEST_F('PluginsTest', 'Plugins', function() {
118 var browserProxy = this.browserProxy; 121 var browserProxy = this.browserProxy;
122 var setupFnResolver = this.setupFnResolver;
119 123
120 var fakePluginData = { 124 var fakePluginData = {
121 name: 'Group Name', 125 name: 'Group Name',
122 description: 'description', 126 description: 'description',
123 version: 'version', 127 version: 'version',
124 update_url: 'http://update/', 128 update_url: 'http://update/',
125 critical: true, 129 critical: true,
126 enabled_mode: 'enabledByUser', 130 enabled_mode: 'enabledByUser',
127 id: 'plugin-name', 131 id: 'plugin-name',
128 always_allowed: false, 132 always_allowed: false,
(...skipping 18 matching lines...) Expand all
147 ], 151 ],
148 enabled_mode: 'enabledByUser', 152 enabled_mode: 'enabledByUser',
149 }, 153 },
150 ], 154 ],
151 }; 155 };
152 156
153 suite('PluginTest', function() { 157 suite('PluginTest', function() {
154 var EXPECTED_PLUGINS = 2; 158 var EXPECTED_PLUGINS = 2;
155 suiteSetup(function() { 159 suiteSetup(function() {
156 browserProxy.setPluginsData([fakePluginData, fakePluginData]); 160 browserProxy.setPluginsData([fakePluginData, fakePluginData]);
161 // Allow code being tested to proceed, now that fake data has been set up.
162 setupFnResolver.resolve();
163
157 return Promise.all([ 164 return Promise.all([
158 browserProxy.whenCalled('getPluginsData'), 165 browserProxy.whenCalled('getPluginsData'),
159 browserProxy.whenCalled('getShowDetails'), 166 browserProxy.whenCalled('getShowDetails'),
160 ]); 167 ]);
161 }); 168 });
162 169
163 teardown(function() { browserProxy.reset(); }); 170 teardown(function() { browserProxy.reset(); });
164 171
165 test('PluginsUpdated', function() { 172 test('PluginsUpdated', function() {
166 var plugins = document.querySelectorAll('.plugin'); 173 var plugins = document.querySelectorAll('.plugin');
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return browserProxy.whenCalled('saveShowDetailsToPrefs'); 206 return browserProxy.whenCalled('saveShowDetailsToPrefs');
200 }).then(function(expanded) { 207 }).then(function(expanded) {
201 assertFalse(Boolean(expanded)); 208 assertFalse(Boolean(expanded));
202 }); 209 });
203 }); 210 });
204 }); 211 });
205 212
206 // Run all registered tests. 213 // Run all registered tests.
207 mocha.run(); 214 mocha.run();
208 }); 215 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698