jazz-jss 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. data/dist/handlebars/handlebars.js +1493 -0
  2. data/dist/hashchange/{jquery.ba-hashchange.js → hashchange.js} +0 -0
  3. data/dist/jazz/lib/controller.js +1 -1
  4. data/dist/jazz/lib/core.js +3 -0
  5. data/dist/jazz/lib/db.js +1 -1
  6. data/dist/jazz/lib/helper.js +2 -1
  7. data/dist/jazz/lib/model.js +11 -4
  8. data/dist/jazz/lib/view.js +1 -1
  9. data/dist/jazz/module.js +15 -0
  10. data/dist/jquery/jquery.js +0 -0
  11. data/dist/require/require.js +0 -0
  12. data/dist/require/template.js +98 -0
  13. data/dist/underscore/underscore.js +0 -0
  14. data/lib/jazz/app_detector.rb +6 -3
  15. data/lib/jazz/app_generator.rb +12 -8
  16. data/lib/jazz/helper_generator.rb +30 -0
  17. data/lib/jazz/scaffold_generator.rb +4 -0
  18. data/templates/app_root/Rakefile +11 -0
  19. data/templates/app_root/{app → development/app}/assets/javascripts/application.js +0 -0
  20. data/templates/app_root/{app → development/app}/assets/stylesheets/application.css +0 -0
  21. data/templates/app_root/development/app/controllers/application_controller.js +11 -0
  22. data/templates/app_root/development/app/helpers/application_helper.js +7 -0
  23. data/templates/app_root/development/config/glue.js +9 -0
  24. data/templates/app_root/development/config/routes.js +5 -0
  25. data/templates/app_root/scripts/build.js +30 -0
  26. data/templates/app_root/scripts/r.js/LICENSE +58 -0
  27. data/templates/app_root/scripts/r.js/README.md +177 -0
  28. data/templates/app_root/scripts/r.js/build/build.js +26 -0
  29. data/templates/app_root/scripts/r.js/build/buildebug.sh +4 -0
  30. data/templates/app_root/scripts/r.js/build/example.build.js +296 -0
  31. data/templates/app_root/scripts/r.js/build/jslib/blank.js +4 -0
  32. data/templates/app_root/scripts/r.js/build/jslib/build.js +952 -0
  33. data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +23 -0
  34. data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +152 -0
  35. data/templates/app_root/scripts/r.js/build/jslib/env.js +47 -0
  36. data/templates/app_root/scripts/r.js/build/jslib/lang.js +49 -0
  37. data/templates/app_root/scripts/r.js/build/jslib/logger.js +58 -0
  38. data/templates/app_root/scripts/r.js/build/jslib/node.js +106 -0
  39. data/templates/app_root/scripts/r.js/build/jslib/node/args.js +20 -0
  40. data/templates/app_root/scripts/r.js/build/jslib/node/file.js +263 -0
  41. data/templates/app_root/scripts/r.js/build/jslib/node/load.js +17 -0
  42. data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +10 -0
  43. data/templates/app_root/scripts/r.js/build/jslib/node/print.js +16 -0
  44. data/templates/app_root/scripts/r.js/build/jslib/optimize.js +279 -0
  45. data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +11 -0
  46. data/templates/app_root/scripts/r.js/build/jslib/parse.js +590 -0
  47. data/templates/app_root/scripts/r.js/build/jslib/pragma.js +251 -0
  48. data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +286 -0
  49. data/templates/app_root/scripts/r.js/build/jslib/rhino.js +22 -0
  50. data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +21 -0
  51. data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +244 -0
  52. data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +12 -0
  53. data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +100 -0
  54. data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +12 -0
  55. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +16 -0
  56. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +21 -0
  57. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +1342 -0
  58. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +2005 -0
  59. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +55 -0
  60. data/templates/app_root/scripts/r.js/build/jslib/x.js +243 -0
  61. data/templates/app_root/scripts/r.js/build/tests/all.js +47 -0
  62. data/templates/app_root/scripts/r.js/build/tests/allj.sh +3 -0
  63. data/templates/app_root/scripts/r.js/build/tests/alln.sh +18 -0
  64. data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +7 -0
  65. data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +19 -0
  66. data/templates/app_root/scripts/r.js/build/tests/builds.js +489 -0
  67. data/templates/app_root/scripts/r.js/build/tests/circular.build.js +18 -0
  68. data/templates/app_root/scripts/r.js/build/tests/convert.js +18 -0
  69. data/templates/app_root/scripts/r.js/build/tests/css.build.js +6 -0
  70. data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +4 -0
  71. data/templates/app_root/scripts/r.js/build/tests/css/master.css +10 -0
  72. data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +7 -0
  73. data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +13 -0
  74. data/templates/app_root/scripts/r.js/build/tests/end.frag +3 -0
  75. data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +23 -0
  76. data/templates/app_root/scripts/r.js/build/tests/exports.build.js +12 -0
  77. data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +10 -0
  78. data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +30 -0
  79. data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +70 -0
  80. data/templates/app_root/scripts/r.js/build/tests/http/main.html +28 -0
  81. data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +18 -0
  82. data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +3 -0
  83. data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +5 -0
  84. data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +7 -0
  85. data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +17 -0
  86. data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +8 -0
  87. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +17 -0
  88. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +8 -0
  89. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +6 -0
  90. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +7 -0
  91. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +5 -0
  92. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +36 -0
  93. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +58 -0
  94. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +188 -0
  95. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +21 -0
  96. data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +10 -0
  97. data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +6 -0
  98. data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +9 -0
  99. data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +13 -0
  100. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +15 -0
  101. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +13 -0
  102. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +7 -0
  103. data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +13 -0
  104. data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +8 -0
  105. data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +1 -0
  106. data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +1 -0
  107. data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +1 -0
  108. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +6 -0
  109. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +12 -0
  110. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +9 -0
  111. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +8 -0
  112. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +47 -0
  113. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +6 -0
  114. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +7 -0
  115. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +9 -0
  116. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +14 -0
  117. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +5 -0
  118. data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +12 -0
  119. data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +3 -0
  120. data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +6 -0
  121. data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +7 -0
  122. data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +3 -0
  123. data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +3 -0
  124. data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +3 -0
  125. data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +36 -0
  126. data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +42 -0
  127. data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +3 -0
  128. data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +10 -0
  129. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +3 -0
  130. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +3 -0
  131. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +6 -0
  132. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +9 -0
  133. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +11 -0
  134. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +11 -0
  135. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +11 -0
  136. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +7 -0
  137. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +3 -0
  138. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +3 -0
  139. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +21 -0
  140. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +31 -0
  141. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +24 -0
  142. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +24 -0
  143. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +25 -0
  144. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +31 -0
  145. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +17 -0
  146. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +6 -0
  147. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +11 -0
  148. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +6 -0
  149. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +29 -0
  150. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +7 -0
  151. data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +10 -0
  152. data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +3 -0
  153. data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +12 -0
  154. data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +10 -0
  155. data/templates/app_root/scripts/r.js/build/tests/order.build.js +16 -0
  156. data/templates/app_root/scripts/r.js/build/tests/override/override.js +36 -0
  157. data/templates/app_root/scripts/r.js/build/tests/packages.build.js +59 -0
  158. data/templates/app_root/scripts/r.js/build/tests/parse.js +103 -0
  159. data/templates/app_root/scripts/r.js/build/tests/simple.build.js +13 -0
  160. data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +17 -0
  161. data/templates/app_root/scripts/r.js/build/tests/start.frag +4 -0
  162. data/templates/app_root/scripts/r.js/build/tests/text.build.js +16 -0
  163. data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +16 -0
  164. data/templates/app_root/scripts/r.js/dist.js +95 -0
  165. data/templates/app_root/scripts/r.js/dist/README.md +6 -0
  166. data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +9042 -0
  167. data/templates/app_root/scripts/r.js/dist/r-edge.js +9191 -0
  168. data/templates/app_root/scripts/r.js/dist/r.js +9099 -0
  169. data/templates/app_root/scripts/r.js/lib/closure/COPYING +202 -0
  170. data/templates/app_root/scripts/r.js/lib/closure/README +292 -0
  171. data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
  172. data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +4 -0
  173. data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
  174. data/templates/app_root/scripts/r.js/require.js +1952 -0
  175. data/templates/app_root/scripts/r.js/tasks.txt +2 -0
  176. data/templates/app_root/scripts/r.js/tests/all.js +49 -0
  177. data/templates/app_root/scripts/r.js/tests/allNode.js +3 -0
  178. data/templates/app_root/scripts/r.js/tests/allj.sh +1 -0
  179. data/templates/app_root/scripts/r.js/tests/alln.sh +2 -0
  180. data/templates/app_root/scripts/r.js/tests/alpha.js +3 -0
  181. data/templates/app_root/scripts/r.js/tests/beta.js +6 -0
  182. data/templates/app_root/scripts/r.js/tests/doh/LICENSE +195 -0
  183. data/templates/app_root/scripts/r.js/tests/doh/README +12 -0
  184. data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +855 -0
  185. data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +20 -0
  186. data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +17 -0
  187. data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +10 -0
  188. data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
  189. data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
  190. data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
  191. data/templates/app_root/scripts/r.js/tests/doh/runner.html +316 -0
  192. data/templates/app_root/scripts/r.js/tests/doh/runner.js +1499 -0
  193. data/templates/app_root/scripts/r.js/tests/doh/runner.sh +3 -0
  194. data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
  195. data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +39 -0
  196. data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +15 -0
  197. data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +1 -0
  198. data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +13 -0
  199. data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +13 -0
  200. data/templates/app_root/scripts/r.js/tests/node/index.js +11 -0
  201. data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +6 -0
  202. data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +9 -0
  203. data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +3 -0
  204. data/templates/app_root/scripts/r.js/tests/node/tests/server.js +11 -0
  205. data/templates/app_root/scripts/r.js/tests/relative.js +10 -0
  206. data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +3 -0
  207. data/templates/application.js +6 -5
  208. data/templates/boot.js +42 -0
  209. data/templates/helper.js +9 -0
  210. data/templates/index.html +1 -1
  211. metadata +201 -11
  212. data/dist/jazz/main.js +0 -65
  213. data/dist/mustache/mustache.js +0 -324
  214. data/templates/app_root/config/routes.js +0 -4
  215. data/templates/glue.js +0 -4
