bigpipe-rails 0.0.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 (78) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +20 -0
  4. data/Gemfile.lock +160 -0
  5. data/Guardfile +21 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +0 -0
  8. data/README.rdoc +19 -0
  9. data/Rakefile +49 -0
  10. data/VERSION +1 -0
  11. data/assets/bigpipe.coffee +150 -0
  12. data/assets/bigpipe.js +164 -0
  13. data/bigpipe-rails.gemspec +153 -0
  14. data/lib/bigpipe_rails/helper.rb +36 -0
  15. data/lib/bigpipe_rails.rb +13 -0
  16. data/lib/engines.rb +16 -0
  17. data/qunit/.DS_Store +0 -0
  18. data/qunit/qunit.css +227 -0
  19. data/qunit/qunit.js +1450 -0
  20. data/qunit/tests.html +302 -0
  21. data/spec/dummy_app/.gitignore +5 -0
  22. data/spec/dummy_app/Gemfile +19 -0
  23. data/spec/dummy_app/Gemfile.lock +143 -0
  24. data/spec/dummy_app/README +261 -0
  25. data/spec/dummy_app/Rakefile +7 -0
  26. data/spec/dummy_app/app/assets/images/rails.png +0 -0
  27. data/spec/dummy_app/app/assets/javascripts/application.js +5 -0
  28. data/spec/dummy_app/app/assets/stylesheets/application.css +7 -0
  29. data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
  30. data/spec/dummy_app/app/controllers/test_controller.rb +8 -0
  31. data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy_app/app/mailers/.gitkeep +0 -0
  33. data/spec/dummy_app/app/models/.gitkeep +0 -0
  34. data/spec/dummy_app/app/views/layouts/application.html.erb +18 -0
  35. data/spec/dummy_app/app/views/test/test.html.erb +3 -0
  36. data/spec/dummy_app/app/views/test/test_with_exception.html.erb +7 -0
  37. data/spec/dummy_app/config/application.rb +47 -0
  38. data/spec/dummy_app/config/boot.rb +6 -0
  39. data/spec/dummy_app/config/database.yml +25 -0
  40. data/spec/dummy_app/config/environment.rb +5 -0
  41. data/spec/dummy_app/config/environments/development.rb +27 -0
  42. data/spec/dummy_app/config/environments/production.rb +54 -0
  43. data/spec/dummy_app/config/environments/test.rb +39 -0
  44. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy_app/config/initializers/inflections.rb +10 -0
  46. data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy_app/config/initializers/secret_token.rb +7 -0
  48. data/spec/dummy_app/config/initializers/session_store.rb +8 -0
  49. data/spec/dummy_app/config/initializers/wrap_parameters.rb +12 -0
  50. data/spec/dummy_app/config/locales/en.yml +5 -0
  51. data/spec/dummy_app/config/routes.rb +62 -0
  52. data/spec/dummy_app/config/unicorn.rb +1 -0
  53. data/spec/dummy_app/config.ru +4 -0
  54. data/spec/dummy_app/db/seeds.rb +7 -0
  55. data/spec/dummy_app/lib/tasks/.gitkeep +0 -0
  56. data/spec/dummy_app/log/.gitkeep +0 -0
  57. data/spec/dummy_app/public/404.html +26 -0
  58. data/spec/dummy_app/public/422.html +26 -0
  59. data/spec/dummy_app/public/500.html +26 -0
  60. data/spec/dummy_app/public/favicon.ico +0 -0
  61. data/spec/dummy_app/public/index.html +241 -0
  62. data/spec/dummy_app/public/javascripts/bigpipe.js +164 -0
  63. data/spec/dummy_app/public/robots.txt +5 -0
  64. data/spec/dummy_app/script/rails +6 -0
  65. data/spec/dummy_app/spec/spec_helper.rb +26 -0
  66. data/spec/dummy_app/test/fixtures/.gitkeep +0 -0
  67. data/spec/dummy_app/test/functional/.gitkeep +0 -0
  68. data/spec/dummy_app/test/integration/.gitkeep +0 -0
  69. data/spec/dummy_app/test/integration/testabc_test.rb +9 -0
  70. data/spec/dummy_app/test/performance/browsing_test.rb +12 -0
  71. data/spec/dummy_app/test/test_helper.rb +13 -0
  72. data/spec/dummy_app/test/unit/.gitkeep +0 -0
  73. data/spec/dummy_app/vendor/assets/stylesheets/.gitkeep +0 -0
  74. data/spec/dummy_app/vendor/plugins/.gitkeep +0 -0
  75. data/spec/lib/bigpipe_rails_spec.rb +18 -0
  76. data/spec/requests/bigpipe_request_spec.rb +21 -0
  77. data/spec/spec_helper.rb +28 -0
  78. metadata +277 -0
