~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/yui/tests/get-tests.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
YUI.add('get-tests', function(Y) {
2
 
 
3
 
    Y.GetTests = new Y.Test.Suite("Get Suite");
4
 
    Y.GetTests.TEST_FILES_BASE = "getfiles/";
5
 
    
6
 
    var FILENAME = /[abc]\.js/;
7
 
 
8
 
    // TODO: Should get.js stick this somewhere public?
9
 
    Y.GetTests.ONLOAD_SUPPORTED = {
10
 
        script: true,
11
 
        css: !(Y.UA.webkit || Y.UA.gecko)
12
 
    };
13
 
 
14
 
    function areObjectsReallyEqual(o1, o2, msg) {
15
 
        Y.ObjectAssert.areEqual(o1, o2, msg);
16
 
        Y.ObjectAssert.areEqual(o2, o1, msg);
17
 
    }
18
 
 
19
 
    function randUrl(url) {
20
 
        return url + ((url.indexOf("?") !== -1) ? "&" : "?") + "dt=" + new Date().getTime();
21
 
    }
22
 
 
23
 
    function path(urls, guid) {
24
 
        var base = Y.GetTests.TEST_FILES_BASE;
25
 
 
26
 
        if (typeof urls === "string") {
27
 
            urls = base + randUrl(urls);
28
 
        } else {
29
 
            for (var i = 0; i < urls.length; i++) {
30
 
                urls[i] = base + randUrl(urls[i]);
31
 
            }
32
 
        }
33
 
        return urls;
34
 
    }
35
 
 
36
 
    Y.GetTests.Scripts = new Y.Test.Case({
37
 
 
38
 
        name: "Script Tests",
39
 
 
40
 
        setUp: function() {
41
 
            G_SCRIPTS = [];
42
 
        },
43
 
 
44
 
        createInsertBeforeNode: function() {
45
 
            this.ib = Y.Node.create('<div id="insertBeforeMe"></div>');
46
 
            Y.Node.one("body").appendChild(this.ib);
47
 
        },
48
 
 
49
 
        removeInsertBeforeNode: function() {
50
 
            if (this.ib) {
51
 
                this.ib.remove(true);
52
 
            }
53
 
        },
54
 
 
55
 
        tearDown: function() {
56
 
            if (this.o) {
57
 
                this.o.purge();
58
 
            }
59
 
            this.removeInsertBeforeNode();
60
 
        },
61
 
 
62
 
        'test: single script, success': function() {
63
 
 
64
 
            var test = this;
65
 
            var progress = [];
66
 
            var counts = {
67
 
                success:0,
68
 
                failure:0
69
 
            };
70
 
 
71
 
            var trans = Y.Get.script(path("a.js"), {
72
 
 
73
 
                data: {a:1, b:2, c:3},
74
 
                context: {bar:"foo"},
75
 
 
76
 
                onProgress: function(o) {
77
 
                    var file = o.url.match(FILENAME);
78
 
                    progress.push(file[0]);
79
 
                },
80
 
 
81
 
                onSuccess: function(o) {
82
 
 
83
 
                    var context = this;
84
 
 
85
 
                    test.resume(function() {
86
 
 
87
 
                        counts.success++;
88
 
 
89
 
                        Y.Assert.areEqual("a.js", G_SCRIPTS[0], "a.js does not seem to be loaded");
90
 
                        Y.ArrayAssert.itemsAreEqual(G_SCRIPTS, progress, "Progress does not match G_SCRIPTS");
91
 
                        
92
 
                        Y.Assert.areEqual(1, G_SCRIPTS.length, "More/Less than 1 script was loaded");
93
 
                        Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
94
 
 
95
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
96
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
97
 
                        Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
98
 
                        Y.Assert.isUndefined(o.statusText, "Payload should not have a statusText");
99
 
                        Y.Assert.isUndefined(o.msg, "Payload should not have a msg");
100
 
 
101
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
102
 
 
103
 
                        test.o = o;
104
 
                    });
105
 
                },
106
 
 
107
 
                onFailure: function(o) {
108
 
                    test.resume(function() {
109
 
                        Y.Assert.fail("onFailure shouldn't have been called");
110
 
                        test.o = o;
111
 
                    });
112
 
                }
113
 
            });
114
 
 
115
 
            this.wait();
116
 
        },
117
 
    
118
 
        'test: single script, failure': function() {
119
 
 
120
 
            var test = this;
121
 
 
122
 
            var counts = {
123
 
                success:0,
124
 
                failure:0
125
 
            };
126
 
 
127
 
            // TODO: abort() is the only thing which causes onFailure to be hit. 404s don't. Fix when we can fail on 404s
128
 
            // Not sure how robust it is to do this inline (that is, could onSuccess fire before abort is hit).
129
 
            
130
 
            var trans = Y.Get.script(path("a.js"), {
131
 
                
132
 
                data: {a:1, b:2, c:3},
133
 
                context: {bar:"foo"},
134
 
                
135
 
                onSuccess: function(o) {
136
 
                    test.resume(function() {
137
 
                        Y.Assert.fail("onSuccess shouldn't have been called");
138
 
                        test.o = o;
139
 
                    });
140
 
                },
141
 
 
142
 
                onFailure: function(o) {
143
 
                    
144
 
                    var context = this;
145
 
                    
146
 
                    test.resume(function() {
147
 
 
148
 
                        counts.failure++;
149
 
 
150
 
                        Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
151
 
 
152
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
153
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
154
 
                        Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
155
 
                        Y.Assert.isUndefined(o.statusText, "Payload should not have a statusText");
156
 
                        Y.Assert.isString(o.msg, "Payload should have a msg");
157
 
 
158
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
159
 
 
160
 
                        test.o = o;
161
 
                    });
162
 
                }
163
 
            });
164
 
 
165
 
            Y.Get.abort(trans.tId);
166
 
 
167
 
            this.wait();
168
 
        },
169
 
 
170
 
        'test: single script success, end': function() {
171
 
 
172
 
            var test = this;
173
 
            var counts = {
174
 
                success:0,
175
 
                failure:0,
176
 
                end:0
177
 
            };
178
 
 
179
 
            var trans = Y.Get.script(path("a.js"), {
180
 
 
181
 
                data: {a:1, b:2, c:3},
182
 
                context: {bar:"foo"},
183
 
                
184
 
                onSuccess: function() {
185
 
                    counts.success++;
186
 
                    Y.Assert.areEqual("a.js", G_SCRIPTS[0], "a.js does not seem to be loaded");
187
 
                    Y.Assert.areEqual(1, G_SCRIPTS.length, "More/Less than 1 script was loaded");
188
 
                    Y.Assert.areEqual(1, counts.success, "onSuccess called more than once");
189
 
                },
190
 
                
191
 
                onFailure: function() {
192
 
                    Y.Assert.fail("onFailure shouldn't have been called");
193
 
                },
194
 
                
195
 
                onEnd : function(o) {
196
 
                    
197
 
                    var context = this;
198
 
                    
199
 
                    test.resume(function() {
200
 
                        counts.end++;
201
 
                        Y.Assert.areEqual(1, counts.end,"onEnd called more than once");
202
 
                        Y.Assert.areEqual(1, counts.success, "onEnd called before onSuccess");
203
 
                        Y.Assert.areEqual("OK", o.statusText, "Expected OK result");
204
 
 
205
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
206
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
207
 
                        Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
208
 
                        Y.Assert.areEqual("OK", o.statusText, "Payload should have an OK statusText");
209
 
                        Y.Assert.isUndefined(o.msg, "Payload should have an undefined msg");
210
 
 
211
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
212
 
 
213
 
                        test.o = o;
214
 
                    });
215
 
                }
216
 
            });
217
 
 
218
 
            this.wait();
219
 
        },
220
 
        
221
 
        'test: single script failure, end': function() {
222
 
 
223
 
            var test = this;
224
 
            var counts = {
225
 
                success:0,
226
 
                failure:0,
227
 
                end:0
228
 
            };
229
 
 
230
 
            var trans = Y.Get.script(path("a.js"), {
231
 
                
232
 
                data: {a:1, b:2, c:3},
233
 
                context: {bar:"foo"},
234
 
                
235
 
                onFailure: function() {
236
 
                    counts.failure++;
237
 
                    Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
238
 
                },
239
 
                
240
 
                onSuccess: function() {
241
 
                    Y.Assert.fail("onSuccess shouldn't have been called");
242
 
                },
243
 
 
244
 
                onEnd : function(o) {
245
 
 
246
 
                    var context = this;
247
 
                    
248
 
                    test.resume(function() {
249
 
                        counts.end++;
250
 
                        Y.Assert.areEqual(1, counts.end,"onEnd called more than once");
251
 
                        Y.Assert.areEqual(1, counts.failure, "onEnd called before onFailure");
252
 
                        Y.Assert.areEqual("failure", o.statusText, "Expected failure result");
253
 
 
254
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
255
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
256
 
                        Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
257
 
                        Y.Assert.areEqual("failure", o.statusText, "Payload should have a failure statusText");
258
 
                        Y.Assert.isString(o.msg, "Payload should have a failure msg");
259
 
 
260
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
261
 
 
262
 
                        test.o = o;
263
 
                    });
264
 
                }
265
 
            });
266
 
 
267
 
            Y.Get.abort(trans.tId);
268
 
 
269
 
            this.wait();
270
 
        },
271
 
 
272
 
        'test: multiple script, success': function() {
273
 
            
274
 
            var test = this;
275
 
            var progress = [];
276
 
            var counts = {
277
 
                success:0,
278
 
                failure:0
279
 
            };
280
 
 
281
 
            var trans = Y.Get.script(path(["b.js", "a.js", "c.js"]), {
282
 
                
283
 
                data: {a:1, b:2, c:3},
284
 
                context: {bar:"foo"},
285
 
                
286
 
                onFailure: function(o) {
287
 
                    test.resume(function() {
288
 
                        Y.Assert.fail("onFailure shouldn't have been called");
289
 
                        test.o = o;
290
 
                    });
291
 
                },
292
 
 
293
 
                onProgress: function(o) {
294
 
                    var file = o.url.match(/[abc]\.js/);
295
 
                    progress.push(file[0]);
296
 
                },
297
 
 
298
 
                onSuccess: function(o) {
299
 
                    
300
 
                    var context = this;
301
 
 
302
 
                    test.resume(function() {
303
 
                        counts.success++;
304
 
                        Y.Assert.areEqual(3, G_SCRIPTS.length, "More/Less than 3 scripts loaded");
305
 
                        Y.ArrayAssert.itemsAreEqual(["b.js", "a.js", "c.js"], G_SCRIPTS, "Unexpected script order");
306
 
                        Y.ArrayAssert.itemsAreEqual(G_SCRIPTS, progress, "Progress does not match G_SCRIPTS");
307
 
 
308
 
                        Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
309
 
 
310
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
311
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
312
 
                        Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
313
 
                        Y.Assert.isUndefined(o.statusText, "Payload should have an undefined statusText");
314
 
                        Y.Assert.isUndefined(o.msg, "Payload should have an undefined msg");
315
 
 
316
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
317
 
                        
318
 
                        test.o = o;
319
 
                    });
320
 
                }
321
 
            });
322
 
 
323
 
            this.wait();
324
 
        },
325
 
 
326
 
        'test: multiple script, failure': function() {
327
 
 
328
 
            var test = this;
329
 
            var counts = {
330
 
                success:0,
331
 
                failure:0
332
 
            };
333
 
 
334
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
335
 
                
336
 
                data: {a:1, b:2, c:3},
337
 
                context: {bar:"foo"},
338
 
                
339
 
                onSuccess: function(o) {
340
 
                    test.resume(function() {
341
 
                        Y.Assert.fail("onSuccess shouldn't have been called");
342
 
                        test.o = o;
343
 
                    });
344
 
                },
345
 
                onFailure: function(o) {
346
 
                    
347
 
                    var context = this;
348
 
                    
349
 
                    test.resume(function() {
350
 
                        counts.failure++;
351
 
                        Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
352
 
                        
353
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
354
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
355
 
 
356
 
                        // TODO: We can't control which script it will fail on. Fix when we can (when we have built in server env).
357
 
                        // Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
358
 
 
359
 
                        Y.Assert.isUndefined(o.statusText, "Payload should have an undefined statusText");
360
 
                        Y.Assert.isString(o.msg, "Payload should have a failure msg");
361
 
 
362
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
363
 
                        
364
 
                        test.o = o;
365
 
                    });
366
 
                }
367
 
            });
368
 
 
369
 
            Y.Get.abort(trans.tId);
370
 
 
371
 
            this.wait();
372
 
        },
373
 
        
374
 
        'test: multiple script, success, end': function() {
375
 
 
376
 
            var test = this;
377
 
            var progress = [];
378
 
            var counts = {
379
 
                success:0,
380
 
                failure:0,
381
 
                end:0
382
 
            };
383
 
 
384
 
            var trans = Y.Get.script(path(["c.js", "b.js", "a.js"]), {
385
 
                
386
 
                data: {a:1, b:2, c:3},
387
 
                context: {bar:"foo"},
388
 
                
389
 
                onSuccess: function() {
390
 
                    counts.success++;
391
 
 
392
 
                    Y.Assert.areEqual(3, G_SCRIPTS.length, "More/Less than 3 scripts loaded");
393
 
                    Y.ArrayAssert.itemsAreEqual(["c.js", "b.js", "a.js"], G_SCRIPTS,  "Unexpected script order");
394
 
                    Y.ArrayAssert.itemsAreEqual(G_SCRIPTS, progress, "Progress does not match G_SCRIPTS");
395
 
                    Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
396
 
                },
397
 
                
398
 
                onProgress: function(o) {
399
 
                    var file = o.url.match(/[abc]\.js/);
400
 
                    progress.push(file[0]);
401
 
                },
402
 
                
403
 
                onFailure: function() {
404
 
                    Y.Assert.fail("onFailure shouldn't have been called");
405
 
                },
406
 
                
407
 
                onEnd : function(o) {
408
 
 
409
 
                    var context = this;
410
 
                    
411
 
                    test.resume(function() {
412
 
                        counts.end++;
413
 
                        Y.Assert.areEqual(1, counts.end,"onEnd called more than once");
414
 
                        Y.Assert.areEqual(1, counts.success, "onEnd called before onSuccess");
415
 
 
416
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
417
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
418
 
                        Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
419
 
                        Y.Assert.areEqual("OK", o.statusText, "Payload should have an OK statusText");
420
 
                        Y.Assert.isUndefined(o.msg, "Payload should have an undefined msg");
421
 
 
422
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
423
 
 
424
 
                        test.o = o;
425
 
                    });
426
 
                }
427
 
            });
428
 
 
429
 
            this.wait();
430
 
            
431
 
        },
432
 
 
433
 
        'test: multiple script, failure, end': function() {
434
 
 
435
 
            var test = this;
436
 
            var counts = {
437
 
                success:0,
438
 
                failure:0,
439
 
                end:0
440
 
            };
441
 
 
442
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
443
 
 
444
 
                data: {a:1, b:2, c:3},
445
 
                context: {bar:"foo"},
446
 
 
447
 
                onSuccess: function() {
448
 
                    Y.Assert.fail("onSuccess shouldn't have been called");
449
 
                },
450
 
 
451
 
                onFailure: function() {
452
 
                    counts.failure++;
453
 
                    Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
454
 
                },
455
 
 
456
 
                onEnd : function(o) {
457
 
 
458
 
                    var context = this;
459
 
                    
460
 
                    test.resume(function() {
461
 
                        counts.end++;
462
 
                        Y.Assert.areEqual(1, counts.end,"onEnd called more than once");
463
 
                        Y.Assert.areEqual(1, counts.failure, "onEnd called before onFailure");
464
 
                        
465
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
466
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
467
 
                        
468
 
                        //Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
469
 
                        
470
 
                        Y.Assert.areEqual("failure", o.statusText, "Payload should have a failure statusText");
471
 
                        Y.Assert.isString(o.msg, "Payload should have a failure msg");
472
 
 
473
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
474
 
                        
475
 
                        test.o = o;
476
 
                    });
477
 
                }
478
 
            });
479
 
 
480
 
            Y.Get.abort(trans.tId);
481
 
 
482
 
            this.wait();
483
 
        },