@@ -0,0 +1,2 @@
1
+ * Need more docs on optimizeAllPluginResources?
2
+ * allow for npm install
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
+ * Available via the MIT or new BSD license.
4
+ * see: http://github.com/jrburke/requirejs for details
5
+ */
6
+
7
+ /**
8
+ * BUILD r.js IN THIS DIRECTORY FIRST BEFORE RUNNING THIS FILE
9
+ *
10
+ * To run in Node:
11
+ * node ../r.js all.js
12
+ *
13
+ * To run in Rhino:
14
+ * java -jar ../../build/lib/rhino/js.jar ../r.js all.js
15
+ * Debug:
16
+ * java -classpath ../../build/lib/rhino/js.jar org.mozilla.javascript.tools.debugger.Main ../r.js all.js
17
+ */
18
+
19
+ /*jslint strict: false */
20
+ /*global require: false, doh: false */
21
+
22
+ //Special global flag used by DOH.
23
+ skipDohSetup = true;
24
+
25
+ require({
26
+ paths: {
27
+ env: '../build/jslib/env'
28
+ }
29
+ }, [
30
+ 'alpha',
31
+ 'beta',
32
+ 'doh/runner',
33
+ 'env!doh/_{env}Runner'
34
+ ], function (alpha, beta, a) {
35
+
36
+ doh.register('rjsTests',
37
+ [
38
+ function rjsTests(t) {
39
+ t.is('alpha', alpha.name);
40
+ t.is('beta', beta.name);
41
+ t.is('betaSubName', beta.subName);
42
+ }
43
+ ]
44
+ );
45
+ doh.run();
46
+
47
+ //Print out the test summary.
48
+ doh.run();
49
+ });
@@ -0,0 +1,3 @@
1
+ var requirejs = require('../r.js');
2
+
3
+ requirejs(['./all']);
@@ -0,0 +1 @@
1
+ java -classpath ../lib/rhino/js.jar:../lib/closure.compiler.jar org.mozilla.javascript.tools.shell.Main ../r.js all.js
@@ -0,0 +1,2 @@
1
+ node allNode.js
2
+ node ../r.js all.js
@@ -0,0 +1,3 @@
1
+ define(function(require, exports) {
2
+ exports.name = 'alpha';
3
+ });
@@ -0,0 +1,6 @@
1
+ define(['./sub/betaSub'], function (betaSub) {
2
+ return {
3
+ name: 'beta',
4
+ subName: betaSub.name
5
+ };
6
+ });
@@ -0,0 +1,195 @@
1
+ Dojo is available under *either* the terms of the modified BSD license *or* the
2
+ Academic Free License version 2.1. As a recipient of Dojo, you may choose which
3
+ license to receive this code under (except as noted in per-module LICENSE
4
+ files). Some modules may not be the copyright of the Dojo Foundation. These
5
+ modules contain explicit declarations of copyright in both the LICENSE files in
6
+ the directories in which they reside and in the code itself. No external
7
+ contributions are allowed under licenses which are fundamentally incompatible
8
+ with the AFL or BSD licenses that Dojo is distributed under.
9
+
10
+ The text of the AFL and BSD licenses is reproduced below.
11
+
12
+ -------------------------------------------------------------------------------
13
+ The "New" BSD License:
14
+ **********************
15
+
16
+ Copyright (c) 2005-2009, The Dojo Foundation
17
+ All rights reserved.
18
+
19
+ Redistribution and use in source and binary forms, with or without
20
+ modification, are permitted provided that the following conditions are met:
21
+
22
+ * Redistributions of source code must retain the above copyright notice, this
23
+ list of conditions and the following disclaimer.
24
+ * Redistributions in binary form must reproduce the above copyright notice,
25
+ this list of conditions and the following disclaimer in the documentation
26
+ and/or other materials provided with the distribution.
27
+ * Neither the name of the Dojo Foundation nor the names of its contributors
28
+ may be used to endorse or promote products derived from this software
29
+ without specific prior written permission.
30
+
31
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
32
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
35
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
37
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
+
42
+ -------------------------------------------------------------------------------
43
+ The Academic Free License, v. 2.1:
44
+ **********************************
45
+
46
+ This Academic Free License (the "License") applies to any original work of
47
+ authorship (the "Original Work") whose owner (the "Licensor") has placed the
48
+ following notice immediately following the copyright notice for the Original
49
+ Work:
50
+
51
+ Licensed under the Academic Free License version 2.1
52
+
53
+ 1) Grant of Copyright License. Licensor hereby grants You a world-wide,
54
+ royalty-free, non-exclusive, perpetual, sublicenseable license to do the
55
+ following:
56
+
57
+ a) to reproduce the Original Work in copies;
58
+
59
+ b) to prepare derivative works ("Derivative Works") based upon the Original
60
+ Work;
61
+
62
+ c) to distribute copies of the Original Work and Derivative Works to the
63
+ public;
64
+
65
+ d) to perform the Original Work publicly; and
66
+
67
+ e) to display the Original Work publicly.
68
+
69
+ 2) Grant of Patent License. Licensor hereby grants You a world-wide,
70
+ royalty-free, non-exclusive, perpetual, sublicenseable license, under patent
71
+ claims owned or controlled by the Licensor that are embodied in the Original
72
+ Work as furnished by the Licensor, to make, use, sell and offer for sale the
73
+ Original Work and Derivative Works.
74
+
75
+ 3) Grant of Source Code License. The term "Source Code" means the preferred
76
+ form of the Original Work for making modifications to it and all available
77
+ documentation describing how to modify the Original Work. Licensor hereby
78
+ agrees to provide a machine-readable copy of the Source Code of the Original
79
+ Work along with each copy of the Original Work that Licensor distributes.
80
+ Licensor reserves the right to satisfy this obligation by placing a
81
+ machine-readable copy of the Source Code in an information repository
82
+ reasonably calculated to permit inexpensive and convenient access by You for as
83
+ long as Licensor continues to distribute the Original Work, and by publishing
84
+ the address of that information repository in a notice immediately following
85
+ the copyright notice that applies to the Original Work.
86
+
87
+ 4) Exclusions From License Grant. Neither the names of Licensor, nor the names
88
+ of any contributors to the Original Work, nor any of their trademarks or
89
+ service marks, may be used to endorse or promote products derived from this
90
+ Original Work without express prior written permission of the Licensor. Nothing
91
+ in this License shall be deemed to grant any rights to trademarks, copyrights,
92
+ patents, trade secrets or any other intellectual property of Licensor except as
93
+ expressly stated herein. No patent license is granted to make, use, sell or
94
+ offer to sell embodiments of any patent claims other than the licensed claims
95
+ defined in Section 2. No right is granted to the trademarks of Licensor even if
96
+ such marks are included in the Original Work. Nothing in this License shall be
97
+ interpreted to prohibit Licensor from licensing under different terms from this
98
+ License any Original Work that Licensor otherwise would have a right to
99
+ license.
100
+
101
+ 5) This section intentionally omitted.
102
+
103
+ 6) Attribution Rights. You must retain, in the Source Code of any Derivative
104
+ Works that You create, all copyright, patent or trademark notices from the
105
+ Source Code of the Original Work, as well as any notices of licensing and any
106
+ descriptive text identified therein as an "Attribution Notice." You must cause
107
+ the Source Code for any Derivative Works that You create to carry a prominent
108
+ Attribution Notice reasonably calculated to inform recipients that You have
109
+ modified the Original Work.
110
+
111
+ 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that
112
+ the copyright in and to the Original Work and the patent rights granted herein
113
+ by Licensor are owned by the Licensor or are sublicensed to You under the terms
114
+ of this License with the permission of the contributor(s) of those copyrights
115
+ and patent rights. Except as expressly stated in the immediately proceeding
116
+ sentence, the Original Work is provided under this License on an "AS IS" BASIS
117
+ and WITHOUT WARRANTY, either express or implied, including, without limitation,
118
+ the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
119
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU.
120
+ This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No
121
+ license to Original Work is granted hereunder except under this disclaimer.
122
+
123
+ 8) Limitation of Liability. Under no circumstances and under no legal theory,
124
+ whether in tort (including negligence), contract, or otherwise, shall the
125
+ Licensor be liable to any person for any direct, indirect, special, incidental,
126
+ or consequential damages of any character arising as a result of this License
127
+ or the use of the Original Work including, without limitation, damages for loss
128
+ of goodwill, work stoppage, computer failure or malfunction, or any and all
129
+ other commercial damages or losses. This limitation of liability shall not
130
+ apply to liability for death or personal injury resulting from Licensor's
131
+ negligence to the extent applicable law prohibits such limitation. Some
132
+ jurisdictions do not allow the exclusion or limitation of incidental or
133
+ consequential damages, so this exclusion and limitation may not apply to You.
134
+
135
+ 9) Acceptance and Termination. If You distribute copies of the Original Work or
136
+ a Derivative Work, You must make a reasonable effort under the circumstances to
137
+ obtain the express assent of recipients to the terms of this License. Nothing
138
+ else but this License (or another written agreement between Licensor and You)
139
+ grants You permission to create Derivative Works based upon the Original Work
140
+ or to exercise any of the rights granted in Section 1 herein, and any attempt
141
+ to do so except under the terms of this License (or another written agreement
142
+ between Licensor and You) is expressly prohibited by U.S. copyright law, the
143
+ equivalent laws of other countries, and by international treaty. Therefore, by
144
+ exercising any of the rights granted to You in Section 1 herein, You indicate
145
+ Your acceptance of this License and all of its terms and conditions.
146
+
147
+ 10) Termination for Patent Action. This License shall terminate automatically
148
+ and You may no longer exercise any of the rights granted to You by this License
149
+ as of the date You commence an action, including a cross-claim or counterclaim,
150
+ against Licensor or any licensee alleging that the Original Work infringes a
151
+ patent. This termination provision shall not apply for an action alleging
152
+ patent infringement by combinations of the Original Work with other software or
153
+ hardware.
154
+
155
+ 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this
156
+ License may be brought only in the courts of a jurisdiction wherein the
157
+ Licensor resides or in which Licensor conducts its primary business, and under
158
+ the laws of that jurisdiction excluding its conflict-of-law provisions. The
159
+ application of the United Nations Convention on Contracts for the International
160
+ Sale of Goods is expressly excluded. Any use of the Original Work outside the
161
+ scope of this License or after its termination shall be subject to the
162
+ requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et
163
+ seq., the equivalent laws of other countries, and international treaty. This
164
+ section shall survive the termination of this License.
165
+
166
+ 12) Attorneys Fees. In any action to enforce the terms of this License or
167
+ seeking damages relating thereto, the prevailing party shall be entitled to
168
+ recover its costs and expenses, including, without limitation, reasonable
169
+ attorneys' fees and costs incurred in connection with such action, including
170
+ any appeal of such action. This section shall survive the termination of this
171
+ License.
172
+
173
+ 13) Miscellaneous. This License represents the complete agreement concerning
174
+ the subject matter hereof. If any provision of this License is held to be
175
+ unenforceable, such provision shall be reformed only to the extent necessary to
176
+ make it enforceable.
177
+
178
+ 14) Definition of "You" in This License. "You" throughout this License, whether
179
+ in upper or lower case, means an individual or a legal entity exercising rights
180
+ under, and complying with all of the terms of, this License. For legal
181
+ entities, "You" includes any entity that controls, is controlled by, or is
182
+ under common control with you. For purposes of this definition, "control" means
183
+ (i) the power, direct or indirect, to cause the direction or management of such
184
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
185
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of such
186
+ entity.
187
+
188
+ 15) Right to Use. You may use the Original Work in all ways not otherwise
189
+ restricted or conditioned by this License or by law, and Licensor promises not
190
+ to interfere with or be responsible for such uses by You.
191
+
192
+ This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved.
193
+ Permission is hereby granted to copy and distribute this license without
194
+ modification. This license may not be modified without the express written
195
+ permission of its copyright owner.
@@ -0,0 +1,12 @@
1
+ DOH may be run standalone by issuing a command like the following:
2
+
3
+ java -jar ../shrinksafe/js.jar runner.js testModule=tests.colors
4
+
5
+ where the testModule argument is optional and shrinksafe/js.jar is just a
6
+ convenient copy of the Rhino JavaScript engine -- the custom patch is not
7
+ required.
8
+
9
+ Optional arguments include:
10
+ * dojoUrl - specifies the location of dojo.js
11
+ * testUrl - specifies a Javascript file to load with initialization code
12
+ * testModule - specifies a test module in the dojo package namespace
@@ -0,0 +1,855 @@
1
+ if(window["dojo"]){
2
+ dojo.provide("doh._browserRunner");
3
+ }
4
+
5
+ // FIXME: need to add prompting for monkey-do testing
6
+
7
+ (function(){
8
+
9
+ doh.setTimeout = function (fn, time) {
10
+ return setTimeout(fn, time);
11
+ };
12
+
13
+ try{
14
+ var topdog = (window.parent == window) || !Boolean(window.parent.doh);
15
+ }catch(e){
16
+ //can't access window.parent.doh, then consider ourselves as topdog
17
+ topdog=true;
18
+ }
19
+ if(topdog){
20
+ // we're the top-dog window.
21
+
22
+ // borrowed from Dojo, etc.
23
+ var byId = function(id){
24
+ return document.getElementById(id);
25
+ };
26
+
27
+ var _addOnEvt = function( type, // string
28
+ refOrName, // function or string
29
+ scope){ // object, defaults is window
30
+
31
+ if(!scope){ scope = window; }
32
+
33
+ var funcRef = refOrName;
34
+ if(typeof refOrName == "string"){
35
+ funcRef = scope[refOrName];
36
+ }
37
+ var enclosedFunc = function(){ return funcRef.apply(scope, arguments); };
38
+
39
+ if((window["dojo"])&&(type == "load")){
40
+ dojo.addOnLoad(enclosedFunc);
41
+ }else{
42
+ if(window["attachEvent"]){
43
+ window.attachEvent("on"+type, enclosedFunc);
44
+ }else if(window["addEventListener"]){
45
+ window.addEventListener(type, enclosedFunc, false);
46
+ }else if(document["addEventListener"]){
47
+ document.addEventListener(type, enclosedFunc, false);
48
+ }
49
+ }
50
+ };
51
+
52
+ //
53
+ // Over-ride or implement base runner.js-provided methods
54
+ //
55
+ var escapeXml = function(str){
56
+ //summary:
57
+ // Adds escape sequences for special characters in XML: &<>"'
58
+ // Optionally skips escapes for single quotes
59
+ return str.replace(/&/gm, "&amp;").replace(/</gm, "&lt;").replace(/>/gm, "&gt;").replace(/"/gm, "&quot;"); // string
60
+ };
61
+
62
+ var _logBacklog = [], _loggedMsgLen = 0;
63
+ var sendToLogPane = function(args, skip){
64
+ var msg = "";
65
+ for(var x=0; x<args.length; x++){
66
+ msg += " "+args[x];
67
+ }
68
+
69
+ msg = escapeXml(msg);
70
+
71
+ // workarounds for IE. Wheeee!!!
72
+ msg = msg.replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;")
73
+ .replace(" ", "&nbsp;")
74
+ .replace("\n", "<br>&nbsp;");
75
+ if(!byId("logBody")){
76
+ _logBacklog.push(msg);
77
+ return;
78
+ }else if(_logBacklog.length && !skip){
79
+ var tm;
80
+ while((tm=_logBacklog.shift())){
81
+ sendToLogPane(tm, true);
82
+ }
83
+ }
84
+ var logBody=byId("logBody");
85
+ var tn = document.createElement("div");
86
+ tn.innerHTML = msg;
87
+ //tn.id="logmsg_"+logBody.childNodes.length;
88
+ logBody.appendChild(tn);
89
+ _loggedMsgLen++;
90
+ }
91
+
92
+ var findTarget = function(n){
93
+ while(n && !n.getAttribute('_target')){
94
+ n=n.parentNode;
95
+ if(!n.getAttribute){
96
+ n=null;
97
+ }
98
+ }
99
+ return n;
100
+ }
101
+
102
+ doh._jumpToLog = function(e){
103
+ //console.log(e);
104
+
105
+ var node = findTarget(e?e.target:window.event.srcElement);
106
+ if(!node){
107
+ return;
108
+ }
109
+ var _t = Number(node.getAttribute('_target'));
110
+ var lb = byId("logBody");
111
+ if(_t>=lb.childNodes.length){
112
+ return;
113
+ }
114
+ var t = lb.childNodes[_t];
115
+ t.scrollIntoView();
116
+ if(window.dojo){
117
+ //t.parentNode.parentNode is <div class="tabBody">, only it has a explicitly set background-color,
118
+ //all children of it are transparent
119
+ var bgColor = dojo.style(t.parentNode.parentNode,'backgroundColor');
120
+ //node.parentNode is the tr which has background-color set explicitly
121
+ var hicolor = dojo.style(node.parentNode,'backgroundColor');
122
+ var unhilight = dojo.animateProperty({
123
+ node: t,
124
+ duration: 500,
125
+ properties:
126
+ {
127
+ backgroundColor: { start:hicolor, end: bgColor }
128
+ },
129
+ onEnd: function(){
130
+ t.style.backgroundColor="";
131
+ }
132
+ });
133
+ var hilight = dojo.animateProperty({
134
+ node: t,
135
+ duration: 500,
136
+ properties:
137
+ {
138
+ backgroundColor: { start:bgColor, end: hicolor }
139
+ },
140
+ onEnd: function(){
141
+ unhilight.play();
142
+ }
143
+ });
144
+ hilight.play();
145
+ }
146
+ };
147
+
148
+ doh._jumpToSuite = function(e){
149
+ var node = findTarget(e ? e.target : window.event.srcElement);
150
+ if(!node){
151
+ return;
152
+ }
153
+ var _g = node.getAttribute('_target');
154
+ var gn = getGroupNode(_g);
155
+ if(!gn){
156
+ return;
157
+ }
158
+ gn.scrollIntoView();
159
+ };
160
+
161
+ doh._init = (function(oi){
162
+ return function(){
163
+ var lb = byId("logBody");
164
+ if(lb){
165
+ // clear the console before each run
166
+ while(lb.firstChild){
167
+ lb.removeChild(lb.firstChild);
168
+ }
169
+ _loggedMsgLen = 0;
170
+ }
171
+ this._totalTime = 0;
172
+ this._suiteCount = 0;
173
+ oi.apply(doh, arguments);
174
+ }
175
+ })(doh._init);
176
+
177
+ doh._setupGroupForRun = (function(os){
178
+ //overload _setupGroupForRun to record which log line to jump to when a suite is clicked
179
+ return function(groupName){
180
+ var tg = doh._groups[groupName];
181
+ doh._curTestCount = tg.length;
182
+ doh._curGroupCount = 1;
183
+ var gn = getGroupNode(groupName);
184
+ if(gn){
185
+ //two lines will be added, scroll the second line into view
186
+ gn.getElementsByTagName("td")[2].setAttribute('_target',_loggedMsgLen+1);
187
+ }
188
+ os.apply(doh,arguments);
189
+ }
190
+ })(doh._setupGroupForRun);
191
+
192
+ doh._report = (function(or){
193
+ //overload _report to insert a tfoot
194
+ return function(){
195
+ var tb = byId("testList");
196
+ if(tb){
197
+ var tfoots=tb.getElementsByTagName('tfoot');
198
+ if(tfoots.length){
199
+ tb.removeChild(tfoots[0]);
200
+ }
201
+ var foot = tb.createTFoot();
202
+ var row = foot.insertRow(-1);
203
+ row.className = 'inProgress';
204
+ var cell=row.insertCell(-1);
205
+ cell.colSpan=2;
206
+ cell.innerHTML="Result";
207
+ cell = row.insertCell(-1);
208
+ cell.innerHTML=this._testCount+" tests in "+this._groupCount+" groups /<span class='failure'>"+this._errorCount+"</span> errors, <span class='failure'>"+this._failureCount+"</span> failures";
209
+ cell.setAttribute('_target',_loggedMsgLen+1);
210
+ row.insertCell(-1).innerHTML=doh._totalTime+"ms";
211
+ }
212
+
213
+ //This location can do the final performance rendering for the results
214
+ //of any performance tests.
215
+ var plotResults = null;
216
+ var standby;
217
+ if(doh.perfTestResults){
218
+ if(window.dojo){
219
+ //If we have dojo and here are perf tests results,
220
+ //well, we'll use the dojo charting functions
221
+ dojo.require("dojox.charting.Chart2D");
222
+ dojo.require("dojox.charting.DataChart");
223
+ dojo.require("dojox.charting.plot2d.Scatter");
224
+ dojo.require("dojox.charting.plot2d.Lines");
225
+ dojo.require("dojo.data.ItemFileReadStore");
226
+ plotResults = doh._dojoPlotPerfResults;
227
+ }else{
228
+ plotResults = doh._asciiPlotPerfResults;
229
+ }
230
+ try{
231
+ var g;
232
+ var pBody = byId("perfTestsBody");
233
+ var chartsToRender = [];
234
+
235
+ if(doh.perfTestResults){
236
+ doh.showPerfTestsPage();
237
+ }
238
+ for(g in doh.perfTestResults){
239
+ var grp = doh.perfTestResults[g];
240
+ var hdr = document.createElement("h1");
241
+ hdr.appendChild(document.createTextNode("Group: " + g));
242
+ pBody.appendChild(hdr);
243
+ var ind = document.createElement("blockquote");
244
+ pBody.appendChild(ind);
245
+ var f;
246
+ for(f in grp){
247
+ var fResults = grp[f];
248
+ if(!fResults){ continue; }
249
+ var fhdr = document.createElement("h3");
250
+ fhdr.appendChild(document.createTextNode("TEST: " + f));
251
+ fhdr.style.textDecoration = "underline";
252
+ ind.appendChild(fhdr);
253
+ var div = document.createElement("div");
254
+ ind.appendChild(div);
255
+
256
+ //Figure out the basic info
257
+ var results = "<b>TRIAL SIZE: </b>" + fResults.trials[0].testIterations + " iterations<br>" +
258
+ "<b>NUMBER OF TRIALS: </b>" + fResults.trials.length + "<br>";
259
+
260
+ //Figure out the average test pass cost.
261
+ var i;
262
+ var iAvgArray = [];
263
+ var tAvgArray = [];
264
+ for(i = 0; i < fResults.trials.length; i++){
265
+ iAvgArray.push(fResults.trials[i].average);
266
+ tAvgArray.push(fResults.trials[i].executionTime);
267
+ }
268
+ results += "<b>AVERAGE TRIAL EXECUTION TIME: </b>" + doh.average(tAvgArray).toFixed(10) + "ms.<br>";
269
+ results += "<b>MAXIMUM TEST ITERATION TIME: </b>" + doh.max(iAvgArray).toFixed(10) + "ms.<br>";
270
+ results += "<b>MINIMUM TEST ITERATION TIME: </b>" + doh.min(iAvgArray).toFixed(10) + "ms.<br>";
271
+ results += "<b>AVERAGE TEST ITERATION TIME: </b>" + doh.average(iAvgArray).toFixed(10) + "ms.<br>";
272
+ results += "<b>MEDIAN TEST ITERATION TIME: </b>" + doh.median(iAvgArray).toFixed(10) + "ms.<br>";
273
+ results += "<b>VARIANCE TEST ITERATION TIME: </b>" + doh.variance(iAvgArray).toFixed(10) + "ms.<br>";
274
+ results += "<b>STANDARD DEVIATION ON TEST ITERATION TIME: </b>" + doh.standardDeviation(iAvgArray).toFixed(10) + "ms.<br>";
275
+
276
+ //Okay, attach it all in.
277
+ div.innerHTML = results;
278
+
279
+ div = document.createElement("div");
280
+ div.innerHTML = "<h3>Average Test Execution Time (in milliseconds, with median line)</h3>";
281
+ ind.appendChild(div);
282
+ div = document.createElement("div");
283
+ dojo.style(div, "width", "600px");
284
+ dojo.style(div, "height", "250px");
285
+ ind.appendChild(div);
286
+ chartsToRender.push({
287
+ div: div,
288
+ title: "Average Test Execution Time",
289
+ data: iAvgArray
290
+ });
291
+
292
+ div = document.createElement("div");
293
+ div.innerHTML = "<h3>Average Trial Execution Time (in milliseconds, with median line)</h3>";
294
+ ind.appendChild(div);
295
+ div = document.createElement("div");
296
+ dojo.style(div, "width", "600px");
297
+ dojo.style(div, "height", "250px");
298
+ ind.appendChild(div);
299
+ chartsToRender.push({
300
+ div: div,
301
+ title: "Average Trial Execution Time",
302
+ data: tAvgArray
303
+ });
304
+ }
305
+ }
306
+
307
+ //Lazy-render these to give the browser time and not appear locked.
308
+ var delayedRenders = function() {
309
+ if(chartsToRender.length){
310
+ var chartData = chartsToRender.shift();
311
+ plotResults(chartData.div, chartData.title, chartData.data);
312
+ }
313
+ doh.setTimeout(delayedRenders, 50);
314
+ };
315
+ doh.setTimeout(delayedRenders, 150);
316
+ }catch(e){
317
+ doh.debug(e);
318
+ }
319
+ }
320
+ or.apply(doh,arguments);
321
+ }
322
+ })(doh._report);
323
+
324
+ if(this["opera"] && opera.postError){
325
+ doh.debug = function(){
326
+ var msg = "";
327
+ for(var x=0; x<arguments.length; x++){
328
+ msg += " "+arguments[x];
329
+ }
330
+ sendToLogPane([msg]);
331
+ opera.postError("DEBUG:"+msg);
332
+ }
333
+ }else if(window["console"]){
334
+ doh.debug = function(){
335
+ var msg = "";
336
+ for(var x=0; x<arguments.length; x++){
337
+ msg += " "+arguments[x];
338
+ }
339
+ sendToLogPane([msg]);
340
+ console.log("DEBUG:"+msg);
341
+ };
342
+ }else{
343
+ doh.debug = function(){
344
+ sendToLogPane.call(window, arguments);
345
+ }
346
+ }
347
+
348
+ var loaded = false;
349
+ var groupTemplate = null;
350
+ var testTemplate = null;
351
+
352
+ var groupNodes = {};
353
+
354
+ var _groupTogglers = {};
355
+
356
+ var _getGroupToggler = function(group, toggle){
357
+ if(_groupTogglers[group]){ return _groupTogglers[group]; }
358
+ var rolledUp = true;
359
+ return (_groupTogglers[group] = function(evt, forceOpen){
360
+ var nodes = groupNodes[group].__items;
361
+ var x;
362
+ if(rolledUp||forceOpen){
363
+ rolledUp = false;
364
+ for(x=0; x<nodes.length; x++){
365
+ nodes[x].style.display = "";
366
+ }
367
+ toggle.innerHTML = "&#9660;";
368
+ }else{
369
+ rolledUp = true;
370
+ for(x=0; x<nodes.length; x++){
371
+ nodes[x].style.display = "none";
372
+ }
373
+ toggle.innerHTML = "&#9658;";
374
+ }
375
+ });
376
+ };
377
+
378
+ var addGroupToList = function(group){
379
+ if(!byId("testList")){ return; }
380
+ var tb = byId("testList").tBodies[0];
381
+ var tg = groupTemplate.cloneNode(true);
382
+ var tds = tg.getElementsByTagName("td");
383
+ var toggle = tds[0];
384
+ toggle.onclick = _getGroupToggler(group, toggle);
385
+ var cb = tds[1].getElementsByTagName("input")[0];
386
+ cb.group = group;
387
+ cb.onclick = function(evt){
388
+ doh._groups[group].skip = (!this.checked);
389
+ }
390
+ tds[2].innerHTML = "<div class='testGroupName'>"+group+"</div><div style='width:0;'>&nbsp;</div>";
391
+ tds[3].innerHTML = "";
392
+
393
+ tb.appendChild(tg);
394
+ return tg;
395
+ }
396
+
397
+ var addFixtureToList = function(group, fixture){
398
+ if(!testTemplate){ return; }
399
+ var cgn = groupNodes[group];
400
+ if(!cgn["__items"]){ cgn.__items = []; }
401
+ var tn = testTemplate.cloneNode(true);
402
+ var tds = tn.getElementsByTagName("td");
403
+
404
+ tds[2].innerHTML = fixture.name;
405
+ tds[3].innerHTML = "";
406
+
407
+ var nn = (cgn.__lastFixture||cgn.__groupNode).nextSibling;
408
+ if(nn){
409
+ nn.parentNode.insertBefore(tn, nn);
410
+ }else{
411
+ cgn.__groupNode.parentNode.appendChild(tn);
412
+ }
413
+ // FIXME: need to make group display toggleable!!
414
+ tn.style.display = "none";
415
+ cgn.__items.push(tn);
416
+ return (cgn.__lastFixture = tn);
417
+ }
418
+
419
+ var getFixtureNode = function(group, fixture){
420
+ if(groupNodes[group]){
421
+ return groupNodes[group][fixture.name];
422
+ }
423
+ return null;
424
+ }
425
+
426
+ var getGroupNode = function(group){
427
+ if(groupNodes[group]){
428
+ return groupNodes[group].__groupNode;
429
+ }
430
+ return null;
431
+ }
432
+
433
+ var updateBacklog = [];
434
+ doh._updateTestList = function(group, fixture, unwindingBacklog){
435
+ if(!loaded){
436
+ if(group && fixture){
437
+ updateBacklog.push([group, fixture]);
438
+ }
439
+ return;
440
+ }else if(updateBacklog.length && !unwindingBacklog){
441
+ var tr;
442
+ while((tr=updateBacklog.shift())){
443
+ doh._updateTestList(tr[0], tr[1], true);
444
+ }
445
+ }
446
+ if(group && fixture){
447
+ if(!groupNodes[group]){
448
+ groupNodes[group] = {
449
+ "__groupNode": addGroupToList(group)
450
+ };
451
+ }
452
+ if(!groupNodes[group][fixture.name]){
453
+ groupNodes[group][fixture.name] = addFixtureToList(group, fixture)
454
+ }
455
+ }
456
+ }
457
+
458
+ doh._testRegistered = doh._updateTestList;
459
+
460
+ doh._groupStarted = function(group){
461
+ if(this._suiteCount == 0){
462
+ this._runedSuite = 0;
463
+ this._currentGlobalProgressBarWidth = 0;
464
+ this._suiteCount = this._testCount;
465
+ }
466
+ // console.debug("_groupStarted", group);
467
+ if(doh._inGroup != group){
468
+ doh._groupTotalTime = 0;
469
+ doh._runed = 0;
470
+ doh._inGroup = group;
471
+ this._runedSuite++;
472
+ }
473
+ var gn = getGroupNode(group);
474
+ if(gn){
475
+ gn.className = "inProgress";
476
+ }
477
+ }
478
+
479
+ doh._groupFinished = function(group, success){
480
+ // console.debug("_groupFinished", group);
481
+ var gn = getGroupNode(group);
482
+ if(gn && doh._inGroup == group){
483
+ doh._totalTime += doh._groupTotalTime;
484
+ gn.getElementsByTagName("td")[3].innerHTML = doh._groupTotalTime+"ms";
485
+ gn.getElementsByTagName("td")[2].lastChild.className = "";
486
+ doh._inGroup = null;
487
+ //doh._runedSuite++;
488
+ var failure = doh._updateGlobalProgressBar(this._runedSuite/this._groupCount,success,group);
489
+ gn.className = failure ? "failure" : "success";
490
+ //doh._runedSuite--;
491
+ doh._currentGlobalProgressBarWidth = parseInt(this._runedSuite/this._groupCount*10000)/100;
492
+ //byId("progressOuter").style.width = parseInt(this._runedSuite/this._suiteCount*100)+"%";
493
+ }
494
+ if(doh._inGroup == group){
495
+ this.debug("Total time for GROUP \"",group,"\" is ",doh._groupTotalTime,"ms");
496
+ }
497
+ }
498
+
499
+ doh._testStarted = function(group, fixture){
500
+ // console.debug("_testStarted", group, fixture.name);
501
+ var fn = getFixtureNode(group, fixture);
502
+ if(fn){
503
+ fn.className = "inProgress";
504
+ }
505
+ }
506
+
507
+ var _nameTimes = {};
508
+ var _playSound = function(name){
509
+ if(byId("hiddenAudio") && byId("audio") && byId("audio").checked){
510
+ // console.debug("playing:", name);
511
+ var nt = _nameTimes[name];
512
+ // only play sounds once every second or so
513
+ if((!nt)||(((new Date)-nt) > 700)){
514
+ _nameTimes[name] = new Date();
515
+ var tc = document.createElement("span");
516
+ byId("hiddenAudio").appendChild(tc);
517
+ tc.innerHTML = '<embed src="_sounds/'+name+'.wav" autostart="true" loop="false" hidden="true" width="1" height="1"></embed>';
518
+ }
519
+ }
520
+ }
521
+
522
+ doh._updateGlobalProgressBar = function(p,success,group){
523
+ var outerContainer=byId("progressOuter");
524
+
525
+ var gdiv=outerContainer.childNodes[doh._runedSuite-1];
526
+ if(!gdiv){
527
+ gdiv=document.createElement('div');
528
+ outerContainer.appendChild(gdiv);
529
+ gdiv.className='success';
530
+ gdiv.setAttribute('_target',group);
531
+ }
532
+ if(!success && !gdiv._failure){
533
+ gdiv._failure=true;
534
+ gdiv.className='failure';
535
+ if(group){
536
+ gdiv.setAttribute('title','failed group '+group);
537
+ }
538
+ }
539
+ var tp=parseInt(p*10000)/100;
540
+ gdiv.style.width = (tp-doh._currentGlobalProgressBarWidth)+"%";
541
+ return gdiv._failure;
542
+ }
543
+ doh._testFinished = function(group, fixture, success){
544
+ var fn = getFixtureNode(group, fixture);
545
+ var elapsed = fixture.endTime-fixture.startTime;
546
+ if(fn){
547
+ fn.getElementsByTagName("td")[3].innerHTML = elapsed+"ms";
548
+ fn.className = (success) ? "success" : "failure";
549
+ fn.getElementsByTagName("td")[2].setAttribute('_target', _loggedMsgLen);
550
+ if(!success){
551
+ _playSound("doh");
552
+ var gn = getGroupNode(group);
553
+ if(gn){
554
+ gn.className = "failure";
555
+ _getGroupToggler(group)(null, true);
556
+ }
557
+ }
558
+ }
559
+ if(doh._inGroup == group){
560
+ var gn = getGroupNode(group);
561
+ doh._runed++;
562
+ if(gn && doh._curTestCount){
563
+ var p = doh._runed/doh._curTestCount;
564
+ var groupfail = this._updateGlobalProgressBar((doh._runedSuite+p-1)/doh._groupCount,success,group);
565
+
566
+ var pbar = gn.getElementsByTagName("td")[2].lastChild;
567
+ pbar.className = groupfail?"failure":"success";
568
+ pbar.style.width = parseInt(p*100)+"%";
569
+ gn.getElementsByTagName("td")[3].innerHTML = parseInt(p*10000)/100+"%";
570
+ }
571
+ }
572
+ this._groupTotalTime += elapsed;
573
+ this.debug((success ? "PASSED" : "FAILED"), "test:", fixture.name, elapsed, 'ms');
574
+ }
575
+
576
+ // FIXME: move implementation to _browserRunner?
577
+ doh.registerUrl = function( /*String*/ group,
578
+ /*String*/ url,
579
+ /*Integer*/ timeout){
580
+ var tg = new String(group);
581
+ this.register(group, {
582
+ name: url,
583
+ setUp: function(){
584
+ doh.currentGroupName = tg;
585
+ doh.currentGroup = this;
586
+ doh.currentUrl = url;
587
+ this.d = new doh.Deferred();
588
+ doh.currentTestDeferred = this.d;
589
+ doh.showTestPage();
590
+ byId("testBody").src = url;
591
+ },
592
+ timeout: timeout||10000, // 10s
593
+ // timeout: timeout||1000, // 10s
594
+ runTest: function(){
595
+ // FIXME: implement calling into the url's groups here!!
596
+ return this.d;
597
+ },
598
+ tearDown: function(){
599
+ doh.currentGroupName = null;
600
+ doh.currentGroup = null;
601
+ doh.currentTestDeferred = null;
602
+ doh.currentUrl = null;
603
+ // this.d.errback(false);
604
+ // byId("testBody").src = "about:blank";
605
+ doh.showLogPage();
606
+ }
607
+ });
608
+ }
609
+
610
+ //
611
+ // Utility code for runner.html
612
+ //
613
+ // var isSafari = navigator.appVersion.indexOf("Safari") >= 0;
614
+ var tabzidx = 1;
615
+ var _showTab = function(toShow, toHide){
616
+ // FIXME: I don't like hiding things this way.
617
+ var i;
618
+ for(i = 0; i < toHide.length; i++){
619
+ var node = byId(toHide[i]);
620
+ if(node){
621
+ node.style.display="none";
622
+ }
623
+ }
624
+ toShow = byId(toShow);
625
+ if(toShow){
626
+ with(toShow.style){
627
+ display = "";
628
+ zIndex = ++tabzidx;
629
+ }
630
+ }
631
+ }
632
+
633
+ doh.showTestPage = function(){
634
+ _showTab("testBody", ["logBody", "perfTestsBody"]);
635
+ }
636
+
637
+ doh.showLogPage = function(){
638
+ _showTab("logBody", ["testBody", "perfTestsBody"]);
639
+ }
640
+
641
+ doh.showPerfTestsPage = function(){
642
+ _showTab("perfTestsBody", ["testBody", "logBody"]);
643
+ }
644
+
645
+ var runAll = true;
646
+ doh.toggleRunAll = function(){
647
+ // would be easier w/ query...sigh
648
+ runAll = !runAll;
649
+ if(!byId("testList")){ return; }
650
+ var tb = byId("testList").tBodies[0];
651
+ var inputs = tb.getElementsByTagName("input");
652
+ var x=0; var tn;
653
+ while((tn=inputs[x++])){
654
+ tn.checked = runAll;
655
+ doh._groups[tn.group].skip = (!runAll);
656
+ }
657
+ }
658
+
659
+ var listHeightTimer = null;
660
+ var setListHeight = function(){
661
+ if(listHeightTimer){
662
+ clearTimeout(listHeightTimer);
663
+ }
664
+ var tl = byId("testList");
665
+ if(!tl){ return; }
666
+ listHeightTimer = doh.setTimeout(function(){
667
+ tl.style.display = "none";
668
+ tl.style.display = "";
669
+
670
+ }, 10);
671
+ }
672
+
673
+ _addOnEvt("resize", setListHeight);
674
+ _addOnEvt("load", setListHeight);
675
+ _addOnEvt("load", function(){
676
+ if(loaded){ return; }
677
+ loaded = true;
678
+ groupTemplate = byId("groupTemplate");
679
+ if(!groupTemplate){
680
+ // make sure we've got an ammenable DOM structure
681
+ return;
682
+ }
683
+ groupTemplate.parentNode.removeChild(groupTemplate);
684
+ groupTemplate.style.display = "";
685
+ testTemplate = byId("testTemplate");
686
+ testTemplate.parentNode.removeChild(testTemplate);
687
+ testTemplate.style.display = "";
688
+ doh._updateTestList();
689
+ });
690
+
691
+ _addOnEvt("load",
692
+ function(){
693
+ // let robot code run if it gets to this first
694
+ var __onEnd = doh._onEnd;
695
+ doh._onEnd = function(){
696
+ __onEnd.apply(doh, arguments);
697
+ if(doh._failureCount == 0){
698
+ doh.debug("WOOHOO!!");
699
+ _playSound("woohoo");
700
+ }else{
701
+ console.debug("doh._failureCount:", doh._failureCount);
702
+ }
703
+ if(byId("play")){
704
+ toggleRunning();
705
+ }
706
+ }
707
+ if(!byId("play")){
708
+ // make sure we've got an amenable DOM structure
709
+ return;
710
+ }
711
+ var isRunning = false;
712
+ var toggleRunning = function(){
713
+ // ugg, this would be so much better w/ dojo.query()
714
+ if(isRunning){
715
+ byId("play").style.display = byId("pausedMsg").style.display = "";
716
+ byId("playingMsg").style.display = byId("pause").style.display = "none";
717
+ isRunning = false;
718
+ }else{
719
+ byId("play").style.display = byId("pausedMsg").style.display = "none";
720
+ byId("playingMsg").style.display = byId("pause").style.display = "";
721
+ isRunning = true;
722
+ }
723
+ }
724
+ doh.run = (function(oldRun){
725
+ return function(){
726
+ if(!doh._currentGroup){
727
+ toggleRunning();
728
+ }
729
+ return oldRun.apply(doh, arguments);
730
+ }
731
+ })(doh.run);
732
+ var btns = byId("toggleButtons").getElementsByTagName("span");
733
+ var node; var idx=0;
734
+ while((node=btns[idx++])){
735
+ node.onclick = toggleRunning;
736
+ }
737
+
738
+ //Performance report generating functions!
739
+ doh._dojoPlotPerfResults = function(div, name, dataArray) {
740
+ var median = doh.median(dataArray);
741
+ var medarray = [];
742
+
743
+ var i;
744
+ for(i = 0; i < dataArray.length; i++){
745
+ medarray.push(median);
746
+ }
747
+
748
+ var data = {
749
+ label: "name",
750
+ items: [
751
+ {name: name, trials: dataArray},
752
+ {name: "Median", trials: medarray}
753
+ ]
754
+ };
755
+ var ifs = new dojo.data.ItemFileReadStore({data: data});
756
+
757
+ var min = Math.floor(doh.min(dataArray));
758
+ var max = Math.ceil(doh.max(dataArray));
759
+ var step = (max - min)/10;
760
+
761
+ //Lets try to pad out the bottom and top a bit
762
+ //Then recalc the step.
763
+ if(min > 0){
764
+ min = min - step;
765
+ if(min < 0){
766
+ min = 0;
767
+ }
768
+ min = Math.floor(min);
769
+ }
770
+ if(max > 0){
771
+ max = max + step;
772
+ max = Math.ceil(max);
773
+ }
774
+ step = (max - min)/10;
775
+
776
+ var chart = new dojox.charting.DataChart(div, {
777
+ type: dojox.charting.plot2d.Lines,
778
+ displayRange:dataArray.length,
779
+ xaxis: {min: 1, max: dataArray.length, majorTickStep: Math.ceil((dataArray.length - 1)/10), htmlLabels: false},
780
+ yaxis: {min: min, max: max, majorTickStep: step, vertical: true, htmlLabels: false}
781
+ });
782
+ chart.setStore(ifs, {name:"*"}, "trials");
783
+ };
784
+
785
+ doh._asciiPlotPerfResults = function(){
786
+ //TODO: Implement!
787
+ };
788
+ }
789
+ );
790
+ }else{
791
+ // we're in an iframe environment. Time to mix it up a bit.
792
+
793
+ _doh = window.parent.doh;
794
+ var _thisGroup = _doh.currentGroupName;
795
+ var _thisUrl = _doh.currentUrl;
796
+ if(_thisGroup){
797
+ doh._testRegistered = function(group, tObj){
798
+ _doh._updateTestList(_thisGroup, tObj);
799
+ }
800
+ doh._onEnd = function(){
801
+ _doh._errorCount += doh._errorCount;
802
+ _doh._failureCount += doh._failureCount;
803
+ _doh._testCount += doh._testCount;
804
+ // should we be really adding raw group counts?
805
+ //_doh._groupCount += doh._groupCount;
806
+ _doh.currentTestDeferred.callback(true);
807
+ }
808
+ var otr = doh._getTestObj;
809
+ doh._getTestObj = function(){
810
+ var tObj = otr.apply(doh, arguments);
811
+ tObj.name = _thisUrl+"::"+arguments[0]+"::"+tObj.name;
812
+ return tObj;
813
+ }
814
+ doh.debug = doh.hitch(_doh, "debug");
815
+ doh.registerUrl = doh.hitch(_doh, "registerUrl");
816
+ doh._testStarted = function(group, fixture){
817
+ _doh._testStarted(_thisGroup, fixture);
818
+ }
819
+ doh._testFinished = function(g, f, s){
820
+ _doh._testFinished(_thisGroup, f, s);
821
+
822
+ //Okay, there may be performance info we need to filter back
823
+ //to the parent, so do that here.
824
+ if(doh.perfTestResults){
825
+ try{
826
+ gName = g.toString();
827
+ var localFName = f.name;
828
+ while(localFName.indexOf("::") >= 0){
829
+ localFName = localFName.substring(localFName.indexOf("::") + 2, localFName.length);
830
+ }
831
+ if(!_doh.perfTestResults){
832
+ _doh.perfTestResults = {};
833
+ }
834
+ if(!_doh.perfTestResults[gName]){
835
+ _doh.perfTestResults[gName] = {};
836
+ }
837
+ _doh.perfTestResults[gName][f.name] = doh.perfTestResults[gName][localFName];
838
+ }catch (e){
839
+ doh.debug(e);
840
+ }
841
+ }
842
+ }
843
+ doh._groupStarted = function(g){
844
+ if(!this._setParent){
845
+ _doh._curTestCount = this._testCount;
846
+ _doh._curGroupCount = this._groupCount;
847
+ this._setParent = true;
848
+ }
849
+ }
850
+ doh._report = function(){
851
+ };
852
+ }
853
+ }
854
+
855
+ })();