Open the console and run testSpec(); and see the source of this file.

The promise code:
	dojox.getPromiseId = function(){
		if(!dojox._promiseId){
			dojox._promiseId = 0;
		}
		return dojox._promiseId++;
	};

	dojox.Promise = function(currentTopicNo){
	
		var topicNo = dojox.getPromiseId();

		return {
			then: function(doneHandler,errHandler){
				dojo.subscribe('/dojox/Promise/'+currentTopicNo, function(data){
					if(doneHandler && !(data instanceof Error)){
						var res = doneHandler(data);
						dojo.publish('/dojox/Promise/'+topicNo,[res]);
					}
					if(errHandler && (data instanceof Error)){
						errHandler(data);
						dojo.publish('/dojox/Promise/'+topicNo,[data]); // we hand over the same Error object
					}
				});
				return new dojox.Promise(topicNo);
			}
		}
	};

	dojox.Promise.prototype.touched = 1;