jenkins-bot has submitted this change and it was merged. Change subject: resourceloader: Support absolute-path references in mw.loader.load() ......................................................................
resourceloader: Support absolute-path references in mw.loader.load() Follows-up b5e69c4ef621 which made loader sources no longer expanded urls. Change-Id: Ia2fcd13f46d548a98620c3e78b8f59b81d976eb4 --- M resources/src/mediawiki/mediawiki.js M tests/qunit/suites/resources/mediawiki/mediawiki.test.js 2 files changed, 18 insertions(+), 3 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index 122e512..5dd2acb 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -1902,9 +1902,10 @@ if ( typeof modules !== 'object' && typeof modules !== 'string' ) { throw new Error( 'modules must be a string or an array, not a ' + typeof modules ); } - // Allow calling with an external url or single dependency as a string + // Allow calling with a url or single dependency as a string if ( typeof modules === 'string' ) { - if ( /^(https?:)?\/\//.test( modules ) ) { + // "https://example.org/x.js", "http://example.org/x.js", "//example.org/x.js", "/x.js" + if ( /^(https?:)?\/?\//.test( modules ) ) { if ( type === 'text/css' ) { // Support: IE 7-8 // Use properties instead of attributes as IE throws security diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js index b55b1e7..111d85b 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js @@ -908,7 +908,7 @@ // This bug was actually already fixed in 1.18 and later when discovered in 1.17. // Test is for regressions! - // Forge an URL to the test callback script + // Forge a URL to the test callback script var target = QUnit.fixurl( mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/qunitOkCall.js' ); @@ -925,6 +925,20 @@ mw.loader.load( target ); } ); + QUnit.asyncTest( 'mw.loader( "/absolute-path" )', 2, function ( assert ) { + // Forge a URL to the test callback script + var target = QUnit.fixurl( + mw.config.get( 'wgScriptPath' ) + '/tests/qunit/data/qunitOkCall.js' + ); + + // Confirm that mw.loader.load() works with absolute-paths (relative to current hostname) + assert.equal( target.slice( 0, 1 ), '/', 'URL is relative to document root' ); + + // Async! + // The target calls QUnit.start + mw.loader.load( target ); + } ); + QUnit.asyncTest( 'mw.loader() executing race (T112232)', 2, function ( assert ) { var done = false; -- To view, visit https://gerrit.wikimedia.org/r/238647 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia2fcd13f46d548a98620c3e78b8f59b81d976eb4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Edokter <er...@darcoury.nl> Gerrit-Reviewer: Helder.wiki <helder.w...@gmail.com> Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits