X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FHtmlTest.php;h=5cc59b39781566f8c9f21bfab7b322066e2669cd;hb=7c091e68e9e9f8dcc5c09353671566f24719009b;hp=3c8fa25dafe533bd15f46b980b2064e16dd1efc8;hpb=925c20a9ca669c67cc44f4468d0e0f3b33b94213;p=lhc%2Fweb%2Fwiklou.git
diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php
index 3c8fa25daf..5cc59b3978 100644
--- a/tests/phpunit/includes/HtmlTest.php
+++ b/tests/phpunit/includes/HtmlTest.php
@@ -1,6 +1,7 @@
setUserLang( $langObj );
$this->setContentLang( $langObj );
+ $this->restoreWarnings = false;
+ }
+
+ protected function tearDown() {
+ Language::factory( 'en' )->resetNamespaces();
+
+ if ( $this->restoreWarnings ) {
+ $this->restoreWarnings = false;
+ Wikimedia\restoreWarnings();
+ }
+
+ parent::tearDown();
}
/**
@@ -476,6 +489,10 @@ class HtmlTest extends MediaWikiTestCase {
Html::errorBox( 'err', 'heading' ),
'
heading
err'
);
+ $this->assertEquals(
+ Html::errorBox( 'err', '0' ),
+ '0
err'
+ );
}
/**
@@ -785,6 +802,58 @@ class HtmlTest extends MediaWikiTestCase {
public function testSrcSet( $images, $expected, $message ) {
$this->assertEquals( Html::srcSet( $images ), $expected, $message );
}
+
+ public static function provideInlineScript() {
+ return [
+ 'Empty' => [
+ '',
+ ''
+ ],
+ 'Simple' => [
+ 'EXAMPLE.label("foo");',
+ ''
+ ],
+ 'Ampersand' => [
+ 'EXAMPLE.is(a && b);',
+ ''
+ ],
+ 'HTML' => [
+ 'EXAMPLE.label("");',
+ ''
+ ],
+ 'Script closing string (lower)' => [
+ 'EXAMPLE.label("");',
+ '',
+ true,
+ ],
+ 'Script closing with non-standard attributes (mixed)' => [
+ 'EXAMPLE.label("");',
+ '',
+ true,
+ ],
+ 'HTML-comment-open and script-open' => [
+ // In HTML, ,
+ // there are levels of escaping modes, and the below sequence puts an
+ // HTML parser in a state where would *not* close the script.
+ // https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escape-end-state
+ 'var a = "