Merge "Load default site theme synchronously"

This commit is contained in:
Viktar Donich
2018-01-19 22:54:40 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 5 deletions

View File

@@ -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);
}
},

View File

@@ -164,7 +164,7 @@ limitations under the License.
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],