summaryrefslogtreecommitdiff
path: root/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js')
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js61
1 files changed, 60 insertions, 1 deletions
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
index 7a58d38d..ba366553 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js
@@ -314,6 +314,66 @@
assert.equal( uri.toString(), 'http://www.example.com/dir/', 'empty array value is ommitted' );
} );
+ QUnit.test( 'Variable defaultUri', 2, function ( assert ) {
+ var uri,
+ href = 'http://example.org/w/index.php#here',
+ UriClass = mw.UriRelative( function () {
+ return href;
+ } );
+
+ uri = new UriClass();
+ assert.deepEqual(
+ {
+ protocol: uri.protocol,
+ user: uri.user,
+ password: uri.password,
+ host: uri.host,
+ port: uri.port,
+ path: uri.path,
+ query: uri.query,
+ fragment: uri.fragment
+ },
+ {
+ protocol: 'http',
+ user: undefined,
+ password: undefined,
+ host: 'example.org',
+ port: undefined,
+ path: '/w/index.php',
+ query: {},
+ fragment: 'here'
+ },
+ 'basic object properties'
+ );
+
+ // Default URI may change, e.g. via history.replaceState, pushState or location.hash (T74334)
+ href = 'https://example.com/wiki/Foo?v=2';
+ uri = new UriClass();
+ assert.deepEqual(
+ {
+ protocol: uri.protocol,
+ user: uri.user,
+ password: uri.password,
+ host: uri.host,
+ port: uri.port,
+ path: uri.path,
+ query: uri.query,
+ fragment: uri.fragment
+ },
+ {
+ protocol: 'https',
+ user: undefined,
+ password: undefined,
+ host: 'example.com',
+ port: undefined,
+ path: '/wiki/Foo',
+ query: { 'v': '2' },
+ fragment: undefined
+ },
+ 'basic object properties'
+ );
+ } );
+
QUnit.test( 'Advanced URL', 11, function ( assert ) {
var uri, queryString, relativePath;
@@ -429,6 +489,5 @@
uri = new UriClass( testPath );
href = uri.toString();
assert.equal( href, testProtocol + testServer + ':' + testPort + testPath, 'Root-relative URL gets host, protocol, and port supplied' );
-
} );
}( mediaWiki, jQuery ) );