You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by mh...@apache.org on 2010/12/09 02:21:41 UTC
svn commit: r1043811 - in /shindig/trunk/features/src:
main/javascript/features/container/ test/javascript/features/container/
Author: mhermanto
Date: Thu Dec 9 01:21:40 2010
New Revision: 1043811
URL: http://svn.apache.org/viewvc?rev=1043811&view=rev
Log:
CC: Enable gadget navigation in cajole mode. http://codereview.appspot.com/3513041
Modified:
shindig/trunk/features/src/main/javascript/features/container/constant.js
shindig/trunk/features/src/main/javascript/features/container/container.js
shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js
shindig/trunk/features/src/test/javascript/features/container/container_test.js
shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js
Modified: shindig/trunk/features/src/main/javascript/features/container/constant.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/constant.js?rev=1043811&r1=1043810&r2=1043811&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/constant.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/constant.js Thu Dec 9 01:21:40 2010
@@ -94,6 +94,7 @@ shindig.container.NavigateTiming.PRT = '
*/
shindig.container.RenderParam = {};
shindig.container.RenderParam.ALLOW_DEFAULT_VIEW = 'allowDefaultView';
+shindig.container.RenderParam.CAJOLE = 'cajole';
shindig.container.RenderParam.CLASS = 'class';
shindig.container.RenderParam.DEBUG = 'debug';
shindig.container.RenderParam.HEIGHT = 'height';
Modified: shindig/trunk/features/src/main/javascript/features/container/container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/container.js?rev=1043811&r1=1043810&r2=1043811&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js Thu Dec 9 01:21:40 2010
@@ -45,12 +45,21 @@ shindig.container.Container = function(o
/**
* @type {boolean}
+ * @private
*/
this.allowDefaultView_ = Boolean(
shindig.container.util.getSafeJsonValue(config,
shindig.container.ContainerConfig.ALLOW_DEFAULT_VIEW, true));
/**
+ * @type {boolean}
+ * @private
+ */
+ this.renderCajole_ = Boolean(
+ shindig.container.util.getSafeJsonValue(config,
+ shindig.container.ContainerConfig.RENDER_CAJOLE, false));
+
+ /**
* @type {string}
* @private
*/
@@ -60,6 +69,7 @@ shindig.container.Container = function(o
/**
* @type {boolean}
+ * @private
*/
var param = window.__CONTAINER_URI.getQP(this.renderDebugParam_);
this.renderDebug_ = (typeof param === 'undefined')
@@ -145,6 +155,9 @@ shindig.container.Container.prototype.na
if (this.allowDefaultView_) {
renderParams[shindig.container.RenderParam.ALLOW_DEFAULT_VIEW] = true;
}
+ if (this.renderCajole_) {
+ renderParams[shindig.container.RenderParam.CAJOLE] = true;
+ }
if (this.renderDebug_) {
renderParams[shindig.container.RenderParam.NO_CACHE] = true;
renderParams[shindig.container.RenderParam.DEBUG] = true;
@@ -301,6 +314,12 @@ shindig.container.Container.prototype.on
*/
shindig.container.ContainerConfig = {};
/**
+ * Whether cajole mode is turned on.
+ * @type {string}
+ * @const
+ */
+shindig.container.ContainerConfig.RENDER_CAJOLE = 'renderCajole';
+/**
* Whether debug mode is turned on.
* @type {string}
* @const
Modified: shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js?rev=1043811&r1=1043810&r2=1043811&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js Thu Dec 9 01:21:40 2010
@@ -309,6 +309,12 @@ shindig.container.GadgetHolder.prototype
uri.setQP('nocache', this.renderParams_[shindig.container.RenderParam.NO_CACHE] ? '1' : '0');
uri.setQP('testmode', this.renderParams_[shindig.container.RenderParam.TEST_MODE] ? '1' : '0');
uri.setQP('view', this.getView());
+ if (this.renderParams_[shindig.container.RenderParam.CAJOLE]) {
+ var libs = uri.getQP('libs');
+ if (libs == null || libs == '') uri.setQP('libs', 'caja');
+ else uri.setQP('libs', [ libs, ':caja' ].join(''));
+ uri.setQP('caja', '1');
+ }
this.updateUserPrefParams_(uri);
// TODO: Share this base container logic
Modified: shindig/trunk/features/src/test/javascript/features/container/container_test.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/container/container_test.js?rev=1043811&r1=1043810&r2=1043811&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/container/container_test.js (original)
+++ shindig/trunk/features/src/test/javascript/features/container/container_test.js Thu Dec 9 01:21:40 2010
@@ -75,6 +75,7 @@ ContainerTest.prototype.testNavigateGadg
this.setupGadgetsRpcRegister();
var container = new shindig.container.Container({
'allowDefaultView' : true,
+ 'renderCajole' : true,
'renderDebug' : true,
'renderTest' : true
});
@@ -84,6 +85,7 @@ ContainerTest.prototype.testNavigateGadg
container.navigateGadget(site, 'gadget.xml', {}, {});
this.assertEquals('gadget.xml', this.site_navigateTo_gadgetUrl);
this.assertTrue(this.site_navigateTo_renderParams['allowDefaultView']);
+ this.assertTrue(this.site_navigateTo_renderParams['cajole']);
this.assertTrue(this.site_navigateTo_renderParams['debug']);
this.assertTrue(this.site_navigateTo_renderParams['nocache']);
this.assertTrue(this.site_navigateTo_renderParams['testmode']);
Modified: shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js?rev=1043811&r1=1043810&r2=1043811&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js (original)
+++ shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js Thu Dec 9 01:21:40 2010
@@ -30,9 +30,14 @@ function GadgetHolderTest(name) {
GadgetHolderTest.inherits(TestCase);
GadgetHolderTest.prototype.setUp = function() {
+ this.containerUri = window.__CONTAINER_URI;
+ window.__CONTAINER_URI = shindig.uri('http://container.com');
+ this.gadgetsRpc = gadgets.rpc;
};
GadgetHolderTest.prototype.tearDown = function() {
+ window.__CONTAINER_URI = this.containerUri;
+ gadgets.rpc = this.gadgetsRpc;
};
GadgetHolderTest.prototype.testNew = function() {
@@ -43,3 +48,68 @@ GadgetHolderTest.prototype.testNew = fun
this.assertNull(holder.getGadgetInfo());
this.assertNull(holder.getUrl());
};
+
+GadgetHolderTest.prototype.testRenderWithoutRenderParams = function() {
+ var element = {};
+ var gadgetInfo = {
+ 'iframeUrl' : 'http://shindig/gadgets/ifr?url=gadget.xml'
+ };
+ this.setupGadgetsRpcSetupReceiver();
+ var holder = new shindig.container.GadgetHolder(123, element);
+ holder.render(gadgetInfo, {}, {});
+ this.assertEquals('<iframe' +
+ ' marginwidth="0"' +
+ ' hspace="0"' +
+ ' frameborder="0"' +
+ ' scrolling="no"' +
+ ' marginheight="0"' +
+ ' vspace="0"' +
+ ' id="__gadget_123"' +
+ ' name="__gadget_123"' +
+ ' src="http://shindig/gadgets/ifr?url=gadget.xml&debug=0&nocache=0&testmode=0' +
+ '&parent=http%3A//container.com&mid=123"' +
+ ' ></iframe>',
+ element.innerHTML);
+};
+
+GadgetHolderTest.prototype.testRenderWithRenderRequests = function() {
+ var element = {};
+ var gadgetInfo = {
+ 'iframeUrl' : 'http://shindig/gadgets/ifr?url=gadget.xml'
+ };
+ var renderParams = {
+ 'cajole' : true,
+ 'class' : 'xyz',
+ 'debug' : true,
+ 'height' : 111,
+ 'nocache' : true,
+ 'testmode' : true,
+ 'width' : 222
+ };
+ this.setupGadgetsRpcSetupReceiver();
+ var holder = new shindig.container.GadgetHolder(123, element);
+ holder.render(gadgetInfo, {}, renderParams);
+ this.assertEquals('<iframe' +
+ ' marginwidth="0"' +
+ ' hspace="0"' +
+ ' height="111"' +
+ ' frameborder="0"' +
+ ' scrolling="no"' +
+ ' class="xyz"' +
+ ' marginheight="0"' +
+ ' vspace="0"' +
+ ' id="__gadget_123"' +
+ ' width="222"' +
+ ' name="__gadget_123"' +
+ ' src="http://shindig/gadgets/ifr?url=gadget.xml&debug=1&nocache=1&testmode=1' +
+ '&libs=caja&caja=1&parent=http%3A//container.com&mid=123"' +
+ ' ></iframe>',
+ element.innerHTML);
+};
+
+GadgetHolderTest.prototype.setupGadgetsRpcSetupReceiver = function() {
+ gadgets.rpc = {
+ setupReceiver: function(iframeId, relayUri, rpcToken) {
+ }
+ };
+};