ende 0.5.20 → 0.5.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/component.json +1 -1
  3. data/components/indefinido/indemma/master/.gitignore +17 -0
  4. data/components/indefinido/indemma/master/.ruby-gemset +1 -0
  5. data/components/indefinido/indemma/master/.ruby-version +1 -0
  6. data/components/indefinido/indemma/master/Gemfile +12 -0
  7. data/components/indefinido/indemma/master/Guardfile +39 -0
  8. data/components/indefinido/indemma/master/History.md +0 -0
  9. data/components/indefinido/indemma/master/Readme.md +445 -0
  10. data/components/indefinido/indemma/master/build/development.js +26123 -0
  11. data/components/indefinido/indemma/master/build/release.js +16741 -0
  12. data/components/indefinido/indemma/master/build/test.js +26123 -0
  13. data/components/indefinido/indemma/master/component.json +1 -1
  14. data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/component.json +18 -0
  15. data/components/indefinido/indemma/master/components/chaijs/assertion-error/1.0.0/index.js +110 -0
  16. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.gitignore +22 -0
  17. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.mailmap +1 -0
  18. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.npmignore +14 -0
  19. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/.travis.yml +14 -0
  20. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/CONTRIBUTING.md +173 -0
  21. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/History.md +895 -0
  22. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/Makefile +93 -0
  23. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/README.md +99 -0
  24. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/ReleaseNotes.md +482 -0
  25. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/bower.json +27 -0
  26. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/chai.js +4782 -0
  27. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/component.json +50 -0
  28. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/index.js +1 -0
  29. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.conf.js +28 -0
  30. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/karma.sauce.js +41 -0
  31. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/assertion.js +130 -0
  32. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/config.js +50 -0
  33. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/core/assertions.js +1314 -0
  34. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/assert.js +1056 -0
  35. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/expect.js +12 -0
  36. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/interface/should.js +78 -0
  37. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addChainableMethod.js +111 -0
  38. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addMethod.js +43 -0
  39. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/addProperty.js +40 -0
  40. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/flag.js +32 -0
  41. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getActual.js +18 -0
  42. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getEnumerableProperties.js +25 -0
  43. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getMessage.js +49 -0
  44. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getName.js +20 -0
  45. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getPathValue.js +102 -0
  46. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/getProperties.js +35 -0
  47. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/index.js +114 -0
  48. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/inspect.js +320 -0
  49. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/objDisplay.js +49 -0
  50. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteChainableMethod.js +53 -0
  51. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteMethod.js +51 -0
  52. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/overwriteProperty.js +54 -0
  53. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/test.js +26 -0
  54. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/transferFlags.js +44 -0
  55. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai/utils/type.js +45 -0
  56. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/lib/chai.js +87 -0
  57. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/package.json +42 -0
  58. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/sauce.browsers.js +128 -0
  59. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_block.sh +7 -0
  60. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/support/sauce/sauce_connect_setup.sh +53 -0
  61. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/assert.js +638 -0
  62. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/auth/.gitkeep +0 -0
  63. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/index.js +22 -0
  64. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/bootstrap/karma.js +22 -0
  65. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/configuration.js +133 -0
  66. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/errors.js +14 -0
  67. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/display/message.js +47 -0
  68. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/expect.js +814 -0
  69. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/globalShould.js +15 -0
  70. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/plugins.js +24 -0
  71. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/should.js +744 -0
  72. data/components/indefinido/indemma/master/components/chaijs/chai/1.9.1/test/utilities.js +309 -0
  73. data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/component.json +20 -0
  74. data/components/indefinido/indemma/master/components/chaijs/deep-eql/0.1.3/lib/eql.js +257 -0
  75. data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/component.json +18 -0
  76. data/components/indefinido/indemma/master/components/chaijs/type-detect/0.1.1/lib/type.js +142 -0
  77. data/components/indefinido/indemma/master/components/component/bind/1.0.0/component.json +14 -0
  78. data/components/indefinido/indemma/master/components/component/bind/1.0.0/index.js +23 -0
  79. data/components/indefinido/indemma/master/components/component/jquery/1.0.0/component.json +10 -0
  80. data/components/indefinido/indemma/master/components/component/jquery/1.0.0/index.js +10308 -0
  81. data/components/indefinido/indemma/master/components/component/type/1.0.0/component.json +20 -0
  82. data/components/indefinido/indemma/master/components/component/type/1.0.0/index.js +32 -0
  83. data/components/indefinido/indemma/master/components/indefinido/advisable/master/component.json +21 -0
  84. data/components/indefinido/indemma/master/components/indefinido/advisable/master/index.js +1 -0
  85. data/components/indefinido/indemma/master/components/indefinido/advisable/master/lib/advisable.js +60 -0
  86. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/component.json +39 -0
  87. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/index.js +1 -0
  88. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/adapters/rivets.js +40 -0
  89. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/notifierable.js +145 -0
  90. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/legacy/schedulerable.js +147 -0
  91. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/lookup.js +38 -0
  92. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/keypath_observer.js +38 -0
  93. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/observation.js +45 -0
  94. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/selection.js +57 -0
  95. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable/self_observer.js +38 -0
  96. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/observable.js +97 -0
  97. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/lib/platform.js +12 -0
  98. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/observe-js/observe.js +1631 -0
  99. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors-legacy.js +92 -0
  100. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/accessors.js +248 -0
  101. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/array.indexOf.js +8 -0
  102. data/components/indefinido/indemma/master/components/indefinido/observable/es6-modules/vendor/shims/object.create.js +77 -0
  103. data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/component.json +25 -0
  104. data/components/indefinido/indemma/master/components/pluma/assimilate/0.4.0/dist/assimilate.js +127 -0
  105. data/components/indefinido/indemma/master/karma.conf.js +75 -0
  106. data/components/indefinido/indemma/master/lib/record/associable.js +4 -2
  107. data/components/indefinido/indemma/master/lib/record/dirtyable.js +1 -1
  108. data/components/indefinido/indemma/master/package.json +9 -0
  109. data/components/indefinido/indemma/master/spec/record/associable_spec.js +211 -0
  110. data/components/indefinido/indemma/master/spec/record/dirtyable_spec.js +57 -0
  111. data/components/indefinido/indemma/master/spec/record/maid_spec.js +40 -0
  112. data/components/indefinido/indemma/master/spec/record/persistable_spec.js +46 -0
  113. data/components/indefinido/indemma/master/spec/record/queryable_spec.js +39 -0
  114. data/components/indefinido/indemma/master/spec/record/resource_spec.js +93 -0
  115. data/components/indefinido/indemma/master/spec/record/rest_spec.js +32 -0
  116. data/components/indefinido/indemma/master/spec/record/restfulable_spec.js +346 -0
  117. data/components/indefinido/indemma/master/spec/record/scopable_spec.js +242 -0
  118. data/components/indefinido/indemma/master/spec/record/storable_spec.js +44 -0
  119. data/components/indefinido/indemma/master/spec/record/translationable.js +28 -0
  120. data/components/indefinido/indemma/master/spec/record/validatable_spec.js +142 -0
  121. data/components/indefinido/indemma/master/spec/record/validations/associated_spec.js +43 -0
  122. data/components/indefinido/indemma/master/spec/record/validations/confirmation_spec.js +36 -0
  123. data/components/indefinido/indemma/master/spec/record/validations/cpf_spec.js +34 -0
  124. data/components/indefinido/indemma/master/spec/record/validations/presence_spec.js +28 -0
  125. data/components/indefinido/indemma/master/spec/record/validations/remote_spec.js +87 -0
  126. data/components/indefinido/indemma/master/spec/record/validations/type_spec.js +48 -0
  127. data/components/indefinido/indemma/master/spec/record_spec.js +49 -0
  128. data/components/indefinido/indemma/master/spec/spec_helper.js +15 -0
  129. data/components/indefinido/indemma/master/spec/support/value_objects/phone.js +45 -0
  130. data/components/indefinido/indemma/master/src/lib/extensions/rivets.coffee +17 -0
  131. data/components/indefinido/indemma/master/src/lib/record/associable.coffee +419 -0
  132. data/components/indefinido/indemma/master/src/lib/record/dirtyable.coffee +47 -0
  133. data/components/indefinido/indemma/master/src/lib/record/errors.coffee +20 -0
  134. data/components/indefinido/indemma/master/src/lib/record/maid.coffee +16 -0
  135. data/components/indefinido/indemma/master/src/lib/record/persistable.coffee +34 -0
  136. data/components/indefinido/indemma/master/src/lib/record/queryable.coffee +29 -0
  137. data/components/indefinido/indemma/master/src/lib/record/resource.coffee +107 -0
  138. data/components/indefinido/indemma/master/src/lib/record/rest.coffee +34 -0
  139. data/components/indefinido/indemma/master/src/lib/record/restfulable.coffee +487 -0
  140. data/components/indefinido/indemma/master/src/lib/record/scopable.coffee +279 -0
  141. data/components/indefinido/indemma/master/src/lib/record/storable.coffee +49 -0
  142. data/components/indefinido/indemma/master/src/lib/record/translationable.coffee +18 -0
  143. data/components/indefinido/indemma/master/src/lib/record/validatable.coffee +241 -0
  144. data/components/indefinido/indemma/master/src/lib/record/validations/associated.coffee +34 -0
  145. data/components/indefinido/indemma/master/src/lib/record/validations/confirmation.coffee +17 -0
  146. data/components/indefinido/indemma/master/src/lib/record/validations/cpf.coffee +57 -0
  147. data/components/indefinido/indemma/master/src/lib/record/validations/presence.coffee +16 -0
  148. data/components/indefinido/indemma/master/src/lib/record/validations/remote.coffee +61 -0
  149. data/components/indefinido/indemma/master/src/lib/record/validations/type.coffee +31 -0
  150. data/components/indefinido/indemma/master/src/lib/record/validations/validatorable.coffee +5 -0
  151. data/components/indefinido/indemma/master/src/lib/record.coffee +143 -0
  152. data/components/indefinido/indemma/master/src/spec/record/associable_spec.coffee +205 -0
  153. data/components/indefinido/indemma/master/src/spec/record/dirtyable_spec.coffee +47 -0
  154. data/components/indefinido/indemma/master/src/spec/record/maid_spec.coffee +34 -0
  155. data/components/indefinido/indemma/master/src/spec/record/persistable_spec.coffee +39 -0
  156. data/components/indefinido/indemma/master/src/spec/record/queryable_spec.coffee +33 -0
  157. data/components/indefinido/indemma/master/src/spec/record/resource_spec.coffee +69 -0
  158. data/components/indefinido/indemma/master/src/spec/record/rest_spec.coffee +22 -0
  159. data/components/indefinido/indemma/master/src/spec/record/restfulable_spec.coffee +257 -0
  160. data/components/indefinido/indemma/master/src/spec/record/scopable_spec.coffee +227 -0
  161. data/components/indefinido/indemma/master/src/spec/record/storable_spec.coffee +39 -0
  162. data/components/indefinido/indemma/master/src/spec/record/translationable.coffee +19 -0
  163. data/components/indefinido/indemma/master/src/spec/record/validatable_spec.coffee +127 -0
  164. data/components/indefinido/indemma/master/src/spec/record/validations/associated_spec.coffee +35 -0
  165. data/components/indefinido/indemma/master/src/spec/record/validations/confirmation_spec.coffee +25 -0
  166. data/components/indefinido/indemma/master/src/spec/record/validations/cpf_spec.coffee +27 -0
  167. data/components/indefinido/indemma/master/src/spec/record/validations/presence_spec.coffee +24 -0
  168. data/components/indefinido/indemma/master/src/spec/record/validations/remote_spec.coffee +74 -0
  169. data/components/indefinido/indemma/master/src/spec/record/validations/type_spec.coffee +33 -0
  170. data/components/indefinido/indemma/master/src/spec/record_spec.coffee +29 -0
  171. data/components/indefinido/indemma/master/src/spec/spec_helper.coffee +11 -0
  172. data/components/indefinido/indemma/master/src/spec/support/value_objects/phone.coffee +30 -0
  173. data/components/indefinido/indemma/master/vendor/object/mixin.js +196 -0
  174. data/components/indefinido/indemma/master/vendor/spec/sinon/assert.js +199 -0
  175. data/components/indefinido/indemma/master/vendor/spec/sinon/behavior.js +334 -0
  176. data/components/indefinido/indemma/master/vendor/spec/sinon/call.js +205 -0
  177. data/components/indefinido/indemma/master/vendor/spec/sinon/collection.js +155 -0
  178. data/components/indefinido/indemma/master/vendor/spec/sinon/match.js +245 -0
  179. data/components/indefinido/indemma/master/vendor/spec/sinon/mock.js +451 -0
  180. data/components/indefinido/indemma/master/vendor/spec/sinon/sandbox.js +144 -0
  181. data/components/indefinido/indemma/master/vendor/spec/sinon/spy.js +413 -0
  182. data/components/indefinido/indemma/master/vendor/spec/sinon/stub.js +161 -0
  183. data/components/indefinido/indemma/master/vendor/spec/sinon/test.js +77 -0
  184. data/components/indefinido/indemma/master/vendor/spec/sinon/test_case.js +99 -0
  185. data/components/indefinido/indemma/master/vendor/spec/sinon/util/event.js +94 -0
  186. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server.js +212 -0
  187. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_server_with_clock.js +83 -0
  188. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_timers.js +405 -0
  189. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xdomain_request.js +206 -0
  190. data/components/indefinido/indemma/master/vendor/spec/sinon/util/fake_xml_http_request.js +575 -0
  191. data/components/indefinido/indemma/master/vendor/spec/sinon/util/timers_ie.js +31 -0
  192. data/components/indefinido/indemma/master/vendor/spec/sinon/util/xdr_ie.js +14 -0
  193. data/components/indefinido/indemma/master/vendor/spec/sinon/util/xhr_ie.js +19 -0
  194. data/components/indefinido/indemma/master/vendor/spec/sinon.js +383 -0
  195. data/lib/assets/javascripts/value_objects/phone.js.coffee +3 -1
  196. data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +5 -5
  197. data/lib/ende/version.rb +1 -1
  198. data/vendor/assets/components/ende_build.css +4 -4
  199. data/vendor/assets/components/ende_build.js +7974 -7889
  200. metadata +191 -5
  201. data/vendor/assets/component/build.css +0 -112
  202. data/vendor/assets/components/build.css +0 -112
  203. data/vendor/assets/components/indemma_with_none.js +0 -30553