484
 
 
485
 
        'test: async multiple script, success': function() {
486
 
 
487
 
            var test = this;
488
 
            var progress = [];
489
 
            var counts = {
490
 
                success:0,
491
 
                failure:0
492
 
            };
493
 
 
494
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
495
 
                
496
 
                data: {a:1, b:2, c:3},
497
 
                context: {bar:"foo"},
498
 
                
499
 
                onFailure: function(o) {
500
 
                    test.resume(function() {
501
 
                        Y.Assert.fail("onFailure shouldn't have been called");
502
 
                        test.o = o;
503
 
                    });
504
 
                },
505
 
                
506
 
                onProgress: function(o) {
507
 
                    var file = o.url.match(/[abc]\.js/);
508
 
                    progress.push(file[0]);
509
 
                },
510
 
                
511
 
                onSuccess: function(o) {
512
 
                    
513
 
                    var context = this;
514
 
                    
515
 
                    test.resume(function() {
516
 
                        counts.success++;
517
 
                        Y.Assert.areEqual(3, G_SCRIPTS.length, "More/Less than 3 scripts loaded");
518
 
                        Y.ArrayAssert.itemsAreEqual(G_SCRIPTS, progress, "Progress does not match G_SCRIPTS");                        
519
 
                        Y.ArrayAssert.containsItems( ["c.js", "a.js", "b.js"], G_SCRIPTS, "Unexpected script contents");
520
 
                        Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
521
 
                        
522
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
523
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
524
 
                        Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
525
 
                        Y.Assert.isUndefined(o.statusText, "Payload should have an undefined statusText");
526
 
                        Y.Assert.isUndefined(o.msg, "Payload should have an undefined msg");
527
 
 
528
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
529
 
                        
530
 
                        test.o = o;
531
 
                    });
532
 
                },
533
 
                async:true
534
 
            });
