Add another pixel test for an edited PDF that regressed
While fixing crbug.com/40932618, the fix caused a regression for other
edited PDFs. Add a test case for the regression, where there are
multiple cross reference streams linked together using the /Prev entries
in the cross reference streams. Rather than being linked by the /Prev
entries in the trailers.
As with other regression tests for edited PDFs:
- The file is yet another handcrafted variant of rectangles.pdf.
- The file uses the same fake objects technique as
testing/resources/pixel/bug_2123.pdf to deliberately confuse
CPDF_Parser::RebuildCrossRef().
Bug: 332462378
Change-Id: I08ef118c427b8133df279b92de2bdac4ac5e91c5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118310
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 96c84d12..f7b7efa 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -662,6 +662,9 @@
# TODO(chromium:237527): Remove after associated bug is fixed
bug_237527_1.in * * * *
+# TODO(crbug.com/332462378): Remove after associated bug is fixed
+bug_332462378.pdf * * * *
+
# TODO(chromium:451366): Remove after associated bug is fixed
bug_451366.in * * * agg
diff --git a/testing/resources/pixel/bug_332462378.pdf b/testing/resources/pixel/bug_332462378.pdf
new file mode 100644
index 0000000..558eca2
--- /dev/null
+++ b/testing/resources/pixel/bug_332462378.pdf
@@ -0,0 +1,136 @@
+%PDF-1.7
+% ò¤ô
+1 0 obj <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [0 0 200 350]
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+3 0 obj <<
+ /Type /Page
+ /Parent 2 0 R
+ /Contents 4 0 R
+>>
+endobj
+% Not actually used. This is just bait for the parser code that reconstructs
+% damaged PDFs.
+4 0 obj <<
+>>
+endobj
+% Actually used.
+4 0 obj <<
+ /Length 188
+>>
+stream
+q
+0 0 0 rg
+0 290 10 10 re B*
+10 150 50 30 re B*
+0 0 1 rg
+190 290 10 10 re B*
+70 232 50 30 re B*
+0 1 0 rg
+190 0 10 10 re B*
+130 150 50 30 re B*
+1 0 0 rg
+0 0 10 10 re B*
+70 67 50 30 re B*
+Q
+endstream
+endobj
+% Not actually used. This is just bait for the parser code that reconstructs
+% damaged PDFs.
+4 0 obj <<
+>>
+endobj
+5 0 obj <<
+ /Type /XRef
+ /Filter /ASCIIHexDecode
+ /Length 72
+ /Root 1 0 R
+ /Size 6
+ /W [1 2 1]
+>>
+stream
+00 00 00 FF
+01 00 0F 00
+01 00 44 00
+01 00 9D 00
+01 01 65 00
+01 02 C7 00
+endstream
+endobj
+xref
+0 6
+0000000000 65535 f
+0000000015 00000 n
+0000000068 00000 n
+0000000157 00000 n
+0000000357 00000 n
+0000000711 00000 n
+trailer <<
+ /Root 1 0 R
+ /Size 6
+>>
+startxref
+911
+%%EOF
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [0 0 200 400]
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+xref
+2 1
+0000001098 00000 n
+trailer <<
+ /Prev 911
+ /Root 1 0 R
+ /Size 6
+ /XRefStm 711
+>>
+startxref
+1187
+%%EOF
+2 0 obj <<
+ /Type /Pages
+ /MediaBox [0 0 200 300]
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+6 0 obj <<
+ /Type /XRef
+ /Filter /ASCIIHexDecode
+ /Length 24
+ /Root 1 0 R
+ /Size 7
+ /Index [2 1 6 1]
+ /Prev 1187
+ /W [1 2 1]
+>>
+stream
+01 05 16 00
+01 05 6F 00
+endstream
+endobj
+xref
+2 1
+0000001302 00000 n
+trailer <<
+ /Prev 1187
+ /Root 1 0 R
+ /Size 7
+ /XRefStm 1391
+>>
+startxref
+1575
+%%EOF
diff --git a/testing/resources/pixel/bug_332462378_expected.pdf.0.png b/testing/resources/pixel/bug_332462378_expected.pdf.0.png
new file mode 100644
index 0000000..ee652fa
--- /dev/null
+++ b/testing/resources/pixel/bug_332462378_expected.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/bug_332462378_expected_gdi.pdf.0.png b/testing/resources/pixel/bug_332462378_expected_gdi.pdf.0.png
new file mode 100644
index 0000000..72da0cd
--- /dev/null
+++ b/testing/resources/pixel/bug_332462378_expected_gdi.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/bug_332462378_expected_skia.pdf.0.png b/testing/resources/pixel/bug_332462378_expected_skia.pdf.0.png
new file mode 100644
index 0000000..8a6b8ed
--- /dev/null
+++ b/testing/resources/pixel/bug_332462378_expected_skia.pdf.0.png
Binary files differ