mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-18 01:00:45 +00:00
Update VE core submodule to master (a8e0eef6d)
New changes: a8e0eef6d Simplify usage of dummy target Local changes: Simplify usage of dummy target, ceating an MWDummyTarget, extending DummyTarget instead of mw.ArticleTarget. Depends-On: I01a6860387087db8149c73793e9bd4294d33aea8 Change-Id: I227486159fe416c219e2c37a1d054201084fe285
This commit is contained in:
parent
1bd430c9d1
commit
3dd3073bd2
2
lib/ve
2
lib/ve
|
@ -1 +1 @@
|
||||||
Subproject commit 099902ddb1f58cc82fc0f4045fb4ce8d19343588
|
Subproject commit a8e0eef6dfbb5b0de5556a8dd84dce55e41d90b6
|
|
@ -5,104 +5,91 @@
|
||||||
* @license The MIT License (MIT); see LICENSE.txt
|
* @license The MIT License (MIT); see LICENSE.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ve.test.utils.createSurfaceFromDocument = function ( doc ) {
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
var target, mwTarget, surface;
|
|
||||||
|
|
||||||
// Prevent the target from setting up the surface immediately
|
|
||||||
ve.init.platform.initialized = $.Deferred();
|
|
||||||
|
|
||||||
// HACK: MW targets are async and heavy, use a DummyTarget
|
|
||||||
// but override the global registration
|
|
||||||
target = new ve.test.utils.DummyTarget();
|
|
||||||
|
|
||||||
// HACK: Mock setDefaultMode() because it causes untracked
|
|
||||||
// ajax requests (T162810)
|
|
||||||
// HACK: Has to be a subclass instead of assignment to mwTarget
|
|
||||||
// because it is called in the constructor
|
|
||||||
function SubMwArticleTarget() {
|
|
||||||
SubMwArticleTarget.super.call( this );
|
|
||||||
}
|
|
||||||
OO.inheritClass( SubMwArticleTarget, ve.init.mw.ArticleTarget );
|
|
||||||
SubMwArticleTarget.prototype.setDefaultMode = function () {};
|
|
||||||
|
|
||||||
mwTarget = new SubMwArticleTarget();
|
|
||||||
|
|
||||||
$( '#qunit-fixture' ).append( target.$element );
|
|
||||||
target.addSurface( doc );
|
|
||||||
|
|
||||||
ve.init.platform.initialized.resolve();
|
|
||||||
mwTarget = null;
|
|
||||||
surface = target.addSurface( doc );
|
|
||||||
// HACK HACK HACK: The target fuckery above results in the surface not being attached to the DOM.
|
|
||||||
// I'm not debugging that, screw it. Let's add another hack on top, surely that won't be a problem.
|
|
||||||
$( '#qunit-fixture' ).append( surface.$element );
|
|
||||||
return surface;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Unregister MW override nodes.
|
|
||||||
// They are temporarily registered in setup/teardown.
|
|
||||||
ve.dm.modelRegistry.unregister( ve.dm.MWHeadingNode );
|
|
||||||
ve.dm.modelRegistry.unregister( ve.dm.MWPreformattedNode );
|
|
||||||
ve.dm.modelRegistry.unregister( ve.dm.MWTableNode );
|
|
||||||
ve.dm.modelRegistry.unregister( ve.dm.MWExternalLinkAnnotation );
|
|
||||||
// Re-register unregistered nodes.
|
|
||||||
ve.dm.modelRegistry.register( ve.dm.InlineImageNode );
|
|
||||||
ve.dm.modelRegistry.register( ve.dm.BlockImageNode );
|
|
||||||
|
|
||||||
ve.test.utils.mwEnvironment = ( function () {
|
|
||||||
var mwPlatform, corePlatform,
|
|
||||||
overrides = [
|
|
||||||
ve.dm.MWHeadingNode,
|
|
||||||
ve.dm.MWPreformattedNode,
|
|
||||||
ve.dm.MWTableNode,
|
|
||||||
ve.dm.MWExternalLinkAnnotation
|
|
||||||
],
|
|
||||||
overridden = [
|
|
||||||
ve.dm.InlineImageNode,
|
|
||||||
ve.dm.BlockImageNode
|
|
||||||
];
|
|
||||||
|
|
||||||
corePlatform = ve.init.platform;
|
|
||||||
mwPlatform = new ve.init.mw.Platform();
|
|
||||||
// Disable some API requests from platform
|
|
||||||
mwPlatform.imageInfoCache = null;
|
|
||||||
// Unregister mwPlatform
|
|
||||||
ve.init.platform = corePlatform;
|
|
||||||
|
|
||||||
function setupOverrides() {
|
|
||||||
var i;
|
|
||||||
for ( i = 0; i < overrides.length; i++ ) {
|
|
||||||
ve.dm.modelRegistry.register( overrides[ i ] );
|
|
||||||
}
|
|
||||||
for ( i = 0; i < overridden.length; i++ ) {
|
|
||||||
ve.dm.modelRegistry.unregister( overridden[ i ] );
|
|
||||||
}
|
|
||||||
ve.init.platform = mwPlatform;
|
|
||||||
}
|
|
||||||
|
|
||||||
function teardownOverrides() {
|
|
||||||
var i;
|
|
||||||
for ( i = 0; i < overrides.length; i++ ) {
|
|
||||||
ve.dm.modelRegistry.unregister( overrides[ i ] );
|
|
||||||
}
|
|
||||||
for ( i = 0; i < overridden.length; i++ ) {
|
|
||||||
ve.dm.modelRegistry.register( overridden[ i ] );
|
|
||||||
}
|
|
||||||
ve.init.platform = corePlatform;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On load, teardown overrides so the first core tests run correctly
|
|
||||||
teardownOverrides();
|
|
||||||
|
|
||||||
return {
|
|
||||||
setup: setupOverrides,
|
|
||||||
teardown: teardownOverrides
|
|
||||||
};
|
|
||||||
}() );
|
|
||||||
|
|
||||||
( function () {
|
( function () {
|
||||||
var getDomElementSummaryCore = ve.getDomElementSummary;
|
var getDomElementSummaryCore;
|
||||||
|
|
||||||
|
function MWDummyTarget() {
|
||||||
|
MWDummyTarget.super.call( this );
|
||||||
|
}
|
||||||
|
OO.inheritClass( MWDummyTarget, ve.test.utils.DummyTarget );
|
||||||
|
MWDummyTarget.prototype.setDefaultMode = function () {};
|
||||||
|
MWDummyTarget.prototype.parseWikitextFragment = function () {
|
||||||
|
// Ensure a mock server is used (e.g. as in ve.ui.MWWikitextStringTransferHandler)
|
||||||
|
return new mw.Api().post();
|
||||||
|
};
|
||||||
|
ve.test.utils.MWDummyTarget = MWDummyTarget;
|
||||||
|
|
||||||
|
// Unregister MW override nodes.
|
||||||
|
// They are temporarily registered in setup/teardown.
|
||||||
|
ve.dm.modelRegistry.unregister( ve.dm.MWHeadingNode );
|
||||||
|
ve.dm.modelRegistry.unregister( ve.dm.MWPreformattedNode );
|
||||||
|
ve.dm.modelRegistry.unregister( ve.dm.MWTableNode );
|
||||||
|
ve.dm.modelRegistry.unregister( ve.dm.MWExternalLinkAnnotation );
|
||||||
|
// Re-register unregistered nodes.
|
||||||
|
ve.dm.modelRegistry.register( ve.dm.InlineImageNode );
|
||||||
|
ve.dm.modelRegistry.register( ve.dm.BlockImageNode );
|
||||||
|
|
||||||
|
ve.test.utils.mwEnvironment = ( function () {
|
||||||
|
var mwPlatform, corePlatform, mwTarget, coreTarget,
|
||||||
|
overrides = [
|
||||||
|
ve.dm.MWHeadingNode,
|
||||||
|
ve.dm.MWPreformattedNode,
|
||||||
|
ve.dm.MWTableNode,
|
||||||
|
ve.dm.MWExternalLinkAnnotation
|
||||||
|
],
|
||||||
|
overridden = [
|
||||||
|
ve.dm.InlineImageNode,
|
||||||
|
ve.dm.BlockImageNode
|
||||||
|
];
|
||||||
|
|
||||||
|
corePlatform = ve.init.platform;
|
||||||
|
coreTarget = ve.init.target;
|
||||||
|
mwPlatform = new ve.init.mw.Platform();
|
||||||
|
// Disable some API requests from platform
|
||||||
|
mwPlatform.imageInfoCache = null;
|
||||||
|
// Unregister mwPlatform
|
||||||
|
ve.init.platform = corePlatform;
|
||||||
|
|
||||||
|
mwTarget = new ve.test.utils.MWDummyTarget();
|
||||||
|
// Unregister mwTarget
|
||||||
|
ve.init.target = coreTarget;
|
||||||
|
|
||||||
|
function setupOverrides() {
|
||||||
|
var i;
|
||||||
|
for ( i = 0; i < overrides.length; i++ ) {
|
||||||
|
ve.dm.modelRegistry.register( overrides[ i ] );
|
||||||
|
}
|
||||||
|
for ( i = 0; i < overridden.length; i++ ) {
|
||||||
|
ve.dm.modelRegistry.unregister( overridden[ i ] );
|
||||||
|
}
|
||||||
|
ve.init.platform = mwPlatform;
|
||||||
|
ve.init.target = mwTarget;
|
||||||
|
// Ensure the current target is appended to the current fixture
|
||||||
|
$( '#qunit-fixture' ).append( ve.init.target.$element );
|
||||||
|
}
|
||||||
|
|
||||||
|
function teardownOverrides() {
|
||||||
|
var i;
|
||||||
|
for ( i = 0; i < overrides.length; i++ ) {
|
||||||
|
ve.dm.modelRegistry.unregister( overrides[ i ] );
|
||||||
|
}
|
||||||
|
for ( i = 0; i < overridden.length; i++ ) {
|
||||||
|
ve.dm.modelRegistry.register( overridden[ i ] );
|
||||||
|
}
|
||||||
|
ve.init.platform = corePlatform;
|
||||||
|
ve.init.target = coreTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
// On load, teardown overrides so the first core tests run correctly
|
||||||
|
teardownOverrides();
|
||||||
|
|
||||||
|
return {
|
||||||
|
setup: setupOverrides,
|
||||||
|
teardown: teardownOverrides
|
||||||
|
};
|
||||||
|
}() );
|
||||||
|
|
||||||
|
getDomElementSummaryCore = ve.getDomElementSummary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override getDomElementSummary to extract HTML from data-mw/body.html
|
* Override getDomElementSummary to extract HTML from data-mw/body.html
|
||||||
|
|
Loading…
Reference in a new issue