535
 
 
536
 
            this.wait();
537
 
        },
538
 
 
539
 
        'test: async multiple script, success, end': function() {
540
 
 
541
 
            var test = this;
542
 
            var counts = {
543
 
                success:0,
544
 
                failure:0,
545
 
                end:0
546
 
            };
547
 
 
548
 
            var trans = Y.Get.script(path(["c.js", "a.js", "b.js"]), {
549
 
 
550
 
                data: {a:1, b:2, c:3},
551
 
                context: {bar:"foo"},
552
 
                
553
 
                onSuccess: function() {
554
 
                    counts.success++;
555
 
                    Y.Assert.areEqual(3, G_SCRIPTS.length, "More/Less than 3 scripts loaded");
556
 
                    Y.ArrayAssert.containsItems(["a.js", "b.js", "c.js"], G_SCRIPTS, "Unexpected script contents");
557
 
                    Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
558
 
                },
559
 
                
560
 
                onFailure: function() {
561
 
                    Y.Assert.fail("onFailure shouldn't have been called");
562
 
                },
563
 
                
564
 
                onEnd : function(o) {
565
 
 
566
 
                    var context = this;
567
 
                    
568
 
                    test.resume(function() {
569
 
                        counts.end++;
570
 
                        Y.Assert.areEqual(1, counts.end,"onEnd called more than once");
571
 
                        Y.Assert.areEqual(1, counts.success, "onEnd called before onSuccess");
572
 
 
573
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
574
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
575
 
                        Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
576
 
                        Y.Assert.areEqual("OK", o.statusText, "Payload should have an OK statusText");
577
 
                        Y.Assert.isUndefined(o.msg, "Payload should have an undefined msg");
578
 
 
579
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
580
 
                        
581
 
                        test.o = o;
582
 
                    });
583
 
                },
584
 
                async:true
585
 
            });
586
 
 
587
 
            this.wait();
588
 
            
589
 
        },
590
 
 
591
 
 
592
 
        // THE ASYNC FAILURE TESTS NEED TO BE AT THE END,
593
 
        // BECAUSE ABORTING THEM WILL NOT STOP PARALLEL SCRIPTS 
594
 
        // FROM DOWNLOADING (at least currently) AND SINCE WE USE
595
 
        // A GLOBAL, IT POLLUTES THE NEXT SUCCESS TEST
596
 
 
597
 
        // TODO: Maybe we can explore the idea of moving from global to something instance based?
598
 
 
599
 
        'test: async multiple script, failure': function() {
600
 
 
601
 
            var test = this;
602
 
            var counts = {
603
 
                success:0,
604
 
                failure:0
605
 
            };
606
 
 
607
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
608
 
 
609
 
                data: {a:1, b:2, c:3},
610
 
                context: {bar:"foo"},
611
 
                
612
 
                onSuccess: function(o) {
613
 
                    test.resume(function() {
614
 
                        Y.Assert.fail("onSuccess shouldn't have been called");
615
 
                        test.o = o;
616
 
                    });
617
 
                },
618
 
                onFailure: function(o) {
619
 
                    
620
 
                    var context = this;
621
 
                    
622
 
                    test.resume(function() {
623
 
                        counts.failure++;
624
 
                        Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
625
 
                        
626
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
627
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
628
 
 
629
 
                        // Can't control which script it will abort at. Also async will keep on downloading
630
 
                        // Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
631
 
 
632
 
                        Y.Assert.isUndefined(o.statusText, "Payload should have an undefined statusText");
633
 
                        Y.Assert.isString(o.msg, "Payload should have a failure msg");
634
 
 
635
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
636
 
 
637
 
                        test.o = o;
638
 
                    });
639
 
                },
640
 
                async:true
641
 
            })
642
 
 
643
 
            Y.Get.abort(trans.tId);
644
 
 
645
 
            this.wait();
646
 
        },
647
 
 
648
 
        'test: async multiple script, failure, end': function() {
649
 
 
650
 
            var test = this;
651
 
            var counts = {
652
 
                success:0,
653
 
                failure:0,
654
 
                end:0
655
 
            };
656
 
 
657
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
658
 
 
659
 
                data: {a:1, b:2, c:3},
660
 
                context: {bar:"foo"},
661
 
                
662
 
                onSuccess: function() {
663
 
                    Y.Assert.fail("onSuccess shouldn't have been called");
664
 
                },
665
 
                
666
 
                onFailure: function() {
667
 
                    counts.failure++;
668
 
                    Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
669
 
                },
670
 
                
671
 
                onEnd : function(o) {
672
 
 
673
 
                    var context = this;
674
 
                    
675
 
                    test.resume(function() {
676
 
                        counts.end++;
677
 
                        Y.Assert.areEqual(1, counts.end,"onEnd called more than once");
678
 
                        Y.Assert.areEqual(1, counts.failure, "onEnd called before onFailure");
679
 
 
680
 
                        areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
681
 
                        Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
682
 
 
683
 
                        //Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
684
 
 
685
 
                        Y.Assert.areEqual("failure", o.statusText, "Payload should have a failure statusText");
686
 
                        Y.Assert.isString(o.msg, "Payload should have a failure msg");
687
 
 
688
 
                        Y.Assert.areEqual("foo", context.bar, "Callback context not set");
689
 
 
690
 
                        test.o = o;
691
 
                    });
692
 
                },
693
 
                async:true
694
 
            });
695
 
 
696
 
            Y.Get.abort(trans.tId);
697
 
 
698
 
            this.wait();
699
 
        },
