mediawiki-extensions-Visual.../modules/ve-mw/tests/ve.test.utils.js
Roan Kattouw e72f804565 "Fix" hack in ve.test.utils to prevent immediate surface setup
This used to work because loading i18n files took time. However,
we now don't register any message paths with the platform, so
platform initialization is now synchronous, which breaks the hack.

Instead, explicitly assign an unresolved deferred to the platform's
initialization promise, and resolve it after the mw.Target has been
constructed.

*barf*

Change-Id: I287cb86ce8c4c534fd723532f34463359a8ccc7c
2014-08-13 12:37:31 -07:00

21 lines
707 B
JavaScript

/*!
* 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
ve.init.platform.initialized = $.Deferred();
// HACK: MW targets are async and heavy, use an SA target but
// override the global registration
var target = new ve.init.sa.Target( $( '#qunit-fixture' ), doc ),
mwTarget = new ve.init.mw.Target( $( '<div>' ).appendTo( $( '#qunit-fixture' ) ) );
ve.init.platform.initialized.resolve();
mwTarget = null;
target.setup( doc );
return target.surface;
};