summaryrefslogtreecommitdiff
path: root/includes/js/dojo/tests/io/iframe.html
blob: c37bcb1202bc5be0908477fdb3c7dcc70cf08b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
	"http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>Testing dojo.io.iframe</title>
		<style type="text/css">
			@import "../../resources/dojo.css";
		</style>
		<script type="text/javascript" 
			src="../../dojo.js" djConfig="isDebug: true"></script>
		<script type="text/javascript">
			dojo.require("doh.runner");
			dojo.require("dojo.io.iframe");

			dojo.addOnLoad(function(){
				doh.register("t", 
					[
						function ioIframeGetText(t){
							var d = new doh.Deferred();
							var td = dojo.io.iframe.send({
								url: "iframeResponse.text.html",
								method: "GET",
								timeoutSeconds: 5,
								preventCache: true,
								handle: function(res, ioArgs){
									if(!(res instanceof Error) && 
										t.is("iframe succeeded", res)){
										d.callback(true);
									}else{
										d.errback(false);
									}								
								}
							});
							return d;							
						},

						function ioIframeGetJson(t){
							var d = new doh.Deferred();
							var td = dojo.io.iframe.send({
								url: "iframeResponse.json.html",
								method: "GET",
								timeoutSeconds: 5,
								preventCache: true,
								handleAs: "json",
								handle: function(res, ioArgs){
									if(!(res instanceof Error) && 
										t.is("blue", res.color)){
										d.callback(true);
									}else{
										d.errback(false);
									}								
								}
							});
							return d;							
						},

						function ioIframeGetJavascript(t){
							var d = new doh.Deferred();
							var td = dojo.io.iframe.send({
								url: "iframeResponse.js.html",
								method: "GET",
								timeoutSeconds: 5,
								preventCache: true,
								handleAs: "javascript",
								handle: function(res, ioArgs){
									console.log("RES: ", res);
									if(!(res instanceof Error) && 
										t.is(42, window.iframeTestingFunction())){
										d.callback(true);
									}else{
										d.errback(false);
									}								
								}
							});
							return d;							
						},

						function ioIframeGetHtml(t){
							var d = new doh.Deferred();
							var td = dojo.io.iframe.send({
								url: "iframeResponse.html",
								method: "GET",
								timeoutSeconds: 5,
								preventCache: true,
								handleAs: "html",
								handle: function(res, ioArgs){
									if(!(res instanceof Error) && 
										t.is("SUCCESSFUL HTML response", res.getElementsByTagName("h1")[0].innerHTML)){
										d.callback(true);
									}else{
										d.errback(false);
									}								
								}
							});
							return d;							
						}
					]
				);
				doh.run();
			});

/*
dojo.addOnLoad(function(){
	var td = dojo.io.iframe.get({
		url: "iframeResponse.text.html",
		timeoutSeconds: 5,
		preventCache: true,
		handle: function(res, ioArgs){
			if(!(res instanceof Error) && 
				"iframe succeeded" == res){
				console.debug("OK");
			}else{
				console.debug("Error", res);
			}								
		}
	});
});
*/
		</script>
	</head>
	<body>

	</body>
</html>