1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
---|
2 | "http://www.w3.org/TR/html4/strict.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Testing dojo.io.script</title> |
---|
6 | <style type="text/css"> |
---|
7 | @import "../../resources/dojo.css"; |
---|
8 | </style> |
---|
9 | <script type="text/javascript" |
---|
10 | src="../../dojo.js" djConfig="isDebug: true"></script> |
---|
11 | <script type="text/javascript"> |
---|
12 | dojo.require("dojo.io.script"); |
---|
13 | |
---|
14 | function startTest(){ |
---|
15 | var td = dojo.io.script.get({ |
---|
16 | url: "../_base/timeout.php", |
---|
17 | callbackParamName: "callback", |
---|
18 | content: {Foo: 'Bar'}, |
---|
19 | timeout: 500, |
---|
20 | handleAs: "json", |
---|
21 | preventCache: true, |
---|
22 | handle: function(response, ioArgs){ |
---|
23 | if(response instanceof Error && response.dojoType == "timeout"){ |
---|
24 | console.debug("TEST OK. No errors should be seen after this timeout error."); |
---|
25 | }else{ |
---|
26 | console.debug("TEST FAILED: some other error or response received: ", response); |
---|
27 | } |
---|
28 | } |
---|
29 | }); |
---|
30 | } |
---|
31 | </script> |
---|
32 | </head> |
---|
33 | <body> |
---|
34 | <h1>Timeout test</h1> |
---|
35 | |
---|
36 | <p> |
---|
37 | This test page tests the timeout functionality of dojo.io.script, and to make |
---|
38 | sure that requests that time out get removed quickly. If the server response |
---|
39 | is received after the script has been timed out, there should not be weird |
---|
40 | errors as the browser tries to evaluate the responses after the desired time |
---|
41 | period. |
---|
42 | </p> |
---|
43 | |
---|
44 | <p>This test requires a server running PHP to work.</p> |
---|
45 | |
---|
46 | <p> |
---|
47 | <p><strong>Firefox Oddity:</strong> Firefox |
---|
48 | will print an error after the script response is received from the server:<br /> |
---|
49 | <span style="color: red">dojo.io.script.jsonp_dojoIoScript1 has no properties</span> |
---|
50 | This is bad because Firefox goes ahead and evaluates the script contents in the page's |
---|
51 | JavaScript space (this happens even when I turn off Firefox Add-Ons). All other browsers |
---|
52 | do not evaluate the script (given the weird Opera 9.22 behavior below). You can test this |
---|
53 | by clicking the <b>Test for SuperXFooBarVariable</b> button after receiving the response |
---|
54 | for timeout.php (check Firebug Net tab to see when request is received). All other browsers |
---|
55 | show an error or show the "undefined" value for SuperXFooBarVariable, but Firefox will show its |
---|
56 | value as being: "Oh no! SuperXFooBarVariable is defined (should not be for timeout case)". |
---|
57 | |
---|
58 | <p><strong>Opera Oddity:</strong> Opera 9.22 does not seem to trigger the timeout case, |
---|
59 | but rather it waits for the server to send a response to the script before continuing past the |
---|
60 | point where the script is added to the DOM? That seems wrong. Dynamic script tags are no longer |
---|
61 | an async operation? |
---|
62 | </p> |
---|
63 | |
---|
64 | <button onclick="startTest()">Start Test</button> |
---|
65 | <button onclick="alert(SuperXFooBarVariable)">Test for SuperXFooBarVariable</button> |
---|
66 | </body> |
---|
67 | </html> |
---|