700
 
 
701
 
        'test: insertBefore, single' : function() {
702
 
 
703
 
            var test = this;
704
 
 
705
 
            test.createInsertBeforeNode();
706
 
 
707
 
            var trans = Y.Get.script(path("a.js"), {
708
 
                
709
 
                insertBefore: "insertBeforeMe",
710
 
 
711
 
                onSuccess: function(o) {
712
 
                    test.resume(function() {
713
 
 
714
 
                        var n = Y.Node.one(o.nodes[0]);
715
 
                        var insertBefore = Y.Node.one("#insertBeforeMe");
716
 
 
717
 
                        Y.Assert.isTrue(n.compareTo(insertBefore.previous()), "Not inserted before insertBeforeMe");
718
 
 
719
 
                        test.o = o;
720
 
                    });
721
 
                },
722
 
 
723
 
                onFailure: function(o) {
724
 
                    test.resume(function() {
725
 
                        Y.Assert.fail("onFailure shouldn't have been called");
726
 
                        test.o = o;
727
 
                    });
728
 
                }
729
 
            });
730
 
 
731
 
            this.wait();
732
 
        },
733
 
 
734
 
        'test: insertBefore, multiple' : function() {
735
 
 
736
 
            var test = this;
737
 
 
738
 
            test.createInsertBeforeNode();
739
 
 
740
 
            var trans = Y.Get.script(path(["a.js", "b.js"]), {
741
 
 
742
 
                insertBefore: "insertBeforeMe",
743
 
 
744
 
                onSuccess: function(o) {
745
 
                    test.resume(function() {
746
 
 
747
 
                        var insertBefore = Y.Node.one("#insertBeforeMe");
748
 
 
749
 
                        for (var i = o.nodes.length-1; i >= 0; i--) {
750
 
                            var n = Y.Node.one(o.nodes[i]);
751
 
                            Y.Assert.isTrue(n.compareTo(insertBefore.previous()), "Not inserted before insertBeforeMe");
752
 
                            insertBefore = n;
753
 
                        }
754
 
                        
755
 
                        test.o = o;
756
 
                    });
757
 
                },
758
 
 
759
 
                onFailure: function(o) {
760
 
                    test.resume(function() {
761
 
                        Y.Assert.fail("onFailure shouldn't have been called");
762
 
                        test.o = o;
763
 
                    });
764
 
                }
765
 
            });
766
 
 
767
 
            this.wait();
768
 
        },
769
 
 
770
 
        'test: async, insertBefore, multiple' : function() {
771
 
 
772
 
            var test = this;
773
 
 
774
 
            test.createInsertBeforeNode();
775
 
 
776
 
            var trans = Y.Get.script(path(["a.js", "b.js"]), {
777
 
 
778
 
                insertBefore: "insertBeforeMe",
779
 
 
780
 
                onSuccess: function(o) {
781
 
                    test.resume(function() {
782
 
 
783
 
                        var insertBefore = Y.Node.one("#insertBeforeMe");
784
 
 
785
 
                        for (var i = o.nodes.length-1; i >= 0; i--) {
786
 
                            var n = Y.Node.one(o.nodes[i]);
787
 
                            Y.Assert.isTrue(n.compareTo(insertBefore.previous()), "Not inserted before insertBeforeMe");
788
 
                            insertBefore = n;
789
 
                        }
790
 
                        
791
 
                        test.o = o;
792
 
                    });
793
 
                },
794
 
 
795
 
                onFailure: function(o) {
796
 
                    test.resume(function() {
797
 
                        Y.Assert.fail("onFailure shouldn't have been called");
798
 
                        test.o = o;
799
 
                    });
800
 
                },
801
 
                async:true
802
 
            });
803
 
 
804
 
            this.wait();
805
 
        },
806
 
 
807
 
        'test: charset, single' : function() {
808
 
 
809
 
            var test = this;
810
 
 
811
 
            var trans = Y.Get.script(path("a.js"), {
812
 
 
813
 
                charset: "ISO-8859-1",  
814
 
 
815
 
                onSuccess: function(o) {
816
 
                    test.resume(function() {
817
 
 
818
 
                        var node = document.getElementById(o.nodes[0].id);
819
 
 
820
 
                        Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
821
 
                        Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
822
 
 
823
 
                        test.o = o;
824
 
                    });
825
 
                },
826
 
 
827
 
                onFailure: function(o) {
828
 
                    test.resume(function() {
829
 
                        Y.Assert.fail("onFailure shouldn't have been called");
830
 
                        test.o = o;
831
 
                    });
832
 
                }
833
 
            });
834
 
 
835
 
            this.wait();
836
 
        },
837
 
 
838
 
        'test: charset, multiple' : function() {
839
 
 
840
 
            var test = this;
841
 
 
842
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
843
 
 
844
 
                charset: "ISO-8859-1",  
845
 
 
846
 
                onSuccess: function(o) {
847
 
 
848
 
                    test.resume(function() {
849
 
 
850
 
                        Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
851
 
 
852
 
                        for (var i = 0; i < o.nodes.length; i++) {
853
 
 
854
 
                            var node = document.getElementById(o.nodes[i].id);
855
 
 
856
 
                            Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
857
 
                            Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
858
 
                        }
859
 
 
860
 
                        test.o = o;
861
 
                    });
862
 
                },
863
 
 
864
 
                onFailure: function(o) {
865
 
                    test.resume(function() {
866
 
                        Y.Assert.fail("onFailure shouldn't have been called");
867
 
                        test.o = o;
868
 
                    });
869
 
                }
870
 
            });
871
 
 
872
 
            this.wait();
873
 
        },
874
 
        
875
 
        'test: async, charset, multiple' : function() {
876
 
 
877
 
            var test = this;
878
 
 
879
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
880
 
 
881
 
                charset: "ISO-8859-1",  
882
 
 
883
 
                onSuccess: function(o) {
884
 
 
885
 
                    test.resume(function() {
886
 
 
887
 
                        Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
888
 
 
889
 
                        for (var i = 0; i < o.nodes.length; i++) {
890
 
 
891
 
                            var node = document.getElementById(o.nodes[i].id);
892
 
 
893
 
                            Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
894
 
                            Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
895
 
                        }
896
 
 
897
 
                        test.o = o;
898
 
                    });
899
 
                },
900
 
 
901
 
                onFailure: function(o) {
902
 
                    test.resume(function() {
903
 
                        Y.Assert.fail("onFailure shouldn't have been called");
904
 
                        test.o = o;
905
 
                    });
906
 
                },
907
 
 
908
 
                async :true
909
 
            });
910
 
 
911
 
            this.wait();
912
 
        },
913
 
 
914
 
        'test: attributes, single' : function() {
915
 
 
916
 
            var test = this;
917
 
 
918
 
            var trans = Y.Get.script(path("a.js"), {
919
 
 
920
 
                attributes: {
921
 
                    "defer":true,         // Too much potential to interfere with global test structure?
922
 
                    "charset": "ISO-8859-1",  
923
 
                    "title": "myscripts"
924
 
                },
925
 
 
926
 
                onSuccess: function(o) {
927
 
                    test.resume(function() {
928
 
 
929
 
                        var node = document.getElementById(o.nodes[0].id);
930
 
 
931
 
                        Y.Assert.areEqual("myscripts", node.title, "title property not set");
932
 
                        Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
933
 
                        Y.Assert.areEqual(true, node.defer, "defer property not set");
934
 
 
935
 
                        Y.Assert.areEqual("myscripts", node.getAttribute("title"), "title attribute not set");
936
 
                        Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
937
 
 
938
 
                        // Needs cross browser normalization, IE8 returns "defer", Safari returns "true" etc. 
939
 
                        // Y.Assert.areEqual("true", node.getAttribute("defer"), "defer attribute not set");
940
 
 
941
 
                        test.o = o;
942
 
                    });
943
 
                },
944
 
 
945
 
                onFailure: function(o) {
946
 
                    test.resume(function() {
947
 
                        Y.Assert.fail("onFailure shouldn't have been called");
948
 
                        test.o = o;
949
 
                    });
950
 
                }
951
 
            });
952
 
 
953
 
            this.wait();
954
 
        },
