Provide full URL to site theme

Bug: Issue 9624
Change-Id: I7c20c6b195c13ba5b730022cc658209609ea7589
This commit is contained in:
Viktar Donich 2018-08-22 11:51:14 -07:00
parent 2dd5d1d3c0
commit 285913683a
2 changed files with 13 additions and 1 deletions

View File

@ -40,7 +40,7 @@
this._handleMigrations(plugins.js_resource_paths || [], htmlPlugins)
.map(p => this._urlFor(p))
.filter(p => !Gerrit._isPluginPreloaded(p));
const defaultTheme = config.default_theme;
const defaultTheme = this._urlFor(config.default_theme);
const pluginsPending =
[].concat(jsPlugins, htmlPlugins, defaultTheme || []);
Gerrit._setPluginsPending(pluginsPending);
@ -98,6 +98,9 @@
},
_urlFor(pathOrUrl) {
if (!pathOrUrl) {
return pathOrUrl;
}
if (pathOrUrl.startsWith('preloaded:') ||
pathOrUrl.startsWith('http')) {
// Plugins are loaded from another domain or preloaded.

View File

@ -188,6 +188,15 @@ limitations under the License.
assert.equal(Gerrit._pluginInstallError.callCount, 2);
});
test('default theme is loaded with html plugins', () => {
sandbox.stub(Gerrit, '_setPluginsPending');
element.config = {
default_theme: '/oof',
plugin: {},
};
assert.isTrue(Gerrit._setPluginsPending.calledWith([url + '/oof']));
});
test('skips preloaded plugins', () => {
sandbox.stub(Gerrit, '_isPluginPreloaded')
.withArgs(url + '/plugins/foo/bar').returns(true)