data/qunit/qunit.js ADDED
@@ -0,0 +1,1450 @@
1
+ /**
2
+ * QUnit - A JavaScript Unit Testing Framework
3
+ *
4
+ * http://docs.jquery.com/QUnit
5
+ *
6
+ * Copyright (c) 2011 John Resig, Jörn Zaefferer
7
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
8
+ * or GPL (GPL-LICENSE.txt) licenses.
9
+ * Pulled Live from Git Sun Jul 24 15:30:01 UTC 2011
10
+ * Last Commit: 28be4753ea257da54721aa44f8599adb005e1033
11
+ */
12
+
13
+ (function(window) {
14
+
15
+ var defined = {
16
+ setTimeout: typeof window.setTimeout !== "undefined",
17
+ sessionStorage: (function() {
18
+ try {
19
+ return !!sessionStorage.getItem;
20
+ } catch(e){
21
+ return false;
22
+ }
23
+ })()
24
+ };
25
+
26
+ var testId = 0;
27
+
28
+ var Test = function(name, testName, expected, testEnvironmentArg, async, callback) {
29
+ this.name = name;
30
+ this.testName = testName;
31
+ this.expected = expected;
32
+ this.testEnvironmentArg = testEnvironmentArg;
33
+ this.async = async;
34
+ this.callback = callback;
35
+ this.assertions = [];
36
+ };
37
+ Test.prototype = {
38
+ init: function() {
39
+ var tests = id("qunit-tests");
40
+ if (tests) {
41
+ var b = document.createElement("strong");
42
+ b.innerHTML = "Running " + this.name;
43
+ var li = document.createElement("li");
44
+ li.appendChild( b );
45
+ li.className = "running";
46
+ li.id = this.id = "test-output" + testId++;
47
+ tests.appendChild( li );
48
+ }
49
+ },
50
+ setup: function() {
51
+ if (this.module != config.previousModule) {
52
+ if ( config.previousModule ) {
53
+ QUnit.moduleDone( {
54
+ name: config.previousModule,
55
+ failed: config.moduleStats.bad,
56
+ passed: config.moduleStats.all - config.moduleStats.bad,
57
+ total: config.moduleStats.all
58
+ } );
59
+ }
60
+ config.previousModule = this.module;
61
+ config.moduleStats = { all: 0, bad: 0 };
62
+ QUnit.moduleStart( {
63
+ name: this.module
64
+ } );
65
+ }
66
+
67
+ config.current = this;
68
+ this.testEnvironment = extend({
69
+ setup: function() {},
70
+ teardown: function() {}
71
+ }, this.moduleTestEnvironment);
72
+ if (this.testEnvironmentArg) {
73
+ extend(this.testEnvironment, this.testEnvironmentArg);
74
+ }
75
+
76
+ QUnit.testStart( {
77
+ name: this.testName
78
+ } );
79
+
80
+ // allow utility functions to access the current test environment
81
+ // TODO why??
82
+ QUnit.current_testEnvironment = this.testEnvironment;
83
+
84
+ try {
85
+ if ( !config.pollution ) {
86
+ saveGlobal();
87
+ }
88
+
89
+ this.testEnvironment.setup.call(this.testEnvironment);
90
+ } catch(e) {
91
+ QUnit.ok( false, "Setup failed on " + this.testName + ": " + e.message );
92
+ }
93
+ },
94
+ run: function() {
95
+ if ( this.async ) {
96
+ QUnit.stop();
97
+ }
98
+
99
+ if ( config.notrycatch ) {
100
+ this.callback.call(this.testEnvironment);
101
+ return;
102
+ }
103
+ try {
104
+ this.callback.call(this.testEnvironment);
105
+ } catch(e) {
106
+ fail("Test " + this.testName + " died, exception and test follows", e, this.callback);
107
+ QUnit.ok( false, "Died on test #" + (this.assertions.length + 1) + ": " + e.message + " - " + QUnit.jsDump.parse(e) );
108
+ // else next test will carry the responsibility
109
+ saveGlobal();
110
+
111
+ // Restart the tests if they're blocking
112
+ if ( config.blocking ) {
113
+ start();
114
+ }
115
+ }
116
+ },
117
+ teardown: function() {
118
+ try {
119
+ this.testEnvironment.teardown.call(this.testEnvironment);
120
+ checkPollution();
121
+ } catch(e) {
122
+ QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message );
123
+ }
124
+ },
125
+ finish: function() {
126
+ if ( this.expected && this.expected != this.assertions.length ) {
127
+ QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
128
+ }
129
+
130
+ var good = 0, bad = 0,
131
+ tests = id("qunit-tests");
132
+
133
+ config.stats.all += this.assertions.length;
134
+ config.moduleStats.all += this.assertions.length;
135
+
136
+ if ( tests ) {
137
+ var ol = document.createElement("ol");
138
+
139
+ for ( var i = 0; i < this.assertions.length; i++ ) {
140
+ var assertion = this.assertions[i];
141
+
142
+ var li = document.createElement("li");
143
+ li.className = assertion.result ? "pass" : "fail";
144
+ li.innerHTML = assertion.message || (assertion.result ? "okay" : "failed");
145
+ ol.appendChild( li );
146
+
147
+ if ( assertion.result ) {
148
+ good++;
149
+ } else {
150
+ bad++;
151
+ config.stats.bad++;
152
+ config.moduleStats.bad++;
153
+ }
154
+ }
155
+
156
+ // store result when possible
157
+ if ( QUnit.config.reorder && defined.sessionStorage ) {
158
+ if (bad) {
159
+ sessionStorage.setItem("qunit-" + this.module + "-" + this.testName, bad);
160
+ } else {
161
+ sessionStorage.removeItem("qunit-" + this.module + "-" + this.testName);
162
+ }
163
+ }
164
+
165
+ if (bad == 0) {
166
+ ol.style.display = "none";
167
+ }
168
+
169
+ var b = document.createElement("strong");
170
+ b.innerHTML = this.name + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
171
+
172
+ var a = document.createElement("a");
173
+ a.innerHTML = "Rerun";
174
+ a.href = QUnit.url({ filter: getText([b]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") });
175
+
176
+ addEvent(b, "click", function() {
177
+ var next = b.nextSibling.nextSibling,
178
+ display = next.style.display;
179
+ next.style.display = display === "none" ? "block" : "none";
180
+ });
181
+
182
+ addEvent(b, "dblclick", function(e) {
183
+ var target = e && e.target ? e.target : window.event.srcElement;
184
+ if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) {
185
+ target = target.parentNode;
186
+ }
187
+ if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
188
+ window.location = QUnit.url({ filter: getText([target]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") });
189
+ }
190
+ });
191
+
192
+ var li = id(this.id);
193
+ li.className = bad ? "fail" : "pass";
194
+ li.removeChild( li.firstChild );
195
+ li.appendChild( b );
196
+ li.appendChild( a );
197
+ li.appendChild( ol );
198
+
199
+ } else {
200
+ for ( var i = 0; i < this.assertions.length; i++ ) {
201
+ if ( !this.assertions[i].result ) {
202
+ bad++;
203
+ config.stats.bad++;
204
+ config.moduleStats.bad++;
205
+ }
206
+ }
207
+ }
208
+
209
+ try {
210
+ QUnit.reset();
211
+ } catch(e) {
212
+ fail("reset() failed, following Test " + this.testName + ", exception and reset fn follows", e, QUnit.reset);
213
+ }
214
+
215
+ QUnit.testDone( {
216
+ name: this.testName,
217
+ failed: bad,
218
+ passed: this.assertions.length - bad,
219
+ total: this.assertions.length
220
+ } );
221
+ },
222
+
223
+ queue: function() {
224
+ var test = this;
225
+ synchronize(function() {
226
+ test.init();
227
+ });
228
+ function run() {
229
+ // each of these can by async
230
+ synchronize(function() {
231
+ test.setup();
232
+ });
233
+ synchronize(function() {
234
+ test.run();
235
+ });
236
+ synchronize(function() {
237
+ test.teardown();
238
+ });
239
+ synchronize(function() {
240
+ test.finish();
241
+ });
242
+ }
243
+ // defer when previous test run passed, if storage is available
244
+ var bad = QUnit.config.reorder && defined.sessionStorage && +sessionStorage.getItem("qunit-" + this.module + "-" + this.testName);
245
+ if (bad) {
246
+ run();
247
+ } else {
248
+ synchronize(run);
249
+ };
250
+ }
251
+
252
+ };
253
+
254
+ var QUnit = {
255
+
256
+ // call on start of module test to prepend name to all tests
257
+ module: function(name, testEnvironment) {
258
+ config.currentModule = name;
259
+ config.currentModuleTestEnviroment = testEnvironment;
260
+ },
261
+
262
+ asyncTest: function(testName, expected, callback) {
263
+ if ( arguments.length === 2 ) {
264
+ callback = expected;
265
+ expected = 0;
266
+ }
267
+
268
+ QUnit.test(testName, expected, callback, true);
269
+ },
270
+
271
+ test: function(testName, expected, callback, async) {
272
+ var name = '<span class="test-name">' + testName + '</span>', testEnvironmentArg;
273
+
274
+ if ( arguments.length === 2 ) {
275
+ callback = expected;
276
+ expected = null;
277
+ }
278
+ // is 2nd argument a testEnvironment?
279
+ if ( expected && typeof expected === 'object') {
280
+ testEnvironmentArg = expected;
281
+ expected = null;
282
+ }
283
+
284
+ if ( config.currentModule ) {
285
+ name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
286
+ }
287
+
288
+ if ( !validTest(config.currentModule + ": " + testName) ) {
289
+ return;
290
+ }
291
+
292
+ var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
293
+ test.module = config.currentModule;
294
+ test.moduleTestEnvironment = config.currentModuleTestEnviroment;
295
+ test.queue();
296
+ },
297
+
298
+ /**
299
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
300
+ */
301
+ expect: function(asserts) {
302
+ config.current.expected = asserts;
303
+ },
304
+
305
+ /**
306
+ * Asserts true.
307
+ * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
308
+ */
309
+ ok: function(a, msg) {
310
+ a = !!a;
311
+ var details = {
312
+ result: a,
313
+ message: msg
314
+ };
315
+ msg = escapeHtml(msg);
316
+ QUnit.log(details);
317
+ config.current.assertions.push({
318
+ result: a,
319
+ message: msg
320
+ });
321
+ },
322
+
323
+ /**
324
+ * Checks that the first two arguments are equal, with an optional message.
325
+ * Prints out both actual and expected values.
326
+ *
327
+ * Prefered to ok( actual == expected, message )
328
+ *
329
+ * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
330
+ *
331
+ * @param Object actual
332
+ * @param Object expected
333
+ * @param String message (optional)
334
+ */
335
+ equal: function(actual, expected, message) {
336
+ QUnit.push(expected == actual, actual, expected, message);
337
+ },
338
+
339
+ notEqual: function(actual, expected, message) {
340
+ QUnit.push(expected != actual, actual, expected, message);
341
+ },
342
+
343
+ deepEqual: function(actual, expected, message) {
344
+ QUnit.push(QUnit.equiv(actual, expected), actual, expected, message);
345
+ },
346
+
347
+ notDeepEqual: function(actual, expected, message) {
348
+ QUnit.push(!QUnit.equiv(actual, expected), actual, expected, message);
349
+ },
350
+
351
+ strictEqual: function(actual, expected, message) {
352
+ QUnit.push(expected === actual, actual, expected, message);
353
+ },
354
+
355
+ notStrictEqual: function(actual, expected, message) {
356
+ QUnit.push(expected !== actual, actual, expected, message);
357
+ },
358
+
359
+ raises: function(block, expected, message) {
360
+ var actual, ok = false;
361
+
362
+ if (typeof expected === 'string') {
363
+ message = expected;
364
+ expected = null;
365
+ }
366
+
367
+ try {
368
+ block();
369
+ } catch (e) {
370
+ actual = e;
371
+ }
372
+
373
+ if (actual) {
374
+ // we don't want to validate thrown error
375
+ if (!expected) {
376
+ ok = true;
377
+ // expected is a regexp
378
+ } else if (QUnit.objectType(expected) === "regexp") {
379
+ ok = expected.test(actual);
380
+ // expected is a constructor
381
+ } else if (actual instanceof expected) {
382
+ ok = true;
383
+ // expected is a validation function which returns true is validation passed
384
+ } else if (expected.call({}, actual) === true) {
385
+ ok = true;
386
+ }
387
+ }
388
+
389
+ QUnit.ok(ok, message);
390
+ },
391
+
392
+ start: function() {
393
+ config.semaphore--;
394
+ if (config.semaphore > 0) {
395
+ // don't start until equal number of stop-calls
396
+ return;
397
+ }
398
+ if (config.semaphore < 0) {
399
+ // ignore if start is called more often then stop
400
+ config.semaphore = 0;
401
+ }
402
+ // A slight delay, to avoid any current callbacks
403
+ if ( defined.setTimeout ) {
404
+ window.setTimeout(function() {
405
+ if ( config.timeout ) {
406
+ clearTimeout(config.timeout);
407
+ }
408
+
409
+ config.blocking = false;
410
+ process();
411
+ }, 13);
412
+ } else {
413
+ config.blocking = false;
414
+ process();
415
+ }
416
+ },
417
+
418
+ stop: function(timeout) {
419
+ config.semaphore++;
420
+ config.blocking = true;
421
+
422
+ if ( timeout && defined.setTimeout ) {
423
+ clearTimeout(config.timeout);
424
+ config.timeout = window.setTimeout(function() {
425
+ QUnit.ok( false, "Test timed out" );
426
+ QUnit.start();
427
+ }, timeout);
428
+ }
429
+ }
430
+ };
431
+
432
+ // Backwards compatibility, deprecated
433
+ QUnit.equals = QUnit.equal;
434
+ QUnit.same = QUnit.deepEqual;
435
+
436
+ // Maintain internal state
437
+ var config = {
438
+ // The queue of tests to run
439
+ queue: [],
440
+
441
+ // block until document ready
442
+ blocking: true,
443
+
444
+ // by default, run previously failed tests first
445
+ // very useful in combination with "Hide passed tests" checked
446
+ reorder: true,
447
+
448
+ noglobals: false,
449
+ notrycatch: false
450
+ };
451
+
452
+ // Load paramaters
453
+ (function() {
454
+ var location = window.location || { search: "", protocol: "file:" },
455
+ params = location.search.slice( 1 ).split( "&" ),
456
+ length = params.length,
457
+ urlParams = {},
458
+ current;
459
+
460
+ if ( params[ 0 ] ) {
461
+ for ( var i = 0; i < length; i++ ) {
462
+ current = params[ i ].split( "=" );
463
+ current[ 0 ] = decodeURIComponent( current[ 0 ] );
464
+ // allow just a key to turn on a flag, e.g., test.html?noglobals
465
+ current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;
466
+ urlParams[ current[ 0 ] ] = current[ 1 ];
467
+ if ( current[ 0 ] in config ) {
468
+ config[ current[ 0 ] ] = current[ 1 ];
469
+ }
470
+ }
471
+ }
472
+
473
+ QUnit.urlParams = urlParams;
474
+ config.filter = urlParams.filter;
475
+
476
+ // Figure out if we're running the tests from a server or not
477
+ QUnit.isLocal = !!(location.protocol === 'file:');
478
+ })();
479
+
480
+ // Expose the API as global variables, unless an 'exports'
481
+ // object exists, in that case we assume we're in CommonJS
482
+ if ( typeof exports === "undefined" || typeof require === "undefined" ) {
483
+ extend(window, QUnit);
484
+ window.QUnit = QUnit;
485
+ } else {
486
+ extend(exports, QUnit);
487
+ exports.QUnit = QUnit;
488
+ }
489
+
490
+ // define these after exposing globals to keep them in these QUnit namespace only
491
+ extend(QUnit, {
492
+ config: config,
493
+
494
+ // Initialize the configuration options
495
+ init: function() {
496
+ extend(config, {
497
+ stats: { all: 0, bad: 0 },
498
+ moduleStats: { all: 0, bad: 0 },
499
+ started: +new Date,
500
+ updateRate: 1000,
501
+ blocking: false,
502
+ autostart: true,
503
+ autorun: false,
504
+ filter: "",
505
+ queue: [],
506
+ semaphore: 0
507
+ });
508
+
509
+ var tests = id( "qunit-tests" ),
510
+ banner = id( "qunit-banner" ),
511
+ result = id( "qunit-testresult" );
512
+
513
+ if ( tests ) {
514
+ tests.innerHTML = "";
515
+ }
516
+
517
+ if ( banner ) {
518
+ banner.className = "";
519
+ }
520
+
521
+ if ( result ) {
522
+ result.parentNode.removeChild( result );
523
+ }
524
+
525
+ if ( tests ) {
526
+ result = document.createElement( "p" );
527
+ result.id = "qunit-testresult";
528
+ result.className = "result";
529
+ tests.parentNode.insertBefore( result, tests );
530
+ result.innerHTML = 'Running...<br/>&nbsp;';
531
+ }
532
+ },
533
+
534
+ /**
535
+ * Resets the test setup. Useful for tests that modify the DOM.
536
+ *
537
+ * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
538
+ */
539
+ reset: function() {
540
+ if ( window.jQuery ) {
541
+ jQuery( "#qunit-fixture" ).html( config.fixture );
542
+ } else {
543
+ var main = id( 'qunit-fixture' );
544
+ if ( main ) {
545
+ main.innerHTML = config.fixture;
546
+ }
547
+ }
548
+ },
549
+
550
+ /**
551
+ * Trigger an event on an element.
552
+ *
553
+ * @example triggerEvent( document.body, "click" );
554
+ *
555
+ * @param DOMElement elem
556
+ * @param String type
557
+ */
558
+ triggerEvent: function( elem, type, event ) {
559
+ if ( document.createEvent ) {
560
+ event = document.createEvent("MouseEvents");
561
+ event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
562
+ 0, 0, 0, 0, 0, false, false, false, false, 0, null);
563
+ elem.dispatchEvent( event );
564
+
565
+ } else if ( elem.fireEvent ) {
566
+ elem.fireEvent("on"+type);
567
+ }
568
+ },
569
+
570
+ // Safe object type checking
571
+ is: function( type, obj ) {
572
+ return QUnit.objectType( obj ) == type;
573
+ },
574
+
575
+ objectType: function( obj ) {
576
+ if (typeof obj === "undefined") {
577
+ return "undefined";
578
+
579
+ // consider: typeof null === object
580
+ }
581
+ if (obj === null) {
582
+ return "null";
583
+ }
584
+
585
+ var type = Object.prototype.toString.call( obj )
586
+ .match(/^\[object\s(.*)\]$/)[1] || '';
587
+
588
+ switch (type) {
589
+ case 'Number':
590
+ if (isNaN(obj)) {
591
+ return "nan";
592
+ } else {
593
+ return "number";
594
+ }
595
+ case 'String':
596
+ case 'Boolean':
597
+ case 'Array':
598
+ case 'Date':
599
+ case 'RegExp':
600
+ case 'Function':
601
+ return type.toLowerCase();
602
+ }
603
+ if (typeof obj === "object") {
604
+ return "object";
605
+ }
606
+ return undefined;
607
+ },
608
+
609
+ push: function(result, actual, expected, message) {
610
+ var details = {
611
+ result: result,
612
+ message: message,
613
+ actual: actual,
614
+ expected: expected
615
+ };
616
+
617
+ message = escapeHtml(message) || (result ? "okay" : "failed");
618
+ message = '<span class="test-message">' + message + "</span>";
619
+ expected = escapeHtml(QUnit.jsDump.parse(expected));
620
+ actual = escapeHtml(QUnit.jsDump.parse(actual));
621
+ var output = message + '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>';
622
+ if (actual != expected) {
623
+ output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>';
624
+ output += '<tr class="test-diff"><th>Diff: </th><td><pre>' + QUnit.diff(expected, actual) +'</pre></td></tr>';
625
+ }
626
+ if (!result) {
627
+ var source = sourceFromStacktrace();
628
+ if (source) {
629
+ details.source = source;
630
+ output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeHtml(source) + '</pre></td></tr>';
631
+ }
632
+ }
633
+ output += "</table>";
634
+
635
+ QUnit.log(details);
636
+
637
+ config.current.assertions.push({
638
+ result: !!result,
639
+ message: output
640
+ });
641
+ },
642
+
643
+ url: function( params ) {
644
+ params = extend( extend( {}, QUnit.urlParams ), params );
645
+ var querystring = "?",
646
+ key;
647
+ for ( key in params ) {
648
+ querystring += encodeURIComponent( key ) + "=" +
649
+ encodeURIComponent( params[ key ] ) + "&";
650
+ }
651
+ return window.location.pathname + querystring.slice( 0, -1 );
652
+ },
653
+
654
+ // Logging callbacks; all receive a single argument with the listed properties
655
+ // run test/logs.html for any related changes
656
+ begin: function() {},
657
+ // done: { failed, passed, total, runtime }
658
+ done: function() {},
659
+ // log: { result, actual, expected, message }
660
+ log: function() {},
661
+ // testStart: { name }
662
+ testStart: function() {},
663
+ // testDone: { name, failed, passed, total }
664
+ testDone: function() {},
665
+ // moduleStart: { name }
666
+ moduleStart: function() {},
667
+ // moduleDone: { name, failed, passed, total }
668
+ moduleDone: function() {}
669
+ });
670
+
671
+ if ( typeof document === "undefined" || document.readyState === "complete" ) {
672
+ config.autorun = true;
673
+ }
674
+
675
+ addEvent(window, "load", function() {
676
+ QUnit.begin({});
677
+
678
+ // Initialize the config, saving the execution queue
679
+ var oldconfig = extend({}, config);
680
+ QUnit.init();
681
+ extend(config, oldconfig);
682
+
683
+ config.blocking = false;
684
+
685
+ var userAgent = id("qunit-userAgent");
686
+ if ( userAgent ) {
687
+ userAgent.innerHTML = navigator.userAgent;
688
+ }
689
+ var banner = id("qunit-header");
690
+ if ( banner ) {
691
+ banner.innerHTML = '<a href="' + QUnit.url({ filter: undefined }) + '"> ' + banner.innerHTML + '</a> ' +
692
+ '<label><input name="noglobals" type="checkbox"' + ( config.noglobals ? ' checked="checked"' : '' ) + '>noglobals</label>' +
693
+ '<label><input name="notrycatch" type="checkbox"' + ( config.notrycatch ? ' checked="checked"' : '' ) + '>notrycatch</label>';
694
+ addEvent( banner, "change", function( event ) {
695
+ var params = {};
696
+ params[ event.target.name ] = event.target.checked ? true : undefined;
697
+ window.location = QUnit.url( params );
698
+ });
699
+ }
700
+
701
+ var toolbar = id("qunit-testrunner-toolbar");
702
+ if ( toolbar ) {
703
+ var filter = document.createElement("input");
704
+ filter.type = "checkbox";
705
+ filter.id = "qunit-filter-pass";
706
+ addEvent( filter, "click", function() {
707
+ var ol = document.getElementById("qunit-tests");
708
+ if ( filter.checked ) {
709
+ ol.className = ol.className + " hidepass";
710
+ } else {
711
+ var tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
712
+ ol.className = tmp.replace(/ hidepass /, " ");
713
+ }
714
+ if ( defined.sessionStorage ) {
715
+ if (filter.checked) {
716
+ sessionStorage.setItem("qunit-filter-passed-tests", "true");
717
+ } else {
718
+ sessionStorage.removeItem("qunit-filter-passed-tests");
719
+ }
720
+ }
721
+ });
722
+ if ( defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
723
+ filter.checked = true;
724
+ var ol = document.getElementById("qunit-tests");
725
+ ol.className = ol.className + " hidepass";
726
+ }
727
+ toolbar.appendChild( filter );
728
+
729
+ var label = document.createElement("label");
730
+ label.setAttribute("for", "qunit-filter-pass");
731
+ label.innerHTML = "Hide passed tests";
732
+ toolbar.appendChild( label );
733
+ }
734
+
735
+ var main = id('qunit-fixture');
736
+ if ( main ) {
737
+ config.fixture = main.innerHTML;
738
+ }
739
+
740
+ if (config.autostart) {
741
+ QUnit.start();
742
+ }
743
+ });
744
+
745
+ function done() {
746
+ config.autorun = true;
747
+
748
+ // Log the last module results
749
+ if ( config.currentModule ) {
750
+ QUnit.moduleDone( {
751
+ name: config.currentModule,
752
+ failed: config.moduleStats.bad,
753
+ passed: config.moduleStats.all - config.moduleStats.bad,
754
+ total: config.moduleStats.all
755
+ } );
756
+ }
757
+
758
+ var banner = id("qunit-banner"),
759
+ tests = id("qunit-tests"),
760
+ runtime = +new Date - config.started,
761
+ passed = config.stats.all - config.stats.bad,
762
+ html = [
763
+ 'Tests completed in ',
764
+ runtime,
765
+ ' milliseconds.<br/>',
766
+ '<span class="passed">',
767
+ passed,
768
+ '</span> tests of <span class="total">',
769
+ config.stats.all,
770
+ '</span> passed, <span class="failed">',
771
+ config.stats.bad,
772
+ '</span> failed.'
773
+ ].join('');
774
+
775
+ if ( banner ) {
776
+ banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass");
777
+ }
778
+
779
+ if ( tests ) {
780
+ id( "qunit-testresult" ).innerHTML = html;
781
+ }
782
+
783
+ if ( typeof document !== "undefined" && document.title ) {
784
+ // show ✖ for good, ✔ for bad suite result in title
785
+ // use escape sequences in case file gets loaded with non-utf-8-charset
786
+ document.title = (config.stats.bad ? "\u2716" : "\u2714") + " " + document.title;
787
+ }
788
+
789
+ QUnit.done( {
790
+ failed: config.stats.bad,
791
+ passed: passed,
792
+ total: config.stats.all,
793
+ runtime: runtime
794
+ } );
795
+ }
796
+
797
+ function validTest( name ) {
798
+ var filter = config.filter,
799
+ run = false;
800
+
801
+ if ( !filter ) {
802
+ return true;
803
+ }
804
+
805
+ var not = filter.charAt( 0 ) === "!";
806
+ if ( not ) {
807
+ filter = filter.slice( 1 );
808
+ }
809
+
810
+ if ( name.indexOf( filter ) !== -1 ) {
811
+ return !not;
812
+ }
813
+
814
+ if ( not ) {
815
+ run = true;
816
+ }
817
+
818
+ return run;
819
+ }
820
+
821
+ // so far supports only Firefox, Chrome and Opera (buggy)
822
+ // could be extended in the future to use something like https://github.com/csnover/TraceKit
823
+ function sourceFromStacktrace() {
824
+ try {
825
+ throw new Error();
826
+ } catch ( e ) {
827
+ if (e.stacktrace) {
828
+ // Opera
829
+ return e.stacktrace.split("\n")[6];
830
+ } else if (e.stack) {
831
+ // Firefox, Chrome
832
+ return e.stack.split("\n")[4];
833
+ }
834
+ }
835
+ }
836
+
837
+ function escapeHtml(s) {
838
+ if (!s) {
839
+ return "";
840
+ }
841
+ s = s + "";
842
+ return s.replace(/[\&"<>\\]/g, function(s) {
843
+ switch(s) {
844
+ case "&": return "&amp;";
845
+ case "\\": return "\\\\";
846
+ case '"': return '\"';
847
+ case "<": return "&lt;";
848
+ case ">": return "&gt;";
849
+ default: return s;
850
+ }
851
+ });
852
+ }
853
+
854
+ function synchronize( callback ) {
855
+ config.queue.push( callback );
856
+
857
+ if ( config.autorun && !config.blocking ) {
858
+ process();
859
+ }
860
+ }
861
+
862
+ function process() {
863
+ var start = (new Date()).getTime();
864
+
865
+ while ( config.queue.length && !config.blocking ) {
866
+ if ( config.updateRate <= 0 || (((new Date()).getTime() - start) < config.updateRate) ) {
867
+ config.queue.shift()();
868
+ } else {
869
+ window.setTimeout( process, 13 );
870
+ break;
871
+ }
872
+ }
873
+ if (!config.blocking && !config.queue.length) {
874
+ done();
875
+ }
876
+ }
877
+
878
+ function saveGlobal() {
879
+ config.pollution = [];
880
+
881
+ if ( config.noglobals ) {
882
+ for ( var key in window ) {
883
+ config.pollution.push( key );
884
+ }
885
+ }
886
+ }
887
+
888
+ function checkPollution( name ) {
889
+ var old = config.pollution;
890
+ saveGlobal();
891
+
892
+ var newGlobals = diff( config.pollution, old );
893
+ if ( newGlobals.length > 0 ) {
894
+ ok( false, "Introduced global variable(s): " + newGlobals.join(", ") );
895
+ }
896
+
897
+ var deletedGlobals = diff( old, config.pollution );
898
+ if ( deletedGlobals.length > 0 ) {
899
+ ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") );
900
+ }
901
+ }
902
+
903
+ // returns a new Array with the elements that are in a but not in b
904
+ function diff( a, b ) {
905
+ var result = a.slice();
906
+ for ( var i = 0; i < result.length; i++ ) {
907
+ for ( var j = 0; j < b.length; j++ ) {
908
+ if ( result[i] === b[j] ) {
909
+ result.splice(i, 1);
910
+ i--;
911
+ break;
912
+ }
913
+ }
914
+ }
915
+ return result;
916
+ }
917
+
918
+ function fail(message, exception, callback) {
919
+ if ( typeof console !== "undefined" && console.error && console.warn ) {
920
+ console.error(message);
921
+ console.error(exception);
922
+ console.warn(callback.toString());
923
+
924
+ } else if ( window.opera && opera.postError ) {
925
+ opera.postError(message, exception, callback.toString);
926
+ }
927
+ }
928
+
929
+ function extend(a, b) {
930
+ for ( var prop in b ) {
931
+ if ( b[prop] === undefined ) {
932
+ delete a[prop];
933
+ } else {
934
+ a[prop] = b[prop];
935
+ }
936
+ }
937
+
938
+ return a;
939
+ }
940
+
941
+ function addEvent(elem, type, fn) {
942
+ if ( elem.addEventListener ) {
943
+ elem.addEventListener( type, fn, false );
944
+ } else if ( elem.attachEvent ) {
945
+ elem.attachEvent( "on" + type, fn );
946
+ } else {
947
+ fn();
948
+ }
949
+ }
950
+
951
+ function id(name) {
952
+ return !!(typeof document !== "undefined" && document && document.getElementById) &&
953
+ document.getElementById( name );
954
+ }
955
+
956
+ // Test for equality any JavaScript type.
957
+ // Discussions and reference: http://philrathe.com/articles/equiv
958
+ // Test suites: http://philrathe.com/tests/equiv
959
+ // Author: Philippe Rathé <prathe@gmail.com>
960
+ QUnit.equiv = function () {
961
+
962
+ var innerEquiv; // the real equiv function
963
+ var callers = []; // stack to decide between skip/abort functions
964
+ var parents = []; // stack to avoiding loops from circular referencing
965
+
966
+ // Call the o related callback with the given arguments.
967
+ function bindCallbacks(o, callbacks, args) {
968
+ var prop = QUnit.objectType(o);
969
+ if (prop) {
970
+ if (QUnit.objectType(callbacks[prop]) === "function") {
971
+ return callbacks[prop].apply(callbacks, args);
972
+ } else {
973
+ return callbacks[prop]; // or undefined
974
+ }
975
+ }
976
+ }
977
+
978
+ var callbacks = function () {
979
+
980
+ // for string, boolean, number and null
981
+ function useStrictEquality(b, a) {
982
+ if (b instanceof a.constructor || a instanceof b.constructor) {
983
+ // to catch short annotaion VS 'new' annotation of a declaration
984
+ // e.g. var i = 1;
985
+ // var j = new Number(1);
986
+ return a == b;
987
+ } else {
988
+ return a === b;
989
+ }
990
+ }
991
+
992
+ return {
993
+ "string": useStrictEquality,
994
+ "boolean": useStrictEquality,
995
+ "number": useStrictEquality,
996
+ "null": useStrictEquality,
997
+ "undefined": useStrictEquality,
998
+
999
+ "nan": function (b) {
1000
+ return isNaN(b);
1001
+ },
1002
+
1003
+ "date": function (b, a) {
1004
+ return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
1005
+ },
1006
+
1007
+ "regexp": function (b, a) {
1008
+ return QUnit.objectType(b) === "regexp" &&
1009
+ a.source === b.source && // the regex itself
1010
+ a.global === b.global && // and its modifers (gmi) ...
1011
+ a.ignoreCase === b.ignoreCase &&
1012
+ a.multiline === b.multiline;
1013
+ },
1014
+
1015
+ // - skip when the property is a method of an instance (OOP)
1016
+ // - abort otherwise,
1017
+ // initial === would have catch identical references anyway
1018
+ "function": function () {
1019
+ var caller = callers[callers.length - 1];
1020
+ return caller !== Object &&
1021
+ typeof caller !== "undefined";
1022
+ },
1023
+
1024
+ "array": function (b, a) {
1025
+ var i, j, loop;
1026
+ var len;
1027
+
1028
+ // b could be an object literal here
1029
+ if ( ! (QUnit.objectType(b) === "array")) {
1030
+ return false;
1031
+ }
1032
+
1033
+ len = a.length;
1034
+ if (len !== b.length) { // safe and faster
1035
+ return false;
1036
+ }
1037
+
1038
+ //track reference to avoid circular references
1039
+ parents.push(a);
1040
+ for (i = 0; i < len; i++) {
1041
+ loop = false;
1042
+ for(j=0;j<parents.length;j++){
1043
+ if(parents[j] === a[i]){
1044
+ loop = true;//dont rewalk array
1045
+ }
1046
+ }
1047
+ if (!loop && ! innerEquiv(a[i], b[i])) {
1048
+ parents.pop();
1049
+ return false;
1050
+ }
1051
+ }
1052
+ parents.pop();
1053
+ return true;
1054
+ },
1055
+
1056
+ "object": function (b, a) {
1057
+ var i, j, loop;
1058
+ var eq = true; // unless we can proove it
1059
+ var aProperties = [], bProperties = []; // collection of strings
1060
+
1061
+ // comparing constructors is more strict than using instanceof
1062
+ if ( a.constructor !== b.constructor) {
1063
+ return false;
1064
+ }
1065
+
1066
+ // stack constructor before traversing properties
1067
+ callers.push(a.constructor);
1068
+ //track reference to avoid circular references
1069
+ parents.push(a);
1070
+
1071
+ for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
1072
+ loop = false;
1073
+ for(j=0;j<parents.length;j++){
1074
+ if(parents[j] === a[i])
1075
+ loop = true; //don't go down the same path twice
1076
+ }
1077
+ aProperties.push(i); // collect a's properties
1078
+
1079
+ if (!loop && ! innerEquiv(a[i], b[i])) {
1080
+ eq = false;
1081
+ break;
1082
+ }
1083
+ }
1084
+
1085
+ callers.pop(); // unstack, we are done
1086
+ parents.pop();
1087
+
1088
+ for (i in b) {
1089
+ bProperties.push(i); // collect b's properties
1090
+ }
1091
+
1092
+ // Ensures identical properties name
1093
+ return eq && innerEquiv(aProperties.sort(), bProperties.sort());
1094
+ }
1095
+ };
1096
+ }();
1097
+
1098
+ innerEquiv = function () { // can take multiple arguments
1099
+ var args = Array.prototype.slice.apply(arguments);
1100
+ if (args.length < 2) {
1101
+ return true; // end transition
1102
+ }
1103
+
1104
+ return (function (a, b) {
1105
+ if (a === b) {
1106
+ return true; // catch the most you can
1107
+ } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || QUnit.objectType(a) !== QUnit.objectType(b)) {
1108
+ return false; // don't lose time with error prone cases
1109
+ } else {
1110
+ return bindCallbacks(a, callbacks, [b, a]);
1111
+ }
1112
+
1113
+ // apply transition with (1..n) arguments
1114
+ })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
1115
+ };
1116
+
1117
+ return innerEquiv;
1118
+
1119
+ }();
1120
+
1121
+ /**
1122
+ * jsDump
1123
+ * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
1124
+ * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
1125
+ * Date: 5/15/2008
1126
+ * @projectDescription Advanced and extensible data dumping for Javascript.
1127
+ * @version 1.0.0
1128
+ * @author Ariel Flesler
1129
+ * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
1130
+ */
1131
+ QUnit.jsDump = (function() {
1132
+ function quote( str ) {
1133
+ return '"' + str.toString().replace(/"/g, '\\"') + '"';
1134
+ };
1135
+ function literal( o ) {
1136
+ return o + '';
1137
+ };
1138
+ function join( pre, arr, post ) {
1139
+ var s = jsDump.separator(),
1140
+ base = jsDump.indent(),
1141
+ inner = jsDump.indent(1);
1142
+ if ( arr.join )
1143
+ arr = arr.join( ',' + s + inner );
1144
+ if ( !arr )
1145
+ return pre + post;
1146
+ return [ pre, inner + arr, base + post ].join(s);
1147
+ };
1148
+ function array( arr ) {
1149
+ var i = arr.length, ret = Array(i);
1150
+ this.up();
1151
+ while ( i-- )
1152
+ ret[i] = this.parse( arr[i] );
1153
+ this.down();
1154
+ return join( '[', ret, ']' );
1155
+ };
1156
+
1157
+ var reName = /^function (\w+)/;
1158
+
1159
+ var jsDump = {
1160
+ parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
1161
+ var parser = this.parsers[ type || this.typeOf(obj) ];
1162
+ type = typeof parser;
1163
+
1164
+ return type == 'function' ? parser.call( this, obj ) :
1165
+ type == 'string' ? parser :
1166
+ this.parsers.error;
1167
+ },
1168
+ typeOf:function( obj ) {
1169
+ var type;
1170
+ if ( obj === null ) {
1171
+ type = "null";
1172
+ } else if (typeof obj === "undefined") {
1173
+ type = "undefined";
1174
+ } else if (QUnit.is("RegExp", obj)) {
1175
+ type = "regexp";
1176
+ } else if (QUnit.is("Date", obj)) {
1177
+ type = "date";
1178
+ } else if (QUnit.is("Function", obj)) {
1179
+ type = "function";
1180
+ } else if (typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined") {
1181
+ type = "window";
1182
+ } else if (obj.nodeType === 9) {
1183
+ type = "document";
1184
+ } else if (obj.nodeType) {
1185
+ type = "node";
1186
+ } else if (typeof obj === "object" && typeof obj.length === "number" && obj.length >= 0) {
1187
+ type = "array";
1188
+ } else {
1189
+ type = typeof obj;
1190
+ }
1191
+ return type;
1192
+ },
1193
+ separator:function() {
1194
+ return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
1195
+ },
1196
+ indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing
1197
+ if ( !this.multiline )
1198
+ return '';
1199
+ var chr = this.indentChar;
1200
+ if ( this.HTML )
1201
+ chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
1202
+ return Array( this._depth_ + (extra||0) ).join(chr);
1203
+ },
1204
+ up:function( a ) {
1205
+ this._depth_ += a || 1;
1206
+ },
1207
+ down:function( a ) {
1208
+ this._depth_ -= a || 1;
1209
+ },
1210
+ setParser:function( name, parser ) {
1211
+ this.parsers[name] = parser;
1212
+ },
1213
+ // The next 3 are exposed so you can use them
1214
+ quote:quote,
1215
+ literal:literal,
1216
+ join:join,
1217
+ //
1218
+ _depth_: 1,
1219
+ // This is the list of parsers, to modify them, use jsDump.setParser
1220
+ parsers:{
1221
+ window: '[Window]',
1222
+ document: '[Document]',
1223
+ error:'[ERROR]', //when no parser is found, shouldn't happen
1224
+ unknown: '[Unknown]',
1225
+ 'null':'null',
1226
+ 'undefined':'undefined',
1227
+ 'function':function( fn ) {
1228
+ var ret = 'function',
1229
+ name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
1230
+ if ( name )
1231
+ ret += ' ' + name;
1232
+ ret += '(';
1233
+
1234
+ ret = [ ret, QUnit.jsDump.parse( fn, 'functionArgs' ), '){'].join('');
1235
+ return join( ret, QUnit.jsDump.parse(fn,'functionCode'), '}' );
1236
+ },
1237
+ array: array,
1238
+ nodelist: array,
1239
+ arguments: array,
1240
+ object:function( map ) {
1241
+ var ret = [ ];
1242
+ QUnit.jsDump.up();
1243
+ for ( var key in map )
1244
+ ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(map[key]) );
1245
+ QUnit.jsDump.down();
1246
+ return join( '{', ret, '}' );
1247
+ },
1248
+ node:function( node ) {
1249
+ var open = QUnit.jsDump.HTML ? '&lt;' : '<',
1250
+ close = QUnit.jsDump.HTML ? '&gt;' : '>';
1251
+
1252
+ var tag = node.nodeName.toLowerCase(),
1253
+ ret = open + tag;
1254
+
1255
+ for ( var a in QUnit.jsDump.DOMAttrs ) {
1256
+ var val = node[QUnit.jsDump.DOMAttrs[a]];
1257
+ if ( val )
1258
+ ret += ' ' + a + '=' + QUnit.jsDump.parse( val, 'attribute' );
1259
+ }
1260
+ return ret + close + open + '/' + tag + close;
1261
+ },
1262
+ functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function
1263
+ var l = fn.length;
1264
+ if ( !l ) return '';
1265
+
1266
+ var args = Array(l);
1267
+ while ( l-- )
1268
+ args[l] = String.fromCharCode(97+l);//97 is 'a'
1269
+ return ' ' + args.join(', ') + ' ';
1270
+ },
1271
+ key:quote, //object calls it internally, the key part of an item in a map
1272
+ functionCode:'[code]', //function calls it internally, it's the content of the function
1273
+ attribute:quote, //node calls it internally, it's an html attribute value
1274
+ string:quote,
1275
+ date:quote,
1276
+ regexp:literal, //regex
1277
+ number:literal,
1278
+ 'boolean':literal
1279
+ },
1280
+ DOMAttrs:{//attributes to dump from nodes, name=>realName
1281
+ id:'id',
1282
+ name:'name',
1283
+ 'class':'className'
1284
+ },
1285
+ HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
1286
+ indentChar:' ',//indentation unit
1287
+ multiline:true //if true, items in a collection, are separated by a \n, else just a space.
1288
+ };
1289
+
1290
+ return jsDump;
1291
+ })();
1292
+
1293
+ // from Sizzle.js
1294
+ function getText( elems ) {
1295
+ var ret = "", elem;
1296
+
1297
+ for ( var i = 0; elems[i]; i++ ) {
1298
+ elem = elems[i];
1299
+
1300
+ // Get the text from text nodes and CDATA nodes
1301
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
1302
+ ret += elem.nodeValue;
1303
+
1304
+ // Traverse everything else, except comment nodes
1305
+ } else if ( elem.nodeType !== 8 ) {
1306
+ ret += getText( elem.childNodes );
1307
+ }
1308
+ }
1309
+
1310
+ return ret;
1311
+ };
1312
+
1313
+ /*
1314
+ * Javascript Diff Algorithm
1315
+ * By John Resig (http://ejohn.org/)
1316
+ * Modified by Chu Alan "sprite"
1317
+ *
1318
+ * Released under the MIT license.
1319
+ *
1320
+ * More Info:
1321
+ * http://ejohn.org/projects/javascript-diff-algorithm/
1322
+ *
1323
+ * Usage: QUnit.diff(expected, actual)
1324
+ *
1325
+ * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
1326
+ */
1327
+ QUnit.diff = (function() {
1328
+ function diff(o, n){
1329
+ var ns = new Object();
1330
+ var os = new Object();
1331
+
1332
+ for (var i = 0; i < n.length; i++) {
1333
+ if (ns[n[i]] == null)
1334
+ ns[n[i]] = {
1335
+ rows: new Array(),
1336
+ o: null
1337
+ };
1338
+ ns[n[i]].rows.push(i);
1339
+ }
1340
+
1341
+ for (var i = 0; i < o.length; i++) {
1342
+ if (os[o[i]] == null)
1343
+ os[o[i]] = {
1344
+ rows: new Array(),
1345
+ n: null
1346
+ };
1347
+ os[o[i]].rows.push(i);
1348
+ }
1349
+
1350
+ for (var i in ns) {
1351
+ if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
1352
+ n[ns[i].rows[0]] = {
1353
+ text: n[ns[i].rows[0]],
1354
+ row: os[i].rows[0]
1355
+ };
1356
+ o[os[i].rows[0]] = {
1357
+ text: o[os[i].rows[0]],
1358
+ row: ns[i].rows[0]
1359
+ };
1360
+ }
1361
+ }
1362
+
1363
+ for (var i = 0; i < n.length - 1; i++) {
1364
+ if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null &&
1365
+ n[i + 1] == o[n[i].row + 1]) {
1366
+ n[i + 1] = {
1367
+ text: n[i + 1],
1368
+ row: n[i].row + 1
1369
+ };
1370
+ o[n[i].row + 1] = {
1371
+ text: o[n[i].row + 1],
1372
+ row: i + 1
1373
+ };
1374
+ }
1375
+ }
1376
+
1377
+ for (var i = n.length - 1; i > 0; i--) {
1378
+ if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null &&
1379
+ n[i - 1] == o[n[i].row - 1]) {
1380
+ n[i - 1] = {
1381
+ text: n[i - 1],
1382
+ row: n[i].row - 1
1383
+ };
1384
+ o[n[i].row - 1] = {
1385
+ text: o[n[i].row - 1],
1386
+ row: i - 1
1387
+ };
1388
+ }
1389
+ }
1390
+
1391
+ return {
1392
+ o: o,
1393
+ n: n
1394
+ };
1395
+ }
1396
+
1397
+ return function(o, n){
1398
+ o = o.replace(/\s+$/, '');
1399
+ n = n.replace(/\s+$/, '');
1400
+ var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/));
1401
+
1402
+ var str = "";
1403
+
1404
+ var oSpace = o.match(/\s+/g);
1405
+ if (oSpace == null) {
1406
+ oSpace = [" "];
1407
+ }
1408
+ else {
1409
+ oSpace.push(" ");
1410
+ }
1411
+ var nSpace = n.match(/\s+/g);
1412
+ if (nSpace == null) {
1413
+ nSpace = [" "];
1414
+ }
1415
+ else {
1416
+ nSpace.push(" ");
1417
+ }
1418
+
1419
+ if (out.n.length == 0) {
1420
+ for (var i = 0; i < out.o.length; i++) {
1421
+ str += '<del>' + out.o[i] + oSpace[i] + "</del>";
1422
+ }
1423
+ }
1424
+ else {
1425
+ if (out.n[0].text == null) {
1426
+ for (n = 0; n < out.o.length && out.o[n].text == null; n++) {
1427
+ str += '<del>' + out.o[n] + oSpace[n] + "</del>";
1428
+ }
1429
+ }
1430
+
1431
+ for (var i = 0; i < out.n.length; i++) {
1432
+ if (out.n[i].text == null) {
1433
+ str += '<ins>' + out.n[i] + nSpace[i] + "</ins>";
1434
+ }
1435
+ else {
1436
+ var pre = "";
1437
+
1438
+ for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) {
1439
+ pre += '<del>' + out.o[n] + oSpace[n] + "</del>";
1440
+ }
1441
+ str += " " + out.n[i].text + nSpace[i] + pre;
1442
+ }
1443
+ }
1444
+ }
1445
+
1446
+ return str;
1447
+ };
1448
+ })();
1449
+
1450
+ })(this);