PageRenderTime 54ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/app/bower_components/requirejs/tests/browsertests/async/async.php

https://github.com/balajin-cse/CS256-Conference-App
PHP | 94 lines | 85 code | 9 blank | 0 comment | 10 complexity | ad1e3cc0e66c4cb5ba2240379023b0fd MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?
  2. if($_GET['quirks'] == "")
  3. {
  4. echo "<!DOCTYPE html>\n";
  5. }
  6. else
  7. {
  8. echo "\n";
  9. }
  10. ?>
  11. <html>
  12. <head>
  13. <title>Async Attribute Test</title>
  14. <script type="text/javascript" src="../common.js"></script>
  15. <script type="text/javascript">
  16. var attachScript = function(url, name, approach){
  17. url += "?stamp=" + (new Date()).getTime();
  18. var node = document.createElement("script");
  19. node.src = url;
  20. node.type = "text/javascript";
  21. node.charset = "utf-8";
  22. if (approach === 'boolean') {
  23. node.async = true;
  24. } else if (approach === 'string') {
  25. node.async = 'async';
  26. } else if (approach === 'attribute') {
  27. node.setAttribute('async', 'async');
  28. }
  29. document.getElementsByTagName("head")[0].appendChild(node);
  30. }
  31. var urls = [
  32. "one.php",
  33. "two.js"
  34. ];
  35. var loadUrls = function(approach) {
  36. for (var i = 0, url; url = urls[i]; i++) {
  37. attachScript(url, url, approach);
  38. }
  39. }
  40. function onFormAction () {
  41. var select = document.getElementById('approach'),
  42. approach = select.value,
  43. text = select.options[select.selectedIndex].text;
  44. window.log('Using approach: [' + text + '] (' + approach + ')...');
  45. loadUrls(approach);
  46. };
  47. </script>
  48. </head>
  49. <body>
  50. <h1>Async Attribute Test</h1>
  51. <p><b>This test requires PHP to be enabled to run.</b></p>
  52. <p>This test tests async attribute. It attaches two scripts to the DOM, <b>one.php</b> and <b>two.js</b>.
  53. The URLs to the scripts always has a timestamp querystring to make sure the scripts are fetched
  54. fresh for each request.</p>
  55. <p>one.php uses a PHP sleep of 3 seconds before returning its result (a log message), where two.js will return
  56. immediately with a log message.</p>
  57. <p>If the async attribute is being effective (In Gecko 1.9.2+/Firefox 3.6+ browsers, maybe
  58. Opera in the future), then the log message for two.js should appear before the one.php log message.
  59. If async is <b>not</b> effective, then one.php's log message will appear first.</p>
  60. <p>You can also <b><a href="async.php?quirks=true">try this page in quirks mode</a></b>.
  61. When you are done, come back to <b><a href="async.php">standards mode</a></b>.</p>
  62. <p>Watch the console for log messages. If no console is available, then it should print
  63. the log messages in the DOM.</p>
  64. <p><b>Expected Results in All Browsers (except Opera)</b>:</p>
  65. <ul>
  66. <li>two.js script</li>
  67. <li>one.php script</li>
  68. </ul>
  69. <form onsubmit="onFormAction(); return false;">
  70. <label for="approach">Choose an approach to indicate async:</label>
  71. <select id="approach" onchange="onFormAction();">
  72. <option value="boolean">script.async = true</option>
  73. <option value="string">script.async = 'async'</option>
  74. <option value="attribute">script.setAttribute('async', 'async')</option>
  75. <option value="">No async (one.php should be first in Firefox 3.6+)</option>
  76. </select>
  77. <input type="submit" name="Go" value="Go">
  78. </form>
  79. </body>
  80. </html>