From caebba387a00802a6c8fdc0f53fec3cbab244be0 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Wed, 14 Dec 2016 14:55:46 -0500 Subject: [PATCH] Sync up with Parsoid parserTests. This now aligns with Parsoid commit 73798df0632e10313b82987d0b99e93c73407ca7 Change-Id: Ia0e511311eb05276617cc7bdff72b07347591ca3 --- tests/parser/parserTests.txt | 555 +++++++++++++++++++++++++++-------- 1 file changed, 426 insertions(+), 129 deletions(-) diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 5b17eacab0..07d50a8ce8 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -271,6 +271,12 @@ Template:EmptyTRWithHTMLAttrTest !!endarticle +!! article +Template:CircularRef +!! text +{{CircularRef}} +!! endarticle + ### ### Basic tests ### @@ -280,6 +286,15 @@ Blank input !! html !! end +!! test +CircularRef +!! wikitext +{{CircularRef}} + +!! html/parsoid +

[1]

+
  1. ↑ Error: Expansion loop detected at Template:CircularRef
+!! end !! test Simple paragraph @@ -2727,6 +2742,10 @@ Templates: Handle comments in the target |foo}} +{{echo + + |foo}} + {{echo |foo}} @@ -2738,10 +2757,13 @@ Templates: Handle comments in the target

foo

foo

foo +

foo

!! html/parsoid

foo

+

foo

+

foo

foo

@@ -3686,7 +3708,6 @@ Definition and unordered list using wiki syntax nested in unordered list using h !! end !! test - Definition list with empty definition and following paragraph !! wikitext ; term: @@ -7596,8 +7617,6 @@ Link with multiple pipes

!! end -# Note that parsoid does not munge anchor text; all non-space -# characters are valid in HTML5 ids. !! test Anchor containing a #. (bug 63430) !! wikitext @@ -7606,7 +7625,7 @@ Anchor containing a #. (bug 63430)

Main Page#And#Link

!! html/parsoid -

Main Page#And#Link

+

Main Page#And#Link

!! end !! test @@ -7721,18 +7740,16 @@ Link containing % as a double hex sequence interpreted to hex sequence

!!end -# note that parsoid does not munge anchor text; all non-space -# characters are valid in HTML5 anchors. +## Example for such a section: == < == !! test Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors -Example for such a section: == < == !! wikitext [[%23%3c]][[%23%3e]] !! html/php

#<#>

!! html/parsoid -

#<#>

+

#<#>

!! end !! test @@ -8252,7 +8269,7 @@ Link with angle bracket after anchor

Foo#<bar>

!! html/parsoid -

Foo#<bar>

+

Foo#<bar>

!! end ### @@ -8310,6 +8327,23 @@ Interwiki link with fragment (bug 2130)

