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 79
|
/* bender-tags: editor,unit */
var tests = {
// test_loadCode : function()
// {
// CKEDITOR.scriptLoader.loadCode( 'var test="Testing!";' );
//
// /*jsl:ignore
// assert.areEqual( 'Testing!', test );
// /*jsl:end
// },
'test load': function() {
var tc = this;
function callback( data ) {
tc.resume( function() {
assert.areSame( 'Test!', testVar );
} );
}
CKEDITOR.scriptLoader.load( '../_assets/sample.js', callback );
this.wait();
},
'test queue': function() {
var tc = this;
function testQueue( scripts ) {
var loaded = [],
script;
for ( var i = 0; i < scripts.length; i++ ) {
// Mark this script as loaded.
// This should happen before scriptLoader.queue() loads
// the next pending script. It allows the final load order
// assertion.
script = scripts[ i ];
( function( script ) {
function callback( success ) {
loaded.push( script );
tc.resume( function() {
assert.areSame( true, success, 'Successful load.' );
wait();
} );
if ( loaded.length == scripts.length ) {
tc.resume( function() {
assert.areSame( 'Foo', testVar1, 'Script has been loaded.' );
assert.areSame( 'Bar', testVar2, 'Script has been loaded.' );
assert.areSame( 'Bam', testVar3, 'Script has been loaded.' );
arrayAssert.itemsAreSame( scripts, loaded, 'Scripts loaded in queue order.' );
} );
}
}
CKEDITOR.scriptLoader.queue( script, callback );
} )( script );
}
}
testQueue( [
'../_assets/queue1.js',
'../_assets/queue2.js',
'../_assets/queue3.js'
] );
this.wait();
}
};
// Repeat the queue tests, to be sure that it is not getting stuck.
tests[ 'test queue again' ] = tests[ 'test queue' ];
bender.test( tests );
|