annotate vakata-jstree-3.3.5/test/unit/libs/qunit.js @ 1:d74e8ffcf88f draft default tip

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Sun, 30 Dec 2018 13:56:16 -0500
parents 0358f6f78adf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2 * QUnit v1.12.0 - A JavaScript Unit Testing Framework
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
3 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
4 * http://qunitjs.com
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
5 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
6 * Copyright 2013 jQuery Foundation and other contributors
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
7 * Released under the MIT license.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
8 * https://jquery.org/license/
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
9 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
10
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
11 (function( window ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
12
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
13 var QUnit,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
14 assert,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
15 config,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
16 onErrorFnPrev,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
17 testId = 0,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
18 fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
19 toString = Object.prototype.toString,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
20 hasOwn = Object.prototype.hasOwnProperty,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
21 // Keep a local reference to Date (GH-283)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
22 Date = window.Date,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
23 setTimeout = window.setTimeout,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
24 defined = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
25 setTimeout: typeof window.setTimeout !== "undefined",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
26 sessionStorage: (function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
27 var x = "qunit-test-string";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
28 try {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
29 sessionStorage.setItem( x, x );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
30 sessionStorage.removeItem( x );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
31 return true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
32 } catch( e ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
33 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
34 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
35 }())
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
36 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
37 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
38 * Provides a normalized error string, correcting an issue
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
39 * with IE 7 (and prior) where Error.prototype.toString is
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
40 * not properly implemented
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
41 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
42 * Based on http://es5.github.com/#x15.11.4.4
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
43 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
44 * @param {String|Error} error
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
45 * @return {String} error message
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
46 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
47 errorString = function( error ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
48 var name, message,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
49 errorString = error.toString();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
50 if ( errorString.substring( 0, 7 ) === "[object" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
51 name = error.name ? error.name.toString() : "Error";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
52 message = error.message ? error.message.toString() : "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
53 if ( name && message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
54 return name + ": " + message;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
55 } else if ( name ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
56 return name;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
57 } else if ( message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
58 return message;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
59 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
60 return "Error";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
61 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
62 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
63 return errorString;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
64 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
65 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
66 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
67 * Makes a clone of an object using only Array or Object as base,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
68 * and copies over the own enumerable properties.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
69 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
70 * @param {Object} obj
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
71 * @return {Object} New object with only the own properties (recursively).
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
72 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
73 objectValues = function( obj ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
74 // Grunt 0.3.x uses an older version of jshint that still has jshint/jshint#392.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
75 /*jshint newcap: false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
76 var key, val,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
77 vals = QUnit.is( "array", obj ) ? [] : {};
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
78 for ( key in obj ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
79 if ( hasOwn.call( obj, key ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
80 val = obj[key];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
81 vals[key] = val === Object(val) ? objectValues(val) : val;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
82 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
83 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
84 return vals;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
85 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
86
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
87 function Test( settings ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
88 extend( this, settings );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
89 this.assertions = [];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
90 this.testNumber = ++Test.count;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
91 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
92
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
93 Test.count = 0;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
94
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
95 Test.prototype = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
96 init: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
97 var a, b, li,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
98 tests = id( "qunit-tests" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
99
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
100 if ( tests ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
101 b = document.createElement( "strong" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
102 b.innerHTML = this.nameHtml;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
103
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
104 // `a` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
105 a = document.createElement( "a" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
106 a.innerHTML = "Rerun";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
107 a.href = QUnit.url({ testNumber: this.testNumber });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
108
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
109 li = document.createElement( "li" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
110 li.appendChild( b );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
111 li.appendChild( a );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
112 li.className = "running";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
113 li.id = this.id = "qunit-test-output" + testId++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
114
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
115 tests.appendChild( li );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
116 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
117 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
118 setup: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
119 if (
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
120 // Emit moduleStart when we're switching from one module to another
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
121 this.module !== config.previousModule ||
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
122 // They could be equal (both undefined) but if the previousModule property doesn't
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
123 // yet exist it means this is the first test in a suite that isn't wrapped in a
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
124 // module, in which case we'll just emit a moduleStart event for 'undefined'.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
125 // Without this, reporters can get testStart before moduleStart which is a problem.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
126 !hasOwn.call( config, "previousModule" )
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
127 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
128 if ( hasOwn.call( config, "previousModule" ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
129 runLoggingCallbacks( "moduleDone", QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
130 name: config.previousModule,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
131 failed: config.moduleStats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
132 passed: config.moduleStats.all - config.moduleStats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
133 total: config.moduleStats.all
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
134 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
135 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
136 config.previousModule = this.module;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
137 config.moduleStats = { all: 0, bad: 0 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
138 runLoggingCallbacks( "moduleStart", QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
139 name: this.module
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
140 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
141 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
142
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
143 config.current = this;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
144
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
145 this.testEnvironment = extend({
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
146 setup: function() {},
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
147 teardown: function() {}
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
148 }, this.moduleTestEnvironment );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
149
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
150 this.started = +new Date();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
151 runLoggingCallbacks( "testStart", QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
152 name: this.testName,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
153 module: this.module
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
154 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
155
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
156 /*jshint camelcase:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
157
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
158
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
159 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
160 * Expose the current test environment.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
161 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
162 * @deprecated since 1.12.0: Use QUnit.config.current.testEnvironment instead.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
163 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
164 QUnit.current_testEnvironment = this.testEnvironment;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
165
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
166 /*jshint camelcase:true */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
167
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
168 if ( !config.pollution ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
169 saveGlobal();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
170 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
171 if ( config.notrycatch ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
172 this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
173 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
174 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
175 try {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
176 this.testEnvironment.setup.call( this.testEnvironment, QUnit.assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
177 } catch( e ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
178 QUnit.pushFailure( "Setup failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
179 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
180 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
181 run: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
182 config.current = this;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
183
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
184 var running = id( "qunit-testresult" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
185
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
186 if ( running ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
187 running.innerHTML = "Running: <br/>" + this.nameHtml;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
188 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
189
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
190 if ( this.async ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
191 QUnit.stop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
192 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
193
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
194 this.callbackStarted = +new Date();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
195
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
196 if ( config.notrycatch ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
197 this.callback.call( this.testEnvironment, QUnit.assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
198 this.callbackRuntime = +new Date() - this.callbackStarted;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
199 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
200 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
201
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
202 try {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
203 this.callback.call( this.testEnvironment, QUnit.assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
204 this.callbackRuntime = +new Date() - this.callbackStarted;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
205 } catch( e ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
206 this.callbackRuntime = +new Date() - this.callbackStarted;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
207
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
208 QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + " " + this.stack + ": " + ( e.message || e ), extractStacktrace( e, 0 ) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
209 // else next test will carry the responsibility
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
210 saveGlobal();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
211
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
212 // Restart the tests if they're blocking
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
213 if ( config.blocking ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
214 QUnit.start();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
215 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
216 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
217 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
218 teardown: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
219 config.current = this;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
220 if ( config.notrycatch ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
221 if ( typeof this.callbackRuntime === "undefined" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
222 this.callbackRuntime = +new Date() - this.callbackStarted;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
223 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
224 this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
225 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
226 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
227 try {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
228 this.testEnvironment.teardown.call( this.testEnvironment, QUnit.assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
229 } catch( e ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
230 QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + ( e.message || e ), extractStacktrace( e, 1 ) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
231 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
232 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
233 checkPollution();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
234 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
235 finish: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
236 config.current = this;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
237 if ( config.requireExpects && this.expected === null ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
238 QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
239 } else if ( this.expected !== null && this.expected !== this.assertions.length ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
240 QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
241 } else if ( this.expected === null && !this.assertions.length ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
242 QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
243 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
244
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
245 var i, assertion, a, b, time, li, ol,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
246 test = this,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
247 good = 0,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
248 bad = 0,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
249 tests = id( "qunit-tests" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
250
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
251 this.runtime = +new Date() - this.started;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
252 config.stats.all += this.assertions.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
253 config.moduleStats.all += this.assertions.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
254
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
255 if ( tests ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
256 ol = document.createElement( "ol" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
257 ol.className = "qunit-assert-list";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
258
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
259 for ( i = 0; i < this.assertions.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
260 assertion = this.assertions[i];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
261
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
262 li = document.createElement( "li" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
263 li.className = assertion.result ? "pass" : "fail";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
264 li.innerHTML = assertion.message || ( assertion.result ? "okay" : "failed" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
265 ol.appendChild( li );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
266
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
267 if ( assertion.result ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
268 good++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
269 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
270 bad++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
271 config.stats.bad++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
272 config.moduleStats.bad++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
273 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
274 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
275
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
276 // store result when possible
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
277 if ( QUnit.config.reorder && defined.sessionStorage ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
278 if ( bad ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
279 sessionStorage.setItem( "qunit-test-" + this.module + "-" + this.testName, bad );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
280 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
281 sessionStorage.removeItem( "qunit-test-" + this.module + "-" + this.testName );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
282 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
283 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
284
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
285 if ( bad === 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
286 addClass( ol, "qunit-collapsed" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
287 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
288
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
289 // `b` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
290 b = document.createElement( "strong" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
291 b.innerHTML = this.nameHtml + " <b class='counts'>(<b class='failed'>" + bad + "</b>, <b class='passed'>" + good + "</b>, " + this.assertions.length + ")</b>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
292
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
293 addEvent(b, "click", function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
294 var next = b.parentNode.lastChild,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
295 collapsed = hasClass( next, "qunit-collapsed" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
296 ( collapsed ? removeClass : addClass )( next, "qunit-collapsed" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
297 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
298
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
299 addEvent(b, "dblclick", function( e ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
300 var target = e && e.target ? e.target : window.event.srcElement;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
301 if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
302 target = target.parentNode;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
303 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
304 if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
305 window.location = QUnit.url({ testNumber: test.testNumber });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
306 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
307 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
308
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
309 // `time` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
310 time = document.createElement( "span" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
311 time.className = "runtime";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
312 time.innerHTML = this.runtime + " ms";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
313
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
314 // `li` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
315 li = id( this.id );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
316 li.className = bad ? "fail" : "pass";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
317 li.removeChild( li.firstChild );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
318 a = li.firstChild;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
319 li.appendChild( b );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
320 li.appendChild( a );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
321 li.appendChild( time );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
322 li.appendChild( ol );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
323
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
324 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
325 for ( i = 0; i < this.assertions.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
326 if ( !this.assertions[i].result ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
327 bad++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
328 config.stats.bad++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
329 config.moduleStats.bad++;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
330 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
331 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
332 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
333
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
334 runLoggingCallbacks( "testDone", QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
335 name: this.testName,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
336 module: this.module,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
337 failed: bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
338 passed: this.assertions.length - bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
339 total: this.assertions.length,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
340 duration: this.runtime
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
341 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
342
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
343 QUnit.reset();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
344
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
345 config.current = undefined;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
346 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
347
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
348 queue: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
349 var bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
350 test = this;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
351
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
352 synchronize(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
353 test.init();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
354 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
355 function run() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
356 // each of these can by async
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
357 synchronize(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
358 test.setup();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
359 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
360 synchronize(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
361 test.run();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
362 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
363 synchronize(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
364 test.teardown();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
365 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
366 synchronize(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
367 test.finish();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
368 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
369 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
370
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
371 // `bad` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
372 // defer when previous test run passed, if storage is available
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
373 bad = QUnit.config.reorder && defined.sessionStorage &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
374 +sessionStorage.getItem( "qunit-test-" + this.module + "-" + this.testName );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
375
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
376 if ( bad ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
377 run();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
378 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
379 synchronize( run, true );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
380 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
381 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
382 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
383
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
384 // Root QUnit object.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
385 // `QUnit` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
386 QUnit = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
387
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
388 // call on start of module test to prepend name to all tests
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
389 module: function( name, testEnvironment ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
390 config.currentModule = name;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
391 config.currentModuleTestEnvironment = testEnvironment;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
392 config.modules[name] = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
393 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
394
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
395 asyncTest: function( testName, expected, callback ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
396 if ( arguments.length === 2 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
397 callback = expected;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
398 expected = null;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
399 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
400
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
401 QUnit.test( testName, expected, callback, true );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
402 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
403
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
404 test: function( testName, expected, callback, async ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
405 var test,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
406 nameHtml = "<span class='test-name'>" + escapeText( testName ) + "</span>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
407
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
408 if ( arguments.length === 2 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
409 callback = expected;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
410 expected = null;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
411 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
412
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
413 if ( config.currentModule ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
414 nameHtml = "<span class='module-name'>" + escapeText( config.currentModule ) + "</span>: " + nameHtml;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
415 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
416
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
417 test = new Test({
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
418 nameHtml: nameHtml,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
419 testName: testName,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
420 expected: expected,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
421 async: async,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
422 callback: callback,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
423 module: config.currentModule,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
424 moduleTestEnvironment: config.currentModuleTestEnvironment,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
425 stack: sourceFromStacktrace( 2 )
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
426 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
427
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
428 if ( !validTest( test ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
429 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
430 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
431
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
432 test.queue();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
433 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
434
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
435 // Specify the number of expected assertions to guarantee that failed test (no assertions are run at all) don't slip through.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
436 expect: function( asserts ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
437 if (arguments.length === 1) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
438 config.current.expected = asserts;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
439 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
440 return config.current.expected;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
441 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
442 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
443
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
444 start: function( count ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
445 // QUnit hasn't been initialized yet.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
446 // Note: RequireJS (et al) may delay onLoad
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
447 if ( config.semaphore === undefined ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
448 QUnit.begin(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
449 // This is triggered at the top of QUnit.load, push start() to the event loop, to allow QUnit.load to finish first
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
450 setTimeout(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
451 QUnit.start( count );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
452 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
453 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
454 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
455 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
456
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
457 config.semaphore -= count || 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
458 // don't start until equal number of stop-calls
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
459 if ( config.semaphore > 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
460 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
461 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
462 // ignore if start is called more often then stop
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
463 if ( config.semaphore < 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
464 config.semaphore = 0;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
465 QUnit.pushFailure( "Called start() while already started (QUnit.config.semaphore was 0 already)", null, sourceFromStacktrace(2) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
466 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
467 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
468 // A slight delay, to avoid any current callbacks
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
469 if ( defined.setTimeout ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
470 setTimeout(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
471 if ( config.semaphore > 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
472 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
473 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
474 if ( config.timeout ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
475 clearTimeout( config.timeout );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
476 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
477
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
478 config.blocking = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
479 process( true );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
480 }, 13);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
481 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
482 config.blocking = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
483 process( true );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
484 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
485 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
486
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
487 stop: function( count ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
488 config.semaphore += count || 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
489 config.blocking = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
490
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
491 if ( config.testTimeout && defined.setTimeout ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
492 clearTimeout( config.timeout );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
493 config.timeout = setTimeout(function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
494 QUnit.ok( false, "Test timed out" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
495 config.semaphore = 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
496 QUnit.start();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
497 }, config.testTimeout );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
498 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
499 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
500 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
501
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
502 // `assert` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
503 // Assert helpers
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
504 // All of these must either call QUnit.push() or manually do:
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
505 // - runLoggingCallbacks( "log", .. );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
506 // - config.current.assertions.push({ .. });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
507 // We attach it to the QUnit object *after* we expose the public API,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
508 // otherwise `assert` will become a global variable in browsers (#341).
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
509 assert = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
510 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
511 * Asserts rough true-ish result.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
512 * @name ok
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
513 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
514 * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
515 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
516 ok: function( result, msg ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
517 if ( !config.current ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
518 throw new Error( "ok() assertion outside test context, was " + sourceFromStacktrace(2) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
519 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
520 result = !!result;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
521 msg = msg || (result ? "okay" : "failed" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
522
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
523 var source,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
524 details = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
525 module: config.current.module,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
526 name: config.current.testName,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
527 result: result,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
528 message: msg
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
529 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
530
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
531 msg = "<span class='test-message'>" + escapeText( msg ) + "</span>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
532
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
533 if ( !result ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
534 source = sourceFromStacktrace( 2 );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
535 if ( source ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
536 details.source = source;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
537 msg += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr></table>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
538 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
539 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
540 runLoggingCallbacks( "log", QUnit, details );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
541 config.current.assertions.push({
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
542 result: result,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
543 message: msg
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
544 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
545 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
546
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
547 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
548 * Assert that the first two arguments are equal, with an optional message.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
549 * Prints out both actual and expected values.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
550 * @name equal
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
551 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
552 * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
553 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
554 equal: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
555 /*jshint eqeqeq:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
556 QUnit.push( expected == actual, actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
557 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
558
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
559 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
560 * @name notEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
561 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
562 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
563 notEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
564 /*jshint eqeqeq:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
565 QUnit.push( expected != actual, actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
566 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
567
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
568 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
569 * @name propEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
570 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
571 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
572 propEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
573 actual = objectValues(actual);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
574 expected = objectValues(expected);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
575 QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
576 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
577
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
578 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
579 * @name notPropEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
580 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
581 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
582 notPropEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
583 actual = objectValues(actual);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
584 expected = objectValues(expected);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
585 QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
586 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
587
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
588 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
589 * @name deepEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
590 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
591 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
592 deepEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
593 QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
594 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
595
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
596 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
597 * @name notDeepEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
598 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
599 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
600 notDeepEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
601 QUnit.push( !QUnit.equiv(actual, expected), actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
602 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
603
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
604 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
605 * @name strictEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
606 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
607 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
608 strictEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
609 QUnit.push( expected === actual, actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
610 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
611
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
612 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
613 * @name notStrictEqual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
614 * @function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
615 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
616 notStrictEqual: function( actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
617 QUnit.push( expected !== actual, actual, expected, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
618 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
619
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
620 "throws": function( block, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
621 var actual,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
622 expectedOutput = expected,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
623 ok = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
624
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
625 // 'expected' is optional
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
626 if ( typeof expected === "string" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
627 message = expected;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
628 expected = null;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
629 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
630
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
631 config.current.ignoreGlobalErrors = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
632 try {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
633 block.call( config.current.testEnvironment );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
634 } catch (e) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
635 actual = e;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
636 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
637 config.current.ignoreGlobalErrors = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
638
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
639 if ( actual ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
640 // we don't want to validate thrown error
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
641 if ( !expected ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
642 ok = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
643 expectedOutput = null;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
644 // expected is a regexp
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
645 } else if ( QUnit.objectType( expected ) === "regexp" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
646 ok = expected.test( errorString( actual ) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
647 // expected is a constructor
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
648 } else if ( actual instanceof expected ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
649 ok = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
650 // expected is a validation function which returns true is validation passed
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
651 } else if ( expected.call( {}, actual ) === true ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
652 expectedOutput = null;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
653 ok = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
654 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
655
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
656 QUnit.push( ok, actual, expectedOutput, message );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
657 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
658 QUnit.pushFailure( message, null, "No exception was thrown." );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
659 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
660 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
661 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
662
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
663 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
664 * @deprecated since 1.8.0
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
665 * Kept assertion helpers in root for backwards compatibility.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
666 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
667 extend( QUnit, assert );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
668
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
669 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
670 * @deprecated since 1.9.0
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
671 * Kept root "raises()" for backwards compatibility.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
672 * (Note that we don't introduce assert.raises).
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
673 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
674 QUnit.raises = assert[ "throws" ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
675
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
676 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
677 * @deprecated since 1.0.0, replaced with error pushes since 1.3.0
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
678 * Kept to avoid TypeErrors for undefined methods.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
679 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
680 QUnit.equals = function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
681 QUnit.push( false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
682 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
683 QUnit.same = function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
684 QUnit.push( false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
685 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
686
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
687 // We want access to the constructor's prototype
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
688 (function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
689 function F() {}
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
690 F.prototype = QUnit;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
691 QUnit = new F();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
692 // Make F QUnit's constructor so that we can add to the prototype later
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
693 QUnit.constructor = F;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
694 }());
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
695
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
696 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
697 * Config object: Maintain internal state
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
698 * Later exposed as QUnit.config
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
699 * `config` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
700 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
701 config = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
702 // The queue of tests to run
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
703 queue: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
704
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
705 // block until document ready
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
706 blocking: true,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
707
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
708 // when enabled, show only failing tests
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
709 // gets persisted through sessionStorage and can be changed in UI via checkbox
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
710 hidepassed: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
711
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
712 // by default, run previously failed tests first
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
713 // very useful in combination with "Hide passed tests" checked
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
714 reorder: true,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
715
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
716 // by default, modify document.title when suite is done
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
717 altertitle: true,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
718
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
719 // when enabled, all tests must call expect()
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
720 requireExpects: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
721
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
722 // add checkboxes that are persisted in the query-string
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
723 // when enabled, the id is set to `true` as a `QUnit.config` property
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
724 urlConfig: [
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
725 {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
726 id: "noglobals",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
727 label: "Check for Globals",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
728 tooltip: "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
729 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
730 {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
731 id: "notrycatch",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
732 label: "No try-catch",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
733 tooltip: "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
734 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
735 ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
736
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
737 // Set of all modules.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
738 modules: {},
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
739
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
740 // logging callback queues
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
741 begin: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
742 done: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
743 log: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
744 testStart: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
745 testDone: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
746 moduleStart: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
747 moduleDone: []
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
748 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
749
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
750 // Export global variables, unless an 'exports' object exists,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
751 // in that case we assume we're in CommonJS (dealt with on the bottom of the script)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
752 if ( typeof exports === "undefined" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
753 extend( window, QUnit.constructor.prototype );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
754
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
755 // Expose QUnit object
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
756 window.QUnit = QUnit;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
757 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
758
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
759 // Initialize more QUnit.config and QUnit.urlParams
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
760 (function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
761 var i,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
762 location = window.location || { search: "", protocol: "file:" },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
763 params = location.search.slice( 1 ).split( "&" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
764 length = params.length,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
765 urlParams = {},
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
766 current;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
767
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
768 if ( params[ 0 ] ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
769 for ( i = 0; i < length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
770 current = params[ i ].split( "=" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
771 current[ 0 ] = decodeURIComponent( current[ 0 ] );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
772 // allow just a key to turn on a flag, e.g., test.html?noglobals
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
773 current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
774 urlParams[ current[ 0 ] ] = current[ 1 ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
775 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
776 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
777
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
778 QUnit.urlParams = urlParams;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
779
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
780 // String search anywhere in moduleName+testName
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
781 config.filter = urlParams.filter;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
782
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
783 // Exact match of the module name
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
784 config.module = urlParams.module;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
785
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
786 config.testNumber = parseInt( urlParams.testNumber, 10 ) || null;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
787
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
788 // Figure out if we're running the tests from a server or not
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
789 QUnit.isLocal = location.protocol === "file:";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
790 }());
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
791
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
792 // Extend QUnit object,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
793 // these after set here because they should not be exposed as global functions
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
794 extend( QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
795 assert: assert,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
796
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
797 config: config,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
798
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
799 // Initialize the configuration options
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
800 init: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
801 extend( config, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
802 stats: { all: 0, bad: 0 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
803 moduleStats: { all: 0, bad: 0 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
804 started: +new Date(),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
805 updateRate: 1000,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
806 blocking: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
807 autostart: true,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
808 autorun: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
809 filter: "",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
810 queue: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
811 semaphore: 1
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
812 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
813
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
814 var tests, banner, result,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
815 qunit = id( "qunit" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
816
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
817 if ( qunit ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
818 qunit.innerHTML =
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
819 "<h1 id='qunit-header'>" + escapeText( document.title ) + "</h1>" +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
820 "<h2 id='qunit-banner'></h2>" +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
821 "<div id='qunit-testrunner-toolbar'></div>" +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
822 "<h2 id='qunit-userAgent'></h2>" +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
823 "<ol id='qunit-tests'></ol>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
824 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
825
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
826 tests = id( "qunit-tests" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
827 banner = id( "qunit-banner" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
828 result = id( "qunit-testresult" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
829
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
830 if ( tests ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
831 tests.innerHTML = "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
832 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
833
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
834 if ( banner ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
835 banner.className = "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
836 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
837
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
838 if ( result ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
839 result.parentNode.removeChild( result );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
840 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
841
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
842 if ( tests ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
843 result = document.createElement( "p" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
844 result.id = "qunit-testresult";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
845 result.className = "result";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
846 tests.parentNode.insertBefore( result, tests );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
847 result.innerHTML = "Running...<br/>&nbsp;";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
848 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
849 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
850
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
851 // Resets the test setup. Useful for tests that modify the DOM.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
852 /*
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
853 DEPRECATED: Use multiple tests instead of resetting inside a test.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
854 Use testStart or testDone for custom cleanup.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
855 This method will throw an error in 2.0, and will be removed in 2.1
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
856 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
857 reset: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
858 var fixture = id( "qunit-fixture" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
859 if ( fixture ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
860 fixture.innerHTML = config.fixture;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
861 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
862 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
863
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
864 // Trigger an event on an element.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
865 // @example triggerEvent( document.body, "click" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
866 triggerEvent: function( elem, type, event ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
867 if ( document.createEvent ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
868 event = document.createEvent( "MouseEvents" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
869 event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
870 0, 0, 0, 0, 0, false, false, false, false, 0, null);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
871
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
872 elem.dispatchEvent( event );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
873 } else if ( elem.fireEvent ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
874 elem.fireEvent( "on" + type );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
875 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
876 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
877
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
878 // Safe object type checking
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
879 is: function( type, obj ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
880 return QUnit.objectType( obj ) === type;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
881 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
882
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
883 objectType: function( obj ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
884 if ( typeof obj === "undefined" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
885 return "undefined";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
886 // consider: typeof null === object
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
887 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
888 if ( obj === null ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
889 return "null";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
890 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
891
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
892 var match = toString.call( obj ).match(/^\[object\s(.*)\]$/),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
893 type = match && match[1] || "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
894
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
895 switch ( type ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
896 case "Number":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
897 if ( isNaN(obj) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
898 return "nan";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
899 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
900 return "number";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
901 case "String":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
902 case "Boolean":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
903 case "Array":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
904 case "Date":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
905 case "RegExp":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
906 case "Function":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
907 return type.toLowerCase();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
908 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
909 if ( typeof obj === "object" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
910 return "object";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
911 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
912 return undefined;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
913 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
914
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
915 push: function( result, actual, expected, message ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
916 if ( !config.current ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
917 throw new Error( "assertion outside test context, was " + sourceFromStacktrace() );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
918 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
919
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
920 var output, source,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
921 details = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
922 module: config.current.module,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
923 name: config.current.testName,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
924 result: result,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
925 message: message,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
926 actual: actual,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
927 expected: expected
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
928 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
929
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
930 message = escapeText( message ) || ( result ? "okay" : "failed" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
931 message = "<span class='test-message'>" + message + "</span>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
932 output = message;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
933
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
934 if ( !result ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
935 expected = escapeText( QUnit.jsDump.parse(expected) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
936 actual = escapeText( QUnit.jsDump.parse(actual) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
937 output += "<table><tr class='test-expected'><th>Expected: </th><td><pre>" + expected + "</pre></td></tr>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
938
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
939 if ( actual !== expected ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
940 output += "<tr class='test-actual'><th>Result: </th><td><pre>" + actual + "</pre></td></tr>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
941 output += "<tr class='test-diff'><th>Diff: </th><td><pre>" + QUnit.diff( expected, actual ) + "</pre></td></tr>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
942 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
943
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
944 source = sourceFromStacktrace();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
945
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
946 if ( source ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
947 details.source = source;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
948 output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
949 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
950
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
951 output += "</table>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
952 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
953
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
954 runLoggingCallbacks( "log", QUnit, details );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
955
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
956 config.current.assertions.push({
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
957 result: !!result,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
958 message: output
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
959 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
960 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
961
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
962 pushFailure: function( message, source, actual ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
963 if ( !config.current ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
964 throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
965 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
966
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
967 var output,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
968 details = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
969 module: config.current.module,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
970 name: config.current.testName,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
971 result: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
972 message: message
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
973 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
974
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
975 message = escapeText( message ) || "error";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
976 message = "<span class='test-message'>" + message + "</span>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
977 output = message;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
978
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
979 output += "<table>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
980
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
981 if ( actual ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
982 output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeText( actual ) + "</pre></td></tr>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
983 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
984
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
985 if ( source ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
986 details.source = source;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
987 output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeText( source ) + "</pre></td></tr>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
988 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
989
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
990 output += "</table>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
991
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
992 runLoggingCallbacks( "log", QUnit, details );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
993
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
994 config.current.assertions.push({
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
995 result: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
996 message: output
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
997 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
998 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
999
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1000 url: function( params ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1001 params = extend( extend( {}, QUnit.urlParams ), params );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1002 var key,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1003 querystring = "?";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1004
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1005 for ( key in params ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1006 if ( hasOwn.call( params, key ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1007 querystring += encodeURIComponent( key ) + "=" +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1008 encodeURIComponent( params[ key ] ) + "&";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1009 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1010 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1011 return window.location.protocol + "//" + window.location.host +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1012 window.location.pathname + querystring.slice( 0, -1 );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1013 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1014
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1015 extend: extend,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1016 id: id,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1017 addEvent: addEvent,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1018 addClass: addClass,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1019 hasClass: hasClass,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1020 removeClass: removeClass
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1021 // load, equiv, jsDump, diff: Attached later
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1022 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1023
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1024 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1025 * @deprecated: Created for backwards compatibility with test runner that set the hook function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1026 * into QUnit.{hook}, instead of invoking it and passing the hook function.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1027 * QUnit.constructor is set to the empty F() above so that we can add to it's prototype here.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1028 * Doing this allows us to tell if the following methods have been overwritten on the actual
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1029 * QUnit object.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1030 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1031 extend( QUnit.constructor.prototype, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1032
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1033 // Logging callbacks; all receive a single argument with the listed properties
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1034 // run test/logs.html for any related changes
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1035 begin: registerLoggingCallback( "begin" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1036
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1037 // done: { failed, passed, total, runtime }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1038 done: registerLoggingCallback( "done" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1039
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1040 // log: { result, actual, expected, message }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1041 log: registerLoggingCallback( "log" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1042
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1043 // testStart: { name }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1044 testStart: registerLoggingCallback( "testStart" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1045
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1046 // testDone: { name, failed, passed, total, duration }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1047 testDone: registerLoggingCallback( "testDone" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1048
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1049 // moduleStart: { name }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1050 moduleStart: registerLoggingCallback( "moduleStart" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1051
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1052 // moduleDone: { name, failed, passed, total }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1053 moduleDone: registerLoggingCallback( "moduleDone" )
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1054 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1055
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1056 if ( typeof document === "undefined" || document.readyState === "complete" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1057 config.autorun = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1058 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1059
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1060 QUnit.load = function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1061 runLoggingCallbacks( "begin", QUnit, {} );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1062
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1063 // Initialize the config, saving the execution queue
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1064 var banner, filter, i, label, len, main, ol, toolbar, userAgent, val,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1065 urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1066 numModules = 0,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1067 moduleNames = [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1068 moduleFilterHtml = "",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1069 urlConfigHtml = "",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1070 oldconfig = extend( {}, config );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1071
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1072 QUnit.init();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1073 extend(config, oldconfig);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1074
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1075 config.blocking = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1076
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1077 len = config.urlConfig.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1078
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1079 for ( i = 0; i < len; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1080 val = config.urlConfig[i];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1081 if ( typeof val === "string" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1082 val = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1083 id: val,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1084 label: val,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1085 tooltip: "[no tooltip available]"
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1086 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1087 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1088 config[ val.id ] = QUnit.urlParams[ val.id ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1089 urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1090 "' name='" + escapeText( val.id ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1091 "' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1092 " title='" + escapeText( val.tooltip ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1093 "'><label for='qunit-urlconfig-" + escapeText( val.id ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1094 "' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1095 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1096 for ( i in config.modules ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1097 if ( config.modules.hasOwnProperty( i ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1098 moduleNames.push(i);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1099 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1100 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1101 numModules = moduleNames.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1102 moduleNames.sort( function( a, b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1103 return a.localeCompare( b );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1104 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1105 moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1106 ( config.module === undefined ? "selected='selected'" : "" ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1107 ">< All Modules ></option>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1108
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1109
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1110 for ( i = 0; i < numModules; i++) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1111 moduleFilterHtml += "<option value='" + escapeText( encodeURIComponent(moduleNames[i]) ) + "' " +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1112 ( config.module === moduleNames[i] ? "selected='selected'" : "" ) +
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1113 ">" + escapeText(moduleNames[i]) + "</option>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1114 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1115 moduleFilterHtml += "</select>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1116
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1117 // `userAgent` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1118 userAgent = id( "qunit-userAgent" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1119 if ( userAgent ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1120 userAgent.innerHTML = navigator.userAgent;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1121 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1122
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1123 // `banner` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1124 banner = id( "qunit-header" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1125 if ( banner ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1126 banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + "'>" + banner.innerHTML + "</a> ";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1127 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1128
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1129 // `toolbar` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1130 toolbar = id( "qunit-testrunner-toolbar" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1131 if ( toolbar ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1132 // `filter` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1133 filter = document.createElement( "input" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1134 filter.type = "checkbox";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1135 filter.id = "qunit-filter-pass";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1136
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1137 addEvent( filter, "click", function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1138 var tmp,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1139 ol = document.getElementById( "qunit-tests" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1140
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1141 if ( filter.checked ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1142 ol.className = ol.className + " hidepass";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1143 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1144 tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " ";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1145 ol.className = tmp.replace( / hidepass /, " " );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1146 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1147 if ( defined.sessionStorage ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1148 if (filter.checked) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1149 sessionStorage.setItem( "qunit-filter-passed-tests", "true" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1150 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1151 sessionStorage.removeItem( "qunit-filter-passed-tests" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1152 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1153 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1154 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1155
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1156 if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem( "qunit-filter-passed-tests" ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1157 filter.checked = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1158 // `ol` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1159 ol = document.getElementById( "qunit-tests" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1160 ol.className = ol.className + " hidepass";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1161 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1162 toolbar.appendChild( filter );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1163
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1164 // `label` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1165 label = document.createElement( "label" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1166 label.setAttribute( "for", "qunit-filter-pass" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1167 label.setAttribute( "title", "Only show tests and assertions that fail. Stored in sessionStorage." );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1168 label.innerHTML = "Hide passed tests";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1169 toolbar.appendChild( label );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1170
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1171 urlConfigCheckboxesContainer = document.createElement("span");
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1172 urlConfigCheckboxesContainer.innerHTML = urlConfigHtml;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1173 urlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName("input");
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1174 // For oldIE support:
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1175 // * Add handlers to the individual elements instead of the container
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1176 // * Use "click" instead of "change"
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1177 // * Fallback from event.target to event.srcElement
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1178 addEvents( urlConfigCheckboxes, "click", function( event ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1179 var params = {},
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1180 target = event.target || event.srcElement;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1181 params[ target.name ] = target.checked ? true : undefined;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1182 window.location = QUnit.url( params );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1183 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1184 toolbar.appendChild( urlConfigCheckboxesContainer );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1185
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1186 if (numModules > 1) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1187 moduleFilter = document.createElement( "span" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1188 moduleFilter.setAttribute( "id", "qunit-modulefilter-container" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1189 moduleFilter.innerHTML = moduleFilterHtml;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1190 addEvent( moduleFilter.lastChild, "change", function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1191 var selectBox = moduleFilter.getElementsByTagName("select")[0],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1192 selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1193
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1194 window.location = QUnit.url({
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1195 module: ( selectedModule === "" ) ? undefined : selectedModule,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1196 // Remove any existing filters
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1197 filter: undefined,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1198 testNumber: undefined
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1199 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1200 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1201 toolbar.appendChild(moduleFilter);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1202 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1203 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1204
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1205 // `main` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1206 main = id( "qunit-fixture" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1207 if ( main ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1208 config.fixture = main.innerHTML;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1209 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1210
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1211 if ( config.autostart ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1212 QUnit.start();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1213 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1214 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1215
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1216 addEvent( window, "load", QUnit.load );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1217
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1218 // `onErrorFnPrev` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1219 // Preserve other handlers
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1220 onErrorFnPrev = window.onerror;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1221
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1222 // Cover uncaught exceptions
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1223 // Returning true will suppress the default browser handler,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1224 // returning false will let it run.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1225 window.onerror = function ( error, filePath, linerNr ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1226 var ret = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1227 if ( onErrorFnPrev ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1228 ret = onErrorFnPrev( error, filePath, linerNr );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1229 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1230
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1231 // Treat return value as window.onerror itself does,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1232 // Only do our handling if not suppressed.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1233 if ( ret !== true ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1234 if ( QUnit.config.current ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1235 if ( QUnit.config.current.ignoreGlobalErrors ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1236 return true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1237 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1238 QUnit.pushFailure( error, filePath + ":" + linerNr );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1239 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1240 QUnit.test( "global failure", extend( function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1241 QUnit.pushFailure( error, filePath + ":" + linerNr );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1242 }, { validTest: validTest } ) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1243 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1244 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1245 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1246
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1247 return ret;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1248 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1249
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1250 function done() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1251 config.autorun = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1252
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1253 // Log the last module results
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1254 if ( config.currentModule ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1255 runLoggingCallbacks( "moduleDone", QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1256 name: config.currentModule,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1257 failed: config.moduleStats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1258 passed: config.moduleStats.all - config.moduleStats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1259 total: config.moduleStats.all
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1260 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1261 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1262 delete config.previousModule;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1263
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1264 var i, key,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1265 banner = id( "qunit-banner" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1266 tests = id( "qunit-tests" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1267 runtime = +new Date() - config.started,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1268 passed = config.stats.all - config.stats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1269 html = [
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1270 "Tests completed in ",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1271 runtime,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1272 " milliseconds.<br/>",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1273 "<span class='passed'>",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1274 passed,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1275 "</span> assertions of <span class='total'>",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1276 config.stats.all,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1277 "</span> passed, <span class='failed'>",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1278 config.stats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1279 "</span> failed."
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1280 ].join( "" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1281
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1282 if ( banner ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1283 banner.className = ( config.stats.bad ? "qunit-fail" : "qunit-pass" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1284 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1285
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1286 if ( tests ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1287 id( "qunit-testresult" ).innerHTML = html;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1288 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1289
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1290 if ( config.altertitle && typeof document !== "undefined" && document.title ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1291 // show ✖ for good, ✔ for bad suite result in title
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1292 // use escape sequences in case file gets loaded with non-utf-8-charset
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1293 document.title = [
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1294 ( config.stats.bad ? "\u2716" : "\u2714" ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1295 document.title.replace( /^[\u2714\u2716] /i, "" )
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1296 ].join( " " );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1297 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1298
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1299 // clear own sessionStorage items if all tests passed
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1300 if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1301 // `key` & `i` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1302 for ( i = 0; i < sessionStorage.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1303 key = sessionStorage.key( i++ );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1304 if ( key.indexOf( "qunit-test-" ) === 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1305 sessionStorage.removeItem( key );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1306 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1307 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1308 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1309
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1310 // scroll back to top to show results
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1311 if ( window.scrollTo ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1312 window.scrollTo(0, 0);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1313 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1314
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1315 runLoggingCallbacks( "done", QUnit, {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1316 failed: config.stats.bad,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1317 passed: passed,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1318 total: config.stats.all,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1319 runtime: runtime
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1320 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1321 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1322
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1323 /** @return Boolean: true if this test should be ran */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1324 function validTest( test ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1325 var include,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1326 filter = config.filter && config.filter.toLowerCase(),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1327 module = config.module && config.module.toLowerCase(),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1328 fullName = (test.module + ": " + test.testName).toLowerCase();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1329
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1330 // Internally-generated tests are always valid
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1331 if ( test.callback && test.callback.validTest === validTest ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1332 delete test.callback.validTest;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1333 return true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1334 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1335
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1336 if ( config.testNumber ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1337 return test.testNumber === config.testNumber;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1338 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1339
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1340 if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1341 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1342 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1343
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1344 if ( !filter ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1345 return true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1346 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1347
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1348 include = filter.charAt( 0 ) !== "!";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1349 if ( !include ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1350 filter = filter.slice( 1 );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1351 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1352
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1353 // If the filter matches, we need to honour include
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1354 if ( fullName.indexOf( filter ) !== -1 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1355 return include;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1356 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1357
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1358 // Otherwise, do the opposite
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1359 return !include;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1360 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1361
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1362 // so far supports only Firefox, Chrome and Opera (buggy), Safari (for real exceptions)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1363 // Later Safari and IE10 are supposed to support error.stack as well
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1364 // See also https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error/Stack
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1365 function extractStacktrace( e, offset ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1366 offset = offset === undefined ? 3 : offset;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1367
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1368 var stack, include, i;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1369
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1370 if ( e.stacktrace ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1371 // Opera
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1372 return e.stacktrace.split( "\n" )[ offset + 3 ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1373 } else if ( e.stack ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1374 // Firefox, Chrome
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1375 stack = e.stack.split( "\n" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1376 if (/^error$/i.test( stack[0] ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1377 stack.shift();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1378 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1379 if ( fileName ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1380 include = [];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1381 for ( i = offset; i < stack.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1382 if ( stack[ i ].indexOf( fileName ) !== -1 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1383 break;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1384 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1385 include.push( stack[ i ] );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1386 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1387 if ( include.length ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1388 return include.join( "\n" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1389 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1390 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1391 return stack[ offset ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1392 } else if ( e.sourceURL ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1393 // Safari, PhantomJS
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1394 // hopefully one day Safari provides actual stacktraces
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1395 // exclude useless self-reference for generated Error objects
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1396 if ( /qunit.js$/.test( e.sourceURL ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1397 return;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1398 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1399 // for actual exceptions, this is useful
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1400 return e.sourceURL + ":" + e.line;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1401 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1402 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1403 function sourceFromStacktrace( offset ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1404 try {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1405 throw new Error();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1406 } catch ( e ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1407 return extractStacktrace( e, offset );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1408 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1409 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1410
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1411 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1412 * Escape text for attribute or text content.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1413 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1414 function escapeText( s ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1415 if ( !s ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1416 return "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1417 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1418 s = s + "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1419 // Both single quotes and double quotes (for attributes)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1420 return s.replace( /['"<>&]/g, function( s ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1421 switch( s ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1422 case "'":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1423 return "&#039;";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1424 case "\"":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1425 return "&quot;";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1426 case "<":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1427 return "&lt;";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1428 case ">":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1429 return "&gt;";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1430 case "&":
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1431 return "&amp;";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1432 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1433 });
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1434 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1435
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1436 function synchronize( callback, last ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1437 config.queue.push( callback );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1438
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1439 if ( config.autorun && !config.blocking ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1440 process( last );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1441 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1442 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1443
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1444 function process( last ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1445 function next() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1446 process( last );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1447 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1448 var start = new Date().getTime();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1449 config.depth = config.depth ? config.depth + 1 : 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1450
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1451 while ( config.queue.length && !config.blocking ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1452 if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1453 config.queue.shift()();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1454 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1455 setTimeout( next, 13 );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1456 break;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1457 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1458 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1459 config.depth--;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1460 if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1461 done();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1462 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1463 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1464
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1465 function saveGlobal() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1466 config.pollution = [];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1467
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1468 if ( config.noglobals ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1469 for ( var key in window ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1470 if ( hasOwn.call( window, key ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1471 // in Opera sometimes DOM element ids show up here, ignore them
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1472 if ( /^qunit-test-output/.test( key ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1473 continue;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1474 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1475 config.pollution.push( key );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1476 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1477 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1478 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1479 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1480
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1481 function checkPollution() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1482 var newGlobals,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1483 deletedGlobals,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1484 old = config.pollution;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1485
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1486 saveGlobal();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1487
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1488 newGlobals = diff( config.pollution, old );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1489 if ( newGlobals.length > 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1490 QUnit.pushFailure( "Introduced global variable(s): " + newGlobals.join(", ") );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1491 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1492
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1493 deletedGlobals = diff( old, config.pollution );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1494 if ( deletedGlobals.length > 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1495 QUnit.pushFailure( "Deleted global variable(s): " + deletedGlobals.join(", ") );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1496 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1497 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1498
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1499 // returns a new Array with the elements that are in a but not in b
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1500 function diff( a, b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1501 var i, j,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1502 result = a.slice();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1503
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1504 for ( i = 0; i < result.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1505 for ( j = 0; j < b.length; j++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1506 if ( result[i] === b[j] ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1507 result.splice( i, 1 );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1508 i--;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1509 break;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1510 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1511 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1512 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1513 return result;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1514 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1515
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1516 function extend( a, b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1517 for ( var prop in b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1518 if ( hasOwn.call( b, prop ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1519 // Avoid "Member not found" error in IE8 caused by messing with window.constructor
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1520 if ( !( prop === "constructor" && a === window ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1521 if ( b[ prop ] === undefined ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1522 delete a[ prop ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1523 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1524 a[ prop ] = b[ prop ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1525 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1526 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1527 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1528 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1529
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1530 return a;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1531 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1532
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1533 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1534 * @param {HTMLElement} elem
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1535 * @param {string} type
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1536 * @param {Function} fn
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1537 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1538 function addEvent( elem, type, fn ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1539 // Standards-based browsers
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1540 if ( elem.addEventListener ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1541 elem.addEventListener( type, fn, false );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1542 // IE
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1543 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1544 elem.attachEvent( "on" + type, fn );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1545 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1546 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1547
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1548 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1549 * @param {Array|NodeList} elems
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1550 * @param {string} type
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1551 * @param {Function} fn
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1552 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1553 function addEvents( elems, type, fn ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1554 var i = elems.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1555 while ( i-- ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1556 addEvent( elems[i], type, fn );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1557 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1558 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1559
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1560 function hasClass( elem, name ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1561 return (" " + elem.className + " ").indexOf(" " + name + " ") > -1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1562 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1563
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1564 function addClass( elem, name ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1565 if ( !hasClass( elem, name ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1566 elem.className += (elem.className ? " " : "") + name;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1567 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1568 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1569
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1570 function removeClass( elem, name ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1571 var set = " " + elem.className + " ";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1572 // Class name may appear multiple times
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1573 while ( set.indexOf(" " + name + " ") > -1 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1574 set = set.replace(" " + name + " " , " ");
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1575 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1576 // If possible, trim it for prettiness, but not necessarily
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1577 elem.className = typeof set.trim === "function" ? set.trim() : set.replace(/^\s+|\s+$/g, "");
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1578 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1579
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1580 function id( name ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1581 return !!( typeof document !== "undefined" && document && document.getElementById ) &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1582 document.getElementById( name );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1583 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1584
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1585 function registerLoggingCallback( key ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1586 return function( callback ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1587 config[key].push( callback );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1588 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1589 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1590
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1591 // Supports deprecated method of completely overwriting logging callbacks
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1592 function runLoggingCallbacks( key, scope, args ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1593 var i, callbacks;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1594 if ( QUnit.hasOwnProperty( key ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1595 QUnit[ key ].call(scope, args );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1596 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1597 callbacks = config[ key ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1598 for ( i = 0; i < callbacks.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1599 callbacks[ i ].call( scope, args );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1600 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1601 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1602 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1603
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1604 // Test for equality any JavaScript type.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1605 // Author: Philippe Rathé <prathe@gmail.com>
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1606 QUnit.equiv = (function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1607
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1608 // Call the o related callback with the given arguments.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1609 function bindCallbacks( o, callbacks, args ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1610 var prop = QUnit.objectType( o );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1611 if ( prop ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1612 if ( QUnit.objectType( callbacks[ prop ] ) === "function" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1613 return callbacks[ prop ].apply( callbacks, args );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1614 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1615 return callbacks[ prop ]; // or undefined
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1616 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1617 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1618 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1619
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1620 // the real equiv function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1621 var innerEquiv,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1622 // stack to decide between skip/abort functions
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1623 callers = [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1624 // stack to avoiding loops from circular referencing
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1625 parents = [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1626 parentsB = [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1627
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1628 getProto = Object.getPrototypeOf || function ( obj ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1629 /*jshint camelcase:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1630 return obj.__proto__;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1631 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1632 callbacks = (function () {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1633
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1634 // for string, boolean, number and null
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1635 function useStrictEquality( b, a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1636 /*jshint eqeqeq:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1637 if ( b instanceof a.constructor || a instanceof b.constructor ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1638 // to catch short annotation VS 'new' annotation of a
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1639 // declaration
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1640 // e.g. var i = 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1641 // var j = new Number(1);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1642 return a == b;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1643 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1644 return a === b;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1645 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1646 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1647
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1648 return {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1649 "string": useStrictEquality,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1650 "boolean": useStrictEquality,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1651 "number": useStrictEquality,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1652 "null": useStrictEquality,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1653 "undefined": useStrictEquality,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1654
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1655 "nan": function( b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1656 return isNaN( b );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1657 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1658
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1659 "date": function( b, a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1660 return QUnit.objectType( b ) === "date" && a.valueOf() === b.valueOf();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1661 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1662
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1663 "regexp": function( b, a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1664 return QUnit.objectType( b ) === "regexp" &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1665 // the regex itself
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1666 a.source === b.source &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1667 // and its modifiers
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1668 a.global === b.global &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1669 // (gmi) ...
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1670 a.ignoreCase === b.ignoreCase &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1671 a.multiline === b.multiline &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1672 a.sticky === b.sticky;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1673 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1674
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1675 // - skip when the property is a method of an instance (OOP)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1676 // - abort otherwise,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1677 // initial === would have catch identical references anyway
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1678 "function": function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1679 var caller = callers[callers.length - 1];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1680 return caller !== Object && typeof caller !== "undefined";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1681 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1682
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1683 "array": function( b, a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1684 var i, j, len, loop, aCircular, bCircular;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1685
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1686 // b could be an object literal here
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1687 if ( QUnit.objectType( b ) !== "array" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1688 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1689 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1690
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1691 len = a.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1692 if ( len !== b.length ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1693 // safe and faster
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1694 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1695 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1696
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1697 // track reference to avoid circular references
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1698 parents.push( a );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1699 parentsB.push( b );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1700 for ( i = 0; i < len; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1701 loop = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1702 for ( j = 0; j < parents.length; j++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1703 aCircular = parents[j] === a[i];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1704 bCircular = parentsB[j] === b[i];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1705 if ( aCircular || bCircular ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1706 if ( a[i] === b[i] || aCircular && bCircular ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1707 loop = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1708 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1709 parents.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1710 parentsB.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1711 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1712 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1713 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1714 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1715 if ( !loop && !innerEquiv(a[i], b[i]) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1716 parents.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1717 parentsB.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1718 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1719 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1720 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1721 parents.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1722 parentsB.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1723 return true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1724 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1725
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1726 "object": function( b, a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1727 /*jshint forin:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1728 var i, j, loop, aCircular, bCircular,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1729 // Default to true
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1730 eq = true,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1731 aProperties = [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1732 bProperties = [];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1733
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1734 // comparing constructors is more strict than using
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1735 // instanceof
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1736 if ( a.constructor !== b.constructor ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1737 // Allow objects with no prototype to be equivalent to
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1738 // objects with Object as their constructor.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1739 if ( !(( getProto(a) === null && getProto(b) === Object.prototype ) ||
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1740 ( getProto(b) === null && getProto(a) === Object.prototype ) ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1741 return false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1742 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1743 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1744
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1745 // stack constructor before traversing properties
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1746 callers.push( a.constructor );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1747
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1748 // track reference to avoid circular references
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1749 parents.push( a );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1750 parentsB.push( b );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1751
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1752 // be strict: don't ensure hasOwnProperty and go deep
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1753 for ( i in a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1754 loop = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1755 for ( j = 0; j < parents.length; j++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1756 aCircular = parents[j] === a[i];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1757 bCircular = parentsB[j] === b[i];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1758 if ( aCircular || bCircular ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1759 if ( a[i] === b[i] || aCircular && bCircular ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1760 loop = true;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1761 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1762 eq = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1763 break;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1764 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1765 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1766 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1767 aProperties.push(i);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1768 if ( !loop && !innerEquiv(a[i], b[i]) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1769 eq = false;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1770 break;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1771 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1772 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1773
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1774 parents.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1775 parentsB.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1776 callers.pop(); // unstack, we are done
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1777
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1778 for ( i in b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1779 bProperties.push( i ); // collect b's properties
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1780 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1781
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1782 // Ensures identical properties name
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1783 return eq && innerEquiv( aProperties.sort(), bProperties.sort() );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1784 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1785 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1786 }());
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1787
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1788 innerEquiv = function() { // can take multiple arguments
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1789 var args = [].slice.apply( arguments );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1790 if ( args.length < 2 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1791 return true; // end transition
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1792 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1793
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1794 return (function( a, b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1795 if ( a === b ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1796 return true; // catch the most you can
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1797 } else if ( a === null || b === null || typeof a === "undefined" ||
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1798 typeof b === "undefined" ||
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1799 QUnit.objectType(a) !== QUnit.objectType(b) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1800 return false; // don't lose time with error prone cases
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1801 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1802 return bindCallbacks(a, callbacks, [ b, a ]);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1803 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1804
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1805 // apply transition with (1..n) arguments
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1806 }( args[0], args[1] ) && innerEquiv.apply( this, args.splice(1, args.length - 1 )) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1807 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1808
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1809 return innerEquiv;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1810 }());
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1811
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1812 /**
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1813 * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com |
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1814 * http://flesler.blogspot.com Licensed under BSD
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1815 * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1816 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1817 * @projectDescription Advanced and extensible data dumping for Javascript.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1818 * @version 1.0.0
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1819 * @author Ariel Flesler
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1820 * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1821 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1822 QUnit.jsDump = (function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1823 function quote( str ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1824 return "\"" + str.toString().replace( /"/g, "\\\"" ) + "\"";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1825 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1826 function literal( o ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1827 return o + "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1828 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1829 function join( pre, arr, post ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1830 var s = jsDump.separator(),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1831 base = jsDump.indent(),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1832 inner = jsDump.indent(1);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1833 if ( arr.join ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1834 arr = arr.join( "," + s + inner );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1835 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1836 if ( !arr ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1837 return pre + post;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1838 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1839 return [ pre, inner + arr, base + post ].join(s);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1840 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1841 function array( arr, stack ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1842 var i = arr.length, ret = new Array(i);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1843 this.up();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1844 while ( i-- ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1845 ret[i] = this.parse( arr[i] , undefined , stack);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1846 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1847 this.down();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1848 return join( "[", ret, "]" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1849 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1850
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1851 var reName = /^function (\w+)/,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1852 jsDump = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1853 // type is used mostly internally, you can fix a (custom)type in advance
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1854 parse: function( obj, type, stack ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1855 stack = stack || [ ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1856 var inStack, res,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1857 parser = this.parsers[ type || this.typeOf(obj) ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1858
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1859 type = typeof parser;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1860 inStack = inArray( obj, stack );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1861
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1862 if ( inStack !== -1 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1863 return "recursion(" + (inStack - stack.length) + ")";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1864 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1865 if ( type === "function" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1866 stack.push( obj );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1867 res = parser.call( this, obj, stack );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1868 stack.pop();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1869 return res;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1870 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1871 return ( type === "string" ) ? parser : this.parsers.error;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1872 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1873 typeOf: function( obj ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1874 var type;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1875 if ( obj === null ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1876 type = "null";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1877 } else if ( typeof obj === "undefined" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1878 type = "undefined";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1879 } else if ( QUnit.is( "regexp", obj) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1880 type = "regexp";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1881 } else if ( QUnit.is( "date", obj) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1882 type = "date";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1883 } else if ( QUnit.is( "function", obj) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1884 type = "function";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1885 } else if ( typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1886 type = "window";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1887 } else if ( obj.nodeType === 9 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1888 type = "document";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1889 } else if ( obj.nodeType ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1890 type = "node";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1891 } else if (
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1892 // native arrays
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1893 toString.call( obj ) === "[object Array]" ||
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1894 // NodeList objects
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1895 ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) )
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1896 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1897 type = "array";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1898 } else if ( obj.constructor === Error.prototype.constructor ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1899 type = "error";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1900 } else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1901 type = typeof obj;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1902 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1903 return type;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1904 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1905 separator: function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1906 return this.multiline ? this.HTML ? "<br />" : "\n" : this.HTML ? "&nbsp;" : " ";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1907 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1908 // extra can be a number, shortcut for increasing-calling-decreasing
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1909 indent: function( extra ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1910 if ( !this.multiline ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1911 return "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1912 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1913 var chr = this.indentChar;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1914 if ( this.HTML ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1915 chr = chr.replace( /\t/g, " " ).replace( / /g, "&nbsp;" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1916 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1917 return new Array( this.depth + ( extra || 0 ) ).join(chr);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1918 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1919 up: function( a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1920 this.depth += a || 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1921 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1922 down: function( a ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1923 this.depth -= a || 1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1924 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1925 setParser: function( name, parser ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1926 this.parsers[name] = parser;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1927 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1928 // The next 3 are exposed so you can use them
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1929 quote: quote,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1930 literal: literal,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1931 join: join,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1932 //
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1933 depth: 1,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1934 // This is the list of parsers, to modify them, use jsDump.setParser
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1935 parsers: {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1936 window: "[Window]",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1937 document: "[Document]",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1938 error: function(error) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1939 return "Error(\"" + error.message + "\")";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1940 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1941 unknown: "[Unknown]",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1942 "null": "null",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1943 "undefined": "undefined",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1944 "function": function( fn ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1945 var ret = "function",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1946 // functions never have name in IE
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1947 name = "name" in fn ? fn.name : (reName.exec(fn) || [])[1];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1948
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1949 if ( name ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1950 ret += " " + name;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1951 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1952 ret += "( ";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1953
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1954 ret = [ ret, QUnit.jsDump.parse( fn, "functionArgs" ), "){" ].join( "" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1955 return join( ret, QUnit.jsDump.parse(fn,"functionCode" ), "}" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1956 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1957 array: array,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1958 nodelist: array,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1959 "arguments": array,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1960 object: function( map, stack ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1961 /*jshint forin:false */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1962 var ret = [ ], keys, key, val, i;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1963 QUnit.jsDump.up();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1964 keys = [];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1965 for ( key in map ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1966 keys.push( key );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1967 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1968 keys.sort();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1969 for ( i = 0; i < keys.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1970 key = keys[ i ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1971 val = map[ key ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1972 ret.push( QUnit.jsDump.parse( key, "key" ) + ": " + QUnit.jsDump.parse( val, undefined, stack ) );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1973 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1974 QUnit.jsDump.down();
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1975 return join( "{", ret, "}" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1976 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1977 node: function( node ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1978 var len, i, val,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1979 open = QUnit.jsDump.HTML ? "&lt;" : "<",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1980 close = QUnit.jsDump.HTML ? "&gt;" : ">",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1981 tag = node.nodeName.toLowerCase(),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1982 ret = open + tag,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1983 attrs = node.attributes;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1984
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1985 if ( attrs ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1986 for ( i = 0, len = attrs.length; i < len; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1987 val = attrs[i].nodeValue;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1988 // IE6 includes all attributes in .attributes, even ones not explicitly set.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1989 // Those have values like undefined, null, 0, false, "" or "inherit".
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1990 if ( val && val !== "inherit" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1991 ret += " " + attrs[i].nodeName + "=" + QUnit.jsDump.parse( val, "attribute" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1992 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1993 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1994 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1995 ret += close;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1996
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1997 // Show content of TextNode or CDATASection
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1998 if ( node.nodeType === 3 || node.nodeType === 4 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1999 ret += node.nodeValue;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2000 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2001
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2002 return ret + open + "/" + tag + close;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2003 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2004 // function calls it internally, it's the arguments part of the function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2005 functionArgs: function( fn ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2006 var args,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2007 l = fn.length;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2008
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2009 if ( !l ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2010 return "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2011 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2012
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2013 args = new Array(l);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2014 while ( l-- ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2015 // 97 is 'a'
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2016 args[l] = String.fromCharCode(97+l);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2017 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2018 return " " + args.join( ", " ) + " ";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2019 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2020 // object calls it internally, the key part of an item in a map
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2021 key: quote,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2022 // function calls it internally, it's the content of the function
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2023 functionCode: "[code]",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2024 // node calls it internally, it's an html attribute value
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2025 attribute: quote,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2026 string: quote,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2027 date: quote,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2028 regexp: literal,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2029 number: literal,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2030 "boolean": literal
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2031 },
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2032 // if true, entities are escaped ( <, >, \t, space and \n )
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2033 HTML: false,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2034 // indentation unit
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2035 indentChar: " ",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2036 // if true, items in a collection, are separated by a \n, else just a space.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2037 multiline: true
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2038 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2039
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2040 return jsDump;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2041 }());
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2042
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2043 // from jquery.js
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2044 function inArray( elem, array ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2045 if ( array.indexOf ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2046 return array.indexOf( elem );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2047 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2048
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2049 for ( var i = 0, length = array.length; i < length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2050 if ( array[ i ] === elem ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2051 return i;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2052 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2053 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2054
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2055 return -1;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2056 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2057
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2058 /*
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2059 * Javascript Diff Algorithm
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2060 * By John Resig (http://ejohn.org/)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2061 * Modified by Chu Alan "sprite"
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2062 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2063 * Released under the MIT license.
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2064 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2065 * More Info:
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2066 * http://ejohn.org/projects/javascript-diff-algorithm/
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2067 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2068 * Usage: QUnit.diff(expected, actual)
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2069 *
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2070 * 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"
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2071 */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2072 QUnit.diff = (function() {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2073 /*jshint eqeqeq:false, eqnull:true */
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2074 function diff( o, n ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2075 var i,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2076 ns = {},
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2077 os = {};
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2078
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2079 for ( i = 0; i < n.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2080 if ( !hasOwn.call( ns, n[i] ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2081 ns[ n[i] ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2082 rows: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2083 o: null
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2084 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2085 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2086 ns[ n[i] ].rows.push( i );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2087 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2088
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2089 for ( i = 0; i < o.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2090 if ( !hasOwn.call( os, o[i] ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2091 os[ o[i] ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2092 rows: [],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2093 n: null
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2094 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2095 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2096 os[ o[i] ].rows.push( i );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2097 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2098
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2099 for ( i in ns ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2100 if ( hasOwn.call( ns, i ) ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2101 if ( ns[i].rows.length === 1 && hasOwn.call( os, i ) && os[i].rows.length === 1 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2102 n[ ns[i].rows[0] ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2103 text: n[ ns[i].rows[0] ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2104 row: os[i].rows[0]
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2105 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2106 o[ os[i].rows[0] ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2107 text: o[ os[i].rows[0] ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2108 row: ns[i].rows[0]
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2109 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2110 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2111 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2112 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2113
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2114 for ( i = 0; i < n.length - 1; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2115 if ( n[i].text != null && n[ i + 1 ].text == null && n[i].row + 1 < o.length && o[ n[i].row + 1 ].text == null &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2116 n[ i + 1 ] == o[ n[i].row + 1 ] ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2117
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2118 n[ i + 1 ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2119 text: n[ i + 1 ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2120 row: n[i].row + 1
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2121 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2122 o[ n[i].row + 1 ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2123 text: o[ n[i].row + 1 ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2124 row: i + 1
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2125 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2126 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2127 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2128
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2129 for ( i = n.length - 1; i > 0; i-- ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2130 if ( n[i].text != null && n[ i - 1 ].text == null && n[i].row > 0 && o[ n[i].row - 1 ].text == null &&
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2131 n[ i - 1 ] == o[ n[i].row - 1 ]) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2132
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2133 n[ i - 1 ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2134 text: n[ i - 1 ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2135 row: n[i].row - 1
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2136 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2137 o[ n[i].row - 1 ] = {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2138 text: o[ n[i].row - 1 ],
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2139 row: i - 1
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2140 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2141 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2142 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2143
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2144 return {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2145 o: o,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2146 n: n
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2147 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2148 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2149
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2150 return function( o, n ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2151 o = o.replace( /\s+$/, "" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2152 n = n.replace( /\s+$/, "" );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2153
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2154 var i, pre,
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2155 str = "",
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2156 out = diff( o === "" ? [] : o.split(/\s+/), n === "" ? [] : n.split(/\s+/) ),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2157 oSpace = o.match(/\s+/g),
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2158 nSpace = n.match(/\s+/g);
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2159
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2160 if ( oSpace == null ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2161 oSpace = [ " " ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2162 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2163 else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2164 oSpace.push( " " );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2165 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2166
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2167 if ( nSpace == null ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2168 nSpace = [ " " ];
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2169 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2170 else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2171 nSpace.push( " " );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2172 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2173
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2174 if ( out.n.length === 0 ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2175 for ( i = 0; i < out.o.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2176 str += "<del>" + out.o[i] + oSpace[i] + "</del>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2177 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2178 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2179 else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2180 if ( out.n[0].text == null ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2181 for ( n = 0; n < out.o.length && out.o[n].text == null; n++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2182 str += "<del>" + out.o[n] + oSpace[n] + "</del>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2183 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2184 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2185
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2186 for ( i = 0; i < out.n.length; i++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2187 if (out.n[i].text == null) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2188 str += "<ins>" + out.n[i] + nSpace[i] + "</ins>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2189 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2190 else {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2191 // `pre` initialized at top of scope
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2192 pre = "";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2193
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2194 for ( n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++ ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2195 pre += "<del>" + out.o[n] + oSpace[n] + "</del>";
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2196 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2197 str += " " + out.n[i].text + nSpace[i] + pre;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2198 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2199 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2200 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2201
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2202 return str;
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2203 };
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2204 }());
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2205
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2206 // for CommonJS environments, export everything
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2207 if ( typeof exports !== "undefined" ) {
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2208 extend( exports, QUnit.constructor.prototype );
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2209 }
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2210
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2211 // get at whatever the global object is, like window in browsers
0358f6f78adf planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2212 }( (function() {return this;}.call()) ));