955
 
 
956
 
        'test: attributes, multiple' : function() {
957
 
 
958
 
            var test = this;
959
 
 
960
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
961
 
 
962
 
                attributes: {
963
 
                    "defer":true,         // Too much potential to interfere with global test structure?
964
 
                    "charset": "ISO-8859-1",  
965
 
                    "title": "myscripts"
966
 
                },
967
 
 
968
 
                onSuccess: function(o) {
969
 
 
970
 
                    test.resume(function() {
971
 
 
972
 
                        Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
973
 
 
974
 
                        for (var i = 0; i < o.nodes.length; i++) {
975
 
 
976
 
                            var node = document.getElementById(o.nodes[i].id);
977
 
 
978
 
                            Y.Assert.areEqual("myscripts", node.title, "title property not set");
979
 
                            Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
980
 
                            Y.Assert.areEqual(true, node.defer, "defer property not set");
981
 
    
982
 
                            Y.Assert.areEqual("myscripts", node.getAttribute("title"), "title attribute not set");
983
 
                            Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
984
 
                        }
985
 
 
986
 
                        test.o = o;
987
 
                    });
988
 
                },
989
 
 
990
 
                onFailure: function(o) {
991
 
                    test.resume(function() {
992
 
                        Y.Assert.fail("onFailure shouldn't have been called");
993
 
                        test.o = o;
994
 
                    });
995
 
                }
996
 
            });
997
 
 
998
 
            this.wait();
999
 
        },
1000
 
        
1001
 
        'test: async, attributes, multiple' : function() {
1002
 
 
1003
 
            var test = this;
1004
 
 
1005
 
            var trans = Y.Get.script(path(["a.js", "b.js", "c.js"]), {
1006
 
 
1007
 
                attributes: {
1008
 
                    "defer":true,         // Too much potential to interfere with global test structure?
1009
 
                    "charset": "ISO-8859-1",  
1010
 
                    "title": "myscripts"
1011
 
                },
1012
 
 
1013
 
                onSuccess: function(o) {
1014
 
 
1015
 
                    test.resume(function() {
1016
 
 
1017
 
                        Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
1018
 
 
1019
 
                        for (var i = 0; i < o.nodes.length; i++) {
1020
 
 
1021
 
                            var node = document.getElementById(o.nodes[i].id);
1022
 
 
1023
 
                            Y.Assert.areEqual("myscripts", node.title, "title property not set");
1024
 
                            Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1025
 
                            Y.Assert.areEqual(true, node.defer, "defer property not set");
1026
 
    
1027
 
                            Y.Assert.areEqual("myscripts", node.getAttribute("title"), "title attribute not set");
1028
 
                            Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1029
 
                        }
1030
 
 
1031
 
                        test.o = o;
1032
 
                    });
1033
 
                },
1034
 
 
1035
 
                onFailure: function(o) {
1036
 
                    test.resume(function() {
1037
 
                        Y.Assert.fail("onFailure shouldn't have been called");
1038
 
                        test.o = o;
1039
 
                    });
1040
 
                },
1041
 
 
1042
 
                async :true
1043
 
            });
1044
 
 
1045
 
            this.wait();
1046
 
        },
1047
 
 
1048
 
        'ignore: abort' : function() {
1049
 
            // Covered above, but worth testing payload also
1050
 
        },
1051
 
 
1052
 
        'ignore: timeout' : function() {
1053
 
            // Need delay.js always available to test this reliably. Leaving out for now
1054
 
        },
1055
 
 
1056
 
        'test: purgethreshold' : function() {
1057
 
 
1058
 
            var test = this;
1059
 
            var nodes = [];
1060
 
            var nodeIds = [];
1061
 
 
1062
 
            // Purge only happens at the start of a queue call.
1063
 
 
1064
 
            Y.Get.script(path("a.js"), {
1065
 
                
1066
 
                purgethreshold: 1000, // Just to make sure we're not purged as part of the default 20 script purge.
1067
 
 
1068
 
                onSuccess: function(o) {
1069
 
 
1070
 
                    nodes = nodes.concat(o.nodes);
1071
 
 
1072
 
                    Y.Get.script(path("b.js"), {
1073
 
                        
1074
 
                        purgethreshold: 1000, // Just to make sure we're not purged as part of the default 20 script purge.
1075
 
                        
1076
 
                        onSuccess: function(o) {
1077
 
 
1078
 
                            nodes = nodes.concat(o.nodes);
1079
 
 
1080
 
                            Y.Assert.areEqual(2, nodes.length, "2 nodes should have been added");
1081
 
 
1082
 
                            for (var i = 0; i < nodes.length; i++) {
1083
 
                                var node = Y.Node.one(nodes[i]);
1084
 
                                Y.Assert.isTrue(node.inDoc(), "Scripts should still be in the document");
1085
 
 
1086
 
                                // Convert to id, for final doc check, because purge destroys parentNode
1087
 
                                nodeIds[i] = node.get("id");
1088
 
                            }
1089
 
 
1090
 
                            Y.Get.script(path("c.js"), {
1091
 
 
1092
 
                                purgethreshold:1,
1093
 
 
1094
 
                                onSuccess: function(o) {
1095
 
 
1096
 
                                    test.resume(function() {
1097
 
 
1098
 
                                        for (var i = 0; i < nodeIds.length; i++) {
1099
 
                                            Y.Assert.isNull(Y.Node.one(nodeIds[i]), "Script from previous transaction was not purged");
1100
 
                                        }
1101
 
    
1102
 
                                        Y.Assert.isTrue(Y.Node.one(o.nodes[0]).inDoc());
1103
 
                                        
1104
 
                                        test.o = o;
1105
 
                                    });                               
1106
 
                                }
1107
 
                            });                                            
1108
 
                        }
1109
 
                    });
1110
 
                }
1111
 
            });
1112
 
 
1113
 
            this.wait();
1114
 
        }
1115
 
 
1116
 
    });
