047828dd9381d92ddb7083d418ae8832dbe21492.svn-base 2.7 KB

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