Skip theme loading if it was preloaded with a bundle

Change-Id: Ib73a9c68ffea49b4905f0512cc3a5931b6343088
This commit is contained in:
Viktar Donich
2018-10-03 15:48:41 -07:00
parent c68d3721fd
commit d402cca857
2 changed files with 15 additions and 1 deletions

View File

@@ -40,7 +40,10 @@
this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins)
.map(p => this._urlFor(p))
.filter(p => !Gerrit._isPluginPreloaded(p));
const defaultTheme = this._urlFor(config.default_theme);
const shouldLoadTheme = config.default_theme &&
!Gerrit._isPluginPreloaded('preloaded:gerrit-theme');
const defaultTheme =
shouldLoadTheme ? this._urlFor(config.default_theme) : null;
const pluginsPending =
[].concat(jsPlugins, htmlPlugins, defaultTheme || []);
Gerrit._setPluginsPending(pluginsPending);

View File

@@ -197,6 +197,17 @@ limitations under the License.
assert.isTrue(Gerrit._setPluginsPending.calledWith([url + '/oof']));
});
test('skips default theme loading if preloaded', () => {
sandbox.stub(Gerrit, '_isPluginPreloaded')
.withArgs('preloaded:gerrit-theme').returns(true);
sandbox.stub(Gerrit, '_setPluginsPending');
element.config = {
default_theme: '/oof',
plugin: {},
};
assert.isFalse(element.importHref.calledWith(url + '/oof'));
});
test('skips preloaded plugins', () => {
sandbox.stub(Gerrit, '_isPluginPreloaded')
.withArgs(url + '/plugins/foo/bar').returns(true)