root / trunk / tests / io / test_BrowserIO.loadProblem.html

Revision 5924, 1.8 kB (checked in by jburke, 2 years ago)

Fixes #475. Added unit test to verify. Thanks for the test Morris.

  • Property svn:eol-style set to native
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4
5<title>Dojo bind exception problem</title>
6
7<script type="text/javascript">
8
9        var djConfig = {isDebug: true};
10
11</script>
12<script type="text/javascript" src="../../dojo.js"></script>
13<script type="text/javascript">
14        dojo.require("dojo.io.BrowserIO");
15</script>
16
17<script type="text/javascript">
18        var testvar = 0;
19
20        function firstBind() {
21                dojo.io.bind({
22                        url: 'frag.xml',
23                        method: 'get',
24                        load: firstBindReply,
25                        error: errorHandler
26                });
27        }
28
29        function firstBindReply(type, data, transport, bindArgs) {
30                testvar++;
31                dojo.debug("Error bind: testvar is now: " + testvar + ". About to throw an error now.");
32                throw new Error('ohhhh, an error happened!');
33        }
34
35        function secondBind() {
36                dojo.io.bind({
37                        url: 'frag.xml',
38                        method: 'get',
39                        load: secondBindReply,
40                        error: errorHandler
41                });
42        }
43
44        function secondBindReply(type, data, transport, bindArgs) {
45                testvar++;
46                dojo.debug("Safe bind: testvar is now: " + testvar);
47        }
48
49        function errorHandler(type, data, transport, bindArgs) {
50                var error = data;
51                if(data.message){
52                        error = data.message;
53                }
54                dojo.debug("errorHandler called with error: " + error);
55        }
56</script>
57
58</head>
59<body style="padding: 50px;">
60<p>
61This test makes sure that throwing an exception in the load callback will not stop further
62dojo.io.bind() requests from proceeding. If <b>Error bind</b> is pressed, an exception
63will be thrown in the load handler. <b>Safe bind</b> does not throw an error. In all cases,
64the value of <b>testvar</b> should increase by 1 any time either button is pressed.
65</p>
66
67<input id="asdf" type="button" value="Error bind (throws error)" onclick="firstBind()">
68<input type="button" value="Safe bind (does not throw error)" onclick="secondBind()">
69
70</body>
71</html>
Note: See TracBrowser for help on using the browser.