/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
( function()
{
function redirectToFort()
{
var tags, metas = document.getElementsByTagName( 'meta' );
for( var i = 0 ; i < metas.length ; i++ )
{
if ( metas[ i ].name == 'tags' )
tags = metas[ i ].content;
}
var scripts = document.getElementsByTagName( 'script' ),
src,
newUrl;
for( var i = 0 ; i < scripts.length ; i++ )
{
if ( ( src = scripts [ i ].src )
&& ( ( src = src.match(/(.*)\bcell\.js/)) && ( newUrl = src[ 1 ] ) ) )
{
newUrl = newUrl + 'fort.html?'
+ '&cells=' + document.location.href
+ '&tags=' + tags || "";
}
}
document.location.href = newUrl;
}
var runnerWindow = opener || ( parent != self ) && parent;
// Redirect to fort for this single cell, if the test page is opened directly.
if ( !runnerWindow )
{
redirectToFort();
return;
}
var runner = runnerWindow.CKTESTER.fort,
cell = runner.currentCell,
mode = ( runnerWindow == opener ) ? cell.mode : 'managed',
dependencies = cell && cell.environment;
if ( cell )
{
function writeScript( url )
{
document.write( '' ) ;
}
function writeStyleSheet( url )
{
document.write( '' ) ;
}
// Cell doesn't require too much APIs right now.
window.CKTESTER =
{
mode : mode,
cell :
{
getAbsolutePath : function ( path, isRelativeToFort )
{
return runnerWindow.CKTESTER.fort.getAbsolutePath( isRelativeToFort == true ? null : window, path );
},
start : mode == 'managed' ?
function( data )
{
runner.cellStart( runnerWindow.$H( cell ).merge( { name : document.title, data : data } ).toObject() );
}
:
runnerWindow.Prototype.emptyFunction,
complete : mode == 'managed' ?
function( data )
{
runner.cellComplete( runnerWindow.$H( cell ).merge( { name : document.title, data : data } ).toObject() );
}
:
runnerWindow.Prototype.emptyFunction
}
};
for ( var i = 0 ; i < dependencies.length ; i++ )
{
var path = dependencies[ i ];
( path.match( /\.js$/ )? writeScript : writeStyleSheet ) ( path );
}
}
} )();