You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by dd...@apache.org on 2012/09/20 22:32:26 UTC
svn commit: r1388199 - in /shindig/trunk: ./ features/
features/src/main/javascript/features/
features/src/main/javascript/features/container.mixin/
features/src/main/javascript/features/container.util/
features/src/main/javascript/features/container/ ...
Author: ddumont
Date: Thu Sep 20 20:32:25 2012
New Revision: 1388199
URL: http://svn.apache.org/viewvc?rev=1388199&view=rev
Log:
Revert the following commits related to the oauthpopup feature:
1387331 9/18/12 3:24 PM 6 ddumont SHINDIG-1869 - OAuth verifier not being added to requests because of recent OAuth popup changes
1383399 9/11/12 9:16 AM 1 ddumont Missing license on mixin_test.js
1383008 9/10/12 2:02 PM 13 ddumont SHINDIG-1864 - Refactor oauthpopup feature to use rpc to the container. Followup fix to create a container.mixin feature
1381228 9/5/12 11:32 AM 1 ddumont oauthpopup - delay checking for container code till it's defined.
1381226 9/5/12 11:28 AM 1 ddumont oauthpopup - delay checking for container code till it's defined.
1381205 9/5/12 10:46 AM 1 ddumont oauthpopup - delay checking for container code till it's defined.
1380656 9/4/12 10:01 AM 9 ddumont SHINDIG-1864 - Refactor oauthpopup feature to use rpc to the container
Removed:
shindig/trunk/features/src/main/javascript/features/container.mixin/feature.xml
shindig/trunk/features/src/main/javascript/features/container.mixin/mixin.js
shindig/trunk/features/src/main/javascript/features/oauthpopup/container_oauthpopup.js
shindig/trunk/features/src/test/javascript/features/container/mixin_test.js
Modified:
shindig/trunk/UPGRADING
shindig/trunk/features/pom.xml
shindig/trunk/features/src/main/javascript/features/container.util/constant.js
shindig/trunk/features/src/main/javascript/features/container/container.js
shindig/trunk/features/src/main/javascript/features/container/feature.xml
shindig/trunk/features/src/main/javascript/features/core.util.base/base.js
shindig/trunk/features/src/main/javascript/features/features.txt
shindig/trunk/features/src/main/javascript/features/oauthpopup/feature.xml
shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js
shindig/trunk/features/src/test/javascript/features/container/container_test.js
shindig/trunk/features/src/test/javascript/features/mocks/window.js
shindig/trunk/features/src/test/javascript/features/oauthpopup/oauthpopup-test.js
shindig/trunk/features/src/test/javascript/features/views/views-init-test.js
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuth2CallbackServlet.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java
Modified: shindig/trunk/UPGRADING
URL: http://svn.apache.org/viewvc/shindig/trunk/UPGRADING?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/UPGRADING (original)
+++ shindig/trunk/UPGRADING Thu Sep 20 20:32:25 2012
@@ -11,9 +11,6 @@ The JavaScript GagdetSite.getActiveGadge
The new property allows for embedding the key directly or referencing a classpath or filesystem
resource. Please see the comments at the top of container.js and around the new property for more
details.
-* The CommonContainer class now depends on the oauthpopup feature for some reworked logic in the
-feature. If you roll your own container and do not use the CommonContainer, update your container
-dependencies to include the oauthpopup feature.
== Java Dependency Changes ==
Modified: shindig/trunk/features/pom.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/pom.xml?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/pom.xml (original)
+++ shindig/trunk/features/pom.xml Thu Sep 20 20:32:25 2012
@@ -140,7 +140,6 @@
<source>core.prefs/prefs.js</source>
<source>core.log/log.js</source>
<source>core.io/io.js</source>
- <source>container.mixin/mixin.js</source>
<source>container.util/constant.js</source>
<source>container.util/util.js</source>
<source>container.site/site.js</source>
@@ -196,7 +195,6 @@
<source>osapi/jsonrpctransport.js</source>
<source>osapi/peoplehelpers.js</source>
<source>../../../../src/test/javascript/lib/testutils.js</source>
- <source>oauthpopup/container_oauthpopup.js</source>
<source>oauthpopup/oauthpopup.js</source>
<source>selection/selection_container.js</source>
<source>selection/selection.js</source>
Modified: shindig/trunk/features/src/main/javascript/features/container.util/constant.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container.util/constant.js?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container.util/constant.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container.util/constant.js Thu Sep 20 20:32:25 2012
@@ -26,7 +26,7 @@
* Set up namespace.
* @type {Object}
*/
-osapi.container = osapi.container || {};
+osapi.container = {};
/**
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=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js Thu Sep 20 20:32:25 2012
@@ -393,9 +393,19 @@ osapi.container.Container.prototype.onCo
* @param {string} namespace the namespace to add.
* @param {function} func to call when creating the namespace.
*/
-// TODO: Deprecate me in 3.0 in favor of new location.
osapi.container.Container.addMixin = function(namespace, func) {
- osapi.container.addMixin(namespace, func);
+ var mixins = osapi.container.Container.prototype.mixins_;
+
+ if (mixins[namespace]) {
+ var orig = mixins[namespace];
+ mixins[namespace] = function(container) {
+ orig.call(this, container);
+ return func.call(this, container);
+ };
+ } else {
+ osapi.container.Container.prototype.mixinsOrder_.push(namespace);
+ mixins[namespace] = func;
+ }
};
@@ -403,13 +413,34 @@ osapi.container.Container.addMixin = fun
// Private variables and methods.
// -----------------------------------------------------------------------------
+
+/**
+ * Adds the ability for features to extend the container with
+ * their own functionality that may be specific to that feature.
+ * @type {Object<string,function>}
+ * @private
+ */
+osapi.container.Container.prototype.mixins_ = {};
+
+/**
+ * Order of addMixin calls.
+ * @type {Array<string>}
+ * @private
+ */
+osapi.container.Container.prototype.mixinsOrder_ = [];
+
+
/**
* Called from the constructor to add any namespace extensions.
* @private
*/
-//TODO: Deprecate me in 3.0 in favor of new location.
osapi.container.Container.prototype.initializeMixins_ = function() {
- osapi.container.mixin(this);
+ var mixins = osapi.container.Container.prototype.mixins_,
+ order = osapi.container.Container.prototype.mixinsOrder_;
+ for (var i = 0; i < order.length; i++) {
+ var namespace = order[i];
+ this[namespace] = new mixins[namespace](this);
+ }
};
Modified: shindig/trunk/features/src/main/javascript/features/container/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/feature.xml?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/container/feature.xml Thu Sep 20 20:32:25 2012
@@ -28,8 +28,6 @@ under the License.
<dependency>container.util</dependency>
<dependency>container.site.gadget</dependency>
<dependency>container.site.url</dependency>
- <dependency>container.mixin</dependency>
- <dependency>oauthpopup</dependency>
<container>
<script src="service.js"/>
<script src="container.js"/>
Modified: shindig/trunk/features/src/main/javascript/features/core.util.base/base.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.base/base.js?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.base/base.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util.base/base.js Thu Sep 20 20:32:25 2012
@@ -44,10 +44,18 @@ gadgets.util = gadgets.util || {};
* @return {function()} a callback function.
*/
gadgets.util.makeClosure = function(scope, callback, var_args) {
- var baseArgs = Array.prototype.slice.call(arguments, 2);
+ // arguments isn't a real array, so we copy it into one.
+ var baseArgs = [];
+ for (var i = 2, j = arguments.length; i < j; ++i) {
+ baseArgs.push(arguments[i]);
+ }
return function() {
- var passedArgs = Array.prototype.slice.call(arguments);
- return callback.apply(scope, baseArgs.concat(passedArgs));
+ // append new arguments.
+ var tmpArgs = baseArgs.slice();
+ for (var i = 0, j = arguments.length; i < j; ++i) {
+ tmpArgs.push(arguments[i]);
+ }
+ return callback.apply(scope, tmpArgs);
};
};
Modified: shindig/trunk/features/src/main/javascript/features/features.txt
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/features.txt?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Thu Sep 20 20:32:25 2012
@@ -28,7 +28,6 @@ features/caja/es53-guest-frame.opt.xml
features/caja/es53-taming-frame.xml
features/caja/es53-taming-frame.opt.xml
features/container/feature.xml
-features/container.mixin/feature.xml
features/container.site/feature.xml
features/container.site.gadget/feature.xml
features/container.site.url/feature.xml
Modified: shindig/trunk/features/src/main/javascript/features/oauthpopup/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/oauthpopup/feature.xml?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/oauthpopup/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/oauthpopup/feature.xml Thu Sep 20 20:32:25 2012
@@ -19,24 +19,12 @@ specific language governing permissions
<feature>
<name>oauthpopup</name>
<dependency>globals</dependency>
- <dependency>container.mixin</dependency>
- <dependency>rpc</dependency>
- <container>
- <script src="container_oauthpopup.js"/>
- <api>
- <exports type="rpc">oauth.open</exports>
- <uses type="rpc">oauth.close</uses>
- </api>
- </container>
<gadget>
<script src="oauthpopup.js"/>
<api>
<exports type="js">gadgets.oauth.Popup</exports>
<exports type="js">gadgets.oauth.Popup.prototype.createOpenerOnClick</exports>
<exports type="js">gadgets.oauth.Popup.prototype.createApprovedOnClick</exports>
- <exports type="js">reportOauthCallbackUrl_</exports>
- <exports type="rpc">oauth.close</exports>
- <uses type="rpc">oauth.open</uses>
</api>
</gadget>
</feature>
Modified: shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js (original)
+++ shindig/trunk/features/src/main/javascript/features/oauthpopup/oauthpopup.js Thu Sep 20 20:32:25 2012
@@ -105,65 +105,89 @@ gadgets.oauth = gadgets.oauth || {};
* @param {string} destination Target URL for the popup window.
* @param {string} windowOptions Options for window.open, used to specify
* look and feel of the window.
- * @param {function()} onOpen Function to call when the window is opened.
- * @param {function()} onClose Function to call when the window is closed.
+ * @param {function()} openCallback Function to call when the window is opened.
+ * @param {function()} closeCallback Function to call when the window is closed.
*/
-gadgets.oauth.Popup = function(destination, windowOptions, onOpen, onClose) {
+gadgets.oauth.Popup = function(destination, windowOptions, openCallback,
+ closeCallback) {
this.destination_ = destination;
this.windowOptions_ = windowOptions;
- this.openCallback_ = onOpen;
- this.closeCallback_ = onClose;
+ this.openCallback_ = openCallback;
+ this.closeCallback_ = closeCallback;
+ this.win_ = null;
};
/**
* @return {function()} an onclick handler for the "open the approval window" link.
*/
+gadgets.oauth.Popup.prototype.createOpenerOnClick = function() {
+ var self = this;
+ return function() {
+ self.onClick_();
+ };
+};
-
-(function() {
- var callbacks = {};
-
- gadgets.util.registerOnLoadHandler(function() {
- gadgets.rpc.register('oauth.close', function(cbid, cburl) {
- if (this.f == '..') {
- gadgets.io.oauthReceivedCallbackUrl_ = cburl; // gadgets.io completion.
- callbacks[cbid] && callbacks[cbid]();
- }
- });
- });
-
- function onOpen(cbid) {
- this.cbid = cbid;
- callbacks[cbid] = this.createApprovedOnClick();
+/**
+ * Called when the user clicks to open the popup window.
+ *
+ * @return {boolean} false to prevent the default action for the click.
+ * @private
+ */
+gadgets.oauth.Popup.prototype.onClick_ = function() {
+ // If a popup blocker blocks the window, we do nothing. The user will
+ // need to approve the popup, then click again to open the window.
+ // Note that because we don't call window.open until the user has clicked
+ // something the popup blockers *should* let us through.
+ this.win_ = window.open(this.destination_, '_blank', this.windowOptions_);
+ if (this.win_) {
+ // Poll every 100ms to check if the window has been closed
+ var self = this;
+ var closure = function() {
+ self.checkClosed_();
+ };
+ this.timer_ = window.setInterval(closure, 100);
this.openCallback_();
}
+ return false;
+};
- /**
- * Called when the user clicks to open the popup window.
- *
- * @return {boolean} false to prevent the default action for the click.
- * @private
- */
- gadgets.oauth.Popup.prototype.createOpenerOnClick = function() {
- return gadgets.util.makeClosure(this, function() {
- gadgets.rpc.call('..', 'oauth.open', gadgets.util.makeClosure(this, onOpen),
- this.destination_, this.windowOptions_
- );
- return false;
- });
- };
+/**
+ * Called at intervals to check whether the window has closed.
+ * @private
+ */
+gadgets.oauth.Popup.prototype.checkClosed_ = function() {
+ if ((!this.win_) || this.win_.closed) {
+ this.win_ = null;
+ this.handleApproval_();
+ }
+};
- /**
- * @return {function()} an onclick handler for the "I've approved" link. This may not
- * ever be called. If we successfully detect that the window was closed,
- * this link is unnecessary.
- */
- gadgets.oauth.Popup.prototype.createApprovedOnClick = function() {
- return gadgets.util.makeClosure(this, function() {
- if (this.cbid) {
- delete callbacks[this.cbid];
- }
- this.closeCallback_();
- });
+/**
+ * Called when we recieve an indication the user has approved access, either
+ * because they closed the popup window or clicked an "I've approved" button.
+ * @private
+ */
+gadgets.oauth.Popup.prototype.handleApproval_ = function() {
+ if (this.timer_) {
+ window.clearInterval(this.timer_);
+ this.timer_ = null;
+ }
+ if (this.win_) {
+ this.win_.close();
+ this.win_ = null;
+ }
+ this.closeCallback_();
+ return false;
+};
+
+/**
+ * @return {function()} an onclick handler for the "I've approved" link. This may not
+ * ever be called. If we successfully detect that the window was closed,
+ * this link is unnecessary.
+ */
+gadgets.oauth.Popup.prototype.createApprovedOnClick = function() {
+ var self = this;
+ return function() {
+ self.handleApproval_();
};
-})();
\ No newline at end of file
+};
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=1388199&r1=1388198&r2=1388199&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 Sep 20 20:32:25 2012
@@ -73,7 +73,7 @@ ContainerTest.prototype.testUnloadGadget
ContainerTest.prototype.testPreloadConfigGadgets = function() {
this.setupGadgetsRpcRegister();
- var container = new osapi.container.Container(
+ var container = new osapi.container.Container(
{ 'preloadMetadatas' : { 'preloaded1.xml' : {}}});
var test = null;
this.assertTrue('1', 'preloaded1.xml' in container.preloadedGadgetUrls_);
@@ -133,6 +133,23 @@ ContainerTest.prototype.testNewGadgetSit
this.assertTrue(container.sites_[2] != null);
};
+ContainerTest.prototype.testMixinViaPrototype = function() {
+ this.setupGadgetsRpcRegister();
+ osapi.container.Container.prototype.mixins_['test'] = function(context) {
+ return {
+ 'getSitesLength' : function() {
+ return context.sites_.length;
+ }
+ };
+ };
+ osapi.container.Container.prototype.mixinsOrder_.push('test');
+ var container = new osapi.container.Container();
+ this.setupGadgetSite(1, {}, null);
+ container.newGadgetSite(null);
+ this.assertTrue(container.sites_[1] != null);
+ this.assertEquals(container.sites_.length, container.test.getSitesLength());
+};
+
ContainerTest.prototype.testMixinViaAdd = function() {
this.setupGadgetsRpcRegister();
osapi.container.Container.addMixin('test2', function(context) {
Modified: shindig/trunk/features/src/test/javascript/features/mocks/window.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/mocks/window.js?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/mocks/window.js (original)
+++ shindig/trunk/features/src/test/javascript/features/mocks/window.js Thu Sep 20 20:32:25 2012
@@ -24,33 +24,13 @@
* the global window object in each test case that uses the window.
*
* Example:
- *
+ *
* ExampleTest.prototype.testSomething = function() {
* window = new mocks.FakeWindow();
* // Test things
* };
*/
-// So tests aren't broken :/
-(function() {
- var timer = new java.util.Timer(),
- timerIds = {},
- inc = 1;
-
- this.setTimeout = function (fn, delay) {
- var id = inc++;
- timerIds[id] = new JavaAdapter(java.util.TimerTask, {run: fn});
- timer.schedule(timerIds[id], delay);
- return id;
- };
-
- this.clearTimeout = function(id) {
- ids[id].cancel();
- timer.purge();
- delete timerIds[id];
- };
-}).call(this);
-
var mocks = mocks || {};
/**
Modified: shindig/trunk/features/src/test/javascript/features/oauthpopup/oauthpopup-test.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/oauthpopup/oauthpopup-test.js?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/oauthpopup/oauthpopup-test.js (original)
+++ shindig/trunk/features/src/test/javascript/features/oauthpopup/oauthpopup-test.js Thu Sep 20 20:32:25 2012
@@ -26,76 +26,58 @@ PopupTest.inherits(TestCase);
PopupTest.prototype.setUp = function() {
this.oldWindow = window;
window = new mocks.FakeWindow();
- window.__API_URI = shindig.uri('http://shindig.com');
- window.__CONTAINER_URI = shindig.uri('http://container.com');
-
- this.gadgetsRpc = gadgets.rpc;
- gadgets.rpc = {};
- var self = this;
- gadgets.rpc.register = function(service, callback) {
- if (self.captures && self.captures.hasOwnProperty(service)) {
- self.captures[service] = callback;
- }
- };
- gadgets.rpc.call = function() {
- self.rpcArguments = Array.prototype.slice.call(arguments);
- };
};
PopupTest.prototype.tearDown = function() {
window = this.oldWindow;
- gadgets.rpc = this.gadgetsRpc;
- delete this.rpcArguments;
- delete this.captures;
};
PopupTest.prototype.testPopup = function() {
- var undef, captures = this.captures = {
- 'oauth.open': undef
+ var opened = false;
+ var open = function() {
+ opened = true;
};
- var container = new osapi.container.Container();
- this.assertNotUndefined('RPC endpoint "oauth.open" was not registered.', captures['oauth.open']);
-
- delete this.rpcArguments;
-
- var cbid, popup, opened = false;
- window.open = function(url, target, options) {
- return popup = mocks.FakeWindow.prototype.open.call(this, url, target, options);
+ var closed = false;
+ var close = function() {
+ closed = true;
};
- this.assertUndefined('Window opened prematurely.', popup);
+ // Create the popup
+ var popup = new gadgets.oauth.Popup('destination', 'options', open, close);
+ var openerOnClick = popup.createOpenerOnClick();
+ var closerOnClick = popup.createApprovedOnClick();
+ this.assertNull('Window opened prematurely', popup.win_);
+ this.assertFalse('Opener callback was called', opened);
- captures['oauth.open'].call({f: 'from', callback: function(id) {
- opened = true;
- cbid = id;
- }}, 'destination', 'options');
- this.assertNotUndefined('Window not opened.', popup);
- this.assertTrue('Opened callback not fired.', opened);
- this.assertEquals('Url incorrect.', 'destination', popup.url_);
- this.assertEquals('Target incorrect.', '_blank', popup.target_);
- this.assertEquals('Options incorrect.', 'options', popup.options_);
+ // Open the window
+ var ranDefaultAction = openerOnClick();
+ this.assertTrue('Window not opened', opened);
+ this.assertFalse('Ran browser default action on open', ranDefaultAction);
+ this.assertNotNull('Window was null', popup.win_);
+ this.assertEquals('Url incorrect', 'destination', popup.win_.url_);
+ this.assertEquals('Target incorrect', '_blank', popup.win_.target_);
+ this.assertEquals('Options incorrect', 'options', popup.win_.options_);
// Wait a bit for our events to run
window.incrementTime(1000);
- this.assertUndefined('close callback called early.', this.rpcArguments);
+ this.assertFalse('closer callback called early', closed);
// User or site closes window
- popup.close();
+ popup.win_.close();
window.incrementTime(100);
- this.assertEquals('Closer callback not called.', ['from', 'oauth.close', null, cbid, undef], this.rpcArguments);
-
- delete this.rpcArguments;
- window.incrementTime(1000);
- this.assertUndefined('Timer not cancelled.', this.rpcArguments);
+ this.assertTrue('Closer callback not called', closed);
};
PopupTest.prototype.testPopup_userClick = function() {
- var opened = false, closed = false;
- // Create the popup
- var popup = new gadgets.oauth.Popup('destination', 'options', function() {
+ var opened = false;
+ var open = function() {
opened = true;
- }, function() {
+ };
+ var closed = false;
+ var close = function() {
closed = true;
- });
+ };
+ // Create the popup
+ var popup = new gadgets.oauth.Popup('destination', 'options', open, close);
var openerOnClick = popup.createOpenerOnClick();
var closerOnClick = popup.createApprovedOnClick();
@@ -111,3 +93,28 @@ PopupTest.prototype.testPopup_userClick
this.assertFalse(ranDefaultAction);
this.assertTrue('Closer callback not called', closed);
};
+
+PopupTest.prototype.testTimerCancelled = function() {
+ var open = function() {};
+ var closeCount = 0;
+ var close = function() {
+ ++closeCount;
+ };
+
+ // Create the popup
+ var popup = new gadgets.oauth.Popup('destination', 'options', open, close);
+ var openerOnClick = popup.createOpenerOnClick();
+ var closerOnClick = popup.createApprovedOnClick();
+
+ // Open the window
+ openerOnClick();
+
+ // Close the window
+ popup.win_.close();
+
+ // Wait a bit for our events to run
+ window.incrementTime(1000);
+ this.assertEquals('Wrong number of calls to close', 1, closeCount);
+ window.incrementTime(1000);
+ this.assertEquals('timer not cancelled', 1, closeCount);
+};
Modified: shindig/trunk/features/src/test/javascript/features/views/views-init-test.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/views/views-init-test.js?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/views/views-init-test.js (original)
+++ shindig/trunk/features/src/test/javascript/features/views/views-init-test.js Thu Sep 20 20:32:25 2012
@@ -65,15 +65,10 @@ ViewsInitTest.prototype.testRewriteLinks
name = arguments[0];
func = arguments[1];
bubble = arguments[2];
- },
- location: {
- href: "http://localhost",
- host: "localhost",
- hostname: "localhost"
- },
- scripts: []
+ }
};
+ document.scripts = [];
gadgets.config.init({views:{rewriteLinks: true}});
this.assertEquals("click", name);
@@ -88,15 +83,12 @@ ViewsInitTest.prototype.testRewriteLinks
attachEvent: function() {
name = arguments[0];
func = arguments[1];
+
},
- location: {
- href: "http://localhost",
- host: "localhost",
- hostname: "localhost"
- },
- scripts: []
+ addEventListener: undefined
};
+ document.scripts = [];
gadgets.config.init({views:{rewriteLinks: true}});
this.assertEquals("onclick", name);
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuth2CallbackServlet.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuth2CallbackServlet.java?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuth2CallbackServlet.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuth2CallbackServlet.java Thu Sep 20 20:32:25 2012
@@ -64,7 +64,7 @@ public class OAuth2CallbackServlet exten
+ "<body>\n"
+ "<script type='text/javascript'>\n"
+ "try {\n"
- + " window.opener.reportOauthCallbackUrl_(window, document.location.href);\n"
+ + " window.opener.gadgets.io.oauthReceivedCallbackUrl_ = document.location.href;\n"
+ "} catch (e) {\n"
+ "}\n"
+ "window.close();\n"
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java?rev=1388199&r1=1388198&r2=1388199&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/OAuthCallbackServlet.java Thu Sep 20 20:32:25 2012
@@ -69,7 +69,7 @@ public class OAuthCallbackServlet extend
"<body>\n" +
"<script type='text/javascript'>\n" +
"try {\n" +
- " window.opener.reportOauthCallbackUrl_(window, document.location.href);\n" +
+ " window.opener.gadgets.io.oauthReceivedCallbackUrl_ = document.location.href;\n" +
"} catch (e) {\n" +
"}\n" +
"window.close();\n" +