"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
This commit is contained in:
Roan Kattouw 2014-08-13 12:35:15 -07:00
parent cda1ee5402
commit e72f804565

View file

@ -7,12 +7,13 @@
ve.test.utils.createSurfaceFromDocument = function ( doc ) {
// Prevent the target from setting up the surface immediately
ve.init.platform.initialized = null;
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;