] );
$client->setModuleScripts( [
'test.scripts',
+ 'test.scripts.user',
'test.scripts.user.empty',
'test.scripts.shouldembed',
'test.unregistered.scripts',
'test.styles.private' => 'ready',
'test.styles.shouldembed' => 'ready',
'test.scripts' => 'loading',
+ 'test.scripts.user' => 'loading',
'test.scripts.user.empty' => 'ready',
'test.scripts.shouldembed' => 'loading',
],
],
'scripts' => [
'test.scripts',
+ 'test.scripts.user',
'test.scripts.shouldembed',
],
'embed' => [
$this->assertEquals( $expected, $client->getHeadHtml() );
}
+ /**
+ * Confirm that 'target' is passed down to the startup module's load url.
+ *
+ * @covers ResourceLoaderClientHtml::getHeadHtml
+ */
+ public function testGetHeadHtmlWithTarget() {
+ $client = new ResourceLoaderClientHtml(
+ self::makeContext(),
+ [ 'target' => 'example' ]
+ );
+
+ // 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&skin=fallback&target=example"></script>';
+ // phpcs:enable
+
+ $this->assertEquals( $expected, $client->getHeadHtml() );
+ }
+
+ /**
+ * Confirm that a null 'target' is the same as no target.
+ *
+ * @covers ResourceLoaderClientHtml::getHeadHtml
+ */
+ public function testGetHeadHtmlWithNullTarget() {
+ $client = new ResourceLoaderClientHtml(
+ self::makeContext(),
+ [ 'target' => null ]
+ );
+
+ // 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&skin=fallback"></script>';
+ // phpcs:enable
+
+ $this->assertEquals( $expected, $client->getHeadHtml() );
+ }
+
/**
* @covers ResourceLoaderClientHtml::getBodyHtml
* @covers ResourceLoaderClientHtml::getLoad