Don't show url parsing errors when checking for preloaded plugins
Bug: Issue 9486 Change-Id: I24a99801fc291e96cee9b2bafffa98e8a045caba
This commit is contained in:
		@@ -39,8 +39,8 @@
 | 
				
			|||||||
      const defaultTheme = config.default_theme;
 | 
					      const defaultTheme = config.default_theme;
 | 
				
			||||||
      const pluginsPending = []
 | 
					      const pluginsPending = []
 | 
				
			||||||
          .concat(jsPlugins, htmlPlugins, defaultTheme || [])
 | 
					          .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);
 | 
					      Gerrit._setPluginsPending(pluginsPending);
 | 
				
			||||||
      if (defaultTheme) {
 | 
					      if (defaultTheme) {
 | 
				
			||||||
        // Make theme first to be first to load.
 | 
					        // Make theme first to be first to load.
 | 
				
			||||||
@@ -96,8 +96,9 @@
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _urlFor(pathOrUrl) {
 | 
					    _urlFor(pathOrUrl) {
 | 
				
			||||||
      if (pathOrUrl.startsWith('http')) {
 | 
					      if (pathOrUrl.startsWith('preloaded:') ||
 | 
				
			||||||
        // Plugins are loaded from another domain.
 | 
					          pathOrUrl.startsWith('http')) {
 | 
				
			||||||
 | 
					        // Plugins are loaded from another domain or preloaded.
 | 
				
			||||||
        return pathOrUrl;
 | 
					        return pathOrUrl;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (!pathOrUrl.startsWith('/')) {
 | 
					      if (!pathOrUrl.startsWith('/')) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -190,8 +190,8 @@ limitations under the License.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    test('skips preloaded plugins', () => {
 | 
					    test('skips preloaded plugins', () => {
 | 
				
			||||||
      sandbox.stub(Gerrit, '_isPluginPreloaded')
 | 
					      sandbox.stub(Gerrit, '_isPluginPreloaded')
 | 
				
			||||||
          .withArgs('plugins/foo/bar').returns(true)
 | 
					          .withArgs(url + '/plugins/foo/bar').returns(true)
 | 
				
			||||||
          .withArgs('plugins/42').returns(true);
 | 
					          .withArgs(url + '/plugins/42').returns(true);
 | 
				
			||||||
      sandbox.stub(Gerrit, '_setPluginsCount');
 | 
					      sandbox.stub(Gerrit, '_setPluginsCount');
 | 
				
			||||||
      sandbox.stub(Gerrit, '_setPluginsPending');
 | 
					      sandbox.stub(Gerrit, '_setPluginsPending');
 | 
				
			||||||
      element.config = {
 | 
					      element.config = {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -412,6 +412,14 @@ limitations under the License.
 | 
				
			|||||||
          element.EventType.ADMIN_MENU_LINKS);
 | 
					          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', () => {
 | 
					    test('preloaded plugins are installed', () => {
 | 
				
			||||||
      const installStub = sandbox.stub();
 | 
					      const installStub = sandbox.stub();
 | 
				
			||||||
      Gerrit._preloadedPlugins = {foo: installStub};
 | 
					      Gerrit._preloadedPlugins = {foo: installStub};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user