2013-10-05 10:27:39 +00:00
|
|
|
/*!
|
2017-06-22 19:55:28 +00:00
|
|
|
* VisualEditor MediaWiki-specific ContentEditable Surface tests.
|
2013-10-05 10:27:39 +00:00
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
2013-10-05 10:27:39 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2022-03-04 13:48:14 +00:00
|
|
|
QUnit.module( 've.ce.Surface (MW)', ve.test.utils.newMwEnvironment() );
|
2013-10-05 10:27:39 +00:00
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2021-04-30 09:33:22 +00:00
|
|
|
QUnit.test( 'beforePaste/afterPaste', ( assert ) => {
|
2021-04-29 14:42:18 +00:00
|
|
|
const cases = [
|
2019-11-06 14:53:03 +00:00
|
|
|
{
|
|
|
|
documentHtml: '<p></p>',
|
|
|
|
rangeOrSelection: new ve.Range( 1 ),
|
|
|
|
pasteHtml: '<span typeof="mw:Entity" id="mwAB">-</span><span typeof="mw:Entity" id="mw-reference-cite">-</span>',
|
|
|
|
fromVe: true,
|
|
|
|
expectedRangeOrSelection: new ve.Range( 5 ),
|
|
|
|
expectedHtml: '<p><span typeof="mw:Entity">-</span><span typeof="mw:Entity" id="mw-reference-cite">-</span></p>',
|
|
|
|
msg: 'RESTBase IDs stripped'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
documentHtml: '<p></p>',
|
|
|
|
rangeOrSelection: new ve.Range( 1 ),
|
|
|
|
pasteHtml: '<span typeof="mw:Entity" id="mwAB">-</span><span typeof="mw:Entity" id="mw-reference-cite">-</span>',
|
|
|
|
pasteTargetHtml: '<span>-</span><span>-</span>',
|
|
|
|
fromVe: true,
|
|
|
|
expectedRangeOrSelection: new ve.Range( 5 ),
|
|
|
|
expectedHtml: '<p><span typeof="mw:Entity">-</span><span typeof="mw:Entity" id="mw-reference-cite">-</span></p>',
|
|
|
|
msg: 'RESTBase IDs still stripped if used when important attributes dropped'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
documentHtml: '<p></p>',
|
|
|
|
rangeOrSelection: new ve.Range( 1 ),
|
|
|
|
pasteHtml: 'a<sup id="cite_ref-1" class="reference"><a href="./Article#cite_note-1">[1]</a></sup>b',
|
|
|
|
expectedRangeOrSelection: new ve.Range( 3 ),
|
|
|
|
expectedHtml: '<p>ab</p>',
|
|
|
|
msg: 'Read mode references stripped'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
documentHtml: '<p></p>',
|
|
|
|
rangeOrSelection: new ve.Range( 1 ),
|
2020-11-06 17:50:00 +00:00
|
|
|
pasteHtml: 'a<sup typeof="mw:Extension/ref" data-mw="{}" class="mw-ref reference" about="#mwt1" id="cite_ref-foo-0" rel="dc:references"><a href="./Article#cite_note-foo-0"><span class="mw-reflink-text ve-pasteProtect">[1]</span></a></sup>b',
|
2019-11-06 14:53:03 +00:00
|
|
|
expectedRangeOrSelection: new ve.Range( 5 ),
|
2020-11-06 17:50:00 +00:00
|
|
|
expectedHtml: '<p>a<sup typeof="mw:Extension/ref" data-mw="{"name":"ref"}" class="mw-ref reference"><a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>b</p>',
|
2019-11-06 14:53:03 +00:00
|
|
|
msg: 'VE references not stripped'
|
2022-03-30 12:34:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
documentHtml: '<p></p>',
|
|
|
|
rangeOrSelection: new ve.Range( 1 ),
|
|
|
|
pasteHtml: 'Lorem <a href="mailto:someone@somewhere.net">ipsum</a> dolor sit amet',
|
|
|
|
expectedRangeOrSelection: new ve.Range( 27 ),
|
|
|
|
expectedHtml: '<p>Lorem <a href="mailto:someone@somewhere.net" rel="mw:ExtLink">ipsum</a> dolor sit amet</p>',
|
|
|
|
config: {
|
|
|
|
importRules: {
|
|
|
|
external: {
|
|
|
|
blacklist: {
|
|
|
|
'link/mwExternal': false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
msg: '"mailto:" pseudo protocol not recognized'
|
2019-11-06 14:53:03 +00:00
|
|
|
}
|
|
|
|
];
|
2016-10-11 19:48:02 +00:00
|
|
|
|
2019-11-06 14:53:03 +00:00
|
|
|
cases.forEach( ve.test.utils.runSurfacePasteTest.bind( this, assert ) );
|
2016-10-11 19:48:02 +00:00
|
|
|
} );
|