From d402cca857fecf2ae1c2452d9d22716e0cc65b56 Mon Sep 17 00:00:00 2001 From: Viktar Donich Date: Wed, 3 Oct 2018 15:48:41 -0700 Subject: [PATCH] Skip theme loading if it was preloaded with a bundle Change-Id: Ib73a9c68ffea49b4905f0512cc3a5931b6343088 --- .../elements/plugins/gr-plugin-host/gr-plugin-host.js | 5 ++++- .../plugins/gr-plugin-host/gr-plugin-host_test.html | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js index 7476637016..111cdc6f6f 100644 --- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js +++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.js @@ -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); diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html index 26958eeea7..9901d9fe51 100644 --- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html +++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host_test.html @@ -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)