Don't show url parsing errors when checking for preloaded plugins

Bug: Issue 9486
Change-Id: I24a99801fc291e96cee9b2bafffa98e8a045caba
This commit is contained in:
Viktar Donich 2018-07-26 10:33:11 -07:00
parent 79972960f1
commit 8948ca6ceb
3 changed files with 15 additions and 6 deletions

View File

@ -39,8 +39,8 @@
const defaultTheme = config.default_theme;
const pluginsPending = []
.concat(jsPlugins, htmlPlugins, defaultTheme || [])
.filter(p => !Gerrit._isPluginPreloaded(p))
.map(p => this._urlFor(p));
.map(p => this._urlFor(p))
.filter(p => !Gerrit._isPluginPreloaded(p));
Gerrit._setPluginsPending(pluginsPending);
if (defaultTheme) {
// Make theme first to be first to load.
@ -96,8 +96,9 @@
},
_urlFor(pathOrUrl) {
if (pathOrUrl.startsWith('http')) {
// Plugins are loaded from another domain.
if (pathOrUrl.startsWith('preloaded:') ||
pathOrUrl.startsWith('http')) {
// Plugins are loaded from another domain or preloaded.
return pathOrUrl;
}
if (!pathOrUrl.startsWith('/')) {

View File

@ -190,8 +190,8 @@ limitations under the License.
test('skips preloaded plugins', () => {
sandbox.stub(Gerrit, '_isPluginPreloaded')
.withArgs('plugins/foo/bar').returns(true)
.withArgs('plugins/42').returns(true);
.withArgs(url + '/plugins/foo/bar').returns(true)
.withArgs(url + '/plugins/42').returns(true);
sandbox.stub(Gerrit, '_setPluginsCount');
sandbox.stub(Gerrit, '_setPluginsPending');
element.config = {

View File

@ -412,6 +412,14 @@ limitations under the License.
element.EventType.ADMIN_MENU_LINKS);
});
test('Gerrit._isPluginPreloaded', () => {
Gerrit._preloadedPlugins = {baz: ()=>{}};
assert.isFalse(Gerrit._isPluginPreloaded('plugins/foo/bar'));
assert.isFalse(Gerrit._isPluginPreloaded('http://a.com/42'));
assert.isTrue(Gerrit._isPluginPreloaded('preloaded:baz'));
Gerrit._preloadedPlugins = null;
});
test('preloaded plugins are installed', () => {
const installStub = sandbox.stub();
Gerrit._preloadedPlugins = {foo: installStub};