diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2018-03-27 17:57:06 -0700 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2018-05-19 22:14:33 +0200 |
commit | ee8a5e488edd0551476c5d0e437834f675533901 (patch) | |
tree | a05824d9bccecc05a7bdb89dfabe0c1271f4a0e3 /tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php | |
parent | 90988b3d8897fd2f1384433eaf148e3a02ce61ff (diff) | |
download | mediawikicore-ee8a5e488edd0551476c5d0e437834f675533901.tar.gz mediawikicore-ee8a5e488edd0551476c5d0e437834f675533901.zip |
resourceloader: Apply safemode to startup module registry
This effectively applies safemode to the mw.loader client,
without the client itself needing specific knowledge of safemode.
Test Plan:
* Unchanged: When viewing a page in safemode, the 'user' and
'site' modules are still not queued by OutputPage.
* New: mw.loader.getState('site'), previously would yield
'registered', but will now yield null.
* New: mw.loader.load('site'), previously loaded the module,
it now logs a dependency warning for unknown module, like for
any other unknown module.
* New: mw.loader.using('site'), previously resolved, it is now
rejected.
Bug: T185303
Change-Id: I672e3891c8e1b3c2d13655fa134d0f1d031b8247
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php')
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 5b5c484b4232..9b03c5ccdd67 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -259,6 +259,25 @@ Deprecation message.' ] } /** + * Confirm that 'safemode' is passed down to startup. + * + * @covers ResourceLoaderClientHtml::getHeadHtml + */ + public function testGetHeadHtmlWithSafemode() { + $client = new ResourceLoaderClientHtml( + self::makeContext(), + [ 'safemode' => '1' ] + ); + + // phpcs:disable Generic.Files.LineLength + $expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n" + . '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&safemode=1&skin=fallback"></script>'; + // phpcs:enable + + $this->assertEquals( $expected, $client->getHeadHtml() ); + } + + /** * Confirm that a null 'target' is the same as no target. * * @covers ResourceLoaderClientHtml::getHeadHtml |