Sha256: 2d743523497462d977fdfff0de9aac7f1345723f187663f6c425c7e719e18822

Contents?: true

Size: 1.84 KB

Versions: 10

Compression:

Stored size: 1.84 KB

Contents

dojo.provide("dojox.io.tests.xhrPlugins");
dojo.require("dojox.io.xhrPlugins");

dojox.io.xhrPlugins.addCrossSiteXhr("http://cssupportingsite.com/"); // make sure the registry is setup
var url = dojo.moduleUrl("dojox.io.tests.crossSite");
url = url.toString();
url = url.substring(0,url.length-1) + ".php";

doh.register("dojox.io.tests.xhrPlugins", [
	function getLocal(t){
		var d = new doh.Deferred();
		var dfd = dojo.xhr("GET",{url:url});
		dfd.addCallback(function(result){
			d.callback(result.match(/response/));
		});
		return d;
	},

	function crossSiteRequest(t){
		// Note: this isn't really testing much unless you are using IE8 (XDomainRequest) or a 
		// browser that supports cross-site XHR (maybe FF3.1?) 
		var d = new doh.Deferred();
		// persevere supports cross-site XHR so we can use it for cross-site testing for now
		dojox.io.xhrPlugins.addCrossSiteXhr("http://persevere.sitepen.com/");
		try {
			var dfd = dojo.xhr("GET",{url:"http://persevere.sitepen.com/SMD"});
		}
		catch (e){
			if(e.message.match(/No match/)){
				return false; // this browser doesn't support this transport
			}
			throw e;
		}
		dfd.addCallback(function(result){
			d.callback(result.match(/transport/)); 
		});
		// TODO: This should run off a fixed URL on some Dojo server.  
		
/*		dojox.io.xhrPlugins.addXdr("http://dojotoolkit.org/...");
		dojox.io.xhrPlugins.addCrossSiteXhr("http://dojotoolkit.org/...");
				
		var dfd = dojo.xhr("GET",{url:"http://dojotoolkit.org/.../dojox/io/tests/crossSite.php"});
		dfd.addCallback(function(result){
			d.callback(result.match(/response/));
		}); */
		return d;
	},
	function proxiedRequest(t){
		var d = new doh.Deferred();
		dojox.io.xhrPlugins.addProxy(url+"?url=");

		var dfd = dojo.xhr("GET",{url:"http://someforeignsite.com/SMD"});
		dfd.addCallback(function(result){
			d.callback(result.match(/proxied/));
		});
		return d;
	}
]);

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
dojo_src-1.5.0 dojo/dojox/io/tests/xhrPlugins.js
dojo_src-1.4.3 dojo/dojox/io/tests/xhrPlugins.js
dojo_src-1.4.102 dojo/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.132.0 data/dojo-release-1.3.2-src/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.120.0 data/dojo-release-1.2.0-src/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.121.0 data/dojo-release-1.2.1-src/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.122.0 data/dojo-release-1.2.2-src/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.123.0 data/dojo-release-1.2.3-src/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.130.0 data/dojo-release-1.3.0-src/dojox/io/tests/xhrPlugins.js
dojo-pkg-1.131.0 data/dojo-release-1.3.1-src/dojox/io/tests/xhrPlugins.js