Drop support for XHTML 1.0
[lhc/web/wiklou.git] / tests / phpunit / includes / SanitizerTest.php
index c84f10c..b745423 100644 (file)
@@ -71,8 +71,6 @@ class SanitizerTest extends MediaWikiTestCase {
         */
        function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) {
                $this->setMwGlobals( array(
-                       # Enable HTML5 mode
-                       'wgHtml5' => true,
                        'wgUseTidy' => false
                ) );
 
@@ -101,18 +99,43 @@ class SanitizerTest extends MediaWikiTestCase {
                );
        }
 
-       function testSelfClosingTag() {
-               $this->setMwGlobals( array(
-                       'wgUseTidy' => false
-               ) );
-
-               $this->assertEquals(
-                       '<div>Hello world</div>',
-                       Sanitizer::removeHTMLtags( '<div>Hello world</div />' ),
-                       'Self-closing closing div'
+       function dataRemoveHTMLtags() {
+               return array(
+                       // former testSelfClosingTag
+                       array(
+                               '<div>Hello world</div />',
+                               '<div>Hello world</div>',
+                               'Self-closing closing div'
+                       ),
+                       // Make sure special nested HTML5 semantics are not broken
+                       // http://www.whatwg.org/html/text-level-semantics.html#the-kbd-element
+                       array(
+                               '<kbd><kbd>Shift</kbd>+<kbd>F3</kbd></kbd>',
+                               '<kbd><kbd>Shift</kbd>+<kbd>F3</kbd></kbd>',
+                               'Nested <kbd>.'
+                       ),
+                       // http://www.whatwg.org/html/text-level-semantics.html#the-sub-and-sup-elements
+                       array(
+                               '<var>x<sub><var>i</var></sub></var>, <var>y<sub><var>i</var></sub></var>',
+                               '<var>x<sub><var>i</var></sub></var>, <var>y<sub><var>i</var></sub></var>',
+                               'Nested <var>.'
+                       ),
+                       // http://www.whatwg.org/html/text-level-semantics.html#the-dfn-element
+                       array(
+                               '<dfn><abbr title="Garage Door Opener">GDO</abbr></dfn>',
+                               '<dfn><abbr title="Garage Door Opener">GDO</abbr></dfn>',
+                               '<abbr> inside <dfn>',
+                       ),
                );
        }
 
+       /**
+        * @dataProvider dataRemoveHTMLtags
+        */
+       function testRemoveHTMLtags( $input, $output, $msg = null ) {
+               $GLOBALS['wgUseTidy'] = false;
+               $this->assertEquals( $output, Sanitizer::removeHTMLtags( $input ), $msg );
+       }
 
        /**
         * @dataProvider provideTagAttributesToDecode