mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
e72f804565
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
21 lines
707 B
JavaScript
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;
|
|
};
|