!! end +!! test +Link scenarios with escaped fragments +!! wikitext +[[#Is this great?]] +[[Foo#Is this great?]] +[[meatball:Foo#Is this great?]] +!! html/php +

#Is this great? +Foo#Is this great? +meatball:Foo#Is this great? +

+!! html/parsoid +

#Is this great? +Foo#Is this great? +meatball:Foo#Is this great?

+!! end + # Ideally the wikipedia: prefix here should be proto-relative too # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't # define the 'en' prefix, and originally the test used 'wikipedia', @@ -10374,7 +10408,6 @@ language=de

!! end - !! test Urlencode !! wikitext @@ -10382,7 +10415,7 @@ Urlencode {{urlencode:hi world?!|WIKI}} {{urlencode:hi world?!|PATH}} {{urlencode:hi world?!|QUERY}} -!! html +!! html/php

hi+world%3F%21 hi_world%3F! hi%20world%3F%21 @@ -15929,7 +15962,7 @@ parsoid=wt2html,html2html

HTML rocks
!! html/parsoid -
HTML rocks
+
HTML rocks
!! end !! test @@ -17107,9 +17140,11 @@ Table not started Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" !! wikitext byte[[#æ: v|backlink]] -!! html +!! html/php

bytebacklink

+!! html/parsoid +

bytebacklink

!! end # In HTML5, the restrictions are that id must contain at least one character, @@ -18858,8 +18893,14 @@ title=[[Parser test]] !! end ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included. +## Parsoid thinks the "centre" here is a property, not a caption. !! test Gallery +!! options +parsoid={ + "modes": ["wt2html"], + "nativeGallery": true +} !! wikitext image1.png | @@ -18871,7 +18912,7 @@ image4 |300px| centre [[x|xx]]]] * image6 -!! html +!! html/php +!! html/parsoid + !! end !! test -Gallery (with options) +Gallery (with options, html) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} !! wikitext - + File:Nonexistent.jpg|caption File:Nonexistent.jpg image:foobar.jpg|some '''caption''' [[Main Page]] image:foobar.jpg image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla. -!! html +!! html/php + + +!! html/parsoid + +!! end + +!! test +Gallery (with options, extsrc) +!! options +parsoid={ + "nativeGallery": false +} +!! wikitext + +File:Nonexistent.jpg|caption +File:Nonexistent.jpg +image:foobar.jpg|some '''caption''' [[Main Page]] +image:foobar.jpg +image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla. + +!! html/php +!! html/parsoid + !! end !! test Gallery with link that has fragment +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} !! wikitext image:foobar.jpg|link=Main_Page image:foobar.jpg|link=Main_Page#section image:foobar.jpg|link=Main Page#section|caption -!! html +!! html/php +!! html/parsoid + +!! end + +## Whoops, Parsoid shouldn't be parsing templates in the attribute caption! +!! test +Gallery with template inside caption +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext + +File:Foobar.jpg|{{echo|ho}} + +!! html/php + + +!! html/parsoid + !! end !! test Gallery with wikitext inside caption +!! options +parsoid={ + "nativeGallery": true +} !! wikitext -File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=inneralt]]|alt=galleryalt -File:foobar.jpg|{{Test|unamedParam|alt=param}}|alt=galleryalt +File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]] +File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}} -!! html +!! html/php +!! html/parsoid + !! end !! test -gallery (with showfilename option) +Gallery (with showfilename option) +!! options +parsoid={ + "nativeGallery": true +} !! wikitext - + File:Nonexistent.jpg|caption File:Nonexistent.jpg -image:foobar.jpg|some '''caption''' [[Main Page]] +File:Foobar.jpg|some '''caption''' [[Main Page]] File:Foobar.jpg -!! html +!! html/php +!! html/parsoid + !! end +## Should Parsoid be preserving these variations? !! test Gallery (with namespace-less filenames) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} !! wikitext File:Nonexistent.jpg @@ -19071,7 +19263,7 @@ Nonexistent.jpg image:foobar.jpg foobar.jpg -!! html +!! html/php +!! html/parsoid + +!! end + +!! test +Gallery override link with WikiLink (T36852) +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext + +File:Foobar.jpg|alt=galleryalt|link=InterWikiLink + +!! html/php + + +!! html/parsoid + +!! end + +!! test +Gallery override link with absolute external link (T36852) +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext + +File:Foobar.jpg|alt=galleryalt|link=http://www.example.org + +!! html/php + + +!! html/parsoid + +!! end + +!! test +Gallery override link with malicious javascript (T36852) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext + +File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!'); + +!! html/php + + +!! html/parsoid + +!! end + +!! test +Gallery with invalid title as link (T45964) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext + +File:Foobar.jpg|link=< + +!! html/php + + +!! html/parsoid + !! end !! test @@ -20954,7 +21255,7 @@ Edit comment with link with more than one pipe (T99346) comment !! wikitext [[Main Page|Many|pipes]] -!! html +!! html/php Many|pipes !! end @@ -20964,7 +21265,7 @@ Complex edit comment with link with more than one pipe (T99346) comment !! wikitext Created page with "[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]] === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..." -!! html +!! html/php Created page with "<noinclude>{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}</noinclude> === User:MineoBot 8=== {{Request for permissions/links|Mineo..." !! end @@ -21765,7 +22066,7 @@ Strip marker in urlencode {{urlencode:xy|wiki}} {{urlencode:xy|path}} {{urlencode:x
two
y}} -!! html +!! html/php

