vexflow 4.0.1-beta.1 → 4.0.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +92 -24
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +38 -16
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow-font-gonville.js +1 -1
  10. package/build/cjs/vexflow-font-gonville.js.map +1 -1
  11. package/build/cjs/vexflow-gonville.js +2 -2
  12. package/build/cjs/vexflow-gonville.js.map +1 -1
  13. package/build/cjs/vexflow-petaluma.js +2 -2
  14. package/build/cjs/vexflow-petaluma.js.map +1 -1
  15. package/build/cjs/vexflow.js +2 -2
  16. package/build/cjs/vexflow.js.map +1 -1
  17. package/build/esm/entry/vexflow-bravura.js +11 -0
  18. package/build/esm/entry/vexflow-core.js +54 -0
  19. package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
  20. package/build/esm/entry/vexflow-debug.js +3 -0
  21. package/build/esm/entry/vexflow-font-bravura.js +7 -0
  22. package/build/esm/entry/vexflow-font-custom.js +7 -0
  23. package/build/esm/entry/vexflow-font-gonville.js +7 -0
  24. package/build/esm/entry/vexflow-font-petaluma.js +7 -0
  25. package/build/esm/entry/vexflow-gonville.js +11 -0
  26. package/build/esm/entry/vexflow-petaluma.js +11 -0
  27. package/build/esm/entry/vexflow.js +9 -0
  28. package/build/esm/src/accidental.js +348 -0
  29. package/build/esm/src/annotation.js +232 -0
  30. package/build/esm/src/articulation.js +267 -0
  31. package/build/esm/src/barnote.js +58 -0
  32. package/build/esm/src/beam.js +632 -0
  33. package/build/esm/src/bend.js +202 -0
  34. package/build/esm/src/boundingbox.js +59 -0
  35. package/build/esm/src/boundingboxcomputation.js +107 -0
  36. package/build/esm/src/canvascontext.js +202 -0
  37. package/build/esm/src/chordsymbol.js +578 -0
  38. package/build/esm/src/clef.js +153 -0
  39. package/build/esm/src/clefnote.js +65 -0
  40. package/build/esm/src/crescendo.js +77 -0
  41. package/build/esm/src/curve.js +118 -0
  42. package/build/esm/src/dot.js +137 -0
  43. package/build/esm/src/easyscore.js +374 -0
  44. package/build/esm/src/element.js +216 -0
  45. package/build/esm/src/factory.js +440 -0
  46. package/build/esm/src/flow.js +275 -0
  47. package/build/esm/src/font.js +264 -0
  48. package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
  49. package/build/esm/src/fonts/bravura_metrics.js +507 -0
  50. package/build/esm/src/fonts/custom_glyphs.js +78 -0
  51. package/build/esm/src/fonts/custom_metrics.js +5 -0
  52. package/build/esm/src/fonts/gonville_glyphs.js +828 -0
  53. package/build/esm/src/fonts/gonville_metrics.js +421 -0
  54. package/build/esm/src/fonts/load_all.js +10 -0
  55. package/build/esm/src/fonts/load_bravura.js +6 -0
  56. package/build/esm/src/fonts/load_custom.js +6 -0
  57. package/build/esm/src/fonts/load_gonville.js +6 -0
  58. package/build/esm/src/fonts/load_petaluma.js +6 -0
  59. package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
  60. package/build/esm/src/fonts/petaluma_metrics.js +536 -0
  61. package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
  62. package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
  63. package/build/esm/src/fonts/textfonts.js +44 -0
  64. package/build/esm/src/formatter.js +568 -0
  65. package/build/esm/src/fraction.js +171 -0
  66. package/build/esm/src/frethandfinger.js +156 -0
  67. package/build/esm/src/ghostnote.js +50 -0
  68. package/build/esm/src/glyph.js +331 -0
  69. package/build/esm/src/glyphnote.js +55 -0
  70. package/build/esm/src/gracenote.js +133 -0
  71. package/build/esm/src/gracenotegroup.js +128 -0
  72. package/build/esm/src/gracetabnote.js +12 -0
  73. package/build/esm/src/index.js +91 -0
  74. package/build/esm/src/keymanager.js +99 -0
  75. package/build/esm/src/keysignature.js +250 -0
  76. package/build/esm/src/keysignote.js +28 -0
  77. package/build/esm/src/modifier.js +128 -0
  78. package/build/esm/src/modifiercontext.js +110 -0
  79. package/build/esm/src/multimeasurerest.js +173 -0
  80. package/build/esm/src/music.js +322 -0
  81. package/build/esm/src/note.js +371 -0
  82. package/build/esm/src/notehead.js +169 -0
  83. package/build/esm/src/notesubgroup.js +59 -0
  84. package/build/esm/src/ornament.js +206 -0
  85. package/build/esm/src/parenthesis.js +76 -0
  86. package/build/esm/src/parser.js +164 -0
  87. package/build/esm/src/pedalmarking.js +192 -0
  88. package/build/esm/src/registry.js +81 -0
  89. package/build/esm/src/rendercontext.js +24 -0
  90. package/build/esm/src/renderer.js +112 -0
  91. package/build/esm/src/repeatnote.js +22 -0
  92. package/build/esm/src/stave.js +547 -0
  93. package/build/esm/src/stavebarline.js +182 -0
  94. package/build/esm/src/staveconnector.js +196 -0
  95. package/build/esm/src/stavehairpin.js +120 -0
  96. package/build/esm/src/staveline.js +218 -0
  97. package/build/esm/src/stavemodifier.js +77 -0
  98. package/build/esm/src/stavenote.js +855 -0
  99. package/build/esm/src/staverepetition.js +155 -0
  100. package/build/esm/src/stavesection.js +58 -0
  101. package/build/esm/src/stavetempo.js +91 -0
  102. package/build/esm/src/stavetext.js +82 -0
  103. package/build/esm/src/stavetie.js +141 -0
  104. package/build/esm/src/stavevolta.js +67 -0
  105. package/build/esm/src/stem.js +131 -0
  106. package/build/esm/src/stemmablenote.js +193 -0
  107. package/build/esm/src/stringnumber.js +231 -0
  108. package/build/esm/src/strokes.js +200 -0
  109. package/build/esm/src/svgcontext.js +414 -0
  110. package/build/esm/src/system.js +116 -0
  111. package/build/esm/src/tables.js +1102 -0
  112. package/build/esm/src/tabnote.js +299 -0
  113. package/build/esm/src/tabslide.js +76 -0
  114. package/build/esm/src/tabstave.js +17 -0
  115. package/build/esm/src/tabtie.js +19 -0
  116. package/build/esm/src/textbracket.js +144 -0
  117. package/build/esm/src/textdynamics.js +81 -0
  118. package/build/esm/src/textformatter.js +177 -0
  119. package/build/esm/src/textnote.js +176 -0
  120. package/build/esm/src/tickable.js +214 -0
  121. package/build/esm/src/tickcontext.js +170 -0
  122. package/build/esm/src/timesigglyph.js +85 -0
  123. package/build/esm/src/timesignature.js +89 -0
  124. package/build/esm/src/timesignote.js +32 -0
  125. package/build/esm/src/tremolo.js +47 -0
  126. package/build/esm/src/tuning.js +54 -0
  127. package/build/esm/src/tuplet.js +240 -0
  128. package/build/esm/src/typeguard.js +30 -0
  129. package/build/esm/src/util.js +58 -0
  130. package/build/esm/src/version.js +3 -3
  131. package/build/esm/src/vex.js +51 -0
  132. package/build/esm/src/vibrato.js +100 -0
  133. package/build/esm/src/vibratobracket.js +50 -0
  134. package/build/esm/src/voice.js +187 -0
  135. package/build/esm/src/web.js +15 -0
  136. package/build/esm/tests/accidental_tests.js +974 -0
  137. package/build/esm/tests/annotation_tests.js +377 -0
  138. package/build/esm/tests/articulation_tests.js +365 -0
  139. package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
  140. package/build/esm/tests/bach_tests.js +335 -0
  141. package/build/esm/tests/barline_tests.js +52 -0
  142. package/build/esm/tests/beam_tests.js +595 -0
  143. package/build/esm/tests/bend_tests.js +215 -0
  144. package/build/esm/tests/boundingbox_tests.js +53 -0
  145. package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
  146. package/build/esm/tests/chordsymbol_tests.js +320 -0
  147. package/build/esm/tests/clef_tests.js +131 -0
  148. package/build/esm/tests/curve_tests.js +118 -0
  149. package/build/esm/tests/dot_tests.js +123 -0
  150. package/build/esm/tests/easyscore_tests.js +459 -0
  151. package/build/esm/tests/factory_tests.js +44 -0
  152. package/build/esm/tests/font_tests.js +135 -0
  153. package/build/esm/tests/formatter/framestack.js +61 -0
  154. package/build/esm/tests/formatter/tests.js +203 -0
  155. package/build/esm/tests/formatter_tests.js +669 -0
  156. package/build/esm/tests/fraction_tests.js +72 -0
  157. package/build/esm/tests/ghostnote_tests.js +77 -0
  158. package/build/esm/tests/glyphnote_tests.js +113 -0
  159. package/build/esm/tests/gracenote_tests.js +413 -0
  160. package/build/esm/tests/gracetabnote_tests.js +79 -0
  161. package/build/esm/tests/index.js +68 -0
  162. package/build/esm/tests/key_clef_tests.js +103 -0
  163. package/build/esm/tests/keymanager_tests.js +68 -0
  164. package/build/esm/tests/keysignature_tests.js +308 -0
  165. package/build/esm/tests/mocks.js +71 -0
  166. package/build/esm/tests/modifier_tests.js +24 -0
  167. package/build/esm/tests/multimeasurerest_tests.js +141 -0
  168. package/build/esm/tests/music_tests.js +161 -0
  169. package/build/esm/tests/notehead_tests.js +137 -0
  170. package/build/esm/tests/notesubgroup_tests.js +149 -0
  171. package/build/esm/tests/offscreencanvas_tests.js +47 -0
  172. package/build/esm/tests/ornament_tests.js +298 -0
  173. package/build/esm/tests/parser_tests.js +122 -0
  174. package/build/esm/tests/pedalmarking_tests.js +64 -0
  175. package/build/esm/tests/percussion_tests.js +180 -0
  176. package/build/esm/tests/registry_tests.js +64 -0
  177. package/build/esm/tests/renderer_tests.js +113 -0
  178. package/build/esm/tests/rests_tests.js +248 -0
  179. package/build/esm/tests/rhythm_tests.js +357 -0
  180. package/build/esm/tests/stave_tests.js +560 -0
  181. package/build/esm/tests/staveconnector_tests.js +402 -0
  182. package/build/esm/tests/stavehairpin_tests.js +90 -0
  183. package/build/esm/tests/staveline_tests.js +122 -0
  184. package/build/esm/tests/stavemodifier_tests.js +51 -0
  185. package/build/esm/tests/stavenote_tests.js +867 -0
  186. package/build/esm/tests/stavetie_tests.js +108 -0
  187. package/build/esm/tests/stringnumber_tests.js +259 -0
  188. package/build/esm/tests/strokes_tests.js +275 -0
  189. package/build/esm/tests/style_tests.js +98 -0
  190. package/build/esm/tests/support/qunit.js +2765 -0
  191. package/build/esm/tests/tabnote_tests.js +474 -0
  192. package/build/esm/tests/tabslide_tests.js +135 -0
  193. package/build/esm/tests/tabstave_tests.js +23 -0
  194. package/build/esm/tests/tabtie_tests.js +173 -0
  195. package/build/esm/tests/textbracket_tests.js +100 -0
  196. package/build/esm/tests/textformatter_tests.js +24 -0
  197. package/build/esm/tests/textnote_tests.js +215 -0
  198. package/build/esm/tests/threevoice_tests.js +132 -0
  199. package/build/esm/tests/tickcontext_tests.js +36 -0
  200. package/build/esm/tests/timesignature_tests.js +134 -0
  201. package/build/esm/tests/tremolo_tests.js +75 -0
  202. package/build/esm/tests/tuning_tests.js +56 -0
  203. package/build/esm/tests/tuplet_tests.js +450 -0
  204. package/build/esm/tests/typeguard_tests.js +82 -0
  205. package/build/esm/tests/vexflow_test_helpers.js +266 -0
  206. package/build/esm/tests/vf_prefix_tests.js +115 -0
  207. package/build/esm/tests/vibrato_tests.js +92 -0
  208. package/build/esm/tests/vibratobracket_tests.js +45 -0
  209. package/build/esm/tests/voice_tests.js +69 -0
  210. package/build/types/entry/vexflow-bravura.d.ts +3 -0
  211. package/build/types/entry/vexflow-core.d.ts +3 -0
  212. package/build/types/entry/vexflow-debug.d.ts +3 -0
  213. package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
  214. package/build/types/entry/vexflow-font-custom.d.ts +86 -0
  215. package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
  216. package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
  217. package/build/types/entry/vexflow-gonville.d.ts +3 -0
  218. package/build/types/entry/vexflow-petaluma.d.ts +3 -0
  219. package/build/types/entry/vexflow.d.ts +3 -0
  220. package/build/types/src/accidental.d.ts +66 -0
  221. package/build/types/src/annotation.d.ts +60 -0
  222. package/build/types/src/articulation.d.ts +62 -0
  223. package/build/types/src/barnote.d.ts +29 -0
  224. package/build/types/src/beam.d.ts +124 -0
  225. package/build/types/src/bend.d.ts +73 -0
  226. package/build/types/src/boundingbox.d.ts +42 -0
  227. package/build/types/src/boundingboxcomputation.d.ts +33 -0
  228. package/build/types/src/canvascontext.d.ts +89 -0
  229. package/build/types/src/chordsymbol.d.ts +149 -0
  230. package/build/types/src/clef.d.ts +48 -0
  231. package/build/types/src/clefnote.d.ts +25 -0
  232. package/build/types/src/crescendo.d.ts +27 -0
  233. package/build/types/src/curve.d.ts +41 -0
  234. package/build/types/src/dot.d.ts +20 -0
  235. package/build/types/src/easyscore.d.ts +148 -0
  236. package/build/types/src/element.d.ts +202 -0
  237. package/build/types/src/factory.d.ts +271 -0
  238. package/build/types/src/flow.d.ts +245 -0
  239. package/build/types/src/font.d.ts +181 -0
  240. package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
  241. package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
  242. package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
  243. package/build/types/src/fonts/custom_metrics.d.ts +5 -0
  244. package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
  245. package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
  246. package/build/types/src/fonts/load_all.d.ts +1 -0
  247. package/build/types/src/fonts/load_bravura.d.ts +1 -0
  248. package/build/types/src/fonts/load_custom.d.ts +1 -0
  249. package/build/types/src/fonts/load_gonville.d.ts +1 -0
  250. package/build/types/src/fonts/load_petaluma.d.ts +1 -0
  251. package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
  252. package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
  253. package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
  254. package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
  255. package/build/types/src/fonts/textfonts.d.ts +1 -0
  256. package/build/types/src/formatter.d.ts +203 -0
  257. package/build/types/src/fraction.d.ts +62 -0
  258. package/build/types/src/frethandfinger.d.ts +22 -0
  259. package/build/types/src/ghostnote.d.ts +16 -0
  260. package/build/types/src/glyph.d.ts +139 -0
  261. package/build/types/src/glyphnote.d.ts +17 -0
  262. package/build/types/src/gracenote.d.ts +19 -0
  263. package/build/types/src/gracenotegroup.d.ts +33 -0
  264. package/build/types/src/gracetabnote.d.ts +5 -0
  265. package/build/types/src/index.d.ts +91 -0
  266. package/build/types/src/keymanager.d.ts +25 -0
  267. package/build/types/src/keysignature.d.ts +50 -0
  268. package/build/types/src/keysignote.d.ts +11 -0
  269. package/build/types/src/modifier.d.ts +97 -0
  270. package/build/types/src/modifiercontext.d.ts +45 -0
  271. package/build/types/src/multimeasurerest.d.ts +61 -0
  272. package/build/types/src/music.d.ts +91 -0
  273. package/build/types/src/note.d.ts +231 -0
  274. package/build/types/src/notehead.d.ts +70 -0
  275. package/build/types/src/notesubgroup.d.ts +18 -0
  276. package/build/types/src/ornament.d.ts +76 -0
  277. package/build/types/src/parenthesis.d.ts +22 -0
  278. package/build/types/src/parser.d.ts +45 -0
  279. package/build/types/src/pedalmarking.d.ts +69 -0
  280. package/build/types/src/registry.d.ts +40 -0
  281. package/build/types/src/rendercontext.d.ts +64 -0
  282. package/build/types/src/renderer.d.ts +35 -0
  283. package/build/types/src/repeatnote.d.ts +6 -0
  284. package/build/types/src/stave.d.ts +186 -0
  285. package/build/types/src/stavebarline.d.ts +28 -0
  286. package/build/types/src/staveconnector.d.ts +67 -0
  287. package/build/types/src/stavehairpin.d.ts +56 -0
  288. package/build/types/src/staveline.d.ts +57 -0
  289. package/build/types/src/stavemodifier.d.ts +44 -0
  290. package/build/types/src/stavenote.d.ts +154 -0
  291. package/build/types/src/staverepetition.d.ts +32 -0
  292. package/build/types/src/stavesection.d.ts +15 -0
  293. package/build/types/src/stavetempo.d.ts +25 -0
  294. package/build/types/src/stavetext.d.ts +25 -0
  295. package/build/types/src/stavetie.d.ts +59 -0
  296. package/build/types/src/stavevolta.d.ts +21 -0
  297. package/build/types/src/stem.d.ts +58 -0
  298. package/build/types/src/stemmablenote.d.ts +39 -0
  299. package/build/types/src/stringnumber.d.ts +27 -0
  300. package/build/types/src/strokes.d.ts +33 -0
  301. package/build/types/src/svgcontext.d.ts +131 -0
  302. package/build/types/src/system.d.ts +92 -0
  303. package/build/types/src/tables.d.ts +96 -0
  304. package/build/types/src/tabnote.d.ts +44 -0
  305. package/build/types/src/tabslide.d.ts +34 -0
  306. package/build/types/src/tabstave.d.ts +7 -0
  307. package/build/types/src/tabtie.d.ts +18 -0
  308. package/build/types/src/textbracket.d.ts +55 -0
  309. package/build/types/src/textdynamics.d.ts +39 -0
  310. package/build/types/src/textformatter.d.ts +109 -0
  311. package/build/types/src/textnote.d.ts +49 -0
  312. package/build/types/src/tickable.d.ts +140 -0
  313. package/build/types/src/tickcontext.d.ts +82 -0
  314. package/build/types/src/timesigglyph.d.ts +14 -0
  315. package/build/types/src/timesignature.d.ts +26 -0
  316. package/build/types/src/timesignote.d.ts +11 -0
  317. package/build/types/src/tremolo.d.ts +17 -0
  318. package/build/types/src/tuning.d.ts +23 -0
  319. package/build/types/src/tuplet.d.ts +105 -0
  320. package/build/types/src/typeguard.d.ts +99 -0
  321. package/build/types/src/util.d.ts +27 -0
  322. package/build/types/src/version.d.ts +3 -0
  323. package/build/types/src/vex.d.ts +18 -0
  324. package/build/types/src/vibrato.d.ts +29 -0
  325. package/build/types/src/vibratobracket.d.ts +33 -0
  326. package/build/types/src/voice.d.ts +108 -0
  327. package/build/types/src/web.d.ts +2 -0
  328. package/package.json +1 -1
  329. package/src/annotation.ts +27 -6
  330. package/src/articulation.ts +8 -2
  331. package/src/fonts/gonville_glyphs.ts +4 -4
