2014-05-23 09:57:58 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki test utilities.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
ve.test.utils.createSurfaceFromDocument = function ( doc ) {
|
|
|
|
// Prevent the target from setting up the surface immediately
|
2014-08-13 19:35:15 +00:00
|
|
|
ve.init.platform.initialized = $.Deferred();
|
2014-05-23 09:57:58 +00:00
|
|
|
// HACK: MW targets are async and heavy, use an SA target but
|
|
|
|
// override the global registration
|
2014-12-03 00:04:07 +00:00
|
|
|
var target = new ve.init.sa.Target( $( '#qunit-fixture' ) ),
|
2014-05-23 09:57:58 +00:00
|
|
|
mwTarget = new ve.init.mw.Target( $( '<div>' ).appendTo( $( '#qunit-fixture' ) ) );
|
|
|
|
|
2014-12-03 00:04:07 +00:00
|
|
|
target.addSurface( doc );
|
|
|
|
|
2014-08-13 19:35:15 +00:00
|
|
|
ve.init.platform.initialized.resolve();
|
2014-05-23 09:57:58 +00:00
|
|
|
mwTarget = null;
|
2014-12-03 00:04:07 +00:00
|
|
|
target.addSurface( doc );
|
2014-05-23 09:57:58 +00:00
|
|
|
return target.surface;
|
|
|
|
};
|