Add optional version parameter to JS API

If a user provides a version that is different than the current
one, a warning will be printed to the console and the plugin
callback won’t be called.

A string version is used for now since comparing versions (to check
for backward compatibility) is not a goal at this time. Plus a
version may have a tag associated like 0.1-beta or be a date.

Also adds a check for when the optional URL parameter was not
passed to the Plugin object and handles it accordingly.

Feature: Bug 3915
Change-Id: I1bbdda5a822e362db459e451595f67709a78aa07
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
index 3be232e..76fa91b 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.html
@@ -40,7 +40,7 @@
     setup(function() {
       element = fixture('basic');
       errorStub = sinon.stub(console, 'error');
-      Gerrit.install(function(p) { plugin = p; },
+      Gerrit.install(function(p) { plugin = p; }, '0.1',
           'http://test.com/plugins/testplugin/static/test.js');
     });
 
@@ -108,5 +108,11 @@
       assert.isTrue(errorStub.calledTwice);
     });
 
+    test('versioning', function() {
+      var callback = sinon.spy();
+      Gerrit.install(callback, '0.0pre-alpha');
+      assert(callback.notCalled);
+    });
+
   });
 </script>