xy xy xy @@ -21903,81 +22204,7 @@ Ignore pipe between table row attributes !! end -!!test -Gallery override link with WikiLink (bug 34852) -!! wikitext - -File:foobar.jpg|caption|alt=galleryalt|link=InterWikiLink - -!! html -

- -!! end - -!!test -Gallery override link with absolute external link (bug 34852) -!! wikitext - -File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org - -!! html - - -!! end - -!!test -Gallery override link with malicious javascript (bug 34852) -!! wikitext - -File:foobar.jpg|caption|alt=galleryalt|link=" onclick="alert('malicious javascript code!'); - -!! html - - -!! end - -!!test -Gallery with invalid title as link (bug 43964) -!! wikitext - -File:foobar.jpg|link=< - -!! html - - -!! end - -!!test +!! test Language parser function !! wikitext {{#language:ar}} @@ -22394,19 +22621,20 @@ Ref: 13. ref-tags are not SOL-transparent and block indent-pres !!end -!!test +## Roundtripping fails because of nowiki'ing +!! test Ref: 14. A nested ref-tag should be emitted as plain text +!! options +parsoid=wt2html !! wikitext foo bar baz !! html/parsoid -

[1] -

-
    -
  1. ↑ foo <ref>bar</ref> baz
  2. -
-!!end +

[1] baz</ref>

+ +
  1. ↑ foo <ref>bar
+!! end !!test Ref: 15. ref-tags with identical names should get identical indexes @@ -22725,24 +22953,6 @@ foo foo
    !! end -#### ---------------------------------------------------------------- -#### Parsoid-only testing of Parsoid's impl of LST -#### Not implemented yet, see -#### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST -#### ---------------------------------------------------------------- - -!! test -LST Sections: 1. Simple section start and end -!! options -parsoid={ "suppressErrors": true } -!! wikitext -
    -
    -!! html/parsoid -

    -

    -!! end - #--------- Test stripping of empty nodes in template content ---------- !!test Empty LI and TR nodes should be stripped from template content @@ -26395,6 +26605,93 @@ parsoid=html2wt,wt2wt !! end +!! test +T149209: WTS: Handle newlines in table cells properly +!! options +parsoid=html2wt +!! html/parsoid + + + + +
    a +b +c

    x

    +
    y
    + + + + +
    a +b +c

    x +

    y
    +!! wikitext +{| +|a +b +|c +|- +|x +{{!}}y +|} +{| +!a +b +!c +|- +!x +!y +|} +!! end + +!! test +T149209: Selser: Handle newlines in table cells properly +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "#h1", "html", "a\nb\n" ], + [ "#h2", "html", "a\nb\n" ], + [ "#c1", "html", "a\nb\n" ], + [ "#c2", "html", "

    a

    " ], + [ "#c3", "html", "

    a

    " ] + ] +} +!! wikitext +{| +! id="h1" |edit-me!!1 +|- +! id="h2" |edit-me||2 +|- +| id="c1" |edit-me||3 +|- +| id="c2" |edit-me||4 +|- +| id="c3" |edit-me||p||q||r +|} +!! wikitext/edited +{| +! id="h1" |a +b +!1 +|- +! id="h2" |a +b +!2 +|- +| id="c1" |a +b +|3 +|- +| id="c2" |a +|4 +|- +| id="c3" |a +|p||q||r +|} +!! end + !! test HTML id attribute with Parsoid-like element ids should not be serialized to wikitext !! options -- 2.20.1