Merge "Load default site theme synchronously"
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 d3ad997..497ea9c 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
@@ -34,11 +34,13 @@
const jsPlugins = this._handleMigrations(plugins.js_resource_paths || [],
htmlPlugins);
const defaultTheme = config.default_theme;
+ Gerrit._setPluginsCount(
+ jsPlugins.length + htmlPlugins.length + (defaultTheme ? 1 : 0));
if (defaultTheme) {
// Make theme first to be first to load.
- htmlPlugins.unshift(defaultTheme);
+ // Load sync to work around rare theme loading race condition.
+ this._importHtmlPlugins([defaultTheme], true);
}
- Gerrit._setPluginsCount(jsPlugins.length + htmlPlugins.length);
this._loadJsPlugins(jsPlugins);
this._importHtmlPlugins(htmlPlugins);
},
@@ -58,13 +60,16 @@
* @suppress {checkTypes}
* States that it expects no more than 3 parameters, but that's not true.
* @todo (beckysiegel) check Polymer annotations and submit change.
+ * @param {Array} plugins
+ * @param {boolean=} opt_sync
*/
- _importHtmlPlugins(plugins) {
+ _importHtmlPlugins(plugins, opt_sync) {
+ const async = !opt_sync;
for (const url of plugins) {
// onload (second param) needs to be a function. When null or undefined
// were passed, plugins were not loaded correctly.
this.importHref(
- this._urlFor(url), () => {}, Gerrit._pluginInstalled, true);
+ this._urlFor(url), () => {}, Gerrit._pluginInstalled, async);
}
},
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 dd664ff..d42cb88 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
@@ -164,7 +164,7 @@
assert.equal(element.importHref.firstCall.args[0], '/oof');
assert.equal(element.importHref.firstCall.args[2],
Gerrit._pluginInstalled);
- assert.isTrue(element.importHref.firstCall.args[3]);
+ assert.isFalse(element.importHref.firstCall.args[3]);
assert.equal(element.importHref.secondCall.args[0], '/some');
assert.equal(element.importHref.secondCall.args[2],