forked from congmo/jquery-jsonp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude.js
More file actions
78 lines (66 loc) · 2.34 KB
/
include.js
File metadata and controls
78 lines (66 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Ensures that tests have cleaned up properly after themselves. Should be passed as the
* teardown function on all modules' lifecycle object.
*/
(function () {
// Store the old counts so that we only assert on tests that have actually leaked,
// instead of asserting every time a test has leaked sometime in the past
var oldCacheLength = 0,
oldFragmentsLength = 0,
oldTimersLength = 0,
oldActive = 0;
window.moduleTeardown = function () {
var i, fragmentsLength = 0, cacheLength = 0;
// Allow QUnit.reset to clean up any attached elements before checking for leaks
QUnit.reset();
for ( i in jQuery.cache ) {
++cacheLength;
}
jQuery.fragments = {};
for ( i in jQuery.fragments ) {
++fragmentsLength;
}
// Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test,
// if we unconditionally assert any of these, the test will fail with too many assertions :|
if ( cacheLength !== oldCacheLength ) {
equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
oldCacheLength = cacheLength;
}
if ( fragmentsLength !== oldFragmentsLength ) {
equal( fragmentsLength, oldFragmentsLength, "No unit tests leak memory in jQuery.fragments" );
oldFragmentsLength = fragmentsLength;
}
if ( jQuery.timers.length !== oldTimersLength ) {
equal( jQuery.timers.length, oldTimersLength, "No timers are still running" );
oldTimersLength = jQuery.timers.length;
}
if ( jQuery.active !== oldActive ) {
equal( jQuery.active, 0, "No AJAX requests are still active" );
oldActive = jQuery.active;
}
};
})();
(function() {
function loadScript( url ) {
document.write( "<script src='" + url + "'></script>" );
}
function getParams() {
var params = document.location.search.replace( /^\?/, "" ).split( "&" ),
output = {},
i = params.length;
while( i-- ) {
params[ i ] = params[ i ].split( "=" );
output[ params[ i ][ 0 ] ] = params[ i ][ 1 ];
}
return output;
}
var params = getParams(),
jQueries = {
git: "http://code.jquery.com/jquery-git.js"
};
params.jquery = params.jquery || "1";
loadScript( jQueries[ params.jquery ] || "https://ajax.googleapis.com/ajax/libs/jquery/" + params.jquery + "/jquery.min.js" );
loadScript( "../src/jquery.jsonp.js" );
loadScript( "qunit/qunit/qunit.js" );
loadScript( "./unit.js" );
})();