1117
 
 
1118
 
    Y.GetTests.CSS = new Y.Test.Case({
1119
 
 
1120
 
        name: "CSS Tests",
1121
 
 
1122
 
        setUp: function() {
1123
 
            this.na = Y.Node.create('<div class="get_test_a">get_test_a</div>');
1124
 
            this.nb = Y.Node.create('<div class="get_test_b">get_test_b</div>');
1125
 
            this.nc = Y.Node.create('<div class="get_test_c">get_test_c</div>');
1126
 
 
1127
 
            naa = this.na;
1128
 
 
1129
 
            var b = Y.Node.one("body");
1130
 
            b.append(this.na);
1131
 
            b.append(this.nb);
1132
 
            b.append(this.nc);
1133
 
 
1134
 
            this.onload = Y.GetTests.ONLOAD_SUPPORTED['css'];
1135
 
        },
1136
 
 
1137
 
        createInsertBeforeNode: function() {
1138
 
            this.ib = Y.Node.create('<link id="insertBeforeMe" href="' + path("ib.css?delay=0") + '" rel="stylesheet" type="text/css" charset="utf-8">');
1139
 
            Y.Node.one("head").appendChild(this.ib);
1140
 
        },
1141
 
 
1142
 
        removeInsertBeforeNode: function() {
1143
 
            if (this.ib) {
1144
 
                this.ib.remove(true);
1145
 
            }
1146
 
        },
1147
 
 
1148
 
        tearDown: function() {
1149
 
            this.na.remove(true);
1150
 
            this.nb.remove(true);
1151
 
            this.nc.remove(true);
1152
 
 
1153
 
            this.o && this.o.purge();
1154
 
            this.removeInsertBeforeNode();
1155
 
        },
1156
 
 
1157
 
        'test: single css, success': function() {
1158
 
            var test = this;
1159
 
            var counts = {
1160
 
                success:0,
1161
 
                failure:0
1162
 
            };
1163
 
            
1164
 
            // Using test.onload to switch test behavior for IE/Opera vs. others.
1165
 
            // In IE/Opera we don't need to artifical timeout, since we're notified
1166
 
            // onload. For the others, onSuccess is called synchronously.
1167
 
 
1168
 
            var trans = Y.Get.css(path("a.css?delay=50"), {
1169
 
 
1170
 
                data: {a:1, b:2, c:3},
1171
 
                context: {bar:"foo"},
1172
 
 
1173
 
                onSuccess: function(o) {
1174
 
 
1175
 
                    var context = this;
1176
 
 
1177
 
                    setTimeout(function() {
1178
 
                        test.resume(function() {
1179
 
                            counts.success++;
1180
 
    
1181
 
                            Y.Assert.areEqual("1111", this.na.getComputedStyle("zIndex"), "a.css does not seem to be loaded");
1182
 
                            Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
1183
 
    
1184
 
                            areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
1185
 
 
1186
 
                            // TODO: Test infrastructure won't let us easily get a populated trans reference and also wait (AFAICT). So commenting this out.
1187
 
                            // Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
1188
 
 
1189
 
                            Y.Assert.areEqual(1, o.nodes.length, "Payload nodes property has unexpected length");
1190
 
                            Y.Assert.isUndefined(o.statusText, "Payload should not have a statusText");
1191
 
                            Y.Assert.isUndefined(o.msg, "Payload should not have a msg");
1192
 
    
1193
 
                            Y.Assert.areEqual("foo", context.bar, "Callback context not set");
1194
 
    
1195
 
                            test.o = o;
1196
 
                        });
1197
 
                    }, test.onload ? 0 : 200); // need arbit delay to make sure CSS is applied
1198
 
 
1199
 
                    if (!test.onload) {
1200
 
                        test.wait();
1201
 
                    }
1202
 
                    
1203
 
                },
1204
 
 
1205
 
                onFailure: function(o) {
1206
 
                    Y.Assert.fail("onFailure shouldn't have been called");
1207
 
                }
1208
 
            });
1209
 
 
1210
 
            if (test.onload) {
1211
 
                test.wait();
1212
 
            }
1213
 
        },
1214
 
 
1215
 
        'test: multiple css, success': function() {
1216
 
 
1217
 
            var test = this;
1218
 
            var counts = {
1219
 
                success:0,
1220
 
                failure:0
1221
 
            };
1222
 
 
1223
 
            var trans = Y.Get.css(path(["a.css?delay=50", "b.css?delay=100", "c.css?delay=75"]), {
1224
 
 
1225
 
                data: {a:1, b:2, c:3},
1226
 
                context: {bar:"foo"},
1227
 
 
1228
 
                onFailure: function(o) {
1229
 
                    Y.Assert.fail("onFailure shouldn't have been called");
1230
 
                },
1231
 
 
1232
 
                onSuccess: function(o) {
1233
 
                    
1234
 
                    var context = this;
1235
 
 
1236
 
                    setTimeout(function() {
1237
 
                        test.resume(function() {
1238
 
                            counts.success++;
1239
 
    
1240
 
                            Y.Assert.areEqual("1111", this.na.getComputedStyle("zIndex"), "a.css does not seem to be loaded");
1241
 
                            Y.Assert.areEqual("1234", this.nb.getComputedStyle("zIndex"), "b.css does not seem to be loaded");
1242
 
                            Y.Assert.areEqual("4321", this.nc.getComputedStyle("zIndex"), "c.css does not seem to be loaded");
1243
 
                            Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
1244
 
                            
1245
 
                            areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
1246
 
                            
1247
 
                            //Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
1248
 
                            
1249
 
                            Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
1250
 
                            Y.Assert.isUndefined(o.statusText, "Payload should not have a statusText");
1251
 
                            Y.Assert.isUndefined(o.msg, "Payload should not have a msg");
1252
 
    
1253
 
                            Y.Assert.areEqual("foo", context.bar, "Callback context not set");
1254
 
                            
1255
 
                            test.o = o;
1256
 
                        });
1257
 
                    }, test.onload ? 0 : 400);
1258
 
 
1259
 
                    if (!test.onload) {
1260
 
                        test.wait();
1261
 
                    }
1262
 
                }
1263
 
            });
1264
 
 
1265
 
            if (test.onload) {
1266
 
                test.wait();
1267
 
            }
1268
 
        },
1269
 
 
1270
 
        'test: async multiple css, success': function() {
1271
 
 
1272
 
            var test = this;
1273
 
            var counts = {
1274
 
                success:0,
1275
 
                failure:0
1276
 
            };
1277
 
 
1278
 
            var trans = Y.Get.css(path(["a.css?delay=100", "b.css?delay=75", "c.css?delay=50"]), {
1279
 
 
1280
 
                data: {a:1, b:2, c:3},
1281
 
                context: {bar:"foo"},
1282
 
 
1283
 
                onFailure: function(o) {
1284
 
                    Y.Assert.fail("onFailure shouldn't have been called");
1285
 
                },
1286
 
                onSuccess: function(o) {
1287
 
 
1288
 
                    var context = this;
1289
 
 
1290
 
                    setTimeout(function() {
1291
 
                        test.resume(function() {
1292
 
                            counts.success++;
1293
 
                            Y.Assert.areEqual("1111", this.na.getComputedStyle("zIndex"), "a.css does not seem to be loaded");
1294
 
                            Y.Assert.areEqual("1234", this.nb.getComputedStyle("zIndex"), "b.css does not seem to be loaded");
1295
 
                            Y.Assert.areEqual("4321", this.nc.getComputedStyle("zIndex"), "c.css does not seem to be loaded");
1296
 
                            Y.Assert.isTrue(counts.success === 1, "onSuccess called more than once");
1297
 
                            
1298
 
                            areObjectsReallyEqual({a:1, b:2, c:3}, o.data, "Payload has unexpected data value");
1299
 
                            
1300
 
                            //Y.Assert.areEqual(trans.tId, o.tId, "Payload has unexpected tId");
1301
 
 
1302
 
                            Y.Assert.areEqual(3, o.nodes.length, "Payload nodes property has unexpected length");
1303
 
                            Y.Assert.isUndefined(o.statusText, "Payload should not have a statusText");
1304
 
                            Y.Assert.isUndefined(o.msg, "Payload should not have a msg");
1305
 
    
1306
 
                            Y.Assert.areEqual("foo", context.bar, "Callback context not set");
1307
 
 
1308
 
                            test.o = o;
1309
 
                        });
1310
 
                    }, test.onload ? 0 : 400);
1311
 
 
1312
 
                    if (!test.onload) {
1313
 
                        test.wait();
1314
 
                    }
1315
 
                },
1316
 
                async:true
1317
 
            });
1318
 
            
1319
 
            if (test.onload) {
1320
 
                test.wait();
1321
 
            }
1322
 
        },
1323
 
 
1324
 
        'test: insertBefore, single' : function() {
1325
 
 
1326
 
            var test = this;
1327
 
 
1328
 
            test.createInsertBeforeNode();
1329
 
 
1330
 
            var trans = Y.Get.css(path("a.css?delay=30"), {
1331
 
 
1332
 
                insertBefore: "insertBeforeMe",
1333
 
 
1334
 
                onSuccess: function(o) {
1335
 
 
1336
 
                    setTimeout(function() {
1337
 
                        test.resume(function() {
1338
 
 
1339
 
                            var n = Y.Node.one(o.nodes[0]);
1340
 
    
1341
 
                            var insertBefore = Y.Node.one("#insertBeforeMe");
1342
 
    
1343
 
                            Y.Assert.isTrue(n.compareTo(insertBefore.previous()), "Not inserted before insertBeforeMe");
1344
 
    
1345
 
                            /* TODO: These don't work as expected on IE (even though insertBefore worked). Better cross-browser assertion? */
1346
 
                            if (!Y.UA.ie) {
1347
 
                                Y.Assert.areEqual("9991", this.na.getComputedStyle("zIndex"), "a.css does not seem to be inserted before ib.css");
1348
 
                            }
1349
 
    
1350
 
                            test.o = o;
1351
 
 
1352
 
                        });
1353
 
                    }, test.onload ? 0 : 100);
1354
 
 
1355
 
                    if (!test.onload) {
1356
 
                        test.wait();
1357
 
                    }
1358
 
                }
1359
 
            });
1360
 
 
1361
 
            if (test.onload) {
1362
 
                test.wait();
1363
 
            }
1364
 
        },
1365
 
 
1366
 
        'test: insertBefore, multiple' : function() {
1367
 
 
1368
 
            var test = this;
1369
 
 
1370
 
            test.createInsertBeforeNode();
1371
 
 
1372
 
            var trans = Y.Get.css(path(["a.css?delay=20", "b.css?delay=75", "c.css?delay=10"]), {
1373
 
 
1374
 
                insertBefore: "insertBeforeMe",
1375
 
 
1376
 
                onSuccess: function(o) {
1377
 
                    setTimeout(function() {
1378
 
                        test.resume(function() {
1379
 
                            var insertBefore = Y.Node.one("#insertBeforeMe");
1380
 
    
1381
 
                            for (var i = o.nodes.length-1; i >= 0; i--) {
1382
 
                                var n = Y.Node.one(o.nodes[i]);
1383
 
                                Y.Assert.isTrue(n.compareTo(insertBefore.previous()), "Not inserted before insertBeforeMe");
1384
 
                                insertBefore = n;
1385
 
                            }
1386
 
 
1387
 
                            /* TODO: These don't work as expected on IE (even though insertBefore worked). Better cross-browser assertion? */
1388
 
                            if (!Y.UA.ie) {
1389
 
                                Y.Assert.areEqual("9991", this.na.getComputedStyle("zIndex"), "a.css does not seem to be inserted before ib.css");
1390
 
                                Y.Assert.areEqual("9992", this.nb.getComputedStyle("zIndex"), "b.css does not seem to be inserted before ib.css");
1391
 
                                Y.Assert.areEqual("9993", this.nc.getComputedStyle("zIndex"), "c.css does not seem to be inserted before ib.css");
1392
 
                            }
1393
 
                           
1394
 
                            test.o = o;
1395
 
                        });
1396
 
                    }, test.onload ? 0 : 200);
1397
 
 
1398
 
                    if (!test.onload) {
1399
 
                        test.wait();
1400
 
                    }
1401
 
                }
1402
 
            });
1403
 
 
1404
 
            if (test.onload) {
1405
 
                test.wait();
1406
 
            }
1407
 
        },
1408
 
 
1409
 
        'test: async, insertBefore, multiple' : function() {
1410
 
 
1411
 
            var test = this;
1412
 
 
1413
 
            test.createInsertBeforeNode();
1414
 
 
1415
 
            var trans = Y.Get.css(path(["a.css?delay=30", "b.css?delay=10", "c.css?delay=50"]), {
1416
 
 
1417
 
                insertBefore: "insertBeforeMe",
1418
 
 
1419
 
                onSuccess: function(o) {
1420
 
 
1421
 
                    setTimeout(function() {
1422
 
                        test.resume(function() {
1423
 
                            var insertBefore = Y.Node.one("#insertBeforeMe");
1424
 
    
1425
 
                            for (var i = o.nodes.length-1; i >= 0; i--) {
1426
 
                                var n = Y.Node.one(o.nodes[i]);
1427
 
                                Y.Assert.isTrue(n.compareTo(insertBefore.previous()), "Not inserted before insertBeforeMe");
1428
 
                                insertBefore = n;
1429
 
                            }
1430
 
 
1431
 
                            /* TODO: These don't work as expected on IE (even though insertBefore worked). Better cross-browser assertion? */
1432
 
                            if (!Y.UA.ie) {        
1433
 
                                Y.Assert.areEqual("9991", this.na.getComputedStyle("zIndex"), "a.css does not seem to be inserted before ib.css");
1434
 
                                Y.Assert.areEqual("9992", this.nb.getComputedStyle("zIndex"), "b.css does not seem to be inserted before ib.css");
1435
 
                                Y.Assert.areEqual("9993", this.nc.getComputedStyle("zIndex"), "c.css does not seem to be inserted before ib.css");
1436
 
                            }
1437
 
                            
1438
 
                            test.o = o;
1439
 
 
1440
 
                        });
1441
 
 
1442
 
                    }, test.onload ? 0 : 200);
1443
 
 
1444
 
                    if (!test.onload) {
1445
 
                        test.wait();
1446
 
                    }
1447
 
                },
1448
 
 
1449
 
                async:true
1450
 
            });
1451
 
 
1452
 
            if (test.onload) {
1453
 
                test.wait();
1454
 
            }
1455
 
        },
1456
 
        
1457
 
        'test: charset, single' : function() {
1458
 
 
1459
 
            var test = this;
1460
 
 
1461
 
            var trans = Y.Get.css(path("a.css?delay=20"), {
1462
 
 
1463
 
                charset: "ISO-8859-1",  
1464
 
 
1465
 
                onSuccess: function(o) {
1466
 
                    setTimeout(function() {
1467
 
                        test.resume(function() {
1468
 
 
1469
 
                            var node = document.getElementById(o.nodes[0].id);
1470
 
    
1471
 
                            Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1472
 
                            Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1473
 
    
1474
 
                            test.o = o;
1475
 
                        });
1476
 
                    
1477
 
                    }, test.onload ? 0 : 100);
1478
 
 
1479
 
                    if (!test.onload) {
1480
 
                        test.wait();
1481
 
                    }
1482
 
                }
1483
 
            });
1484
 
 
1485
 
            if (test.onload) {
1486
 
                test.wait();
1487
 
            }
1488
 
        },
1489
 
 
1490
 
        'test: charset, multiple' : function() {
1491
 
 
1492
 
            var test = this;
1493
 
 
1494
 
            var trans = Y.Get.css(path(["a.css?delay=10", "b.css?delay=50", "c.css?delay=20"]), {
1495
 
 
1496
 
                charset: "ISO-8859-1",  
1497
 
 
1498
 
                onSuccess: function(o) {
1499
 
 
1500
 
                    setTimeout(function() {
1501
 
                        test.resume(function() {
1502
 
 
1503
 
                            Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
1504
 
    
1505
 
                            for (var i = 0; i < o.nodes.length; i++) {
1506
 
    
1507
 
                                var node = document.getElementById(o.nodes[i].id);
1508
 
    
1509
 
                                Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1510
 
                                Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1511
 
                            }
1512
 
    
1513
 
                            test.o = o;
1514
 
                        });
1515
 
                    }, test.onload ? 0 : 200);
1516
 
 
1517
 
                    if (!test.onload) {
1518
 
                        test.wait();
1519
 
                    }
1520
 
                }
1521
 
            });
1522
 
 
1523
 
            if (test.onload) {
1524
 
                test.wait();
1525
 
            }
1526
 
        },
1527
 
        
1528
 
        'test: async, charset, multiple' : function() {
1529
 
 
1530
 
            var test = this;
1531
 
 
1532
 
            var trans = Y.Get.css(path(["a.css?delay=30", "b.css?delay=10", "c.css?delay=20"]), {
1533
 
 
1534
 
                charset: "ISO-8859-1",  
1535
 
 
1536
 
                onSuccess: function(o) {
1537
 
 
1538
 
                    setTimeout(function() {
1539
 
                        test.resume(function() {
1540
 
 
1541
 
                            Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
1542
 
    
1543
 
                            for (var i = 0; i < o.nodes.length; i++) {
1544
 
    
1545
 
                                var node = document.getElementById(o.nodes[i].id);
1546
 
    
1547
 
                                Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1548
 
                                Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1549
 
                            }
1550
 
    
1551
 
                            test.o = o;
1552
 
                        });
1553
 
                        
1554
 
                    }, test.onload ? 0 : 200);
1555
 
 
1556
 
                    if (!test.onload) {
1557
 
                        test.wait();
1558
 
                    }
1559
 
                },
1560
 
                async :true
1561
 
            });
1562
 
 
1563
 
            if (test.onload) {
1564
 
                test.wait();
1565
 
            }
1566
 
        },
1567
 
        
1568
 
        'test: attributes, single' : function() {
1569
 
 
1570
 
            var test = this;
1571
 
 
1572
 
            var trans = Y.Get.css(path("a.css?delay=10"), {
1573
 
 
1574
 
                attributes: {
1575
 
                    "charset": "ISO-8859-1",
1576
 
                    "title": "myscripts"
1577
 
                },
1578
 
 
1579
 
                onSuccess: function(o) {
1580
 
 
1581
 
                    setTimeout(function() {
1582
 
                        test.resume(function() {
1583
 
 
1584
 
                            var node = document.getElementById(o.nodes[0].id);
1585
 
    
1586
 
                            Y.Assert.areEqual("myscripts", node.title, "title property not set");
1587
 
                            Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1588
 
                            Y.Assert.areEqual("myscripts", node.getAttribute("title"), "title attribute not set");
1589
 
                            Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1590
 
    
1591
 
                            test.o = o;
1592
 
                        });
1593
 
 
1594
 
                    }, test.onload ? 0 : 100);
1595
 
 
1596
 
                    if (!test.onload) {
1597
 
                        test.wait();
1598
 
                    }
1599
 
                }
1600
 
            });
1601
 
 
1602
 
 
1603
 
            if (test.onload) {
1604
 
                test.wait();
1605
 
            }
1606
 
        },
1607
 
 
1608
 
        'test: attributes, multiple' : function() {
1609
 
 
1610
 
            var test = this;
1611
 
 
1612
 
            var trans = Y.Get.css(path(["a.css?delay=10", "b.css?delay=50", "c.css?delay=20"]), {
1613
 
 
1614
 
                attributes: {
1615
 
                    "charset": "ISO-8859-1",  
1616
 
                    "title": "myscripts"
1617
 
                },
1618
 
 
1619
 
                onSuccess: function(o) {
1620
 
 
1621
 
                    setTimeout(function() {
1622
 
                        test.resume(function() {
1623
 
 
1624
 
                            Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
1625
 
    
1626
 
                            for (var i = 0; i < o.nodes.length; i++) {
1627
 
    
1628
 
                                var node = document.getElementById(o.nodes[i].id);
1629
 
    
1630
 
                                Y.Assert.areEqual("myscripts", node.title, "title property not set");
1631
 
                                Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1632
 
                                Y.Assert.areEqual("myscripts", node.getAttribute("title"), "title attribute not set");
1633
 
                                Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1634
 
                            }
1635
 
    
1636
 
                            test.o = o;
1637
 
                        });
1638
 
                    }, test.onload ? 0 : 200);
1639
 
 
1640
 
                    if (!test.onload) {
1641
 
                        test.wait();
1642
 
                    }
1643
 
                        
1644
 
                }
1645
 
            });
1646
 
 
1647
 
 
1648
 
            if (test.onload) {
1649
 
                test.wait();
1650
 
            }
1651
 
        },
1652
 
        
1653
 
        'test: async, attributes, multiple' : function() {
1654
 
 
1655
 
            var test = this;
1656
 
 
1657
 
            var trans = Y.Get.css(path(["a.css?delay=10", "b.css?delay=50", "c.css?delay=20"]), {
1658
 
 
1659
 
                attributes: {
1660
 
                    "charset": "ISO-8859-1",  
1661
 
                    "title": "myscripts"
1662
 
                },
1663
 
 
1664
 
                onSuccess: function(o) {
1665
 
 
1666
 
                    setTimeout(function() {
1667
 
                        test.resume(function() {
1668
 
 
1669
 
                            Y.Assert.areEqual(3, o.nodes.length, "Unexpected node count");
1670
 
    
1671
 
                            for (var i = 0; i < o.nodes.length; i++) {
1672
 
    
1673
 
                                var node = document.getElementById(o.nodes[i].id);
1674
 
    
1675
 
                                Y.Assert.areEqual("myscripts", node.title, "title property not set");
1676
 
                                Y.Assert.areEqual("ISO-8859-1", node.charset, "charset property not set");
1677
 
                                Y.Assert.areEqual("myscripts", node.getAttribute("title"), "title attribute not set");
1678
 
                                Y.Assert.areEqual("ISO-8859-1", node.getAttribute("charset"), "charset attribute not set");
1679
 
                            }
1680
 
    
1681
 
                            test.o = o;
1682
 
                        });
1683
 
                    }, test.onload ? 0 : 200);
1684
 
 
1685
 
                    if (!test.onload) {
1686
 
                        test.wait();
1687
 
                    }
1688
 
                },
1689
 
 
1690
 
                async :true
1691
 
            });
1692
 
 
1693
 
 
1694
 
            if (test.onload) {
1695
 
                test.wait();
1696
 
            }
1697
 
        },
1698
 
 
1699
 
        // TODO: CSS failure not widely supported. Enable when success/failure handling is in place
1700
 
    
1701
 
        'ignore: single css, failure': function() {
1702
 
 
1703
 
            var test = this;
1704
 
            var counts = {
1705
 
                success:0,
1706
 
                failure:0
1707
 
            };
1708
 
            
1709
 
            Y.Get.abort(Y.Get.css(path("a.css"), {
1710
 
 
1711
 
                data: {a:1, b:2, c:3},
1712
 
                context: {bar:"foo"},
1713
 
 
1714
 
                onSuccess: function(o) {
1715
 
                    Y.Assert.fail("onSuccess shouldn't have been called");
1716
 
                },
1717
 
 
1718
 
                onFailure: function(o) {
1719
 
                    counts.failure++;
1720
 
                    Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
1721
 
                },
1722
 
                
1723
 
                onEnd: function(o) {
1724
 
                    test.o = o;
1725
 
                }
1726
 
            }));
1727
 
        },
1728
 
 
1729
 
        // TODO: CSS failure not widely supported. Enable when success/failure handling is in place
1730
 
 
1731
 
        'ignore: multiple css, failure': function() {
1732
 
            var test = this;
1733
 
            var counts = {
1734
 
                success:0,
1735
 
                failure:0
1736
 
            };
1737
 
 
1738
 
            Y.Get.abort(Y.Get.css(path(["a.css", "b.css", "c.css"]), {
1739
 
 
1740
 
                data: {a:1, b:2, c:3},
1741
 
                context: {bar:"foo"},
1742
 
                
1743
 
                onSuccess: function(o) {
1744
 
                    test.resume(function() {
1745
 
                        Y.Assert.fail("onSuccess shouldn't have been called");
1746
 
                    });
1747
 
                },
1748
 
                
1749
 
                onFailure: function(o) {
1750
 
                    test.resume(function() {
1751
 
                        counts.failure++;
1752
 
                        Y.Assert.isTrue(counts.failure === 1, "onFailure called more than once");
1753
 
                        test.o = o;
1754
 
                    });
1755
 
                },
1756
 
                
1757
 
                onEnd: function(o) {
1758
 
                    test.o = o;
1759
 
                }
1760
 
            }));
1761
 
 
1762
 
            this.wait();
1763
 
        },
1764
 
 
1765
 
        // TODO: CSS failure not widely supported. Enable when success/failure handling is in place
1766
 
 
1767
 
        'ignore: async multiple css, failure': function() {
1768
 
        }
1769
 
    });
1770
 
 
1771
 
 
1772
 
    Y.GetTests.Functional = new Y.Test.Case({
1773
 
 
1774
 
        name: "Functional Tests",
1775
 
 
1776
 
        'test: Loader, ScrollView' : function() {
1777
 
            var test = this;
1778
 
 
1779
 
            YUI().use("scrollview", function(Y2) {
1780
 
                test.resume(function() {
1781
 
                    Y.Assert.isFunction(Y2.ScrollView, "ScrollView not loaded");    
1782
 
                });
1783
 
            });
1784
 
 
1785
 
            this.wait();
1786
 
        },
1787
 
 
1788
 
        'test: Loader, Autocomplete' : function() {
1789
 
            var test = this;
1790
 
 
1791
 
            YUI().use("autocomplete-list", function(Y2) {
1792
 
                test.resume(function() {
1793
 
                    Y.Assert.isFunction(Y2.AutoCompleteList, "Autocomplete not loaded");    
1794
 
                });
1795
 
            });
1796
 
 
1797
 
            this.wait();
1798
 
        }
1799
 
    });
1800
 
 
1801
 
});