source: Dev/trunk/src/client/dojox/io/tests/windowName.js @ 524

Last change on this file since 524 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.9 KB
Line 
1define(['doh', 'dojo/_base/kernel', 'dojo/_base/xhr', 'dojox/io/xhrPlugins', 'dojo/_base/url'], function(doh, dojo, xhr, xhrPlugins){
2
3xhrPlugins.addXdr("http://xdrsupportingsite.com/"); // make sure the registry is setup
4var url = dojo.moduleUrl("dojox.io", "tests/crossSite.php");
5url = url.toString();
6
7doh.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 both XDR and cross-site XHR so we can use it for cross-site testing for now
22                dojox.io.xhrPlugins.addXdr("http://persevere.sitepen.com/");
23                dojox.io.xhrPlugins.addCrossSiteXhr("http://persevere.sitepen.com/");
24                try {
25                        var dfd = xhr("GET",{url:"http://persevere.sitepen.com/SMD"});
26                }
27                catch (e){
28                        if(e.message.match(/No match/)){
29                                return null; // this browser doesn't support this transport
30                        }
31                        throw e;
32                }
33                dfd.addCallback(function(result){
34                        d.callback(result.match(/transport/));
35                });
36                // TODO: This should run off a fixed URL on some Dojo server.
37               
38/*              dojox.io.xhrPlugins.addXdr("http://dojotoolkit.org/...");
39                dojox.io.xhrPlugins.addCrossSiteXhr("http://dojotoolkit.org/...");
40                               
41                var dfd = xhr("GET",{url:"http://dojotoolkit.org/.../dojox/io/tests/crossSite.php"});
42                dfd.addCallback(function(result){
43                        d.callback(result.match(/response/));
44                }); */
45                return d;
46        },
47        function proxiedRequest(t){
48                var d = new doh.Deferred();
49                dojox.io.xhrPlugins.addProxy(url+"?url=");
50
51                var dfd = xhr("GET",{url:"http://someforeignsite.com/SMD"});
52                dfd.addCallback(function(result){
53                        d.callback(result.match(/proxied/));
54                });
55                return d;
56        }
57]);
58
59});
Note: See TracBrowser for help on using the repository browser.