[483] | 1 | define(['doh', 'dojo/_base/kernel', 'dojo/_base/xhr', 'dojox/io/xhrPlugins', 'dojo/_base/url'], function(doh, dojo, xhr, xhrPlugins){ |
---|
| 2 | |
---|
| 3 | xhrPlugins.addCrossSiteXhr("http://cssupportingsite.com/"); // make sure the registry is setup |
---|
| 4 | var url = dojo.moduleUrl("dojox.io", "tests/crossSite.php"); |
---|
| 5 | url = url.toString(); |
---|
| 6 | |
---|
| 7 | doh.register("dojox.io.tests.xhrPlugins", [ |
---|
| 8 | function getLocal(t){ |
---|
| 9 | var d = new doh.Deferred(); |
---|
| 10 | var dfd = xhr("GET",{url:url}); |
---|
| 11 | dfd.addCallback(function(result){ |
---|
| 12 | d.callback(result.match(/response/)); |
---|
| 13 | }); |
---|
| 14 | return d; |
---|
| 15 | }, |
---|
| 16 | |
---|
| 17 | function crossSiteRequest(t){ |
---|
| 18 | // Note: this isn't really testing much unless you are using IE8 (XDomainRequest) or a |
---|
| 19 | // browser that supports cross-site XHR (maybe FF3.1?) |
---|
| 20 | var d = new doh.Deferred(); |
---|
| 21 | // persevere supports cross-site XHR so we can use it for cross-site testing for now |
---|
| 22 | xhrPlugins.addCrossSiteXhr("http://persevere.sitepen.com/"); |
---|
| 23 | try { |
---|
| 24 | var dfd = xhr("GET",{url:"http://persevere.sitepen.com/SMD"}); |
---|
| 25 | } |
---|
| 26 | catch (e){ |
---|
| 27 | if(e.message.match(/No match/)){ |
---|
| 28 | return false; // this browser doesn't support this transport |
---|
| 29 | } |
---|
| 30 | throw e; |
---|
| 31 | } |
---|
| 32 | dfd.addCallback(function(result){ |
---|
| 33 | d.callback(result.match(/transport/)); |
---|
| 34 | }); |
---|
| 35 | // TODO: This should run off a fixed URL on some Dojo server. |
---|
| 36 | |
---|
| 37 | /* xhrPlugins.addXdr("http://dojotoolkit.org/..."); |
---|
| 38 | xhrPlugins.addCrossSiteXhr("http://dojotoolkit.org/..."); |
---|
| 39 | |
---|
| 40 | var dfd = xhr("GET",{url:"http://dojotoolkit.org/.../dojox/io/tests/crossSite.php"}); |
---|
| 41 | dfd.addCallback(function(result){ |
---|
| 42 | d.callback(result.match(/response/)); |
---|
| 43 | }); */ |
---|
| 44 | return d; |
---|
| 45 | }, |
---|
| 46 | function proxiedRequest(t){ |
---|
| 47 | var d = new doh.Deferred(); |
---|
| 48 | xhrPlugins.addProxy(url+"?url="); |
---|
| 49 | |
---|
| 50 | var dfd = xhr("GET",{url:"http://someforeignsite.com/SMD"}); |
---|
| 51 | dfd.addCallback(function(result){ |
---|
| 52 | d.callback(result.match(/proxied/)); |
---|
| 53 | }); |
---|
| 54 | return d; |
---|
| 55 | } |
---|
| 56 | ]); |
---|
| 57 | |
---|
| 58 | }); |
---|