OLD | NEW |
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 = '../../../../'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 * @constructor | 48 * @constructor |
49 * @extends {TestBrowserProxyBase} | 49 * @extends {TestBrowserProxyBase} |
50 */ | 50 */ |
51 var TestBrowserProxy = function() { | 51 var TestBrowserProxy = function() { |
52 settings.TestBrowserProxy.call(this, [ | 52 settings.TestBrowserProxy.call(this, [ |
53 'getPluginsData', | 53 'getPluginsData', |
54 'getShowDetails', | 54 'getShowDetails', |
55 'saveShowDetailsToPrefs', | 55 'saveShowDetailsToPrefs', |
56 ]); | 56 ]); |
57 | 57 |
| 58 this.bindingSet = null; |
| 59 |
58 /** | 60 /** |
59 * The data to be returned by |getPluginsData_|. | 61 * The data to be returned by |getPluginsData_|. |
60 * @private | 62 * @private |
61 */ | 63 */ |
62 this.pluginsData_ = []; | 64 this.pluginsData_ = []; |
63 }; | 65 }; |
64 | 66 |
65 TestBrowserProxy.prototype = { | 67 TestBrowserProxy.prototype = { |
66 __proto__: settings.TestBrowserProxy.prototype, | 68 __proto__: settings.TestBrowserProxy.prototype, |
67 | 69 |
(...skipping 21 matching lines...) Expand all Loading... |
89 }; | 91 }; |
90 | 92 |
91 this.browserProxy = new TestBrowserProxy(); | 93 this.browserProxy = new TestBrowserProxy(); |
92 | 94 |
93 // A function that is called from chrome://plugins to allow this test to | 95 // A function that is called from chrome://plugins to allow this test to |
94 // replace the real Mojo browser proxy with a fake one, before any other | 96 // replace the real Mojo browser proxy with a fake one, before any other |
95 // code runs. | 97 // code runs. |
96 window.setupFn = function() { | 98 window.setupFn = function() { |
97 return importModules([ | 99 return importModules([ |
98 'mojo/public/js/bindings', | 100 'mojo/public/js/bindings', |
99 'mojo/public/js/connection', | |
100 'chrome/browser/ui/webui/plugins/plugins.mojom', | 101 'chrome/browser/ui/webui/plugins/plugins.mojom', |
101 'content/public/renderer/frame_interfaces', | 102 'content/public/renderer/frame_interfaces', |
102 ]).then(function(modules) { | 103 ]).then(function(modules) { |
103 var bindings = modules[0]; | 104 var bindings = modules[0]; |
104 var connection = modules[1]; | 105 var pluginsMojom = modules[1]; |
105 var pluginsMojom = modules[2]; | 106 var frameInterfaces = modules[2]; |
106 var frameInterfaces = modules[3]; | |
107 | 107 |
| 108 this.browserProxy.bindingSet = new bindings.BindingSet( |
| 109 pluginsMojom.PluginsPageHandler); |
108 frameInterfaces.addInterfaceOverrideForTesting( | 110 frameInterfaces.addInterfaceOverrideForTesting( |
109 pluginsMojom.PluginsPageHandler.name, function(handle) { | 111 pluginsMojom.PluginsPageHandler.name, function(handle) { |
110 var stub = connection.bindHandleToStub( | 112 this.browserProxy.bindingSet.addBinding(this.browserProxy, |
111 handle, pluginsMojom.PluginsPageHandler); | 113 handle); |
112 bindings.StubBindings(stub).delegate = this.browserProxy; | |
113 }.bind(this)); | 114 }.bind(this)); |
114 return this.setupFnResolver.promise; | 115 return this.setupFnResolver.promise; |
115 }.bind(this)); | 116 }.bind(this)); |
116 }.bind(this); | 117 }.bind(this); |
117 }, | 118 }, |
118 }; | 119 }; |
119 | 120 |
120 TEST_F('PluginsTest', 'Plugins', function() { | 121 TEST_F('PluginsTest', 'Plugins', function() { |
121 var browserProxy = this.browserProxy; | 122 var browserProxy = this.browserProxy; |
122 var setupFnResolver = this.setupFnResolver; | 123 var setupFnResolver = this.setupFnResolver; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return browserProxy.whenCalled('saveShowDetailsToPrefs'); | 207 return browserProxy.whenCalled('saveShowDetailsToPrefs'); |
207 }).then(function(expanded) { | 208 }).then(function(expanded) { |
208 assertFalse(Boolean(expanded)); | 209 assertFalse(Boolean(expanded)); |
209 }); | 210 }); |
210 }); | 211 }); |
211 }); | 212 }); |
212 | 213 |
213 // Run all registered tests. | 214 // Run all registered tests. |
214 mocha.run(); | 215 mocha.run(); |
215 }); | 216 }); |
OLD | NEW |