Author: ssievers
Date: Tue Nov 19 12:19:45 2013
New Revision: 1543398
URL: http://svn.apache.org/r1543398
Log:
SHINDIG-1952 | GadgetHolder.dispose does not cleanup the OAHub container
Modified:
shindig/trunk/features/src/main/javascript/features/container.site.gadget/gadget_holder.js
shindig/trunk/features/src/test/javascript/features/container/gadget_holder_test.js
Modified:
shindig/trunk/features/src/main/javascript/features/container.site.gadget/gadget_holder.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container.site.gadget/gadget_holder.js?rev=1543398&r1=1543397&r2=1543398&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/container.site.gadget/gadget_holder.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/container.site.gadget/gadget_holder.js
Tue Nov 19 12:19:45 2013
@@ -57,6 +57,14 @@ osapi.container.GadgetHolder = function(
*/
this.securityToken_ = undef;
+ /**
+ * Whether or not this holder is for an OpenAjax Iframe, i.e.,
+ * if the gadget is using pubsub-2
+ * @type {boolean}
+ * @private
+ */
+ this.isOaaIframe_ = false;
+
this.onConstructed();
};
osapi.container.GadgetHolder.prototype = new osapi.container.SiteHolder;
@@ -81,6 +89,9 @@ osapi.container.GadgetHolder.prototype.g
* @inheritDoc
*/
osapi.container.GadgetHolder.prototype.dispose = function() {
+ if (this.isOaaIframe_) {
+ this.removeOaaContainer_(this.iframeId_);
+ }
osapi.container.SiteHolder.prototype.dispose.call(this); // super.dispose();
this.gadgetInfo_ = null;
};
@@ -131,17 +142,13 @@ osapi.container.GadgetHolder.prototype.s
* @param {Object} renderParams Look at osapi.container.RenderParam.
*/
osapi.container.GadgetHolder.prototype.render = function(gadgetInfo,
viewParams, renderParams) {
- this.iframeId_ = osapi.container.GadgetHolder.IFRAME_ID_PREFIX_ +
- this.site_.getId();
+ this.iframeId_ = osapi.container.GadgetHolder.IFRAME_ID_PREFIX_ +
this.site_.getId();
this.gadgetInfo_ = gadgetInfo;
this.viewParams_ = viewParams;
this.renderParams_ = renderParams;
- if (this.hasFeature_(gadgetInfo, 'pubsub-2')) {
- this.doOaaIframeHtml_();
- } else {
- this.doNormalIframeHtml_();
- }
+ this.isOaaIframe_ = this.hasFeature_(gadgetInfo, 'pubsub-2');
+ this.isOaaIframe_ ? this.doOaaIframeHtml_() : this.doNormalIframeHtml_();
};
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=1543398&r1=1543397&r2=1543398&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
Tue Nov 19 12:19:45 2013
@@ -134,6 +134,7 @@ GadgetHolderTest.prototype.testRenderWit
' ></iframe>',
element.innerHTML);
};
+
GadgetHolderTest.prototype.testRemoveOaContainer_exisiting = function() {
var hub = this.setupMockPubsub2router(true);
var holder = new osapi.container.GadgetHolder();
@@ -142,6 +143,7 @@ GadgetHolderTest.prototype.testRemoveOaC
this.assertEquals(answer, hub.getCallArgs().g.id);
this.assertEquals(answer, hub.getCallArgs().r.container.passedId);
};
+
GadgetHolderTest.prototype.testRemoveOaContainer_nonexisting = function() {
var hub = this.setupMockPubsub2router(false);
var holder = new osapi.container.GadgetHolder();
@@ -151,6 +153,37 @@ GadgetHolderTest.prototype.testRemoveOaC
this.assertEquals("undefined", typeof hub.getCallArgs().r.container);
};
+GadgetHolderTest.prototype.testDisposeOaContainer = function() {
+ osapi.container.GadgetHolder.prototype.relayPath_ =
'/gadgets/files/container/rpc_relay.html';
+ var gadgetInfo = {
+ 'iframeUrls' : {'default' :
'http://shindig/gadgets/ifr?url=gadget.xml&lang=en&country=US#rpctoken=1234'},
+ 'url' : 'gadget.xml',
+ 'modulePrefs' : {
+ 'features' : {
+ 'pubsub-2' : {}
+ }
+ }
+ };
+ this.setupMockOAHub();
+ var hub = this.setupMockPubsub2router(true);
+ var element = {
+ id: '123'
+ };
+ var service = {};
+ service.getCountry = function(){return "US";};
+ service.getLanguage = function(){return "en"};
+ var site = new osapi.container.GadgetSite(null, service, {gadgetEl:
element});
+ site.id_ = 42;
+ var holder = new osapi.container.GadgetHolder(site, element,
'__gadgetOnLoad');
+ // I would like to call holder.render, but I can't get the setup to work, so
I "mock it"
+ holder.iframeId_ = site.id_;
+ holder.isOaaIframe_ = true;
+ holder.dispose();
+
+ this.assertEquals(site.id_, hub.getCallArgs().g.id);
+ this.assertEquals(site.id_, hub.getCallArgs().r.container.passedId);
+};
+
GadgetHolderTest.prototype.setupGadgetsRpcSetupReceiver = function() {
gadgets.rpc = {
setupReceiver: function(iframeId, relayUri, rpcToken) {
@@ -178,3 +211,11 @@ GadgetHolderTest.prototype.setupMockPubs
};
return gadgets.pubsub2router.hub;
};
+
+GadgetHolderTest.prototype.setupMockOAHub = function() {
+ OpenAjax = {};
+ OpenAjax.hub = {};
+ OpenAjax.hub.IframeContainer = function() {
+ // Do nothing
+ };
+};