diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2021-09-24 23:52:05 +0100 |
---|---|---|
committer | Krinkle <krinklemail@gmail.com> | 2021-09-25 20:06:42 +0000 |
commit | 6d14529c691324bb132881044a65d6b764df7d8e (patch) | |
tree | bbd2ebe974d66e23e06491f1de9f3d5330c83210 /tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | |
parent | 1ed7ad4ffb501ac5ffd024125d628901ad968ea7 (diff) | |
download | mediawikicore-6d14529c691324bb132881044a65d6b764df7d8e.tar.gz mediawikicore-6d14529c691324bb132881044a65d6b764df7d8e.zip |
resourceloader: Preserve new 'debug' param in getScriptURLsForDebug()
Follows-up Ieaf04e0c289646dd5 which changed internal references to
bool(true) for 'debug' to the integer DEBUG_ constants, and introduced
a new debug=2 parameter.
In the refactor, I missed the setDebug() calls for
DerivativeResourceLoaderContext, which were still passing a boolean,
but more importantly were effectively passing debug=1 even if the
pageview carried debug=2. This isn't a problem yet in production since
debug=2 is currently identical in behaviour to debug=1.
The impact of this issue is mainly noticed through secondary CSS
requests. The URLs for primary stylesheets, and JS modules was already
forwarding the current "debug" version.
Test Plan:
* Open Main_Page?action=edit&debug=2
* Before this patch, e.g. on mediawiki.org today, secondary
stylesheet requests (part of a JS module) have debug=1.
For example "modules=jquery.makeCollapsible.styles&only=styles".
* After this, everything has debug=2 when the page view has debug=2.
Bug: T85805
Change-Id: Ia8fba4e30397bc5890033f13417b6739b0f83c38
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php')
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index 51f15355a857..e66b7f36569f 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -181,14 +181,17 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { } /** - * @covers ResourceLoader::expandUrl * @covers ResourceLoaderFileModule + * @covers ResourceLoaderModule + * @covers ResourceLoader::createLoaderURL + * @covers ResourceLoader::expandUrl */ - public function testGetScriptURLsForDebug() { + public function testGetURLsForDebug() { $ctx = $this->getResourceLoaderContext(); $module = new ResourceLoaderFileModule( [ 'localBasePath' => __DIR__ . '/../../data/resourceloader', 'remoteBasePath' => '/w/something', + 'styles' => [ 'simple.css' ], 'scripts' => [ 'script-comment.js' ], ] ); $module->setName( 'testing' ); @@ -198,7 +201,15 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { [ 'https://example.org/w/something/script-comment.js' ], - $module->getScriptURLsForDebug( $ctx ) + $module->getScriptURLsForDebug( $ctx ), + 'script urls' + ); + $this->assertEquals( + [ 'all' => [ + '/w/something/simple.css' + ] ], + $module->getStyleURLsForDebug( $ctx ), + 'style urls' ); } |