3
3
var amdDefined , fireNative ,
4
4
originaljQuery = this . jQuery || "jQuery" ,
5
5
original$ = this . $ || "$" ,
6
- hasPHP = true ,
7
- isLocal = window . location . protocol === "file:" ,
8
6
// see RFC 2606
9
7
externalHost = "example.com" ;
10
8
9
+ this . hasPHP = true ;
10
+ this . isLocal = window . location . protocol === "file:" ;
11
+
11
12
// For testing .noConflict()
12
13
this . jQuery = originaljQuery ;
13
14
this . $ = original$ ;
@@ -26,15 +27,15 @@ define.amd = {};
26
27
* @example q("main", "foo", "bar")
27
28
* @result [<div id="main">, <span id="foo">, <input id="bar">]
28
29
*/
29
- function q ( ) {
30
+ this . q = function ( ) {
30
31
var r = [ ] ,
31
32
i = 0 ;
32
33
33
34
for ( ; i < arguments . length ; i ++ ) {
34
35
r . push ( document . getElementById ( arguments [ i ] ) ) ;
35
36
}
36
37
return r ;
37
- }
38
+ } ;
38
39
39
40
/**
40
41
* Asserts that a select matches the given IDs
@@ -44,7 +45,7 @@ function q() {
44
45
* @example t("Check for something", "//[a]", ["foo", "baar"]);
45
46
* @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
46
47
*/
47
- function t ( a , b , c ) {
48
+ this . t = function ( a , b , c ) {
48
49
var f = jQuery ( b ) . get ( ) ,
49
50
s = "" ,
50
51
i = 0 ;
@@ -54,9 +55,9 @@ function t( a, b, c ) {
54
55
}
55
56
56
57
deepEqual ( f , q . apply ( q , c ) , a + " (" + b + ")" ) ;
57
- }
58
+ } ;
58
59
59
- function createDashboardXML ( ) {
60
+ this . createDashboardXML = function ( ) {
60
61
var string = '<?xml version="1.0" encoding="UTF-8"?> \
61
62
<dashboard> \
62
63
<locations class="foo"> \
@@ -70,9 +71,9 @@ function createDashboardXML() {
70
71
</dashboard>' ;
71
72
72
73
return jQuery . parseXML ( string ) ;
73
- }
74
+ } ;
74
75
75
- function createWithFriesXML ( ) {
76
+ this . createWithFriesXML = function ( ) {
76
77
var string = '<?xml version="1.0" encoding="UTF-8"?> \
77
78
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" \
78
79
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
@@ -100,9 +101,9 @@ function createWithFriesXML() {
100
101
</soap:Envelope>' ;
101
102
102
103
return jQuery . parseXML ( string . replace ( / \{ \{ \s * e x t e r n a l H o s t \s * \} \} / g, externalHost ) ) ;
103
- }
104
+ } ;
104
105
105
- function createXMLFragment ( ) {
106
+ this . createXMLFragment = function ( ) {
106
107
var xml , frag ;
107
108
if ( window . ActiveXObject ) {
108
109
xml = new ActiveXObject ( "msxml2.domdocument" ) ;
@@ -115,7 +116,7 @@ function createXMLFragment() {
115
116
}
116
117
117
118
return frag ;
118
- }
119
+ } ;
119
120
120
121
fireNative = document . createEvent ?
121
122
function ( node , type ) {
@@ -142,7 +143,7 @@ function url( value ) {
142
143
}
143
144
144
145
// Ajax testing helper
145
- function ajaxTest ( title , expect , options ) {
146
+ this . ajaxTest = function ( title , expect , options ) {
146
147
var requestOptions ;
147
148
if ( jQuery . isFunction ( options ) ) {
148
149
options = options ( ) ;
@@ -205,63 +206,59 @@ function ajaxTest( title, expect, options ) {
205
206
}
206
207
} ;
207
208
} ) ;
208
- }
209
+ } ;
209
210
210
- ( function ( ) {
211
-
212
- this . testIframe = function ( fileName , name , fn ) {
213
-
214
- test ( name , function ( ) {
215
- // pause execution for now
216
- stop ( ) ;
217
-
218
- // load fixture in iframe
219
- var iframe = loadFixture ( ) ,
220
- win = iframe . contentWindow ,
221
- interval = setInterval ( function ( ) {
222
- if ( win && win . jQuery && win . jQuery . isReady ) {
223
- clearInterval ( interval ) ;
224
- // continue
225
- start ( ) ;
226
- // call actual tests passing the correct jQuery instance to use
227
- fn . call ( this , win . jQuery , win , win . document ) ;
228
- document . body . removeChild ( iframe ) ;
229
- iframe = null ;
230
- }
231
- } , 15 ) ;
232
- } ) ;
233
-
234
- function loadFixture ( ) {
235
- var src = url ( "./data/" + fileName + ".html" ) ,
236
- iframe = jQuery ( "<iframe />" ) . appendTo ( "body" ) [ 0 ] ;
237
- iframe . style . cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;" ;
238
- iframe . contentWindow . location = src ;
239
- return iframe ;
240
- }
241
- } ;
242
211
243
- this . testIframeWithCallback = function ( title , fileName , func ) {
212
+ this . testIframe = function ( fileName , name , fn ) {
244
213
245
- test ( title , function ( ) {
246
- var iframe ;
214
+ test ( name , function ( ) {
215
+ // pause execution for now
216
+ stop ( ) ;
247
217
248
- stop ( ) ;
249
- window . iframeCallback = function ( ) {
250
- var self = this ,
251
- args = arguments ;
252
- setTimeout ( function ( ) {
253
- window . iframeCallback = undefined ;
254
- iframe . remove ( ) ;
255
- func . apply ( self , args ) ;
256
- func = function ( ) { } ;
218
+ // load fixture in iframe
219
+ var iframe = loadFixture ( ) ,
220
+ win = iframe . contentWindow ,
221
+ interval = setInterval ( function ( ) {
222
+ if ( win && win . jQuery && win . jQuery . isReady ) {
223
+ clearInterval ( interval ) ;
224
+ // continue
257
225
start ( ) ;
258
- } , 0 ) ;
259
- } ;
260
- iframe = jQuery ( "<div/>" ) . append (
261
- jQuery ( "< iframe/>" ) . attr ( "src" , url ( "./data/" + fileName ) )
262
- ) . appendTo ( "body" ) ;
263
- } ) ;
264
- } ;
226
+ // call actual tests passing the correct jQuery instance to use
227
+ fn . call ( this , win . jQuery , win , win . document ) ;
228
+ document . body . removeChild ( iframe ) ;
229
+ iframe = null ;
230
+ }
231
+ } , 15 ) ;
232
+ } ) ;
265
233
266
- window . iframeCallback = undefined ;
267
- } ( ) ) ;
234
+ function loadFixture ( ) {
235
+ var src = url ( "./data/" + fileName + ".html" ) ,
236
+ iframe = jQuery ( "<iframe />" ) . appendTo ( "body" ) [ 0 ] ;
237
+ iframe . style . cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;" ;
238
+ iframe . contentWindow . location = src ;
239
+ return iframe ;
240
+ }
241
+ } ;
242
+
243
+ this . testIframeWithCallback = function ( title , fileName , func ) {
244
+
245
+ test ( title , function ( ) {
246
+ var iframe ;
247
+
248
+ stop ( ) ;
249
+ window . iframeCallback = function ( ) {
250
+ var self = this ,
251
+ args = arguments ;
252
+ setTimeout ( function ( ) {
253
+ window . iframeCallback = undefined ;
254
+ iframe . remove ( ) ;
255
+ func . apply ( self , args ) ;
256
+ func = function ( ) { } ;
257
+ start ( ) ;
258
+ } , 0 ) ;
259
+ } ;
260
+ iframe = jQuery ( "<div/>" ) . append (
261
+ jQuery ( "<iframe/>" ) . attr ( "src" , url ( "./data/" + fileName ) )
262
+ ) . appendTo ( "body" ) ;
263
+ } ) ;
264
+ } ;
0 commit comments