mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 19:21:39 +00:00
72df451bd3
Help with readability by using module.exports and require rather than the MobileFrontend provided mw.mobileFrontend module manager (and avoid adopting webpack at this time) Replace usages of mw.mobileFrontend.require with local require and module.exports (compatible with RL or Node implementation) Changes: * Notifications modules are merged into skins.minerva.scripts and initialised via a client side check. * new file overlayManager for exporting an overlayManager singleton rather than being hidden inside resources/skins.minerva.scripts/init.js * All M.define/M.requires swapped out for require where possible The `define` method is now forbidden in the repo. Bug: T212944 Change-Id: I44790dd3fc6fe42bb502d79c39c4081c223bf2b1
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
( function () {
|
|
var UriUtil = require( '../../../resources/skins.minerva.scripts/UriUtil.js' );
|
|
|
|
QUnit.module( 'Minerva UriUtil', QUnit.newMwEnvironment( {
|
|
setup: function () {
|
|
this.mwUriOrg = mw.Uri;
|
|
mw.Uri = mw.UriRelative( 'https://meta.wikimedia.org/w/index.php' );
|
|
},
|
|
teardown: function () {
|
|
mw.Uri = this.mwUriOrg;
|
|
delete this.mwUriOrg;
|
|
}
|
|
} ) );
|
|
|
|
QUnit.test( '.isInternal()', function ( assert ) {
|
|
assert.strictEqual(
|
|
UriUtil.isInternal( new mw.Uri( '/relative' ) ),
|
|
true,
|
|
'relative URLs are internal'
|
|
);
|
|
assert.strictEqual(
|
|
UriUtil.isInternal( new mw.Uri( 'http://meta.wikimedia.org/' ) ),
|
|
true,
|
|
'matching hosts are internal'
|
|
);
|
|
assert.strictEqual(
|
|
UriUtil.isInternal( new mw.Uri( 'https:/meta.wikimedia.org/' ) ),
|
|
true,
|
|
'protocol is irrelevant'
|
|
);
|
|
assert.strictEqual(
|
|
UriUtil.isInternal( new mw.Uri( 'https://meta.wikimedia.org/path' ) ),
|
|
true,
|
|
'path is irrelevant'
|
|
);
|
|
assert.strictEqual(
|
|
UriUtil.isInternal( new mw.Uri( 'https://archive.org/' ) ),
|
|
false,
|
|
'external links are not internal'
|
|
);
|
|
assert.strictEqual(
|
|
UriUtil.isInternal( new mw.Uri( 'https://www.meta.wikimedia.org/' ) ),
|
|
false,
|
|
'differing subdomains are not internal'
|
|
);
|
|
} );
|
|
}() );
|