@@ -0,0 +1,2765 @@
1
+ "use strict";
2
+ /*!
3
+ * QUnit 1.19.0
4
+ * http://qunitjs.com/
5
+ *
6
+ * Copyright jQuery Foundation and other contributors
7
+ * Released under the MIT license
8
+ * http://jquery.org/license
9
+ *
10
+ * Date: 2015-09-01T15:00Z
11
+ */
12
+ (function (global) {
13
+ var QUnit = {};
14
+ var Date = global.Date;
15
+ var now = Date.now ||
16
+ function () {
17
+ return new Date().getTime();
18
+ };
19
+ var setTimeout = global.setTimeout;
20
+ var clearTimeout = global.clearTimeout;
21
+ var window = global.window;
22
+ var defined = {
23
+ document: window && window.document !== undefined,
24
+ setTimeout: setTimeout !== undefined,
25
+ sessionStorage: (function () {
26
+ var x = 'qunit-test-string';
27
+ try {
28
+ sessionStorage.setItem(x, x);
29
+ sessionStorage.removeItem(x);
30
+ return true;
31
+ }
32
+ catch (e) {
33
+ return false;
34
+ }
35
+ })(),
36
+ };
37
+ var fileName = (sourceFromStacktrace(0) || '').replace(/(:\d+)+\)?/, '').replace(/.+\//, '');
38
+ var globalStartCalled = false;
39
+ var runStarted = false;
40
+ var toString = Object.prototype.toString, hasOwn = Object.prototype.hasOwnProperty;
41
+ function diff(a, b) {
42
+ var i, j, result = a.slice();
43
+ for (i = 0; i < result.length; i++) {
44
+ for (j = 0; j < b.length; j++) {
45
+ if (result[i] === b[j]) {
46
+ result.splice(i, 1);
47
+ i--;
48
+ break;
49
+ }
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+ function inArray(elem, array) {
55
+ if (array.indexOf) {
56
+ return array.indexOf(elem);
57
+ }
58
+ for (var i = 0, length = array.length; i < length; i++) {
59
+ if (array[i] === elem) {
60
+ return i;
61
+ }
62
+ }
63
+ return -1;
64
+ }
65
+ function objectValues(obj) {
66
+ var key, val, vals = QUnit.is('array', obj) ? [] : {};
67
+ for (key in obj) {
68
+ if (hasOwn.call(obj, key)) {
69
+ val = obj[key];
70
+ vals[key] = val === Object(val) ? objectValues(val) : val;
71
+ }
72
+ }
73
+ return vals;
74
+ }
75
+ function extend(a, b, undefOnly) {
76
+ for (var prop in b) {
77
+ if (hasOwn.call(b, prop)) {
78
+ if (prop !== 'constructor' || a !== global) {
79
+ if (b[prop] === undefined) {
80
+ delete a[prop];
81
+ }
82
+ else if (!(undefOnly && typeof a[prop] !== 'undefined')) {
83
+ a[prop] = b[prop];
84
+ }
85
+ }
86
+ }
87
+ }
88
+ return a;
89
+ }
90
+ function objectType(obj) {
91
+ if (typeof obj === 'undefined') {
92
+ return 'undefined';
93
+ }
94
+ if (obj === null) {
95
+ return 'null';
96
+ }
97
+ var match = toString.call(obj).match(/^\[object\s(.*)\]$/), type = (match && match[1]) || '';
98
+ switch (type) {
99
+ case 'Number':
100
+ if (isNaN(obj)) {
101
+ return 'nan';
102
+ }
103
+ return 'number';
104
+ case 'String':
105
+ case 'Boolean':
106
+ case 'Array':
107
+ case 'Set':
108
+ case 'Map':
109
+ case 'Date':
110
+ case 'RegExp':
111
+ case 'Function':
112
+ return type.toLowerCase();
113
+ }
114
+ if (typeof obj === 'object') {
115
+ return 'object';
116
+ }
117
+ return undefined;
118
+ }
119
+ function is(type, obj) {
120
+ return QUnit.objectType(obj) === type;
121
+ }
122
+ var getUrlParams = function () {
123
+ var i, current;
124
+ var urlParams = {};
125
+ var location = window.location;
126
+ var params = location.search.slice(1).split('&');
127
+ var length = params.length;
128
+ if (params[0]) {
129
+ for (i = 0; i < length; i++) {
130
+ current = params[i].split('=');
131
+ current[0] = decodeURIComponent(current[0]);
132
+ current[1] = current[1] ? decodeURIComponent(current[1]) : true;
133
+ if (urlParams[current[0]]) {
134
+ urlParams[current[0]] = [].concat(urlParams[current[0]], current[1]);
135
+ }
136
+ else {
137
+ urlParams[current[0]] = current[1];
138
+ }
139
+ }
140
+ }
141
+ return urlParams;
142
+ };
143
+ function extractStacktrace(e, offset) {
144
+ offset = offset === undefined ? 4 : offset;
145
+ var stack, include, i;
146
+ if (e.stack) {
147
+ stack = e.stack.split('\n');
148
+ if (/^error$/i.test(stack[0])) {
149
+ stack.shift();
150
+ }
151
+ if (fileName) {
152
+ include = [];
153
+ for (i = offset; i < stack.length; i++) {
154
+ if (stack[i].indexOf(fileName) !== -1) {
155
+ break;
156
+ }
157
+ include.push(stack[i]);
158
+ }
159
+ if (include.length) {
160
+ return include.join('\n');
161
+ }
162
+ }
163
+ return stack[offset];
164
+ }
165
+ else if (e.sourceURL) {
166
+ if (/qunit.js$/.test(e.sourceURL)) {
167
+ return;
168
+ }
169
+ return e.sourceURL + ':' + e.line;
170
+ }
171
+ }
172
+ function sourceFromStacktrace(offset) {
173
+ var error = new Error();
174
+ if (!error.stack) {
175
+ try {
176
+ throw error;
177
+ }
178
+ catch (err) {
179
+ error = err;
180
+ }
181
+ }
182
+ return extractStacktrace(error, offset);
183
+ }
184
+ var config = {
185
+ queue: [],
186
+ blocking: true,
187
+ reorder: true,
188
+ altertitle: true,
189
+ scrolltop: true,
190
+ maxDepth: 5,
191
+ requireExpects: false,
192
+ urlConfig: [
193
+ {
194
+ id: 'hidepassed',
195
+ label: 'Hide passed tests',
196
+ tooltip: 'Only show tests and assertions that fail. Stored as query-strings.',
197
+ },
198
+ {
199
+ id: 'noglobals',
200
+ label: 'Check for Globals',
201
+ tooltip: 'Enabling this will test if any test introduces new properties on the ' +
202
+ 'global object (`window` in Browsers). Stored as query-strings.',
203
+ },
204
+ {
205
+ id: 'notrycatch',
206
+ label: 'No try-catch',
207
+ tooltip: 'Enabling this will run tests outside of a try-catch block. Makes debugging ' +
208
+ 'exceptions in IE reasonable. Stored as query-strings.',
209
+ },
210
+ ],
211
+ modules: [],
212
+ currentModule: {
213
+ name: '',
214
+ tests: [],
215
+ },
216
+ callbacks: {},
217
+ };
218
+ var urlParams = defined.document ? getUrlParams() : {};
219
+ config.modules.push(config.currentModule);
220
+ if (urlParams.filter === true) {
221
+ delete urlParams.filter;
222
+ }
223
+ config.filter = urlParams.filter;
224
+ config.testId = [];
225
+ if (urlParams.testId) {
226
+ urlParams.testId = decodeURIComponent(urlParams.testId).split(',');
227
+ for (var i = 0; i < urlParams.testId.length; i++) {
228
+ config.testId.push(urlParams.testId[i]);
229
+ }
230
+ }
231
+ var loggingCallbacks = {};
232
+ function registerLoggingCallbacks(obj) {
233
+ var i, l, key, callbackNames = ['begin', 'done', 'log', 'testStart', 'testDone', 'moduleStart', 'moduleDone'];
234
+ function registerLoggingCallback(key) {
235
+ var loggingCallback = function (callback) {
236
+ if (objectType(callback) !== 'function') {
237
+ throw new Error('QUnit logging methods require a callback function as their first parameters.');
238
+ }
239
+ config.callbacks[key].push(callback);
240
+ };
241
+ loggingCallbacks[key] = loggingCallback;
242
+ return loggingCallback;
243
+ }
244
+ for (i = 0, l = callbackNames.length; i < l; i++) {
245
+ key = callbackNames[i];
246
+ if (objectType(config.callbacks[key]) === 'undefined') {
247
+ config.callbacks[key] = [];
248
+ }
249
+ obj[key] = registerLoggingCallback(key);
250
+ }
251
+ }
252
+ function runLoggingCallbacks(key, args) {
253
+ var i, l, callbacks;
254
+ callbacks = config.callbacks[key];
255
+ for (i = 0, l = callbacks.length; i < l; i++) {
256
+ callbacks[i](args);
257
+ }
258
+ }
259
+ function verifyLoggingCallbacks() {
260
+ var loggingCallback, userCallback;
261
+ for (loggingCallback in loggingCallbacks) {
262
+ if (QUnit[loggingCallback] !== loggingCallbacks[loggingCallback]) {
263
+ userCallback = QUnit[loggingCallback];
264
+ QUnit[loggingCallback] = loggingCallbacks[loggingCallback];
265
+ QUnit[loggingCallback](userCallback);
266
+ if (global.console && global.console.warn) {
267
+ global.console.warn('QUnit.' +
268
+ loggingCallback +
269
+ ' was replaced with a new value.\n' +
270
+ 'Please, check out the documentation on how to apply logging callbacks.\n' +
271
+ 'Reference: http://api.qunitjs.com/category/callbacks/');
272
+ }
273
+ }
274
+ }
275
+ }
276
+ (function () {
277
+ if (!defined.document) {
278
+ return;
279
+ }
280
+ var onErrorFnPrev = window.onerror;
281
+ window.onerror = function (error, filePath, linerNr) {
282
+ var ret = false;
283
+ if (onErrorFnPrev) {
284
+ ret = onErrorFnPrev(error, filePath, linerNr);
285
+ }
286
+ if (ret !== true) {
287
+ if (QUnit.config.current) {
288
+ if (QUnit.config.current.ignoreGlobalErrors) {
289
+ return true;
290
+ }
291
+ QUnit.pushFailure(error, filePath + ':' + linerNr);
292
+ }
293
+ else {
294
+ QUnit.test('global failure', extend(function () {
295
+ QUnit.pushFailure(error, filePath + ':' + linerNr);
296
+ }, { validTest: true }));
297
+ }
298
+ return false;
299
+ }
300
+ return ret;
301
+ };
302
+ })();
303
+ QUnit.urlParams = urlParams;
304
+ QUnit.isLocal = !(defined.document && window.location.protocol !== 'file:');
305
+ QUnit.version = '1.19.0';
306
+ extend(QUnit, {
307
+ module: function (name, testEnvironment) {
308
+ var currentModule = {
309
+ name: name,
310
+ testEnvironment: testEnvironment,
311
+ tests: [],
312
+ };
313
+ if (testEnvironment && testEnvironment.setup) {
314
+ testEnvironment.beforeEach = testEnvironment.setup;
315
+ delete testEnvironment.setup;
316
+ }
317
+ if (testEnvironment && testEnvironment.teardown) {
318
+ testEnvironment.afterEach = testEnvironment.teardown;
319
+ delete testEnvironment.teardown;
320
+ }
321
+ config.modules.push(currentModule);
322
+ config.currentModule = currentModule;
323
+ },
324
+ asyncTest: asyncTest,
325
+ test: test,
326
+ skip: skip,
327
+ start: function (count) {
328
+ var globalStartAlreadyCalled = globalStartCalled;
329
+ if (!config.current) {
330
+ globalStartCalled = true;
331
+ if (runStarted) {
332
+ throw new Error('Called start() outside of a test context while already started');
333
+ }
334
+ else if (globalStartAlreadyCalled || count > 1) {
335
+ throw new Error('Called start() outside of a test context too many times');
336
+ }
337
+ else if (config.autostart) {
338
+ throw new Error('Called start() outside of a test context when ' + 'QUnit.config.autostart was true');
339
+ }
340
+ else if (!config.pageLoaded) {
341
+ config.autostart = true;
342
+ return;
343
+ }
344
+ }
345
+ else {
346
+ config.current.semaphore -= count || 1;
347
+ if (config.current.semaphore > 0) {
348
+ return;
349
+ }
350
+ if (config.current.semaphore < 0) {
351
+ config.current.semaphore = 0;
352
+ QUnit.pushFailure("Called start() while already started (test's semaphore was 0 already)", sourceFromStacktrace(2));
353
+ return;
354
+ }
355
+ }
356
+ resumeProcessing();
357
+ },
358
+ stop: function (count) {
359
+ if (!config.current) {
360
+ throw new Error('Called stop() outside of a test context');
361
+ }
362
+ config.current.semaphore += count || 1;
363
+ pauseProcessing();
364
+ },
365
+ config: config,
366
+ is: is,
367
+ objectType: objectType,
368
+ extend: extend,
369
+ load: function () {
370
+ config.pageLoaded = true;
371
+ extend(config, {
372
+ stats: { all: 0, bad: 0 },
373
+ moduleStats: { all: 0, bad: 0 },
374
+ started: 0,
375
+ updateRate: 1000,
376
+ autostart: true,
377
+ filter: '',
378
+ }, true);
379
+ config.blocking = false;
380
+ if (config.autostart) {
381
+ resumeProcessing();
382
+ }
383
+ },
384
+ stack: function (offset) {
385
+ offset = (offset || 0) + 2;
386
+ return sourceFromStacktrace(offset);
387
+ },
388
+ });
389
+ registerLoggingCallbacks(QUnit);
390
+ function begin() {
391
+ var i, l, modulesLog = [];
392
+ if (!config.started) {
393
+ config.started = now();
394
+ verifyLoggingCallbacks();
395
+ if (config.modules[0].name === '' && config.modules[0].tests.length === 0) {
396
+ config.modules.shift();
397
+ }
398
+ for (i = 0, l = config.modules.length; i < l; i++) {
399
+ modulesLog.push({
400
+ name: config.modules[i].name,
401
+ tests: config.modules[i].tests,
402
+ });
403
+ }
404
+ runLoggingCallbacks('begin', {
405
+ totalTests: Test.count,
406
+ modules: modulesLog,
407
+ });
408
+ }
409
+ config.blocking = false;
410
+ process(true);
411
+ }
412
+ function process(last) {
413
+ function next() {
414
+ process(last);
415
+ }
416
+ var start = now();
417
+ config.depth = (config.depth || 0) + 1;
418
+ while (config.queue.length && !config.blocking) {
419
+ if (!defined.setTimeout || config.updateRate <= 0 || now() - start < config.updateRate) {
420
+ if (config.current) {
421
+ config.current.usedAsync = false;
422
+ }
423
+ config.queue.shift()();
424
+ }
425
+ else {
426
+ setTimeout(next, 13);
427
+ break;
428
+ }
429
+ }
430
+ config.depth--;
431
+ if (last && !config.blocking && !config.queue.length && config.depth === 0) {
432
+ done();
433
+ }
434
+ }
435
+ function pauseProcessing() {
436
+ config.blocking = true;
437
+ if (config.testTimeout && defined.setTimeout) {
438
+ clearTimeout(config.timeout);
439
+ config.timeout = setTimeout(function () {
440
+ if (config.current) {
441
+ config.current.semaphore = 0;
442
+ QUnit.pushFailure('Test timed out', sourceFromStacktrace(2));
443
+ }
444
+ else {
445
+ throw new Error('Test timed out');
446
+ }
447
+ resumeProcessing();
448
+ }, config.testTimeout);
449
+ }
450
+ }
451
+ function resumeProcessing() {
452
+ runStarted = true;
453
+ if (defined.setTimeout) {
454
+ setTimeout(function () {
455
+ if (config.current && config.current.semaphore > 0) {
456
+ return;
457
+ }
458
+ if (config.timeout) {
459
+ clearTimeout(config.timeout);
460
+ }
461
+ begin();
462
+ }, 13);
463
+ }
464
+ else {
465
+ begin();
466
+ }
467
+ }
468
+ function done() {
469
+ var runtime, passed;
470
+ config.autorun = true;
471
+ if (config.previousModule) {
472
+ runLoggingCallbacks('moduleDone', {
473
+ name: config.previousModule.name,
474
+ tests: config.previousModule.tests,
475
+ failed: config.moduleStats.bad,
476
+ passed: config.moduleStats.all - config.moduleStats.bad,
477
+ total: config.moduleStats.all,
478
+ runtime: now() - config.moduleStats.started,
479
+ });
480
+ }
481
+ delete config.previousModule;
482
+ runtime = now() - config.started;
483
+ passed = config.stats.all - config.stats.bad;
484
+ runLoggingCallbacks('done', {
485
+ failed: config.stats.bad,
486
+ passed: passed,
487
+ total: config.stats.all,
488
+ runtime: runtime,
489
+ });
490
+ }
491
+ function Test(settings) {
492
+ var i, l;
493
+ ++Test.count;
494
+ extend(this, settings);
495
+ this.assertions = [];
496
+ this.semaphore = 0;
497
+ this.usedAsync = false;
498
+ this.module = config.currentModule;
499
+ this.stack = sourceFromStacktrace(3);
500
+ for (i = 0, l = this.module.tests; i < l.length; i++) {
501
+ if (this.module.tests[i].name === this.testName) {
502
+ this.testName += ' ';
503
+ }
504
+ }
505
+ this.testId = generateHash(this.module.name, this.testName);
506
+ this.module.tests.push({
507
+ name: this.testName,
508
+ testId: this.testId,
509
+ });
510
+ if (settings.skip) {
511
+ this.callback = function () { };
512
+ this.async = false;
513
+ this.expected = 0;
514
+ }
515
+ else {
516
+ this.assert = new Assert(this);
517
+ }
518
+ }
519
+ Test.count = 0;
520
+ Test.prototype = {
521
+ before: function () {
522
+ if (this.module !== config.previousModule ||
523
+ !hasOwn.call(config, 'previousModule')) {
524
+ if (hasOwn.call(config, 'previousModule')) {
525
+ runLoggingCallbacks('moduleDone', {
526
+ name: config.previousModule.name,
527
+ tests: config.previousModule.tests,
528
+ failed: config.moduleStats.bad,
529
+ passed: config.moduleStats.all - config.moduleStats.bad,
530
+ total: config.moduleStats.all,
531
+ runtime: now() - config.moduleStats.started,
532
+ });
533
+ }
534
+ config.previousModule = this.module;
535
+ config.moduleStats = { all: 0, bad: 0, started: now() };
536
+ runLoggingCallbacks('moduleStart', {
537
+ name: this.module.name,
538
+ tests: this.module.tests,
539
+ });
540
+ }
541
+ config.current = this;
542
+ if (this.module.testEnvironment) {
543
+ delete this.module.testEnvironment.beforeEach;
544
+ delete this.module.testEnvironment.afterEach;
545
+ }
546
+ this.testEnvironment = extend({}, this.module.testEnvironment);
547
+ this.started = now();
548
+ runLoggingCallbacks('testStart', {
549
+ name: this.testName,
550
+ module: this.module.name,
551
+ testId: this.testId,
552
+ });
553
+ if (!config.pollution) {
554
+ saveGlobal();
555
+ }
556
+ },
557
+ run: function () {
558
+ var promise;
559
+ config.current = this;
560
+ if (this.async) {
561
+ QUnit.stop();
562
+ }
563
+ this.callbackStarted = now();
564
+ if (config.notrycatch) {
565
+ promise = this.callback.call(this.testEnvironment, this.assert);
566
+ this.resolvePromise(promise);
567
+ return;
568
+ }
569
+ try {
570
+ promise = this.callback.call(this.testEnvironment, this.assert);
571
+ this.resolvePromise(promise);
572
+ }
573
+ catch (e) {
574
+ this.pushFailure('Died on test #' + (this.assertions.length + 1) + ' ' + this.stack + ': ' + (e.message || e), extractStacktrace(e, 0));
575
+ saveGlobal();
576
+ if (config.blocking) {
577
+ QUnit.start();
578
+ }
579
+ }
580
+ },
581
+ after: function () {
582
+ checkPollution();
583
+ },
584
+ queueHook: function (hook, hookName) {
585
+ var promise, test = this;
586
+ return function runHook() {
587
+ config.current = test;
588
+ if (config.notrycatch) {
589
+ promise = hook.call(test.testEnvironment, test.assert);
590
+ test.resolvePromise(promise, hookName);
591
+ return;
592
+ }
593
+ try {
594
+ promise = hook.call(test.testEnvironment, test.assert);
595
+ test.resolvePromise(promise, hookName);
596
+ }
597
+ catch (error) {
598
+ test.pushFailure(hookName + ' failed on ' + test.testName + ': ' + (error.message || error), extractStacktrace(error, 0));
599
+ }
600
+ };
601
+ },
602
+ hooks: function (handler) {
603
+ var hooks = [];
604
+ if (this.skip) {
605
+ return hooks;
606
+ }
607
+ if (this.module.testEnvironment && QUnit.objectType(this.module.testEnvironment[handler]) === 'function') {
608
+ hooks.push(this.queueHook(this.module.testEnvironment[handler], handler));
609
+ }
610
+ return hooks;
611
+ },
612
+ finish: function () {
613
+ config.current = this;
614
+ if (config.requireExpects && this.expected === null) {
615
+ this.pushFailure('Expected number of assertions to be defined, but expect() was ' + 'not called.', this.stack);
616
+ }
617
+ else if (this.expected !== null && this.expected !== this.assertions.length) {
618
+ this.pushFailure('Expected ' + this.expected + ' assertions, but ' + this.assertions.length + ' were run', this.stack);
619
+ }
620
+ else if (this.expected === null && !this.assertions.length) {
621
+ this.pushFailure('Expected at least one assertion, but none were run - call ' + 'expect(0) to accept zero assertions.', this.stack);
622
+ }
623
+ var i, bad = 0;
624
+ this.runtime = now() - this.started;
625
+ config.stats.all += this.assertions.length;
626
+ config.moduleStats.all += this.assertions.length;
627
+ for (i = 0; i < this.assertions.length; i++) {
628
+ if (!this.assertions[i].result) {
629
+ bad++;
630
+ config.stats.bad++;
631
+ config.moduleStats.bad++;
632
+ }
633
+ }
634
+ runLoggingCallbacks('testDone', {
635
+ name: this.testName,
636
+ module: this.module.name,
637
+ skipped: !!this.skip,
638
+ failed: bad,
639
+ passed: this.assertions.length - bad,
640
+ total: this.assertions.length,
641
+ runtime: this.runtime,
642
+ assertions: this.assertions,
643
+ testId: this.testId,
644
+ source: this.stack,
645
+ duration: this.runtime,
646
+ });
647
+ QUnit.reset();
648
+ config.current = undefined;
649
+ },
650
+ queue: function () {
651
+ var bad, test = this;
652
+ if (!this.valid()) {
653
+ return;
654
+ }
655
+ function run() {
656
+ synchronize([
657
+ function () {
658
+ test.before();
659
+ },
660
+ test.hooks('beforeEach'),
661
+ function () {
662
+ test.run();
663
+ },
664
+ test.hooks('afterEach').reverse(),
665
+ function () {
666
+ test.after();
667
+ },
668
+ function () {
669
+ test.finish();
670
+ },
671
+ ]);
672
+ }
673
+ bad =
674
+ QUnit.config.reorder &&
675
+ defined.sessionStorage &&
676
+ +sessionStorage.getItem('qunit-test-' + this.module.name + '-' + this.testName);
677
+ if (bad) {
678
+ run();
679
+ }
680
+ else {
681
+ synchronize(run, true);
682
+ }
683
+ },
684
+ push: function (result, actual, expected, message, negative) {
685
+ var source, details = {
686
+ module: this.module.name,
687
+ name: this.testName,
688
+ result: result,
689
+ message: message,
690
+ actual: actual,
691
+ expected: expected,
692
+ testId: this.testId,
693
+ negative: negative || false,
694
+ runtime: now() - this.started,
695
+ };
696
+ if (!result) {
697
+ source = sourceFromStacktrace();
698
+ if (source) {
699
+ details.source = source;
700
+ }
701
+ }
702
+ runLoggingCallbacks('log', details);
703
+ this.assertions.push({
704
+ result: !!result,
705
+ message: message,
706
+ });
707
+ },
708
+ pushFailure: function (message, source, actual) {
709
+ if (!(this instanceof Test)) {
710
+ throw new Error('pushFailure() assertion outside test context, was ' + sourceFromStacktrace(2));
711
+ }
712
+ var details = {
713
+ module: this.module.name,
714
+ name: this.testName,
715
+ result: false,
716
+ message: message || 'error',
717
+ actual: actual || null,
718
+ testId: this.testId,
719
+ runtime: now() - this.started,
720
+ };
721
+ if (source) {
722
+ details.source = source;
723
+ }
724
+ runLoggingCallbacks('log', details);
725
+ this.assertions.push({
726
+ result: false,
727
+ message: message,
728
+ });
729
+ },
730
+ resolvePromise: function (promise, phase) {
731
+ var then, message, test = this;
732
+ if (promise != null) {
733
+ then = promise.then;
734
+ if (QUnit.objectType(then) === 'function') {
735
+ QUnit.stop();
736
+ then.call(promise, function () {
737
+ QUnit.start();
738
+ }, function (error) {
739
+ message =
740
+ 'Promise rejected ' +
741
+ (!phase ? 'during' : phase.replace(/Each$/, '')) +
742
+ ' ' +
743
+ test.testName +
744
+ ': ' +
745
+ (error.message || error);
746
+ test.pushFailure(message, extractStacktrace(error, 0));
747
+ saveGlobal();
748
+ QUnit.start();
749
+ });
750
+ }
751
+ }
752
+ },
753
+ valid: function () {
754
+ var include, filter = config.filter && config.filter.toLowerCase(), module = QUnit.urlParams.module && QUnit.urlParams.module.toLowerCase(), fullName = (this.module.name + ': ' + this.testName).toLowerCase();
755
+ if (this.callback && this.callback.validTest) {
756
+ return true;
757
+ }
758
+ if (config.testId.length > 0 && inArray(this.testId, config.testId) < 0) {
759
+ return false;
760
+ }
761
+ if (module && (!this.module.name || this.module.name.toLowerCase() !== module)) {
762
+ return false;
763
+ }
764
+ if (!filter) {
765
+ return true;
766
+ }
767
+ include = filter.charAt(0) !== '!';
768
+ if (!include) {
769
+ filter = filter.slice(1);
770
+ }
771
+ if (fullName.indexOf(filter) !== -1) {
772
+ return include;
773
+ }
774
+ return !include;
775
+ },
776
+ };
777
+ QUnit.reset = function () {
778
+ if (!defined.document) {
779
+ return;
780
+ }
781
+ var fixture = defined.document && document.getElementById && document.getElementById('qunit-fixture');
782
+ if (fixture) {
783
+ fixture.innerHTML = config.fixture;
784
+ }
785
+ };
786
+ QUnit.pushFailure = function () {
787
+ if (!QUnit.config.current) {
788
+ throw new Error('pushFailure() assertion outside test context, in ' + sourceFromStacktrace(2));
789
+ }
790
+ var currentTest = QUnit.config.current;
791
+ return currentTest.pushFailure.apply(currentTest, arguments);
792
+ };
793
+ function generateHash(module, testName) {
794
+ var hex, i = 0, hash = 0, str = module + '\x1C' + testName, len = str.length;
795
+ for (; i < len; i++) {
796
+ hash = (hash << 5) - hash + str.charCodeAt(i);
797
+ hash |= 0;
798
+ }
799
+ hex = (0x100000000 + hash).toString(16);
800
+ if (hex.length < 8) {
801
+ hex = '0000000' + hex;
802
+ }
803
+ return hex.slice(-8);
804
+ }
805
+ function synchronize(callback, last) {
806
+ if (QUnit.objectType(callback) === 'array') {
807
+ while (callback.length) {
808
+ synchronize(callback.shift());
809
+ }
810
+ return;
811
+ }
812
+ config.queue.push(callback);
813
+ if (config.autorun && !config.blocking) {
814
+ process(last);
815
+ }
816
+ }
817
+ function saveGlobal() {
818
+ config.pollution = [];
819
+ if (config.noglobals) {
820
+ for (var key in global) {
821
+ if (hasOwn.call(global, key)) {
822
+ if (/^qunit-test-output/.test(key)) {
823
+ continue;
824
+ }
825
+ config.pollution.push(key);
826
+ }
827
+ }
828
+ }
829
+ }
830
+ function checkPollution() {
831
+ var newGlobals, deletedGlobals, old = config.pollution;
832
+ saveGlobal();
833
+ newGlobals = diff(config.pollution, old);
834
+ if (newGlobals.length > 0) {
835
+ QUnit.pushFailure('Introduced global variable(s): ' + newGlobals.join(', '));
836
+ }
837
+ deletedGlobals = diff(old, config.pollution);
838
+ if (deletedGlobals.length > 0) {
839
+ QUnit.pushFailure('Deleted global variable(s): ' + deletedGlobals.join(', '));
840
+ }
841
+ }
842
+ function asyncTest(testName, expected, callback) {
843
+ if (arguments.length === 2) {
844
+ callback = expected;
845
+ expected = null;
846
+ }
847
+ QUnit.test(testName, expected, callback, true);
848
+ }
849
+ function test(testName, expected, callback, async) {
850
+ var newTest;
851
+ if (arguments.length === 2) {
852
+ callback = expected;
853
+ expected = null;
854
+ }
855
+ newTest = new Test({
856
+ testName: testName,
857
+ expected: expected,
858
+ async: async,
859
+ callback: callback,
860
+ });
861
+ newTest.queue();
862
+ }
863
+ function skip(testName) {
864
+ var test = new Test({
865
+ testName: testName,
866
+ skip: true,
867
+ });
868
+ test.queue();
869
+ }
870
+ function Assert(testContext) {
871
+ this.test = testContext;
872
+ }
873
+ QUnit.assert = Assert.prototype = {
874
+ expect: function (asserts) {
875
+ if (arguments.length === 1) {
876
+ this.test.expected = asserts;
877
+ }
878
+ else {
879
+ return this.test.expected;
880
+ }
881
+ },
882
+ async: function () {
883
+ var test = this.test, popped = false;
884
+ test.semaphore += 1;
885
+ test.usedAsync = true;
886
+ pauseProcessing();
887
+ return function done() {
888
+ if (!popped) {
889
+ test.semaphore -= 1;
890
+ popped = true;
891
+ resumeProcessing();
892
+ }
893
+ else {
894
+ test.pushFailure('Called the callback returned from `assert.async` more than once', sourceFromStacktrace(2));
895
+ }
896
+ };
897
+ },
898
+ push: function () {
899
+ var assert = this, currentTest = (assert instanceof Assert && assert.test) || QUnit.config.current;
900
+ if (!currentTest) {
901
+ throw new Error('assertion outside test context, in ' + sourceFromStacktrace(2));
902
+ }
903
+ if (currentTest.usedAsync === true && currentTest.semaphore === 0) {
904
+ currentTest.pushFailure('Assertion after the final `assert.async` was resolved', sourceFromStacktrace(2));
905
+ }
906
+ if (!(assert instanceof Assert)) {
907
+ assert = currentTest.assert;
908
+ }
909
+ return assert.test.push.apply(assert.test, arguments);
910
+ },
911
+ ok: function (result, message) {
912
+ message =
913
+ message || (result ? 'okay' : 'failed, expected argument to be truthy, was: ' + QUnit.dump.parse(result));
914
+ this.push(!!result, result, true, message);
915
+ },
916
+ notOk: function (result, message) {
917
+ message =
918
+ message || (!result ? 'okay' : 'failed, expected argument to be falsy, was: ' + QUnit.dump.parse(result));
919
+ this.push(!result, result, false, message, true);
920
+ },
921
+ equal: function (actual, expected, message) {
922
+ this.push(expected == actual, actual, expected, message);
923
+ },
924
+ notEqual: function (actual, expected, message) {
925
+ this.push(expected != actual, actual, expected, message, true);
926
+ },
927
+ propEqual: function (actual, expected, message) {
928
+ actual = objectValues(actual);
929
+ expected = objectValues(expected);
930
+ this.push(QUnit.equiv(actual, expected), actual, expected, message);
931
+ },
932
+ notPropEqual: function (actual, expected, message) {
933
+ actual = objectValues(actual);
934
+ expected = objectValues(expected);
935
+ this.push(!QUnit.equiv(actual, expected), actual, expected, message, true);
936
+ },
937
+ deepEqual: function (actual, expected, message) {
938
+ this.push(QUnit.equiv(actual, expected), actual, expected, message);
939
+ },
940
+ notDeepEqual: function (actual, expected, message) {
941
+ this.push(!QUnit.equiv(actual, expected), actual, expected, message, true);
942
+ },
943
+ strictEqual: function (actual, expected, message) {
944
+ this.push(expected === actual, actual, expected, message);
945
+ },
946
+ notStrictEqual: function (actual, expected, message) {
947
+ this.push(expected !== actual, actual, expected, message, true);
948
+ },
949
+ throws: function (block, expected, message) {
950
+ var actual, expectedType, expectedOutput = expected, ok = false, currentTest = (this instanceof Assert && this.test) || QUnit.config.current;
951
+ if (message == null && typeof expected === 'string') {
952
+ message = expected;
953
+ expected = null;
954
+ }
955
+ currentTest.ignoreGlobalErrors = true;
956
+ try {
957
+ block.call(currentTest.testEnvironment);
958
+ }
959
+ catch (e) {
960
+ actual = e;
961
+ }
962
+ currentTest.ignoreGlobalErrors = false;
963
+ if (actual) {
964
+ expectedType = QUnit.objectType(expected);
965
+ if (!expected) {
966
+ ok = true;
967
+ expectedOutput = null;
968
+ }
969
+ else if (expectedType === 'regexp') {
970
+ ok = expected.test(errorString(actual));
971
+ }
972
+ else if (expectedType === 'string') {
973
+ ok = expected === errorString(actual);
974
+ }
975
+ else if (expectedType === 'function' && actual instanceof expected) {
976
+ ok = true;
977
+ }
978
+ else if (expectedType === 'object') {
979
+ ok =
980
+ actual instanceof expected.constructor &&
981
+ actual.name === expected.name &&
982
+ actual.message === expected.message;
983
+ }
984
+ else if (expectedType === 'function' && expected.call({}, actual) === true) {
985
+ expectedOutput = null;
986
+ ok = true;
987
+ }
988
+ }
989
+ currentTest.assert.push(ok, actual, expectedOutput, message);
990
+ },
991
+ };
992
+ (function () {
993
+ Assert.prototype.raises = Assert.prototype['throws'];
994
+ })();
995
+ function errorString(error) {
996
+ var name, message, resultErrorString = error.toString();
997
+ if (resultErrorString.substring(0, 7) === '[object') {
998
+ name = error.name ? error.name.toString() : 'Error';
999
+ message = error.message ? error.message.toString() : '';
1000
+ if (name && message) {
1001
+ return name + ': ' + message;
1002
+ }
1003
+ else if (name) {
1004
+ return name;
1005
+ }
1006
+ else if (message) {
1007
+ return message;
1008
+ }
1009
+ else {
1010
+ return 'Error';
1011
+ }
1012
+ }
1013
+ else {
1014
+ return resultErrorString;
1015
+ }
1016
+ }
1017
+ QUnit.equiv = (function () {
1018
+ function bindCallbacks(o, callbacks, args) {
1019
+ var prop = QUnit.objectType(o);
1020
+ if (prop) {
1021
+ if (QUnit.objectType(callbacks[prop]) === 'function') {
1022
+ return callbacks[prop].apply(callbacks, args);
1023
+ }
1024
+ else {
1025
+ return callbacks[prop];
1026
+ }
1027
+ }
1028
+ }
1029
+ var innerEquiv, callers = [], parents = [], parentsB = [], getProto = Object.getPrototypeOf ||
1030
+ function (obj) {
1031
+ return obj.__proto__;
1032
+ }, callbacks = (function () {
1033
+ function useStrictEquality(b, a) {
1034
+ if (b instanceof a.constructor || a instanceof b.constructor) {
1035
+ return a == b;
1036
+ }
1037
+ else {
1038
+ return a === b;
1039
+ }
1040
+ }
1041
+ return {
1042
+ string: useStrictEquality,
1043
+ boolean: useStrictEquality,
1044
+ number: useStrictEquality,
1045
+ null: useStrictEquality,
1046
+ undefined: useStrictEquality,
1047
+ nan: function (b) {
1048
+ return isNaN(b);
1049
+ },
1050
+ date: function (b, a) {
1051
+ return QUnit.objectType(b) === 'date' && a.valueOf() === b.valueOf();
1052
+ },
1053
+ regexp: function (b, a) {
1054
+ return (QUnit.objectType(b) === 'regexp' &&
1055
+ a.source === b.source &&
1056
+ a.global === b.global &&
1057
+ a.ignoreCase === b.ignoreCase &&
1058
+ a.multiline === b.multiline &&
1059
+ a.sticky === b.sticky);
1060
+ },
1061
+ function: function () {
1062
+ var caller = callers[callers.length - 1];
1063
+ return caller !== Object && typeof caller !== 'undefined';
1064
+ },
1065
+ array: function (b, a) {
1066
+ var i, j, len, loop, aCircular, bCircular;
1067
+ if (QUnit.objectType(b) !== 'array') {
1068
+ return false;
1069
+ }
1070
+ len = a.length;
1071
+ if (len !== b.length) {
1072
+ return false;
1073
+ }
1074
+ parents.push(a);
1075
+ parentsB.push(b);
1076
+ for (i = 0; i < len; i++) {
1077
+ loop = false;
1078
+ for (j = 0; j < parents.length; j++) {
1079
+ aCircular = parents[j] === a[i];
1080
+ bCircular = parentsB[j] === b[i];
1081
+ if (aCircular || bCircular) {
1082
+ if (a[i] === b[i] || (aCircular && bCircular)) {
1083
+ loop = true;
1084
+ }
1085
+ else {
1086
+ parents.pop();
1087
+ parentsB.pop();
1088
+ return false;
1089
+ }
1090
+ }
1091
+ }
1092
+ if (!loop && !innerEquiv(a[i], b[i])) {
1093
+ parents.pop();
1094
+ parentsB.pop();
1095
+ return false;
1096
+ }
1097
+ }
1098
+ parents.pop();
1099
+ parentsB.pop();
1100
+ return true;
1101
+ },
1102
+ set: function (b, a) {
1103
+ var aArray, bArray;
1104
+ if (QUnit.objectType(b) !== 'set') {
1105
+ return false;
1106
+ }
1107
+ aArray = [];
1108
+ a.forEach(function (v) {
1109
+ aArray.push(v);
1110
+ });
1111
+ bArray = [];
1112
+ b.forEach(function (v) {
1113
+ bArray.push(v);
1114
+ });
1115
+ return innerEquiv(bArray, aArray);
1116
+ },
1117
+ map: function (b, a) {
1118
+ var aArray, bArray;
1119
+ if (QUnit.objectType(b) !== 'map') {
1120
+ return false;
1121
+ }
1122
+ aArray = [];
1123
+ a.forEach(function (v, k) {
1124
+ aArray.push([k, v]);
1125
+ });
1126
+ bArray = [];
1127
+ b.forEach(function (v, k) {
1128
+ bArray.push([k, v]);
1129
+ });
1130
+ return innerEquiv(bArray, aArray);
1131
+ },
1132
+ object: function (b, a) {
1133
+ var i, j, loop, aCircular, bCircular, eq = true, aProperties = [], bProperties = [];
1134
+ if (a.constructor !== b.constructor) {
1135
+ if (!((getProto(a) === null && getProto(b) === Object.prototype) ||
1136
+ (getProto(b) === null && getProto(a) === Object.prototype))) {
1137
+ return false;
1138
+ }
1139
+ }
1140
+ callers.push(a.constructor);
1141
+ parents.push(a);
1142
+ parentsB.push(b);
1143
+ for (i in a) {
1144
+ loop = false;
1145
+ for (j = 0; j < parents.length; j++) {
1146
+ aCircular = parents[j] === a[i];
1147
+ bCircular = parentsB[j] === b[i];
1148
+ if (aCircular || bCircular) {
1149
+ if (a[i] === b[i] || (aCircular && bCircular)) {
1150
+ loop = true;
1151
+ }
1152
+ else {
1153
+ eq = false;
1154
+ break;
1155
+ }
1156
+ }
1157
+ }
1158
+ aProperties.push(i);
1159
+ if (!loop && !innerEquiv(a[i], b[i])) {
1160
+ eq = false;
1161
+ break;
1162
+ }
1163
+ }
1164
+ parents.pop();
1165
+ parentsB.pop();
1166
+ callers.pop();
1167
+ for (i in b) {
1168
+ bProperties.push(i);
1169
+ }
1170
+ return eq && innerEquiv(aProperties.sort(), bProperties.sort());
1171
+ },
1172
+ };
1173
+ })();
1174
+ innerEquiv = function () {
1175
+ var args = [].slice.apply(arguments);
1176
+ if (args.length < 2) {
1177
+ return true;
1178
+ }
1179
+ return ((function (a, b) {
1180
+ if (a === b) {
1181
+ return true;
1182
+ }
1183
+ else if (a === null ||
1184
+ b === null ||
1185
+ typeof a === 'undefined' ||
1186
+ typeof b === 'undefined' ||
1187
+ QUnit.objectType(a) !== QUnit.objectType(b)) {
1188
+ return false;
1189
+ }
1190
+ else {
1191
+ return bindCallbacks(a, callbacks, [b, a]);
1192
+ }
1193
+ })(args[0], args[1]) && innerEquiv.apply(this, args.splice(1, args.length - 1)));
1194
+ };
1195
+ return innerEquiv;
1196
+ })();
1197
+ QUnit.dump = (function () {
1198
+ function quote(str) {
1199
+ return '"' + str.toString().replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
1200
+ }
1201
+ function literal(o) {
1202
+ return o + '';
1203
+ }
1204
+ function join(pre, arr, post) {
1205
+ var s = dump.separator(), base = dump.indent(), inner = dump.indent(1);
1206
+ if (arr.join) {
1207
+ arr = arr.join(',' + s + inner);
1208
+ }
1209
+ if (!arr) {
1210
+ return pre + post;
1211
+ }
1212
+ return [pre, inner + arr, base + post].join(s);
1213
+ }
1214
+ function array(arr, stack) {
1215
+ var i = arr.length, ret = new Array(i);
1216
+ if (dump.maxDepth && dump.depth > dump.maxDepth) {
1217
+ return '[object Array]';
1218
+ }
1219
+ this.up();
1220
+ while (i--) {
1221
+ ret[i] = this.parse(arr[i], undefined, stack);
1222
+ }
1223
+ this.down();
1224
+ return join('[', ret, ']');
1225
+ }
1226
+ var reName = /^function (\w+)/, dump = {
1227
+ parse: function (obj, objType, stack) {
1228
+ stack = stack || [];
1229
+ var res, parser, parserType, inStack = inArray(obj, stack);
1230
+ if (inStack !== -1) {
1231
+ return 'recursion(' + (inStack - stack.length) + ')';
1232
+ }
1233
+ objType = objType || this.typeOf(obj);
1234
+ parser = this.parsers[objType];
1235
+ parserType = typeof parser;
1236
+ if (parserType === 'function') {
1237
+ stack.push(obj);
1238
+ res = parser.call(this, obj, stack);
1239
+ stack.pop();
1240
+ return res;
1241
+ }
1242
+ return parserType === 'string' ? parser : this.parsers.error;
1243
+ },
1244
+ typeOf: function (obj) {
1245
+ var type;
1246
+ if (obj === null) {
1247
+ type = 'null';
1248
+ }
1249
+ else if (typeof obj === 'undefined') {
1250
+ type = 'undefined';
1251
+ }
1252
+ else if (QUnit.is('regexp', obj)) {
1253
+ type = 'regexp';
1254
+ }
1255
+ else if (QUnit.is('date', obj)) {
1256
+ type = 'date';
1257
+ }
1258
+ else if (QUnit.is('function', obj)) {
1259
+ type = 'function';
1260
+ }
1261
+ else if (obj.setInterval !== undefined && obj.document !== undefined && obj.nodeType === undefined) {
1262
+ type = 'window';
1263
+ }
1264
+ else if (obj.nodeType === 9) {
1265
+ type = 'document';
1266
+ }
1267
+ else if (obj.nodeType) {
1268
+ type = 'node';
1269
+ }
1270
+ else if (toString.call(obj) === '[object Array]' ||
1271
+ (typeof obj.length === 'number' &&
1272
+ obj.item !== undefined &&
1273
+ (obj.length ? obj.item(0) === obj[0] : obj.item(0) === null && obj[0] === undefined))) {
1274
+ type = 'array';
1275
+ }
1276
+ else if (obj.constructor === Error.prototype.constructor) {
1277
+ type = 'error';
1278
+ }
1279
+ else {
1280
+ type = typeof obj;
1281
+ }
1282
+ return type;
1283
+ },
1284
+ separator: function () {
1285
+ return this.multiline ? (this.HTML ? '<br />' : '\n') : this.HTML ? '&#160;' : ' ';
1286
+ },
1287
+ indent: function (extra) {
1288
+ if (!this.multiline) {
1289
+ return '';
1290
+ }
1291
+ var chr = this.indentChar;
1292
+ if (this.HTML) {
1293
+ chr = chr.replace(/\t/g, ' ').replace(/ /g, '&#160;');
1294
+ }
1295
+ return new Array(this.depth + (extra || 0)).join(chr);
1296
+ },
1297
+ up: function (a) {
1298
+ this.depth += a || 1;
1299
+ },
1300
+ down: function (a) {
1301
+ this.depth -= a || 1;
1302
+ },
1303
+ setParser: function (name, parser) {
1304
+ this.parsers[name] = parser;
1305
+ },
1306
+ quote: quote,
1307
+ literal: literal,
1308
+ join: join,
1309
+ depth: 1,
1310
+ maxDepth: QUnit.config.maxDepth,
1311
+ parsers: {
1312
+ window: '[Window]',
1313
+ document: '[Document]',
1314
+ error: function (error) {
1315
+ return 'Error("' + error.message + '")';
1316
+ },
1317
+ unknown: '[Unknown]',
1318
+ null: 'null',
1319
+ undefined: 'undefined',
1320
+ function: function (fn) {
1321
+ var ret = 'function', name = 'name' in fn ? fn.name : (reName.exec(fn) || [])[1];
1322
+ if (name) {
1323
+ ret += ' ' + name;
1324
+ }
1325
+ ret += '( ';
1326
+ ret = [ret, dump.parse(fn, 'functionArgs'), '){'].join('');
1327
+ return join(ret, dump.parse(fn, 'functionCode'), '}');
1328
+ },
1329
+ array: array,
1330
+ nodelist: array,
1331
+ arguments: array,
1332
+ object: function (map, stack) {
1333
+ var keys, key, val, i, nonEnumerableProperties, ret = [];
1334
+ if (dump.maxDepth && dump.depth > dump.maxDepth) {
1335
+ return '[object Object]';
1336
+ }
1337
+ dump.up();
1338
+ keys = [];
1339
+ for (key in map) {
1340
+ keys.push(key);
1341
+ }
1342
+ nonEnumerableProperties = ['message', 'name'];
1343
+ for (i in nonEnumerableProperties) {
1344
+ key = nonEnumerableProperties[i];
1345
+ if (key in map && inArray(key, keys) < 0) {
1346
+ keys.push(key);
1347
+ }
1348
+ }
1349
+ keys.sort();
1350
+ for (i = 0; i < keys.length; i++) {
1351
+ key = keys[i];
1352
+ val = map[key];
1353
+ ret.push(dump.parse(key, 'key') + ': ' + dump.parse(val, undefined, stack));
1354
+ }
1355
+ dump.down();
1356
+ return join('{', ret, '}');
1357
+ },
1358
+ node: function (node) {
1359
+ var len, i, val, open = dump.HTML ? '&lt;' : '<', close = dump.HTML ? '&gt;' : '>', tag = node.nodeName.toLowerCase(), ret = open + tag, attrs = node.attributes;
1360
+ if (attrs) {
1361
+ for (i = 0, len = attrs.length; i < len; i++) {
1362
+ val = attrs[i].nodeValue;
1363
+ if (val && val !== 'inherit') {
1364
+ ret += ' ' + attrs[i].nodeName + '=' + dump.parse(val, 'attribute');
1365
+ }
1366
+ }
1367
+ }
1368
+ ret += close;
1369
+ if (node.nodeType === 3 || node.nodeType === 4) {
1370
+ ret += node.nodeValue;
1371
+ }
1372
+ return ret + open + '/' + tag + close;
1373
+ },
1374
+ functionArgs: function (fn) {
1375
+ var args, l = fn.length;
1376
+ if (!l) {
1377
+ return '';
1378
+ }
1379
+ args = new Array(l);
1380
+ while (l--) {
1381
+ args[l] = String.fromCharCode(97 + l);
1382
+ }
1383
+ return ' ' + args.join(', ') + ' ';
1384
+ },
1385
+ key: quote,
1386
+ functionCode: '[code]',
1387
+ attribute: quote,
1388
+ string: quote,
1389
+ date: quote,
1390
+ regexp: literal,
1391
+ number: literal,
1392
+ boolean: literal,
1393
+ },
1394
+ HTML: false,
1395
+ indentChar: ' ',
1396
+ multiline: true,
1397
+ };
1398
+ return dump;
1399
+ })();
1400
+ QUnit.jsDump = QUnit.dump;
1401
+ if (defined.document) {
1402
+ (function () {
1403
+ var i, assertions = Assert.prototype;
1404
+ function applyCurrent(current) {
1405
+ return function () {
1406
+ var assert = new Assert(QUnit.config.current);
1407
+ current.apply(assert, arguments);
1408
+ };
1409
+ }
1410
+ for (i in assertions) {
1411
+ QUnit[i] = applyCurrent(assertions[i]);
1412
+ }
1413
+ })();
1414
+ (function () {
1415
+ var i, l, keys = [
1416
+ 'test',
1417
+ 'module',
1418
+ 'expect',
1419
+ 'asyncTest',
1420
+ 'start',
1421
+ 'stop',
1422
+ 'ok',
1423
+ 'notOk',
1424
+ 'equal',
1425
+ 'notEqual',
1426
+ 'propEqual',
1427
+ 'notPropEqual',
1428
+ 'deepEqual',
1429
+ 'notDeepEqual',
1430
+ 'strictEqual',
1431
+ 'notStrictEqual',
1432
+ 'throws',
1433
+ ];
1434
+ for (i = 0, l = keys.length; i < l; i++) {
1435
+ window[keys[i]] = QUnit[keys[i]];
1436
+ }
1437
+ })();
1438
+ window.QUnit = QUnit;
1439
+ }
1440
+ if (typeof module !== 'undefined' && module && module.exports) {
1441
+ module.exports = QUnit;
1442
+ module.exports.QUnit = QUnit;
1443
+ }
1444
+ if (typeof exports !== 'undefined' && exports) {
1445
+ exports.QUnit = QUnit;
1446
+ }
1447
+ if (typeof define === 'function' && define.amd) {
1448
+ define(function () {
1449
+ return QUnit;
1450
+ });
1451
+ QUnit.config.autostart = false;
1452
+ }
1453
+ QUnit.diff = (function () {
1454
+ function DiffMatchPatch() { }
1455
+ var DIFF_DELETE = -1, DIFF_INSERT = 1, DIFF_EQUAL = 0;
1456
+ DiffMatchPatch.prototype.DiffMain = function (text1, text2, optChecklines) {
1457
+ var deadline, checklines, commonlength, commonprefix, commonsuffix, diffs;
1458
+ deadline = new Date().getTime() + 1000;
1459
+ if (text1 === null || text2 === null) {
1460
+ throw new Error('Null input. (DiffMain)');
1461
+ }
1462
+ if (text1 === text2) {
1463
+ if (text1) {
1464
+ return [[DIFF_EQUAL, text1]];
1465
+ }
1466
+ return [];
1467
+ }
1468
+ if (typeof optChecklines === 'undefined') {
1469
+ optChecklines = true;
1470
+ }
1471
+ checklines = optChecklines;
1472
+ commonlength = this.diffCommonPrefix(text1, text2);
1473
+ commonprefix = text1.substring(0, commonlength);
1474
+ text1 = text1.substring(commonlength);
1475
+ text2 = text2.substring(commonlength);
1476
+ commonlength = this.diffCommonSuffix(text1, text2);
1477
+ commonsuffix = text1.substring(text1.length - commonlength);
1478
+ text1 = text1.substring(0, text1.length - commonlength);
1479
+ text2 = text2.substring(0, text2.length - commonlength);
1480
+ diffs = this.diffCompute(text1, text2, checklines, deadline);
1481
+ if (commonprefix) {
1482
+ diffs.unshift([DIFF_EQUAL, commonprefix]);
1483
+ }
1484
+ if (commonsuffix) {
1485
+ diffs.push([DIFF_EQUAL, commonsuffix]);
1486
+ }
1487
+ this.diffCleanupMerge(diffs);
1488
+ return diffs;
1489
+ };
1490
+ DiffMatchPatch.prototype.diffCleanupEfficiency = function (diffs) {
1491
+ var changes, equalities, equalitiesLength, lastequality, pointer, preIns, preDel, postIns, postDel;
1492
+ changes = false;
1493
+ equalities = [];
1494
+ equalitiesLength = 0;
1495
+ lastequality = null;
1496
+ pointer = 0;
1497
+ preIns = false;
1498
+ preDel = false;
1499
+ postIns = false;
1500
+ postDel = false;
1501
+ while (pointer < diffs.length) {
1502
+ if (diffs[pointer][0] === DIFF_EQUAL) {
1503
+ if (diffs[pointer][1].length < 4 && (postIns || postDel)) {
1504
+ equalities[equalitiesLength++] = pointer;
1505
+ preIns = postIns;
1506
+ preDel = postDel;
1507
+ lastequality = diffs[pointer][1];
1508
+ }
1509
+ else {
1510
+ equalitiesLength = 0;
1511
+ lastequality = null;
1512
+ }
1513
+ postIns = postDel = false;
1514
+ }
1515
+ else {
1516
+ if (diffs[pointer][0] === DIFF_DELETE) {
1517
+ postDel = true;
1518
+ }
1519
+ else {
1520
+ postIns = true;
1521
+ }
1522
+ if (lastequality &&
1523
+ ((preIns && preDel && postIns && postDel) ||
1524
+ (lastequality.length < 2 && preIns + preDel + postIns + postDel === 3))) {
1525
+ diffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]);
1526
+ diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
1527
+ equalitiesLength--;
1528
+ lastequality = null;
1529
+ if (preIns && preDel) {
1530
+ postIns = postDel = true;
1531
+ equalitiesLength = 0;
1532
+ }
1533
+ else {
1534
+ equalitiesLength--;
1535
+ pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
1536
+ postIns = postDel = false;
1537
+ }
1538
+ changes = true;
1539
+ }
1540
+ }
1541
+ pointer++;
1542
+ }
1543
+ if (changes) {
1544
+ this.diffCleanupMerge(diffs);
1545
+ }
1546
+ };
1547
+ DiffMatchPatch.prototype.diffPrettyHtml = function (diffs) {
1548
+ var op, data, x, html = [];
1549
+ for (x = 0; x < diffs.length; x++) {
1550
+ op = diffs[x][0];
1551
+ data = diffs[x][1];
1552
+ switch (op) {
1553
+ case DIFF_INSERT:
1554
+ html[x] = '<ins>' + data + '</ins>';
1555
+ break;
1556
+ case DIFF_DELETE:
1557
+ html[x] = '<del>' + data + '</del>';
1558
+ break;
1559
+ case DIFF_EQUAL:
1560
+ html[x] = '<span>' + data + '</span>';
1561
+ break;
1562
+ }
1563
+ }
1564
+ return html.join('');
1565
+ };
1566
+ DiffMatchPatch.prototype.diffCommonPrefix = function (text1, text2) {
1567
+ var pointermid, pointermax, pointermin, pointerstart;
1568
+ if (!text1 || !text2 || text1.charAt(0) !== text2.charAt(0)) {
1569
+ return 0;
1570
+ }
1571
+ pointermin = 0;
1572
+ pointermax = Math.min(text1.length, text2.length);
1573
+ pointermid = pointermax;
1574
+ pointerstart = 0;
1575
+ while (pointermin < pointermid) {
1576
+ if (text1.substring(pointerstart, pointermid) === text2.substring(pointerstart, pointermid)) {
1577
+ pointermin = pointermid;
1578
+ pointerstart = pointermin;
1579
+ }
1580
+ else {
1581
+ pointermax = pointermid;
1582
+ }
1583
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
1584
+ }
1585
+ return pointermid;
1586
+ };
1587
+ DiffMatchPatch.prototype.diffCommonSuffix = function (text1, text2) {
1588
+ var pointermid, pointermax, pointermin, pointerend;
1589
+ if (!text1 || !text2 || text1.charAt(text1.length - 1) !== text2.charAt(text2.length - 1)) {
1590
+ return 0;
1591
+ }
1592
+ pointermin = 0;
1593
+ pointermax = Math.min(text1.length, text2.length);
1594
+ pointermid = pointermax;
1595
+ pointerend = 0;
1596
+ while (pointermin < pointermid) {
1597
+ if (text1.substring(text1.length - pointermid, text1.length - pointerend) ===
1598
+ text2.substring(text2.length - pointermid, text2.length - pointerend)) {
1599
+ pointermin = pointermid;
1600
+ pointerend = pointermin;
1601
+ }
1602
+ else {
1603
+ pointermax = pointermid;
1604
+ }
1605
+ pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
1606
+ }
1607
+ return pointermid;
1608
+ };
1609
+ DiffMatchPatch.prototype.diffCompute = function (text1, text2, checklines, deadline) {
1610
+ var diffs, longtext, shorttext, i, hm, text1A, text2A, text1B, text2B, midCommon, diffsA, diffsB;
1611
+ if (!text1) {
1612
+ return [[DIFF_INSERT, text2]];
1613
+ }
1614
+ if (!text2) {
1615
+ return [[DIFF_DELETE, text1]];
1616
+ }
1617
+ longtext = text1.length > text2.length ? text1 : text2;
1618
+ shorttext = text1.length > text2.length ? text2 : text1;
1619
+ i = longtext.indexOf(shorttext);
1620
+ if (i !== -1) {
1621
+ diffs = [
1622
+ [DIFF_INSERT, longtext.substring(0, i)],
1623
+ [DIFF_EQUAL, shorttext],
1624
+ [DIFF_INSERT, longtext.substring(i + shorttext.length)],
1625
+ ];
1626
+ if (text1.length > text2.length) {
1627
+ diffs[0][0] = diffs[2][0] = DIFF_DELETE;
1628
+ }
1629
+ return diffs;
1630
+ }
1631
+ if (shorttext.length === 1) {
1632
+ return [
1633
+ [DIFF_DELETE, text1],
1634
+ [DIFF_INSERT, text2],
1635
+ ];
1636
+ }
1637
+ hm = this.diffHalfMatch(text1, text2);
1638
+ if (hm) {
1639
+ text1A = hm[0];
1640
+ text1B = hm[1];
1641
+ text2A = hm[2];
1642
+ text2B = hm[3];
1643
+ midCommon = hm[4];
1644
+ diffsA = this.DiffMain(text1A, text2A, checklines, deadline);
1645
+ diffsB = this.DiffMain(text1B, text2B, checklines, deadline);
1646
+ return diffsA.concat([[DIFF_EQUAL, midCommon]], diffsB);
1647
+ }
1648
+ if (checklines && text1.length > 100 && text2.length > 100) {
1649
+ return this.diffLineMode(text1, text2, deadline);
1650
+ }
1651
+ return this.diffBisect(text1, text2, deadline);
1652
+ };
1653
+ DiffMatchPatch.prototype.diffHalfMatch = function (text1, text2) {
1654
+ var longtext, shorttext, dmp, text1A, text2B, text2A, text1B, midCommon, hm1, hm2, hm;
1655
+ longtext = text1.length > text2.length ? text1 : text2;
1656
+ shorttext = text1.length > text2.length ? text2 : text1;
1657
+ if (longtext.length < 4 || shorttext.length * 2 < longtext.length) {
1658
+ return null;
1659
+ }
1660
+ dmp = this;
1661
+ function diffHalfMatchI(longtext, shorttext, i) {
1662
+ var seed, j, bestCommon, prefixLength, suffixLength, bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB;
1663
+ seed = longtext.substring(i, i + Math.floor(longtext.length / 4));
1664
+ j = -1;
1665
+ bestCommon = '';
1666
+ while ((j = shorttext.indexOf(seed, j + 1)) !== -1) {
1667
+ prefixLength = dmp.diffCommonPrefix(longtext.substring(i), shorttext.substring(j));
1668
+ suffixLength = dmp.diffCommonSuffix(longtext.substring(0, i), shorttext.substring(0, j));
1669
+ if (bestCommon.length < suffixLength + prefixLength) {
1670
+ bestCommon = shorttext.substring(j - suffixLength, j) + shorttext.substring(j, j + prefixLength);
1671
+ bestLongtextA = longtext.substring(0, i - suffixLength);
1672
+ bestLongtextB = longtext.substring(i + prefixLength);
1673
+ bestShorttextA = shorttext.substring(0, j - suffixLength);
1674
+ bestShorttextB = shorttext.substring(j + prefixLength);
1675
+ }
1676
+ }
1677
+ if (bestCommon.length * 2 >= longtext.length) {
1678
+ return [bestLongtextA, bestLongtextB, bestShorttextA, bestShorttextB, bestCommon];
1679
+ }
1680
+ else {
1681
+ return null;
1682
+ }
1683
+ }
1684
+ hm1 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 4));
1685
+ hm2 = diffHalfMatchI(longtext, shorttext, Math.ceil(longtext.length / 2));
1686
+ if (!hm1 && !hm2) {
1687
+ return null;
1688
+ }
1689
+ else if (!hm2) {
1690
+ hm = hm1;
1691
+ }
1692
+ else if (!hm1) {
1693
+ hm = hm2;
1694
+ }
1695
+ else {
1696
+ hm = hm1[4].length > hm2[4].length ? hm1 : hm2;
1697
+ }
1698
+ text1A, text1B, text2A, text2B;
1699
+ if (text1.length > text2.length) {
1700
+ text1A = hm[0];
1701
+ text1B = hm[1];
1702
+ text2A = hm[2];
1703
+ text2B = hm[3];
1704
+ }
1705
+ else {
1706
+ text2A = hm[0];
1707
+ text2B = hm[1];
1708
+ text1A = hm[2];
1709
+ text1B = hm[3];
1710
+ }
1711
+ midCommon = hm[4];
1712
+ return [text1A, text1B, text2A, text2B, midCommon];
1713
+ };
1714
+ DiffMatchPatch.prototype.diffLineMode = function (text1, text2, deadline) {
1715
+ var a, diffs, linearray, pointer, countInsert, countDelete, textInsert, textDelete, j;
1716
+ a = this.diffLinesToChars(text1, text2);
1717
+ text1 = a.chars1;
1718
+ text2 = a.chars2;
1719
+ linearray = a.lineArray;
1720
+ diffs = this.DiffMain(text1, text2, false, deadline);
1721
+ this.diffCharsToLines(diffs, linearray);
1722
+ this.diffCleanupSemantic(diffs);
1723
+ diffs.push([DIFF_EQUAL, '']);
1724
+ pointer = 0;
1725
+ countDelete = 0;
1726
+ countInsert = 0;
1727
+ textDelete = '';
1728
+ textInsert = '';
1729
+ while (pointer < diffs.length) {
1730
+ switch (diffs[pointer][0]) {
1731
+ case DIFF_INSERT:
1732
+ countInsert++;
1733
+ textInsert += diffs[pointer][1];
1734
+ break;
1735
+ case DIFF_DELETE:
1736
+ countDelete++;
1737
+ textDelete += diffs[pointer][1];
1738
+ break;
1739
+ case DIFF_EQUAL:
1740
+ if (countDelete >= 1 && countInsert >= 1) {
1741
+ diffs.splice(pointer - countDelete - countInsert, countDelete + countInsert);
1742
+ pointer = pointer - countDelete - countInsert;
1743
+ a = this.DiffMain(textDelete, textInsert, false, deadline);
1744
+ for (j = a.length - 1; j >= 0; j--) {
1745
+ diffs.splice(pointer, 0, a[j]);
1746
+ }
1747
+ pointer = pointer + a.length;
1748
+ }
1749
+ countInsert = 0;
1750
+ countDelete = 0;
1751
+ textDelete = '';
1752
+ textInsert = '';
1753
+ break;
1754
+ }
1755
+ pointer++;
1756
+ }
1757
+ diffs.pop();
1758
+ return diffs;
1759
+ };
1760
+ DiffMatchPatch.prototype.diffBisect = function (text1, text2, deadline) {
1761
+ var text1Length, text2Length, maxD, vOffset, vLength, v1, v2, x, delta, front, k1start, k1end, k2start, k2end, k2Offset, k1Offset, x1, x2, y1, y2, d, k1, k2;
1762
+ text1Length = text1.length;
1763
+ text2Length = text2.length;
1764
+ maxD = Math.ceil((text1Length + text2Length) / 2);
1765
+ vOffset = maxD;
1766
+ vLength = 2 * maxD;
1767
+ v1 = new Array(vLength);
1768
+ v2 = new Array(vLength);
1769
+ for (x = 0; x < vLength; x++) {
1770
+ v1[x] = -1;
1771
+ v2[x] = -1;
1772
+ }
1773
+ v1[vOffset + 1] = 0;
1774
+ v2[vOffset + 1] = 0;
1775
+ delta = text1Length - text2Length;
1776
+ front = delta % 2 !== 0;
1777
+ k1start = 0;
1778
+ k1end = 0;
1779
+ k2start = 0;
1780
+ k2end = 0;
1781
+ for (d = 0; d < maxD; d++) {
1782
+ if (new Date().getTime() > deadline) {
1783
+ break;
1784
+ }
1785
+ for (k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
1786
+ k1Offset = vOffset + k1;
1787
+ if (k1 === -d || (k1 !== d && v1[k1Offset - 1] < v1[k1Offset + 1])) {
1788
+ x1 = v1[k1Offset + 1];
1789
+ }
1790
+ else {
1791
+ x1 = v1[k1Offset - 1] + 1;
1792
+ }
1793
+ y1 = x1 - k1;
1794
+ while (x1 < text1Length && y1 < text2Length && text1.charAt(x1) === text2.charAt(y1)) {
1795
+ x1++;
1796
+ y1++;
1797
+ }
1798
+ v1[k1Offset] = x1;
1799
+ if (x1 > text1Length) {
1800
+ k1end += 2;
1801
+ }
1802
+ else if (y1 > text2Length) {
1803
+ k1start += 2;
1804
+ }
1805
+ else if (front) {
1806
+ k2Offset = vOffset + delta - k1;
1807
+ if (k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] !== -1) {
1808
+ x2 = text1Length - v2[k2Offset];
1809
+ if (x1 >= x2) {
1810
+ return this.diffBisectSplit(text1, text2, x1, y1, deadline);
1811
+ }
1812
+ }
1813
+ }
1814
+ }
1815
+ for (k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
1816
+ k2Offset = vOffset + k2;
1817
+ if (k2 === -d || (k2 !== d && v2[k2Offset - 1] < v2[k2Offset + 1])) {
1818
+ x2 = v2[k2Offset + 1];
1819
+ }
1820
+ else {
1821
+ x2 = v2[k2Offset - 1] + 1;
1822
+ }
1823
+ y2 = x2 - k2;
1824
+ while (x2 < text1Length &&
1825
+ y2 < text2Length &&
1826
+ text1.charAt(text1Length - x2 - 1) === text2.charAt(text2Length - y2 - 1)) {
1827
+ x2++;
1828
+ y2++;
1829
+ }
1830
+ v2[k2Offset] = x2;
1831
+ if (x2 > text1Length) {
1832
+ k2end += 2;
1833
+ }
1834
+ else if (y2 > text2Length) {
1835
+ k2start += 2;
1836
+ }
1837
+ else if (!front) {
1838
+ k1Offset = vOffset + delta - k2;
1839
+ if (k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] !== -1) {
1840
+ x1 = v1[k1Offset];
1841
+ y1 = vOffset + x1 - k1Offset;
1842
+ x2 = text1Length - x2;
1843
+ if (x1 >= x2) {
1844
+ return this.diffBisectSplit(text1, text2, x1, y1, deadline);
1845
+ }
1846
+ }
1847
+ }
1848
+ }
1849
+ }
1850
+ return [
1851
+ [DIFF_DELETE, text1],
1852
+ [DIFF_INSERT, text2],
1853
+ ];
1854
+ };
1855
+ DiffMatchPatch.prototype.diffBisectSplit = function (text1, text2, x, y, deadline) {
1856
+ var text1a, text1b, text2a, text2b, diffs, diffsb;
1857
+ text1a = text1.substring(0, x);
1858
+ text2a = text2.substring(0, y);
1859
+ text1b = text1.substring(x);
1860
+ text2b = text2.substring(y);
1861
+ diffs = this.DiffMain(text1a, text2a, false, deadline);
1862
+ diffsb = this.DiffMain(text1b, text2b, false, deadline);
1863
+ return diffs.concat(diffsb);
1864
+ };
1865
+ DiffMatchPatch.prototype.diffCleanupSemantic = function (diffs) {
1866
+ var changes, equalities, equalitiesLength, lastequality, pointer, lengthInsertions2, lengthDeletions2, lengthInsertions1, lengthDeletions1, deletion, insertion, overlapLength1, overlapLength2;
1867
+ changes = false;
1868
+ equalities = [];
1869
+ equalitiesLength = 0;
1870
+ lastequality = null;
1871
+ pointer = 0;
1872
+ lengthInsertions1 = 0;
1873
+ lengthDeletions1 = 0;
1874
+ lengthInsertions2 = 0;
1875
+ lengthDeletions2 = 0;
1876
+ while (pointer < diffs.length) {
1877
+ if (diffs[pointer][0] === DIFF_EQUAL) {
1878
+ equalities[equalitiesLength++] = pointer;
1879
+ lengthInsertions1 = lengthInsertions2;
1880
+ lengthDeletions1 = lengthDeletions2;
1881
+ lengthInsertions2 = 0;
1882
+ lengthDeletions2 = 0;
1883
+ lastequality = diffs[pointer][1];
1884
+ }
1885
+ else {
1886
+ if (diffs[pointer][0] === DIFF_INSERT) {
1887
+ lengthInsertions2 += diffs[pointer][1].length;
1888
+ }
1889
+ else {
1890
+ lengthDeletions2 += diffs[pointer][1].length;
1891
+ }
1892
+ if (lastequality &&
1893
+ lastequality.length <= Math.max(lengthInsertions1, lengthDeletions1) &&
1894
+ lastequality.length <= Math.max(lengthInsertions2, lengthDeletions2)) {
1895
+ diffs.splice(equalities[equalitiesLength - 1], 0, [DIFF_DELETE, lastequality]);
1896
+ diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
1897
+ equalitiesLength--;
1898
+ equalitiesLength--;
1899
+ pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1;
1900
+ lengthInsertions1 = 0;
1901
+ lengthDeletions1 = 0;
1902
+ lengthInsertions2 = 0;
1903
+ lengthDeletions2 = 0;
1904
+ lastequality = null;
1905
+ changes = true;
1906
+ }
1907
+ }
1908
+ pointer++;
1909
+ }
1910
+ if (changes) {
1911
+ this.diffCleanupMerge(diffs);
1912
+ }
1913
+ pointer = 1;
1914
+ while (pointer < diffs.length) {
1915
+ if (diffs[pointer - 1][0] === DIFF_DELETE && diffs[pointer][0] === DIFF_INSERT) {
1916
+ deletion = diffs[pointer - 1][1];
1917
+ insertion = diffs[pointer][1];
1918
+ overlapLength1 = this.diffCommonOverlap(deletion, insertion);
1919
+ overlapLength2 = this.diffCommonOverlap(insertion, deletion);
1920
+ if (overlapLength1 >= overlapLength2) {
1921
+ if (overlapLength1 >= deletion.length / 2 || overlapLength1 >= insertion.length / 2) {
1922
+ diffs.splice(pointer, 0, [DIFF_EQUAL, insertion.substring(0, overlapLength1)]);
1923
+ diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlapLength1);
1924
+ diffs[pointer + 1][1] = insertion.substring(overlapLength1);
1925
+ pointer++;
1926
+ }
1927
+ }
1928
+ else {
1929
+ if (overlapLength2 >= deletion.length / 2 || overlapLength2 >= insertion.length / 2) {
1930
+ diffs.splice(pointer, 0, [DIFF_EQUAL, deletion.substring(0, overlapLength2)]);
1931
+ diffs[pointer - 1][0] = DIFF_INSERT;
1932
+ diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlapLength2);
1933
+ diffs[pointer + 1][0] = DIFF_DELETE;
1934
+ diffs[pointer + 1][1] = deletion.substring(overlapLength2);
1935
+ pointer++;
1936
+ }
1937
+ }
1938
+ pointer++;
1939
+ }
1940
+ pointer++;
1941
+ }
1942
+ };
1943
+ DiffMatchPatch.prototype.diffCommonOverlap = function (text1, text2) {
1944
+ var text1Length, text2Length, textLength, best, length, pattern, found;
1945
+ text1Length = text1.length;
1946
+ text2Length = text2.length;
1947
+ if (text1Length === 0 || text2Length === 0) {
1948
+ return 0;
1949
+ }
1950
+ if (text1Length > text2Length) {
1951
+ text1 = text1.substring(text1Length - text2Length);
1952
+ }
1953
+ else if (text1Length < text2Length) {
1954
+ text2 = text2.substring(0, text1Length);
1955
+ }
1956
+ textLength = Math.min(text1Length, text2Length);
1957
+ if (text1 === text2) {
1958
+ return textLength;
1959
+ }
1960
+ best = 0;
1961
+ length = 1;
1962
+ while (true) {
1963
+ pattern = text1.substring(textLength - length);
1964
+ found = text2.indexOf(pattern);
1965
+ if (found === -1) {
1966
+ return best;
1967
+ }
1968
+ length += found;
1969
+ if (found === 0 || text1.substring(textLength - length) === text2.substring(0, length)) {
1970
+ best = length;
1971
+ length++;
1972
+ }
1973
+ }
1974
+ };
1975
+ DiffMatchPatch.prototype.diffLinesToChars = function (text1, text2) {
1976
+ var lineArray, lineHash, chars1, chars2;
1977
+ lineArray = [];
1978
+ lineHash = {};
1979
+ lineArray[0] = '';
1980
+ function diffLinesToCharsMunge(text) {
1981
+ var chars, lineStart, lineEnd, lineArrayLength, line;
1982
+ chars = '';
1983
+ lineStart = 0;
1984
+ lineEnd = -1;
1985
+ lineArrayLength = lineArray.length;
1986
+ while (lineEnd < text.length - 1) {
1987
+ lineEnd = text.indexOf('\n', lineStart);
1988
+ if (lineEnd === -1) {
1989
+ lineEnd = text.length - 1;
1990
+ }
1991
+ line = text.substring(lineStart, lineEnd + 1);
1992
+ lineStart = lineEnd + 1;
1993
+ if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : lineHash[line] !== undefined) {
1994
+ chars += String.fromCharCode(lineHash[line]);
1995
+ }
1996
+ else {
1997
+ chars += String.fromCharCode(lineArrayLength);
1998
+ lineHash[line] = lineArrayLength;
1999
+ lineArray[lineArrayLength++] = line;
2000
+ }
2001
+ }
2002
+ return chars;
2003
+ }
2004
+ chars1 = diffLinesToCharsMunge(text1);
2005
+ chars2 = diffLinesToCharsMunge(text2);
2006
+ return {
2007
+ chars1: chars1,
2008
+ chars2: chars2,
2009
+ lineArray: lineArray,
2010
+ };
2011
+ };
2012
+ DiffMatchPatch.prototype.diffCharsToLines = function (diffs, lineArray) {
2013
+ var x, chars, text, y;
2014
+ for (x = 0; x < diffs.length; x++) {
2015
+ chars = diffs[x][1];
2016
+ text = [];
2017
+ for (y = 0; y < chars.length; y++) {
2018
+ text[y] = lineArray[chars.charCodeAt(y)];
2019
+ }
2020
+ diffs[x][1] = text.join('');
2021
+ }
2022
+ };
2023
+ DiffMatchPatch.prototype.diffCleanupMerge = function (diffs) {
2024
+ var pointer, countDelete, countInsert, textInsert, textDelete, commonlength, changes, diffPointer, position;
2025
+ diffs.push([DIFF_EQUAL, '']);
2026
+ pointer = 0;
2027
+ countDelete = 0;
2028
+ countInsert = 0;
2029
+ textDelete = '';
2030
+ textInsert = '';
2031
+ commonlength;
2032
+ while (pointer < diffs.length) {
2033
+ switch (diffs[pointer][0]) {
2034
+ case DIFF_INSERT:
2035
+ countInsert++;
2036
+ textInsert += diffs[pointer][1];
2037
+ pointer++;
2038
+ break;
2039
+ case DIFF_DELETE:
2040
+ countDelete++;
2041
+ textDelete += diffs[pointer][1];
2042
+ pointer++;
2043
+ break;
2044
+ case DIFF_EQUAL:
2045
+ if (countDelete + countInsert > 1) {
2046
+ if (countDelete !== 0 && countInsert !== 0) {
2047
+ commonlength = this.diffCommonPrefix(textInsert, textDelete);
2048
+ if (commonlength !== 0) {
2049
+ if (pointer - countDelete - countInsert > 0 &&
2050
+ diffs[pointer - countDelete - countInsert - 1][0] === DIFF_EQUAL) {
2051
+ diffs[pointer - countDelete - countInsert - 1][1] += textInsert.substring(0, commonlength);
2052
+ }
2053
+ else {
2054
+ diffs.splice(0, 0, [DIFF_EQUAL, textInsert.substring(0, commonlength)]);
2055
+ pointer++;
2056
+ }
2057
+ textInsert = textInsert.substring(commonlength);
2058
+ textDelete = textDelete.substring(commonlength);
2059
+ }
2060
+ commonlength = this.diffCommonSuffix(textInsert, textDelete);
2061
+ if (commonlength !== 0) {
2062
+ diffs[pointer][1] = textInsert.substring(textInsert.length - commonlength) + diffs[pointer][1];
2063
+ textInsert = textInsert.substring(0, textInsert.length - commonlength);
2064
+ textDelete = textDelete.substring(0, textDelete.length - commonlength);
2065
+ }
2066
+ }
2067
+ if (countDelete === 0) {
2068
+ diffs.splice(pointer - countInsert, countDelete + countInsert, [DIFF_INSERT, textInsert]);
2069
+ }
2070
+ else if (countInsert === 0) {
2071
+ diffs.splice(pointer - countDelete, countDelete + countInsert, [DIFF_DELETE, textDelete]);
2072
+ }
2073
+ else {
2074
+ diffs.splice(pointer - countDelete - countInsert, countDelete + countInsert, [DIFF_DELETE, textDelete], [DIFF_INSERT, textInsert]);
2075
+ }
2076
+ pointer = pointer - countDelete - countInsert + (countDelete ? 1 : 0) + (countInsert ? 1 : 0) + 1;
2077
+ }
2078
+ else if (pointer !== 0 && diffs[pointer - 1][0] === DIFF_EQUAL) {
2079
+ diffs[pointer - 1][1] += diffs[pointer][1];
2080
+ diffs.splice(pointer, 1);
2081
+ }
2082
+ else {
2083
+ pointer++;
2084
+ }
2085
+ countInsert = 0;
2086
+ countDelete = 0;
2087
+ textDelete = '';
2088
+ textInsert = '';
2089
+ break;
2090
+ }
2091
+ }
2092
+ if (diffs[diffs.length - 1][1] === '') {
2093
+ diffs.pop();
2094
+ }
2095
+ changes = false;
2096
+ pointer = 1;
2097
+ while (pointer < diffs.length - 1) {
2098
+ if (diffs[pointer - 1][0] === DIFF_EQUAL && diffs[pointer + 1][0] === DIFF_EQUAL) {
2099
+ diffPointer = diffs[pointer][1];
2100
+ position = diffPointer.substring(diffPointer.length - diffs[pointer - 1][1].length);
2101
+ if (position === diffs[pointer - 1][1]) {
2102
+ diffs[pointer][1] =
2103
+ diffs[pointer - 1][1] +
2104
+ diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length);
2105
+ diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1];
2106
+ diffs.splice(pointer - 1, 1);
2107
+ changes = true;
2108
+ }
2109
+ else if (diffPointer.substring(0, diffs[pointer + 1][1].length) === diffs[pointer + 1][1]) {
2110
+ diffs[pointer - 1][1] += diffs[pointer + 1][1];
2111
+ diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1];
2112
+ diffs.splice(pointer + 1, 1);
2113
+ changes = true;
2114
+ }
2115
+ }
2116
+ pointer++;
2117
+ }
2118
+ if (changes) {
2119
+ this.diffCleanupMerge(diffs);
2120
+ }
2121
+ };
2122
+ return function (o, n) {
2123
+ var diff, output, text;
2124
+ diff = new DiffMatchPatch();
2125
+ output = diff.DiffMain(o, n);
2126
+ diff.diffCleanupEfficiency(output);
2127
+ text = diff.diffPrettyHtml(output);
2128
+ return text;
2129
+ };
2130
+ })();
2131
+ })((function () {
2132
+ return this;
2133
+ })());
2134
+ (function () {
2135
+ if (typeof window === 'undefined' || !window.document) {
2136
+ return;
2137
+ }
2138
+ QUnit.init = function () {
2139
+ var tests, banner, result, qunit, config = QUnit.config;
2140
+ config.stats = { all: 0, bad: 0 };
2141
+ config.moduleStats = { all: 0, bad: 0 };
2142
+ config.started = 0;
2143
+ config.updateRate = 1000;
2144
+ config.blocking = false;
2145
+ config.autostart = true;
2146
+ config.autorun = false;
2147
+ config.filter = '';
2148
+ config.queue = [];
2149
+ if (typeof window === 'undefined') {
2150
+ return;
2151
+ }
2152
+ qunit = id('qunit');
2153
+ if (qunit) {
2154
+ qunit.innerHTML =
2155
+ "<h1 id='qunit-header'>" +
2156
+ escapeText(document.title) +
2157
+ '</h1>' +
2158
+ "<h2 id='qunit-banner'></h2>" +
2159
+ "<div id='qunit-testrunner-toolbar'></div>" +
2160
+ "<h2 id='qunit-userAgent'></h2>" +
2161
+ "<ol id='qunit-tests'></ol>";
2162
+ }
2163
+ tests = id('qunit-tests');
2164
+ banner = id('qunit-banner');
2165
+ result = id('qunit-testresult');
2166
+ if (tests) {
2167
+ tests.innerHTML = '';
2168
+ }
2169
+ if (banner) {
2170
+ banner.className = '';
2171
+ }
2172
+ if (result) {
2173
+ result.parentNode.removeChild(result);
2174
+ }
2175
+ if (tests) {
2176
+ result = document.createElement('p');
2177
+ result.id = 'qunit-testresult';
2178
+ result.className = 'result';
2179
+ tests.parentNode.insertBefore(result, tests);
2180
+ result.innerHTML = 'Running...<br />&#160;';
2181
+ }
2182
+ };
2183
+ var config = QUnit.config, hasOwn = Object.prototype.hasOwnProperty, defined = {
2184
+ document: window.document !== undefined,
2185
+ sessionStorage: (function () {
2186
+ var x = 'qunit-test-string';
2187
+ try {
2188
+ sessionStorage.setItem(x, x);
2189
+ sessionStorage.removeItem(x);
2190
+ return true;
2191
+ }
2192
+ catch (e) {
2193
+ return false;
2194
+ }
2195
+ })(),
2196
+ }, modulesList = [];
2197
+ function escapeText(s) {
2198
+ if (!s) {
2199
+ return '';
2200
+ }
2201
+ s = s + '';
2202
+ return s.replace(/['"<>&]/g, function (s) {
2203
+ switch (s) {
2204
+ case "'":
2205
+ return '&#039;';
2206
+ case '"':
2207
+ return '&quot;';
2208
+ case '<':
2209
+ return '&lt;';
2210
+ case '>':
2211
+ return '&gt;';
2212
+ case '&':
2213
+ return '&amp;';
2214
+ }
2215
+ });
2216
+ }
2217
+ function addEvent(elem, type, fn) {
2218
+ if (elem.addEventListener) {
2219
+ elem.addEventListener(type, fn, false);
2220
+ }
2221
+ else if (elem.attachEvent) {
2222
+ elem.attachEvent('on' + type, function () {
2223
+ var event = window.event;
2224
+ if (!event.target) {
2225
+ event.target = event.srcElement || document;
2226
+ }
2227
+ fn.call(elem, event);
2228
+ });
2229
+ }
2230
+ }
2231
+ function addEvents(elems, type, fn) {
2232
+ var i = elems.length;
2233
+ while (i--) {
2234
+ addEvent(elems[i], type, fn);
2235
+ }
2236
+ }
2237
+ function hasClass(elem, name) {
2238
+ return (' ' + elem.className + ' ').indexOf(' ' + name + ' ') >= 0;
2239
+ }
2240
+ function addClass(elem, name) {
2241
+ if (!hasClass(elem, name)) {
2242
+ elem.className += (elem.className ? ' ' : '') + name;
2243
+ }
2244
+ }
2245
+ function toggleClass(elem, name) {
2246
+ if (hasClass(elem, name)) {
2247
+ removeClass(elem, name);
2248
+ }
2249
+ else {
2250
+ addClass(elem, name);
2251
+ }
2252
+ }
2253
+ function removeClass(elem, name) {
2254
+ var set = ' ' + elem.className + ' ';
2255
+ while (set.indexOf(' ' + name + ' ') >= 0) {
2256
+ set = set.replace(' ' + name + ' ', ' ');
2257
+ }
2258
+ elem.className = typeof set.trim === 'function' ? set.trim() : set.replace(/^\s+|\s+$/g, '');
2259
+ }
2260
+ function id(name) {
2261
+ return defined.document && document.getElementById && document.getElementById(name);
2262
+ }
2263
+ function getUrlConfigHtml() {
2264
+ var i, j, val, escaped, escapedTooltip, selection = false, len = config.urlConfig.length, urlConfigHtml = '';
2265
+ for (i = 0; i < len; i++) {
2266
+ val = config.urlConfig[i];
2267
+ if (typeof val === 'string') {
2268
+ val = {
2269
+ id: val,
2270
+ label: val,
2271
+ };
2272
+ }
2273
+ escaped = escapeText(val.id);
2274
+ escapedTooltip = escapeText(val.tooltip);
2275
+ if (config[val.id] === undefined) {
2276
+ config[val.id] = QUnit.urlParams[val.id];
2277
+ }
2278
+ if (!val.value || typeof val.value === 'string') {
2279
+ urlConfigHtml +=
2280
+ "<input id='qunit-urlconfig-" +
2281
+ escaped +
2282
+ "' name='" +
2283
+ escaped +
2284
+ "' type='checkbox'" +
2285
+ (val.value ? " value='" + escapeText(val.value) + "'" : '') +
2286
+ (config[val.id] ? " checked='checked'" : '') +
2287
+ " title='" +
2288
+ escapedTooltip +
2289
+ "' /><label for='qunit-urlconfig-" +
2290
+ escaped +
2291
+ "' title='" +
2292
+ escapedTooltip +
2293
+ "'>" +
2294
+ val.label +
2295
+ '</label>';
2296
+ }
2297
+ else {
2298
+ urlConfigHtml +=
2299
+ "<label for='qunit-urlconfig-" +
2300
+ escaped +
2301
+ "' title='" +
2302
+ escapedTooltip +
2303
+ "'>" +
2304
+ val.label +
2305
+ ": </label><select id='qunit-urlconfig-" +
2306
+ escaped +
2307
+ "' name='" +
2308
+ escaped +
2309
+ "' title='" +
2310
+ escapedTooltip +
2311
+ "'><option></option>";
2312
+ if (QUnit.is('array', val.value)) {
2313
+ for (j = 0; j < val.value.length; j++) {
2314
+ escaped = escapeText(val.value[j]);
2315
+ urlConfigHtml +=
2316
+ "<option value='" +
2317
+ escaped +
2318
+ "'" +
2319
+ (config[val.id] === val.value[j] ? (selection = true) && " selected='selected'" : '') +
2320
+ '>' +
2321
+ escaped +
2322
+ '</option>';
2323
+ }
2324
+ }
2325
+ else {
2326
+ for (j in val.value) {
2327
+ if (hasOwn.call(val.value, j)) {
2328
+ urlConfigHtml +=
2329
+ "<option value='" +
2330
+ escapeText(j) +
2331
+ "'" +
2332
+ (config[val.id] === j ? (selection = true) && " selected='selected'" : '') +
2333
+ '>' +
2334
+ escapeText(val.value[j]) +
2335
+ '</option>';
2336
+ }
2337
+ }
2338
+ }
2339
+ if (config[val.id] && !selection) {
2340
+ escaped = escapeText(config[val.id]);
2341
+ urlConfigHtml +=
2342
+ "<option value='" + escaped + "' selected='selected' disabled='disabled'>" + escaped + '</option>';
2343
+ }
2344
+ urlConfigHtml += '</select>';
2345
+ }
2346
+ }
2347
+ return urlConfigHtml;
2348
+ }
2349
+ function toolbarChanged() {
2350
+ var updatedUrl, value, field = this, params = {};
2351
+ if ('selectedIndex' in field) {
2352
+ value = field.options[field.selectedIndex].value || undefined;
2353
+ }
2354
+ else {
2355
+ value = field.checked ? field.defaultValue || true : undefined;
2356
+ }
2357
+ params[field.name] = value;
2358
+ updatedUrl = setUrl(params);
2359
+ if ('hidepassed' === field.name && 'replaceState' in window.history) {
2360
+ config[field.name] = value || false;
2361
+ if (value) {
2362
+ addClass(id('qunit-tests'), 'hidepass');
2363
+ }
2364
+ else {
2365
+ removeClass(id('qunit-tests'), 'hidepass');
2366
+ }
2367
+ window.history.replaceState(null, '', updatedUrl);
2368
+ }
2369
+ else {
2370
+ window.location = updatedUrl;
2371
+ }
2372
+ }
2373
+ function setUrl(params) {
2374
+ var key, querystring = '?';
2375
+ params = QUnit.extend(QUnit.extend({}, QUnit.urlParams), params);
2376
+ for (key in params) {
2377
+ if (hasOwn.call(params, key)) {
2378
+ if (params[key] === undefined) {
2379
+ continue;
2380
+ }
2381
+ querystring += encodeURIComponent(key);
2382
+ if (params[key] !== true) {
2383
+ querystring += '=' + encodeURIComponent(params[key]);
2384
+ }
2385
+ querystring += '&';
2386
+ }
2387
+ }
2388
+ return location.protocol + '//' + location.host + location.pathname + querystring.slice(0, -1);
2389
+ }
2390
+ function applyUrlParams() {
2391
+ var selectedModule, modulesList = id('qunit-modulefilter'), filter = id('qunit-filter-input').value;
2392
+ selectedModule = modulesList ? decodeURIComponent(modulesList.options[modulesList.selectedIndex].value) : undefined;
2393
+ window.location = setUrl({
2394
+ module: selectedModule === '' ? undefined : selectedModule,
2395
+ filter: filter === '' ? undefined : filter,
2396
+ testId: undefined,
2397
+ });
2398
+ }
2399
+ function toolbarUrlConfigContainer() {
2400
+ var urlConfigContainer = document.createElement('span');
2401
+ urlConfigContainer.innerHTML = getUrlConfigHtml();
2402
+ addClass(urlConfigContainer, 'qunit-url-config');
2403
+ addEvents(urlConfigContainer.getElementsByTagName('input'), 'click', toolbarChanged);
2404
+ addEvents(urlConfigContainer.getElementsByTagName('select'), 'change', toolbarChanged);
2405
+ return urlConfigContainer;
2406
+ }
2407
+ function toolbarLooseFilter() {
2408
+ var filter = document.createElement('form'), label = document.createElement('label'), input = document.createElement('input'), button = document.createElement('button');
2409
+ addClass(filter, 'qunit-filter');
2410
+ label.innerHTML = 'Filter: ';
2411
+ input.type = 'text';
2412
+ input.value = config.filter || '';
2413
+ input.name = 'filter';
2414
+ input.id = 'qunit-filter-input';
2415
+ button.innerHTML = 'Go';
2416
+ label.appendChild(input);
2417
+ filter.appendChild(label);
2418
+ filter.appendChild(button);
2419
+ addEvent(filter, 'submit', function (ev) {
2420
+ applyUrlParams();
2421
+ if (ev && ev.preventDefault) {
2422
+ ev.preventDefault();
2423
+ }
2424
+ return false;
2425
+ });
2426
+ return filter;
2427
+ }
2428
+ function toolbarModuleFilterHtml() {
2429
+ var i, moduleFilterHtml = '';
2430
+ if (!modulesList.length) {
2431
+ return false;
2432
+ }
2433
+ modulesList.sort(function (a, b) {
2434
+ return a.localeCompare(b);
2435
+ });
2436
+ moduleFilterHtml +=
2437
+ "<label for='qunit-modulefilter'>Module: </label>" +
2438
+ "<select id='qunit-modulefilter' name='modulefilter'><option value='' " +
2439
+ (QUnit.urlParams.module === undefined ? "selected='selected'" : '') +
2440
+ '>< All Modules ></option>';
2441
+ for (i = 0; i < modulesList.length; i++) {
2442
+ moduleFilterHtml +=
2443
+ "<option value='" +
2444
+ escapeText(encodeURIComponent(modulesList[i])) +
2445
+ "' " +
2446
+ (QUnit.urlParams.module === modulesList[i] ? "selected='selected'" : '') +
2447
+ '>' +
2448
+ escapeText(modulesList[i]) +
2449
+ '</option>';
2450
+ }
2451
+ moduleFilterHtml += '</select>';
2452
+ return moduleFilterHtml;
2453
+ }
2454
+ function toolbarModuleFilter() {
2455
+ var toolbar = id('qunit-testrunner-toolbar'), moduleFilter = document.createElement('span'), moduleFilterHtml = toolbarModuleFilterHtml();
2456
+ if (!toolbar || !moduleFilterHtml) {
2457
+ return false;
2458
+ }
2459
+ moduleFilter.setAttribute('id', 'qunit-modulefilter-container');
2460
+ moduleFilter.innerHTML = moduleFilterHtml;
2461
+ addEvent(moduleFilter.lastChild, 'change', applyUrlParams);
2462
+ toolbar.appendChild(moduleFilter);
2463
+ }
2464
+ function appendToolbar() {
2465
+ var toolbar = id('qunit-testrunner-toolbar');
2466
+ if (toolbar) {
2467
+ toolbar.appendChild(toolbarUrlConfigContainer());
2468
+ toolbar.appendChild(toolbarLooseFilter());
2469
+ }
2470
+ }
2471
+ function appendHeader() {
2472
+ var header = id('qunit-header');
2473
+ if (header) {
2474
+ header.innerHTML =
2475
+ "<a href='" +
2476
+ setUrl({ filter: undefined, module: undefined, testId: undefined }) +
2477
+ "'>" +
2478
+ header.innerHTML +
2479
+ '</a> ';
2480
+ }
2481
+ }
2482
+ function appendBanner() {
2483
+ var banner = id('qunit-banner');
2484
+ if (banner) {
2485
+ banner.className = '';
2486
+ }
2487
+ }
2488
+ function appendTestResults() {
2489
+ var tests = id('qunit-tests'), result = id('qunit-testresult');
2490
+ if (result) {
2491
+ result.parentNode.removeChild(result);
2492
+ }
2493
+ if (tests) {
2494
+ tests.innerHTML = '';
2495
+ result = document.createElement('p');
2496
+ result.id = 'qunit-testresult';
2497
+ result.className = 'result';
2498
+ tests.parentNode.insertBefore(result, tests);
2499
+ result.innerHTML = 'Running...<br />&#160;';
2500
+ }
2501
+ }
2502
+ function storeFixture() {
2503
+ var fixture = id('qunit-fixture');
2504
+ if (fixture) {
2505
+ config.fixture = fixture.innerHTML;
2506
+ }
2507
+ }
2508
+ function appendUserAgent() {
2509
+ var userAgent = id('qunit-userAgent');
2510
+ if (userAgent) {
2511
+ userAgent.innerHTML = '';
2512
+ userAgent.appendChild(document.createTextNode('QUnit ' + QUnit.version + '; ' + navigator.userAgent));
2513
+ }
2514
+ }
2515
+ function appendTestsList(modules) {
2516
+ var i, l, x, z, test, moduleObj;
2517
+ for (i = 0, l = modules.length; i < l; i++) {
2518
+ moduleObj = modules[i];
2519
+ if (moduleObj.name) {
2520
+ modulesList.push(moduleObj.name);
2521
+ }
2522
+ for (x = 0, z = moduleObj.tests.length; x < z; x++) {
2523
+ test = moduleObj.tests[x];
2524
+ appendTest(test.name, test.testId, moduleObj.name);
2525
+ }
2526
+ }
2527
+ }
2528
+ function appendTest(name, testId, moduleName) {
2529
+ var title, rerunTrigger, testBlock, assertList, tests = id('qunit-tests');
2530
+ if (!tests) {
2531
+ return;
2532
+ }
2533
+ title = document.createElement('strong');
2534
+ title.innerHTML = getNameHtml(name, moduleName);
2535
+ rerunTrigger = document.createElement('a');
2536
+ rerunTrigger.innerHTML = 'Rerun';
2537
+ rerunTrigger.href = setUrl({ testId: testId });
2538
+ testBlock = document.createElement('li');
2539
+ testBlock.appendChild(title);
2540
+ testBlock.appendChild(rerunTrigger);
2541
+ testBlock.id = 'qunit-test-output-' + testId;
2542
+ assertList = document.createElement('ol');
2543
+ assertList.className = 'qunit-assert-list';
2544
+ testBlock.appendChild(assertList);
2545
+ tests.appendChild(testBlock);
2546
+ }
2547
+ QUnit.begin(function (details) {
2548
+ var qunit = id('qunit');
2549
+ storeFixture();
2550
+ if (qunit) {
2551
+ qunit.innerHTML =
2552
+ "<h1 id='qunit-header'>" +
2553
+ escapeText(document.title) +
2554
+ '</h1>' +
2555
+ "<h2 id='qunit-banner'></h2>" +
2556
+ "<div id='qunit-testrunner-toolbar'></div>" +
2557
+ "<h2 id='qunit-userAgent'></h2>" +
2558
+ "<ol id='qunit-tests'></ol>";
2559
+ }
2560
+ appendHeader();
2561
+ appendBanner();
2562
+ appendTestResults();
2563
+ appendUserAgent();
2564
+ appendToolbar();
2565
+ appendTestsList(details.modules);
2566
+ toolbarModuleFilter();
2567
+ if (qunit && config.hidepassed) {
2568
+ addClass(qunit.lastChild, 'hidepass');
2569
+ }
2570
+ });
2571
+ QUnit.done(function (details) {
2572
+ var i, key, banner = id('qunit-banner'), tests = id('qunit-tests'), html = [
2573
+ 'Tests completed in ',
2574
+ details.runtime,
2575
+ ' milliseconds.<br />',
2576
+ "<span class='passed'>",
2577
+ details.passed,
2578
+ "</span> assertions of <span class='total'>",
2579
+ details.total,
2580
+ "</span> passed, <span class='failed'>",
2581
+ details.failed,
2582
+ '</span> failed.',
2583
+ ].join('');
2584
+ if (banner) {
2585
+ banner.className = details.failed ? 'qunit-fail' : 'qunit-pass';
2586
+ }
2587
+ if (tests) {
2588
+ id('qunit-testresult').innerHTML = html;
2589
+ }
2590
+ if (config.altertitle && defined.document && document.title) {
2591
+ document.title = [details.failed ? '\u2716' : '\u2714', document.title.replace(/^[\u2714\u2716] /i, '')].join(' ');
2592
+ }
2593
+ if (config.reorder && defined.sessionStorage && details.failed === 0) {
2594
+ for (i = 0; i < sessionStorage.length; i++) {
2595
+ key = sessionStorage.key(i++);
2596
+ if (key.indexOf('qunit-test-') === 0) {
2597
+ sessionStorage.removeItem(key);
2598
+ }
2599
+ }
2600
+ }
2601
+ if (config.scrolltop && window.scrollTo) {
2602
+ window.scrollTo(0, 0);
2603
+ }
2604
+ });
2605
+ function getNameHtml(name, module) {
2606
+ var nameHtml = '';
2607
+ if (module) {
2608
+ nameHtml = "<span class='module-name'>" + escapeText(module) + '</span>: ';
2609
+ }
2610
+ nameHtml += "<span class='test-name'>" + escapeText(name) + '</span>';
2611
+ return nameHtml;
2612
+ }
2613
+ QUnit.testStart(function (details) {
2614
+ var running, testBlock, bad;
2615
+ testBlock = id('qunit-test-output-' + details.testId);
2616
+ if (testBlock) {
2617
+ testBlock.className = 'running';
2618
+ }
2619
+ else {
2620
+ appendTest(details.name, details.testId, details.module);
2621
+ }
2622
+ running = id('qunit-testresult');
2623
+ if (running) {
2624
+ bad =
2625
+ QUnit.config.reorder &&
2626
+ defined.sessionStorage &&
2627
+ +sessionStorage.getItem('qunit-test-' + details.module + '-' + details.name);
2628
+ running.innerHTML =
2629
+ (bad ? 'Rerunning previously failed test: <br />' : 'Running: <br />') +
2630
+ getNameHtml(details.name, details.module);
2631
+ }
2632
+ });
2633
+ function stripHtml(string) {
2634
+ return string
2635
+ .replace(/<\/?[^>]+(>|$)/g, '')
2636
+ .replace(/\&quot;/g, '')
2637
+ .replace(/\s+/g, '');
2638
+ }
2639
+ QUnit.log(function (details) {
2640
+ var assertList, assertLi, message, expected, actual, diff, showDiff = false, testItem = id('qunit-test-output-' + details.testId);
2641
+ if (!testItem) {
2642
+ return;
2643
+ }
2644
+ message = escapeText(details.message) || (details.result ? 'okay' : 'failed');
2645
+ message = "<span class='test-message'>" + message + '</span>';
2646
+ message += "<span class='runtime'>@ " + details.runtime + ' ms</span>';
2647
+ if (!details.result && hasOwn.call(details, 'expected')) {
2648
+ if (details.negative) {
2649
+ expected = escapeText('NOT ' + QUnit.dump.parse(details.expected));
2650
+ }
2651
+ else {
2652
+ expected = escapeText(QUnit.dump.parse(details.expected));
2653
+ }
2654
+ actual = escapeText(QUnit.dump.parse(details.actual));
2655
+ message += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + '</pre></td></tr>';
2656
+ if (actual !== expected) {
2657
+ message += "<tr class='test-actual'><th>Result: </th><td><pre>" + actual + '</pre></td></tr>';
2658
+ if (!/^(true|false)$/.test(actual) && !/^(true|false)$/.test(expected)) {
2659
+ diff = QUnit.diff(expected, actual);
2660
+ showDiff = stripHtml(diff).length !== stripHtml(expected).length + stripHtml(actual).length;
2661
+ }
2662
+ if (showDiff) {
2663
+ message += "<tr class='test-diff'><th>Diff: </th><td><pre>" + diff + '</pre></td></tr>';
2664
+ }
2665
+ }
2666
+ else if (expected.indexOf('[object Array]') !== -1 || expected.indexOf('[object Object]') !== -1) {
2667
+ message +=
2668
+ "<tr class='test-message'><th>Message: </th><td>" +
2669
+ 'Diff suppressed as the depth of object is more than current max depth (' +
2670
+ QUnit.config.maxDepth +
2671
+ ').<p>Hint: Use <code>QUnit.dump.maxDepth</code> to ' +
2672
+ " run with a higher max depth or <a href='" +
2673
+ setUrl({ maxDepth: -1 }) +
2674
+ "'>" +
2675
+ 'Rerun</a> without max depth.</p></td></tr>';
2676
+ }
2677
+ if (details.source) {
2678
+ message +=
2679
+ "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText(details.source) + '</pre></td></tr>';
2680
+ }
2681
+ message += '</table>';
2682
+ }
2683
+ else if (!details.result && details.source) {
2684
+ message +=
2685
+ '<table>' +
2686
+ "<tr class='test-source'><th>Source: </th><td><pre>" +
2687
+ escapeText(details.source) +
2688
+ '</pre></td></tr>' +
2689
+ '</table>';
2690
+ }
2691
+ assertList = testItem.getElementsByTagName('ol')[0];
2692
+ assertLi = document.createElement('li');
2693
+ assertLi.className = details.result ? 'pass' : 'fail';
2694
+ assertLi.innerHTML = message;
2695
+ assertList.appendChild(assertLi);
2696
+ });
2697
+ QUnit.testDone(function (details) {
2698
+ var testTitle, time, testItem, assertList, good, bad, testCounts, skipped, sourceName, tests = id('qunit-tests');
2699
+ if (!tests) {
2700
+ return;
2701
+ }
2702
+ testItem = id('qunit-test-output-' + details.testId);
2703
+ assertList = testItem.getElementsByTagName('ol')[0];
2704
+ good = details.passed;
2705
+ bad = details.failed;
2706
+ if (config.reorder && defined.sessionStorage) {
2707
+ if (bad) {
2708
+ sessionStorage.setItem('qunit-test-' + details.module + '-' + details.name, bad);
2709
+ }
2710
+ else {
2711
+ sessionStorage.removeItem('qunit-test-' + details.module + '-' + details.name);
2712
+ }
2713
+ }
2714
+ if (bad === 0) {
2715
+ addClass(assertList, 'qunit-collapsed');
2716
+ }
2717
+ testTitle = testItem.firstChild;
2718
+ testCounts = bad ? "<b class='failed'>" + bad + '</b>, ' + "<b class='passed'>" + good + '</b>, ' : '';
2719
+ testTitle.innerHTML += " <b class='counts'>(" + testCounts + details.assertions.length + ')</b>';
2720
+ if (details.skipped) {
2721
+ testItem.className = 'skipped';
2722
+ skipped = document.createElement('em');
2723
+ skipped.className = 'qunit-skipped-label';
2724
+ skipped.innerHTML = 'skipped';
2725
+ testItem.insertBefore(skipped, testTitle);
2726
+ }
2727
+ else {
2728
+ addEvent(testTitle, 'click', function () {
2729
+ toggleClass(assertList, 'qunit-collapsed');
2730
+ });
2731
+ testItem.className = bad ? 'fail' : 'pass';
2732
+ time = document.createElement('span');
2733
+ time.className = 'runtime';
2734
+ time.innerHTML = details.runtime + ' ms';
2735
+ testItem.insertBefore(time, assertList);
2736
+ }
2737
+ if (details.source) {
2738
+ sourceName = document.createElement('p');
2739
+ sourceName.innerHTML = '<strong>Source: </strong>' + details.source;
2740
+ addClass(sourceName, 'qunit-source');
2741
+ if (bad === 0) {
2742
+ addClass(sourceName, 'qunit-collapsed');
2743
+ }
2744
+ addEvent(testTitle, 'click', function () {
2745
+ toggleClass(sourceName, 'qunit-collapsed');
2746
+ });
2747
+ testItem.appendChild(sourceName);
2748
+ }
2749
+ });
2750
+ if (defined.document) {
2751
+ var notPhantom = (function (p) {
2752
+ return !(p && p.version && p.version.major > 0);
2753
+ })(window.phantom);
2754
+ if (notPhantom && document.readyState === 'complete') {
2755
+ QUnit.load();
2756
+ }
2757
+ else {
2758
+ addEvent(window, 'load', QUnit.load);
2759
+ }
2760
+ }
2761
+ else {
2762
+ config.pageLoaded = true;
2763
+ config.autorun = true;
2764
+ }
2765
+ })();