diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 9245137323c..fb6d92f1321 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -583,7 +583,7 @@ Extra newlines between heading and content are swallowed (Parsoid does not)
!! end
!! test
@@ -3016,6 +3016,36 @@ parsoid=wt2html
!! end
+# Regression test to prevent problematic simplifications of parser tests
+!! test
+Don't paragraph-wrap empty newlines between HTML list items
+!! options
+parsoid=wt2html
+!! wikitext
+
+
!! html/parsoid
-This is a caption
+This is a caption
!! end
!! test
@@ -15221,7 +15258,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/php
This is a caption
!! html/parsoid
-This is a caption
+This is a caption
!! end
!! test
@@ -15232,7 +15269,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
+
!! end
## Parsoid does not provide editing support for images where templates produce multiple image attributes.
@@ -15268,7 +15305,8 @@ thumbsize=220
!! html/parsoid
123456
123
456
-123
456
+123
+
456
!! end
!! test
@@ -15289,7 +15327,7 @@ Image with multiple widths -- use last
!! html/parsoid
-
+
!! end
!! test
@@ -15305,7 +15343,7 @@ thumbsize=220
!! html/parsoid
-caption
+caption
!! end
@@ -15320,9 +15358,9 @@ Image with width attribute at different positions
!! html/parsoid
-Caption
-Caption
-Caption
+Caption
+Caption
+Caption
!! end
# a sad bit of backward-compatibility
@@ -15338,7 +15376,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
+
!! end
!! test
@@ -15480,7 +15518,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/php
Title
!! html/parsoid
-Title
+Title
!! end
!! test
@@ -15607,7 +15645,7 @@ Alt image option should handle most kinds of wikitext without barfing
!! html/php
This is the image caption
!! html/parsoid
-This is the image caption
+This is the image caption
!! end
!! test
@@ -15635,7 +15673,7 @@ File:Foobar.jpg|alt=&
!! end
!! test
@@ -16134,9 +16176,9 @@ parsoid=wt2html,wt2wt,html2html
caption
caption
!! html/parsoid
-caption
-caption
-caption
+caption
+caption
+caption
!! end
###################
@@ -16149,6 +16191,7 @@ parsoid=wt2html,wt2wt,html2html
# 2. Framed images always ignore size options; always render at default size.
# 3. "Unspecified format" and border are the only types which can be
# enlarged.
+# 4. The srcset attribute doesn't occur if image is being enlarged
!! test
Image: unspecified format and border enlarge
@@ -16180,8 +16223,8 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
-
+
+
!! end
!! test
@@ -16193,7 +16236,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/php
!! html/parsoid
-
+
!! end
!! test
@@ -16209,7 +16252,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
+
!! end
!! test
@@ -16222,7 +16265,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
+
!! end
!! test
@@ -16239,7 +16282,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
+
!! end
!! test
@@ -16321,7 +16364,7 @@ thumbsize=220
!! html/php
!! html/parsoid
-caption
+caption
!! end
!! test
@@ -16357,7 +16400,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/php
caption
!! html/parsoid
-caption
+caption
!! end
!! test
@@ -16369,7 +16412,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/php
lang=invalid:language:code
!! html/parsoid
-lang=invalid:language:code
+lang=invalid:language:code
!! end
!! test
@@ -16401,7 +16444,7 @@ T3887: A ISBN with a thumbnail
!! html/php
!! html/parsoid
-This is a caption with another inside it!
+This is a caption with another inside it!
!! end
!! test
@@ -16566,7 +16609,7 @@ Image: caption containing leading space
!! html/php
bar
!! html/parsoid
- bar
+ bar
!!end
# html/php output not have newlines after table, td, th, etc. because
@@ -16588,7 +16631,7 @@ and some more text.]]
!! html/php
This is an example image thumbnail caption with a table
Foo
Bar
Foo1
Bar1
and some more text.
!! html/parsoid
-
This is an example image thumbnail caption with a table
+
This is an example image thumbnail caption with a table
Foo
Bar
@@ -16604,7 +16647,7 @@ T5090: External links other than http: in image captions
!! html/php
!! html/parsoid
-This caption has irc and Secure ext links in it.
+This caption has irc and Secure ext links in it.
!! end
!! test
@@ -16644,7 +16687,7 @@ language=es
!! html/php
caption
!! html/parsoid
-caption
+caption
!! end
!! test
@@ -16669,7 +16712,7 @@ parsoid=wt2html,wt2wt,html2html
!! html/parsoid
-
+
!! end
# Note that 'right' is the default alignment, despite the misspelled 'righ' below
@@ -16689,9 +16732,9 @@ parsoid=wt2html,wt2wt,html2html
!! end
!! test
@@ -16747,7 +16790,7 @@ parsoid=wt2wt,wt2html,html2html
!! wikitext
[[Image:Foobar.jpg|middle|50px]]
!! html/parsoid
-
+
!! end
!! test
@@ -16755,7 +16798,7 @@ Parsoid-specific image handling - simple image with size and middle alignment (e
!! wikitext
[[File:Foobar.jpg|50px|middle]]
!! html/parsoid
-
+
!! end
!! test
@@ -16765,7 +16808,7 @@ parsoid=wt2html,wt2wt,html2html
!! wikitext
[[Image:Foobar.jpg|50px|middle]]
!! html/parsoid
-
+
!! end
!! test
@@ -16773,7 +16816,7 @@ Parsoid-specific image handling - simple image with both sizes, a baseline align
!! wikitext
[[File:Foobar.jpg|500x10px|baseline|caption]]
!! html/parsoid
-
+
!! end
!! test
@@ -16781,7 +16824,7 @@ Parsoid-specific image handling - simple image with border and size spec
!! wikitext
[[File:Foobar.jpg|50px|border|caption]]
!! html/parsoid
-
+
!! end
!! test
@@ -16791,7 +16834,7 @@ parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|left|baseline|thumb|caption content]]
!! html/parsoid
-caption content
+caption content
!! end
!! test
@@ -16801,7 +16844,7 @@ parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|thumb|left|baseline|caption content]]
!! html/parsoid
-caption content
+caption content
!! end
!! test
@@ -16811,7 +16854,7 @@ parsoid=wt2html,html2html
!! wikitext
[[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
!! html/parsoid
-caption
+caption
!! end
!! test
@@ -16821,7 +16864,7 @@ parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
!! html/parsoid
-caption
+caption
!! end
!! test
@@ -16849,7 +16892,7 @@ Parsoid-specific image handling - frameless image with specific size, border, an
!! wikitext
[[File:Foobar.jpg|frameless|442x50px|border|caption]]
!! html/parsoid
-
+
!! end
!! test
@@ -16865,7 +16908,7 @@ Parsoid-specific image handling - caption with a template in it
!! wikitext
[[File:Foobar.jpg|thumb|200x23px|This caption has a {{1x|transclusion}} in it.]]
!! html/parsoid
-This caption has a transclusion in it.
+This caption has a transclusion in it.
!! end
!! test
@@ -16878,7 +16921,7 @@ foo
bar
!! html/parsoid
foo
-This caption has a
unbalanced tag in it.
+This caption has a
unbalanced tag in it.
bar
!! end
@@ -16889,7 +16932,7 @@ parsoid=wt2html,wt2wt
!! wikitext
[[File:Foobar.jpg|thumb|]]
!! html/parsoid
-
+
!! end
# empty captions don't get serialized unless we're in the "round trip" case
@@ -16916,7 +16959,7 @@ Parsoid-specific image handling - whitespace caption
!! wikitext
[[File:Foobar.jpg|thumb| ]]
!! html/parsoid
-
+
!! end
!! test
@@ -16939,7 +16982,7 @@ T93580: 1. Templated inside block images
!! html/parsoid
-Caption with templated ref: [1]
+Caption with templated ref: [1]
!! end
!! test
@@ -18970,6 +19013,7 @@ Test for unicode normalization
The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
!! endarticle
+# Parsoid has a regression here (T258858) note the incorrect redlink as well
!! test
(T21451) Links should refer to the normalized form.
!! wikitext
@@ -18978,13 +19022,19 @@ The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
[[אַ]]
[[אַ]]
[[אַ]]
-!! html
+!! html/php
!! end
!! test
@@ -22616,7 +22666,7 @@ Width + Height sized image (using px) (height is ignored)
!! html/parsoid
-
+
!! end
!! test
@@ -22627,7 +22677,7 @@ Width-sized image (using px, no following whitespace)
!! html/parsoid
-
+
!! end
!! test
@@ -22638,8 +22688,8 @@ Width-sized image (using px, with following whitespace - test regression from r3
!! html/parsoid
-
-!!end
+
+!! end
!! test
Width-sized image (using px, with preceding whitespace - test regression from r39467)
@@ -22649,21 +22699,80 @@ Width-sized image (using px, with preceding whitespace - test regression from r3
!! html/parsoid
-
+
!! end
-## FIXME: Parsoid mocking should include the page in the url to catch regressions
!! test
Image with page parameter
!! options
djvu
!! wikitext
+[[File:LoremIpsum.djvu]]
+
[[File:LoremIpsum.djvu|page=2]]
!! html/php
+
+
+
+!! html/parsoid
+
+
+!! end
+
+!! test
+Image with page parameter generated by a template
+!! options
+djvu
+!! wikitext
+[[File:LoremIpsum.djvu|page={{1x|2}}]]
+!! html/php
!! html/parsoid
-
+
+!! end
+
+!! test
+Image with modified page parameter; serialize href query not data-mw
+!! options
+djvu
+parsoid={
+ "modes": ["wt2wt", "selser"],
+ "changes": [
+ ["a[href]", "attr", "href", "./File:LoremIpsum.djvu?page=3"]
+ ]
+}
+!! wikitext
+[[File:LoremIpsum.djvu|page 2]]
+
+[[File:LoremIpsum.djvu|page {{1x|2}}]]
+!! wikitext/edited
+[[File:LoremIpsum.djvu|page 3]]
+
+[[File:LoremIpsum.djvu|page 3]]
+!! end
+
+# This tests for RESTBase content backward-compatibility;
+# the output should change when T259931 has been resolved (the page
+# parameter should be removed in the wikitext/edited section)
+!! test
+Image with modified page parameter; serialize href query not data-mw (2)
+!! options
+djvu
+parsoid={
+ "modes": ["wt2wt", "selser"],
+ "changes": [
+ ["a[href]", "attr", "href", "./File:LoremIpsum.djvu"]
+ ]
+}
+!! wikitext
+[[File:LoremIpsum.djvu|page 2]]
+
+[[File:LoremIpsum.djvu|page {{1x|2}}]]
+!! wikitext/edited
+[[File:LoremIpsum.djvu|page 2]]
+
+[[File:LoremIpsum.djvu|page {{1x|2}}]]
!! end
!! test
@@ -22691,7 +22800,7 @@ Images with the "|" character in the comment
!! html/php
!! end
@@ -22734,9 +22845,11 @@ Parents of subpages, one level up, not named
subpage title=[[Subpage test/L1/L2/L3]]
!! wikitext
[[../]]
-!! html
+!! html/php
!! end
!! test
@@ -22772,9 +22889,11 @@ Parents of subpages, two levels up, with lots of extra trailing slashes.
subpage title=[[Subpage test/L1/L2/L3]]
!! wikitext
[[../../////]]
-!! html
+!! html/php
!! end
!! article
@@ -23185,6 +23304,7 @@ Both [[Dunav]] and [[Дунав]] are names for this river.
content
!! endarticle
+# T258856: Parsoid doesn't handle redlink processing correctly in this case
!! test
Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
!! options
@@ -23195,9 +23315,10 @@ title=[[Duna]] language=sr
Дуна is not a self-link while Duna and Dуна are still self-links.
!! html/parsoid
-
Дуна is not a self-link while Duna and Dуна are still self-links.
+
Дуна is not a self-link while Duna and Dуна are still self-links.
!! end
+# T258856: Parsoid doesn't handle redlink processing correctly in this case
!! test
Link to a section of a variant of this title shouldn't be parsed as self-link
!! options
@@ -23208,9 +23329,10 @@ title=[[Duna]] language=sr
!! end
+# T258856: Parsoid doesn't handle redlink processing correctly in this case
!! test
Link to pages in language variants
!! options
@@ -23221,10 +23343,11 @@ Main Page can be written as [[Маин Паге]]
!! end
+# T258856: Parsoid doesn't handle redlink processing correctly in this case
!! test
Multiple links to pages in language variants
!! options
@@ -23235,7 +23358,7 @@ language=sr
!! end
@@ -24172,7 +24295,7 @@ language=sr
!! html/php
caption:
!! html/parsoid
-
+
!! end
!! test
@@ -24184,7 +24307,7 @@ language=zh variant=zh-cn
!! html/php
blog (hk: WEBJOURNAL, tw: WEBLOG)
!! html/parsoid
-
+
!! end
# XXX html2wt disabled because rich markup in alt is not preserved.
@@ -24217,8 +24340,8 @@ File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=-{R|param}-}}
!! html/parsoid
-
-
This is a test template
+
+
This is a test template
!! end
@@ -24805,7 +24928,7 @@ Free external link invading image caption
!! html/php
hello
!! html/parsoid
-hello
+hello
!! end
!! test
@@ -25501,10 +25624,10 @@ percent-encoding and + signs in internal links (T28410)
3E3E+
!! html/parsoid
-
-!! end
-
-# In this example, the template scope is mildly expanded to incorporate the
-# trailing newline after the transclusion since that is part of section 1.1.1
-!! test
-Section wrapping with template-generated sections (good nesting 2)
-!! options
-notoc
-parsoid={
- "wrapSections": true,
- "modes": ["wt2html", "wt2wt"]
-}
-!! wikitext
-=1=
-a
-
-{{1x|1=
-==1.1==
-b
-===1.1.1===
-d
-}}
-=2=
-e
-!! html/php+tidy
-
-
-!! end
-
-# In this example, the template scope is mildly expanded to incorporate the
-# trailing newline after the transclusion since that is part of section 1.2.1
-!! test
-Section wrapping with template-generated sections (good nesting 3)
-!! options
-notoc
-parsoid={
- "wrapSections": true,
- "modes": ["wt2html", "wt2wt"]
-}
-!! wikitext
-=1=
-a
-
-{{1x|1=
-x
-==1.1==
-b
-==1.2==
-c
-===1.2.1===
-d
-}}
-=2=
-e
-!! html/php+tidy
-
-
-!! end
-
-# Because of section-wrapping and template-wrapping interactions,
-# the scope of the template is expanded so that the template markup
-# is valid in the presence of tags.
-# This exercises the s1 is null scenario in the wrapSections code
-!! test
-Section wrapping with template-generated sections (bad nesting 1)
-!! options
-notoc
-parsoid={
- "wrapSections": true
-}
-!! wikitext
-
-a
-
-{{1x|1=
-=1=
-b
-}}
-
-c
-
-!! html/php+tidy
-
-
a
-
-
1
-
b
-
c
-
-
-!! html/parsoid
-
-
a
-
-
1
-
b
-
-
c
-
-!! end
-
-# Because of section-wrapping and template-wrapping interactions,
-# the scope of the template is expanded so that the template markup
-# is valid in the presence of tags.
-# This exercises the s1 is ancestor of s2 scenario in the wrapSections code
-!! test
-Section wrapping with template-generated sections (bad nesting 2)
-!! options
-notoc
-parsoid={
- "wrapSections": true
-}
-!! wikitext
-=1=
-a
-
-{{1x|1=
-=2=
-b
-==2.1==
-c
-}}
-
-d
-
-=3=
-e
-!! html/php+tidy
-
-
-!! end
-
-# Because of section-wrapping and template-wrapping interactions,
-# additional template wrappers are added to tags
-# so that template wrapping semantics are valid whether section
-# tags are retained or stripped. But, the template scope can expand
-# greatly when accounting for section tags.
-# This exercises the s1 and s2 are in different subtrees scenario
-!! test
-Section wrapping with template-generated sections (bad nesting 3)
-!! options
-notoc
-parsoid={
- "wrapSections": true,
- "modes": ["wt2html", "wt2wt"]
-}
-!! wikitext
-=1=
-a
-
-{{1x|1=
-==1.2==
-b
-=2=
-c
-}}
-
-d
-
-=3=
-e
-!! html/php+tidy
-
-
-
-!! end
-
-!! test
-HTML header tags should not be wrapped in section tags
-!! options
-notoc
-parsoid={
- "wrapSections": true
-}
-!! wikitext
-foo
-
-
-
-!! end
-
-!! test
-Pseudo-sections emitted by templates should have id -2
-!! options
-notoc
-parsoid={
- "wrapSections": true
-}
-!! wikitext
-foo
-{{1x|
-==a==
-==b==
-
-}}
-!! html/php+tidy
-
foo
-
-
-
a
-
b
-
-!! html/parsoid
-
foo
-
-
a
-
b
-
-
-!! end
-
-!! test
-T213468: Transcluded sections don't get PHP section numbers
-!! options
-notoc
-parsoid={
- "wrapSections": true
-}
-!! wikitext
-==PHP section=1==
-{{1x|1=
-== This is counted as if it were section 2 ==
-}}
-==PHP section=3==
-!! html/php+tidy
-
-!! end
-
-!! test
-T213468: Corner cases in edit section ID assignment in tokenizer
-!! options
-notoc
-parsoid={
- "wrapSections": true
-}
-!! wikitext
-==PHP section=1==
-{{1x|Not a section|
-== This is counted as if it were section 2 ==
-}}
-==PHP section=3==
-{{3x_on_newline|1=
-== This is counted as if it were section 4 ==
-}}
-==PHP section=5==
-{{#tag:p|Not a section|data-ignored=
-== This is counted as if it were section 6 ==
-}}
-==PHP section=7==
-{{1x|1=Not a ==heading==}}
-==PHP section=8==
-[[File:Foobar.jpg|thumb|
-==This is section 9, even though it's in a caption==
-]]
-==PHP section=10==
-!! html/php+tidy
-
-
-!! html/parsoid
-PARSOID HAS A BUG HERE: T215628
-!! end
-
##########################################################################
# Tests demonstrating white-space insensitivity in input wikitext
# for wikitext headings, wikitext list items, and wikitext table captions,
@@ -33478,7 +32807,7 @@ __NOTOC__