@@ -0,0 +1,405 @@
1
+ /*jslint eqeqeq: false, plusplus: false, evil: true, onevar: false, browser: true, forin: false*/
2
+ /*global module, require, window*/
3
+ /**
4
+ * Fake timer API
5
+ * setTimeout
6
+ * setInterval
7
+ * clearTimeout
8
+ * clearInterval
9
+ * tick
10
+ * reset
11
+ * Date
12
+ *
13
+ * Inspired by jsUnitMockTimeOut from JsUnit
14
+ *
15
+ * @author Christian Johansen (christian@cjohansen.no)
16
+ * @license BSD
17
+ *
18
+ * Copyright (c) 2010-2013 Christian Johansen
19
+ */
20
+ "use strict";
21
+
22
+ if (typeof sinon == "undefined") {
23
+ var sinon = {};
24
+ }
25
+
26
+ (function (global) {
27
+ // node expects setTimeout/setInterval to return a fn object w/ .ref()/.unref()
28
+ // browsers, a number.
29
+ // see https://github.com/cjohansen/Sinon.JS/pull/436
30
+ var timeoutResult = setTimeout(function() {}, 0);
31
+ var addTimerReturnsObject = typeof timeoutResult === 'object';
32
+ clearTimeout(timeoutResult);
33
+
34
+ var id = 1;
35
+
36
+ function addTimer(args, recurring) {
37
+ if (args.length === 0) {
38
+ throw new Error("Function requires at least 1 parameter");
39
+ }
40
+
41
+ if (typeof args[0] === "undefined") {
42
+ throw new Error("Callback must be provided to timer calls");
43
+ }
44
+
45
+ var toId = id++;
46
+ var delay = args[1] || 0;
47
+
48
+ if (!this.timeouts) {
49
+ this.timeouts = {};
50
+ }
51
+
52
+ this.timeouts[toId] = {
53
+ id: toId,
54
+ func: args[0],
55
+ callAt: this.now + delay,
56
+ invokeArgs: Array.prototype.slice.call(args, 2)
57
+ };
58
+
59
+ if (recurring === true) {
60
+ this.timeouts[toId].interval = delay;
61
+ }
62
+
63
+ if (addTimerReturnsObject) {
64
+ return {
65
+ id: toId,
66
+ ref: function() {},
67
+ unref: function() {}
68
+ };
69
+ }
70
+ else {
71
+ return toId;
72
+ }
73
+ }
74
+
75
+ function parseTime(str) {
76
+ if (!str) {
77
+ return 0;
78
+ }
79
+
80
+ var strings = str.split(":");
81
+ var l = strings.length, i = l;
82
+ var ms = 0, parsed;
83
+
84
+ if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
85
+ throw new Error("tick only understands numbers and 'h:m:s'");
86
+ }
87
+
88
+ while (i--) {
89
+ parsed = parseInt(strings[i], 10);
90
+
91
+ if (parsed >= 60) {
92
+ throw new Error("Invalid time " + str);
93
+ }
94
+
95
+ ms += parsed * Math.pow(60, (l - i - 1));
96
+ }
97
+
98
+ return ms * 1000;
99
+ }
100
+
101
+ function createObject(object) {
102
+ var newObject;
103
+
104
+ if (Object.create) {
105
+ newObject = Object.create(object);
106
+ } else {
107
+ var F = function () {};
108
+ F.prototype = object;
109
+ newObject = new F();
110
+ }
111
+
112
+ newObject.Date.clock = newObject;
113
+ return newObject;
114
+ }
115
+
116
+ sinon.clock = {
117
+ now: 0,
118
+
119
+ create: function create(now) {
120
+ var clock = createObject(this);
121
+
122
+ if (typeof now == "number") {
123
+ clock.now = now;
124
+ }
125
+
126
+ if (!!now && typeof now == "object") {
127
+ throw new TypeError("now should be milliseconds since UNIX epoch");
128
+ }
129
+
130
+ return clock;
131
+ },
132
+
133
+ setTimeout: function setTimeout(callback, timeout) {
134
+ return addTimer.call(this, arguments, false);
135
+ },
136
+
137
+ clearTimeout: function clearTimeout(timerId) {
138
+ if (!this.timeouts) {
139
+ this.timeouts = [];
140
+ }
141
+ // in Node, timerId is an object with .ref()/.unref(), and
142
+ // its .id field is the actual timer id.
143
+ if (typeof timerId === 'object') {
144
+ timerId = timerId.id
145
+ }
146
+ if (timerId in this.timeouts) {
147
+ delete this.timeouts[timerId];
148
+ }
149
+ },
150
+
151
+ setInterval: function setInterval(callback, timeout) {
152
+ return addTimer.call(this, arguments, true);
153
+ },
154
+
155
+ clearInterval: function clearInterval(timerId) {
156
+ this.clearTimeout(timerId);
157
+ },
158
+
159
+ setImmediate: function setImmediate(callback) {
160
+ var passThruArgs = Array.prototype.slice.call(arguments, 1);
161
+
162
+ return addTimer.call(this, [callback, 0].concat(passThruArgs), false);
163
+ },
164
+
165
+ clearImmediate: function clearImmediate(timerId) {
166
+ this.clearTimeout(timerId);
167
+ },
168
+
169
+ tick: function tick(ms) {
170
+ ms = typeof ms == "number" ? ms : parseTime(ms);
171
+ var tickFrom = this.now, tickTo = this.now + ms, previous = this.now;
172
+ var timer = this.firstTimerInRange(tickFrom, tickTo);
173
+
174
+ var firstException;
175
+ while (timer && tickFrom <= tickTo) {
176
+ if (this.timeouts[timer.id]) {
177
+ tickFrom = this.now = timer.callAt;
178
+ try {
179
+ this.callTimer(timer);
180
+ } catch (e) {
181
+ firstException = firstException || e;
182
+ }
183
+ }
184
+
185
+ timer = this.firstTimerInRange(previous, tickTo);
186
+ previous = tickFrom;
187
+ }
188
+
189
+ this.now = tickTo;
190
+
191
+ if (firstException) {
192
+ throw firstException;
193
+ }
194
+
195
+ return this.now;
196
+ },
197
+
198
+ firstTimerInRange: function (from, to) {
199
+ var timer, smallest = null, originalTimer;
200
+
201
+ for (var id in this.timeouts) {
202
+ if (this.timeouts.hasOwnProperty(id)) {
203
+ if (this.timeouts[id].callAt < from || this.timeouts[id].callAt > to) {
204
+ continue;
205
+ }
206
+
207
+ if (smallest === null || this.timeouts[id].callAt < smallest) {
208
+ originalTimer = this.timeouts[id];
209
+ smallest = this.timeouts[id].callAt;
210
+
211
+ timer = {
212
+ func: this.timeouts[id].func,
213
+ callAt: this.timeouts[id].callAt,
214
+ interval: this.timeouts[id].interval,
215
+ id: this.timeouts[id].id,
216
+ invokeArgs: this.timeouts[id].invokeArgs
217
+ };
218
+ }
219
+ }
220
+ }
221
+
222
+ return timer || null;
223
+ },
224
+
225
+ callTimer: function (timer) {
226
+ if (typeof timer.interval == "number") {
227
+ this.timeouts[timer.id].callAt += timer.interval;
228
+ } else {
229
+ delete this.timeouts[timer.id];
230
+ }
231
+
232
+ try {
233
+ if (typeof timer.func == "function") {
234
+ timer.func.apply(null, timer.invokeArgs);
235
+ } else {
236
+ eval(timer.func);
237
+ }
238
+ } catch (e) {
239
+ var exception = e;
240
+ }
241
+
242
+ if (!this.timeouts[timer.id]) {
243
+ if (exception) {
244
+ throw exception;
245
+ }
246
+ return;
247
+ }
248
+
249
+ if (exception) {
250
+ throw exception;
251
+ }
252
+ },
253
+
254
+ reset: function reset() {
255
+ this.timeouts = {};
256
+ },
257
+
258
+ Date: (function () {
259
+ var NativeDate = Date;
260
+
261
+ function ClockDate(year, month, date, hour, minute, second, ms) {
262
+ // Defensive and verbose to avoid potential harm in passing
263
+ // explicit undefined when user does not pass argument
264
+ switch (arguments.length) {
265
+ case 0:
266
+ return new NativeDate(ClockDate.clock.now);
267
+ case 1:
268
+ return new NativeDate(year);
269
+ case 2:
270
+ return new NativeDate(year, month);
271
+ case 3:
272
+ return new NativeDate(year, month, date);
273
+ case 4:
274
+ return new NativeDate(year, month, date, hour);
275
+ case 5:
276
+ return new NativeDate(year, month, date, hour, minute);
277
+ case 6:
278
+ return new NativeDate(year, month, date, hour, minute, second);
279
+ default:
280
+ return new NativeDate(year, month, date, hour, minute, second, ms);
281
+ }
282
+ }
283
+
284
+ return mirrorDateProperties(ClockDate, NativeDate);
285
+ }())
286
+ };
287
+
288
+ function mirrorDateProperties(target, source) {
289
+ if (source.now) {
290
+ target.now = function now() {
291
+ return target.clock.now;
292
+ };
293
+ } else {
294
+ delete target.now;
295
+ }
296
+
297
+ if (source.toSource) {
298
+ target.toSource = function toSource() {
299
+ return source.toSource();
300
+ };
301
+ } else {
302
+ delete target.toSource;
303
+ }
304
+
305
+ target.toString = function toString() {
306
+ return source.toString();
307
+ };
308
+
309
+ target.prototype = source.prototype;
310
+ target.parse = source.parse;
311
+ target.UTC = source.UTC;
312
+ target.prototype.toUTCString = source.prototype.toUTCString;
313
+
314
+ for (var prop in source) {
315
+ if (source.hasOwnProperty(prop)) {
316
+ target[prop] = source[prop];
317
+ }
318
+ }
319
+
320
+ return target;
321
+ }
322
+
323
+ var methods = ["Date", "setTimeout", "setInterval",
324
+ "clearTimeout", "clearInterval"];
325
+
326
+ if (typeof global.setImmediate !== "undefined") {
327
+ methods.push("setImmediate");
328
+ }
329
+
330
+ if (typeof global.clearImmediate !== "undefined") {
331
+ methods.push("clearImmediate");
332
+ }
333
+
334
+ function restore() {
335
+ var method;
336
+
337
+ for (var i = 0, l = this.methods.length; i < l; i++) {
338
+ method = this.methods[i];
339
+
340
+ if (global[method].hadOwnProperty) {
341
+ global[method] = this["_" + method];
342
+ } else {
343
+ try {
344
+ delete global[method];
345
+ } catch (e) {}
346
+ }
347
+ }
348
+
349
+ // Prevent multiple executions which will completely remove these props
350
+ this.methods = [];
351
+ }
352
+
353
+ function stubGlobal(method, clock) {
354
+ clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(global, method);
355
+ clock["_" + method] = global[method];
356
+
357
+ if (method == "Date") {
358
+ var date = mirrorDateProperties(clock[method], global[method]);
359
+ global[method] = date;
360
+ } else {
361
+ global[method] = function () {
362
+ return clock[method].apply(clock, arguments);
363
+ };
364
+
365
+ for (var prop in clock[method]) {
366
+ if (clock[method].hasOwnProperty(prop)) {
367
+ global[method][prop] = clock[method][prop];
368
+ }
369
+ }
370
+ }
371
+
372
+ global[method].clock = clock;
373
+ }
374
+
375
+ sinon.useFakeTimers = function useFakeTimers(now) {
376
+ var clock = sinon.clock.create(now);
377
+ clock.restore = restore;
378
+ clock.methods = Array.prototype.slice.call(arguments,
379
+ typeof now == "number" ? 1 : 0);
380
+
381
+ if (clock.methods.length === 0) {
382
+ clock.methods = methods;
383
+ }
384
+
385
+ for (var i = 0, l = clock.methods.length; i < l; i++) {
386
+ stubGlobal(clock.methods[i], clock);
387
+ }
388
+
389
+ return clock;
390
+ };
391
+ }(typeof global != "undefined" && typeof global !== "function" ? global : this));
392
+
393
+ sinon.timers = {
394
+ setTimeout: setTimeout,
395
+ clearTimeout: clearTimeout,
396
+ setImmediate: (typeof setImmediate !== "undefined" ? setImmediate : undefined),
397
+ clearImmediate: (typeof clearImmediate !== "undefined" ? clearImmediate: undefined),
398
+ setInterval: setInterval,
399
+ clearInterval: clearInterval,
400
+ Date: Date
401
+ };
402
+
403
+ if (typeof module !== 'undefined' && module.exports) {
404
+ module.exports = sinon;
405
+ }
@@ -0,0 +1,206 @@
1
+ /**
2
+ * @depend ../../sinon.js
3
+ * @depend event.js
4
+ */
5
+ /*jslint eqeqeq: false, onevar: false*/
6
+ /*global sinon, module, require, XDomainRequest*/
7
+ /**
8
+ * Fake XDomainRequest object
9
+ */
10
+ "use strict";
11
+
12
+ if (typeof sinon == "undefined") {
13
+ this.sinon = {};
14
+ }
15
+ sinon.xdr = { XDomainRequest: this.XDomainRequest };
16
+
17
+ // wrapper for global
18
+ (function (global) {
19
+ var xdr = sinon.xdr;
20
+ xdr.GlobalXDomainRequest = global.XDomainRequest;
21
+ xdr.supportsXDR = typeof xdr.GlobalXDomainRequest != "undefined";
22
+ xdr.workingXDR = xdr.supportsXDR ? xdr.GlobalXDomainRequest : false;
23
+
24
+ function FakeXDomainRequest() {
25
+ this.readyState = FakeXDomainRequest.UNSENT;
26
+ this.requestBody = null;
27
+ this.requestHeaders = {};
28
+ this.status = 0;
29
+ this.timeout = null;
30
+
31
+ if (typeof FakeXDomainRequest.onCreate == "function") {
32
+ FakeXDomainRequest.onCreate(this);
33
+ }
34
+ }
35
+
36
+ function verifyState(xdr) {
37
+ if (xdr.readyState !== FakeXDomainRequest.OPENED) {
38
+ throw new Error("INVALID_STATE_ERR");
39
+ }
40
+
41
+ if (xdr.sendFlag) {
42
+ throw new Error("INVALID_STATE_ERR");
43
+ }
44
+ }
45
+
46
+ function verifyRequestSent(xdr) {
47
+ if (xdr.readyState == FakeXDomainRequest.UNSENT) {
48
+ throw new Error("Request not sent");
49
+ }
50
+ if (xdr.readyState == FakeXDomainRequest.DONE) {
51
+ throw new Error("Request done");
52
+ }
53
+ }
54
+
55
+ function verifyResponseBodyType(body) {
56
+ if (typeof body != "string") {
57
+ var error = new Error("Attempted to respond to fake XDomainRequest with " +
58
+ body + ", which is not a string.");
59
+ error.name = "InvalidBodyException";
60
+ throw error;
61
+ }
62
+ }
63
+
64
+ sinon.extend(FakeXDomainRequest.prototype, sinon.EventTarget, {
65
+ open: function open(method, url) {
66
+ this.method = method;
67
+ this.url = url;
68
+
69
+ this.responseText = null;
70
+ this.sendFlag = false;
71
+
72
+ this.readyStateChange(FakeXDomainRequest.OPENED);
73
+ },
74
+
75
+ readyStateChange: function readyStateChange(state) {
76
+ this.readyState = state;
77
+ var eventName = '';
78
+ switch (this.readyState) {
79
+ case FakeXDomainRequest.UNSENT:
80
+ break;
81
+ case FakeXDomainRequest.OPENED:
82
+ break;
83
+ case FakeXDomainRequest.LOADING:
84
+ if (this.sendFlag){
85
+ //raise the progress event
86
+ eventName = 'onprogress';
87
+ }
88
+ break;
89
+ case FakeXDomainRequest.DONE:
90
+ if (this.isTimeout){
91
+ eventName = 'ontimeout'
92
+ }
93
+ else if (this.errorFlag || (this.status < 200 || this.status > 299)) {
94
+ eventName = 'onerror';
95
+ }
96
+ else {
97
+ eventName = 'onload'
98
+ }
99
+ break;
100
+ }
101
+
102
+ // raising event (if defined)
103
+ if (eventName) {
104
+ if (typeof this[eventName] == "function") {
105
+ try {
106
+ this[eventName]();
107
+ } catch (e) {
108
+ sinon.logError("Fake XHR " + eventName + " handler", e);
109
+ }
110
+ }
111
+ }
112
+ },
113
+
114
+ send: function send(data) {
115
+ verifyState(this);
116
+
117
+ if (!/^(get|head)$/i.test(this.method)) {
118
+ this.requestBody = data;
119
+ }
120
+ this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8";
121
+
122
+ this.errorFlag = false;
123
+ this.sendFlag = true;
124
+ this.readyStateChange(FakeXDomainRequest.OPENED);
125
+
126
+ if (typeof this.onSend == "function") {
127
+ this.onSend(this);
128
+ }
129
+ },
130
+
131
+ abort: function abort() {
132
+ this.aborted = true;
133
+ this.responseText = null;
134
+ this.errorFlag = true;
135
+
136
+ if (this.readyState > sinon.FakeXDomainRequest.UNSENT && this.sendFlag) {
137
+ this.readyStateChange(sinon.FakeXDomainRequest.DONE);
138
+ this.sendFlag = false;
139
+ }
140
+ },
141
+
142
+ setResponseBody: function setResponseBody(body) {
143
+ verifyRequestSent(this);
144
+ verifyResponseBodyType(body);
145
+
146
+ var chunkSize = this.chunkSize || 10;
147
+ var index = 0;
148
+ this.responseText = "";
149
+
150
+ do {
151
+ this.readyStateChange(FakeXDomainRequest.LOADING);
152
+ this.responseText += body.substring(index, index + chunkSize);
153
+ index += chunkSize;
154
+ } while (index < body.length);
155
+
156
+ this.readyStateChange(FakeXDomainRequest.DONE);
157
+ },
158
+
159
+ respond: function respond(status, contentType, body) {
160
+ // content-type ignored, since XDomainRequest does not carry this
161
+ // we keep the same syntax for respond(...) as for FakeXMLHttpRequest to ease
162
+ // test integration across browsers
163
+ this.status = typeof status == "number" ? status : 200;
164
+ this.setResponseBody(body || "");
165
+ },
166
+
167
+ simulatetimeout: function(){
168
+ this.status = 0;
169
+ this.isTimeout = true;
170
+ // Access to this should actually throw an error
171
+ this.responseText = undefined;
172
+ this.readyStateChange(FakeXDomainRequest.DONE);
173
+ }
174
+ });
175
+
176
+ sinon.extend(FakeXDomainRequest, {
177
+ UNSENT: 0,
178
+ OPENED: 1,
179
+ LOADING: 3,
180
+ DONE: 4
181
+ });
182
+
183
+ sinon.useFakeXDomainRequest = function () {
184
+ sinon.FakeXDomainRequest.restore = function restore(keepOnCreate) {
185
+ if (xdr.supportsXDR) {
186
+ global.XDomainRequest = xdr.GlobalXDomainRequest;
187
+ }
188
+
189
+ delete sinon.FakeXDomainRequest.restore;
190
+
191
+ if (keepOnCreate !== true) {
192
+ delete sinon.FakeXDomainRequest.onCreate;
193
+ }
194
+ };
195
+ if (xdr.supportsXDR) {
196
+ global.XDomainRequest = sinon.FakeXDomainRequest;
197
+ }
198
+ return sinon.FakeXDomainRequest;
199
+ };
200
+
201
+ sinon.FakeXDomainRequest = FakeXDomainRequest;
202
+ })(this);
203
+
204
+ if (typeof module == "object" && typeof require == "function") {
205
+ module.exports = sinon;
206
+ }