Repository navigation
Add HtmlRenderer.Test project, port applicable tests from PeachPDF #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bc7f351
Add HtmlRenderer.Test project, port applicable tests from PeachPDF
jhaygood86 69f5ef0
Fix non-Windows CI test step for multiple *.Test.csproj matches
jhaygood86 bf2de64
Fix ported tests broken by the CSS engine port and adapter API drift
jhaygood86 0091828
Un-ignore tests the CSS engine port genuinely fixed
jhaygood86 3aa8b22
Port PeachPDF CSS engine tests now that HTML-Renderer has a real CSS …
jhaygood86 6deac2d
Fix MSTEST0017: swapped actual/expected args in GapPropertyTests
jhaygood86 8dc1f7e
Remove unused Microsoft.Win32.Registry package reference
jhaygood86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
Source/Test/HtmlRenderer.IntegrationTest/BoxModel/AtomicInlineLevelBoxCorrectionTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| using HtmlRenderer.IntegrationTest.TestSupport; | ||
|
|
||
| namespace HtmlRenderer.IntegrationTest.BoxModel; | ||
|
|
||
| /// <summary> | ||
| /// DomParser's "block inside inline" DOM-correction pass (CorrectBlockInsideInline) should never look through an | ||
| /// inline-level box that establishes its own independent formatting context (inline-block/inline-table both do) | ||
| /// when deciding whether an ANCESTOR box needs splitting - DomUtils.ContainsInlinesOnly is meant to make such a | ||
| /// box opaque for that purpose. A child whose own resolved display is "none" (not "inline") should not make the | ||
| /// correction pass misclassify the box's content as containing a "block", incorrectly splitting the child out of | ||
| /// its real parent entirely. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The triage note for this file claimed both cases already pass on this fork. Direct testing shows otherwise | ||
| /// for the inline-block case: dumping the box tree for the <select>/<option> markup below shows | ||
| /// <c>opt1</c> (the FIRST display:none <option>) gets hoisted out from under <select> entirely and | ||
| /// becomes a sibling of the anonymous block box CorrectInlineBoxesParent wraps <select> in, while | ||
| /// <c>opt2</c> (the second, otherwise-identical <option>) correctly stays nested. That first-child-only | ||
| /// asymmetry is exactly the atomic-inline-level gap the class doc describes - it just was not caught by the | ||
| /// triage pass. The inline-table case genuinely does pass, so only the inline-block test method is ignored | ||
| /// (with the real, faithfully-ported assertions kept, to document the target behavior). | ||
| /// </remarks> | ||
| [DoNotParallelize] | ||
| [TestClass] | ||
| public sealed class AtomicInlineLevelBoxCorrectionTests | ||
| { | ||
| [Ignore("Confirmed real bug on this fork, not a porting mistake: dumping the box tree shows opt1 (the " + | ||
| "FIRST display:none <option> child of an inline-block <select>) gets hoisted out from under " + | ||
| "<select> and becomes a sibling of the anonymous block wrapper CorrectInlineBoxesParent creates, " + | ||
| "while opt2 (second, otherwise-identical child) stays correctly nested. DomUtils.ContainsInlinesOnly " + | ||
| "does not treat inline-block as opaque the way an atomic-inline-level check should.")] | ||
| [TestMethod] | ||
| public void DisplayNoneChildOfInlineBlockBox_StaysNestedUnderItsRealParent() | ||
| { | ||
| var html = LayoutHarness.Wrap( | ||
| "<select id='sel'>" + | ||
| "<option id='opt1' style='display:none'>Red</option>" + | ||
| "<option id='opt2' style='display:none'>Green</option>" + | ||
| "</select>"); | ||
|
|
||
| var (root, _) = LayoutHarness.Layout(html); | ||
| var select = LayoutHarness.FindById(root, "sel")!; | ||
| var opt1 = LayoutHarness.FindById(root, "opt1")!; | ||
| var opt2 = LayoutHarness.FindById(root, "opt2")!; | ||
|
|
||
| Assert.IsTrue(IsDescendantOf(opt1, select), "opt1 (display:none) must stay nested under its real <select> parent."); | ||
| Assert.IsTrue(IsDescendantOf(opt2, select), "opt2 must stay nested under its real <select> parent."); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void DisplayNoneChildOfInlineTableBox_StaysNestedUnderItsRealParent() | ||
| { | ||
| var html = LayoutHarness.Wrap( | ||
| "<div id='wrap'>" + | ||
| "<div id='it' style='display:inline-table'>" + | ||
| "<div style='display:table-row'><div id='cell' style='display:table-cell'>cell</div></div>" + | ||
| "<div id='hidden' style='display:none'>hidden</div>" + | ||
| "</div>" + | ||
| "</div>"); | ||
|
|
||
| var (root, _) = LayoutHarness.Layout(html); | ||
| var inlineTable = LayoutHarness.FindById(root, "it")!; | ||
| var hidden = LayoutHarness.FindById(root, "hidden")!; | ||
|
|
||
| Assert.IsTrue(IsDescendantOf(hidden, inlineTable), "a display:none sibling inside an inline-table must stay nested under it."); | ||
| } | ||
|
|
||
| // PeachPDF's source file also has a "DisplayNoneChildOfInlineFlexBox_StillStaysNestedUnderItsRealParent" | ||
| // regression case, guarding pre-existing display:inline-flex handling. HTML-Renderer (this fork) implements | ||
| // no flexbox layout at all - "flex"/"inline-flex" are not recognized display values anywhere in | ||
| // TheArtOfDev.HtmlRenderer.Core (confirmed: no "flex" hits in the Core source tree) - so there is no such | ||
| // pre-existing handling to guard, and porting that case would document a feature this fork doesn't have. | ||
| // Intentionally dropped rather than ported under a false premise. | ||
|
|
||
| private static bool IsDescendantOf(TheArtOfDev.HtmlRenderer.Core.Dom.CssBox box, TheArtOfDev.HtmlRenderer.Core.Dom.CssBox ancestor) | ||
| { | ||
| var current = box.ParentBox; | ||
| while (current != null) | ||
| { | ||
| if (ReferenceEquals(current, ancestor)) return true; | ||
| current = current.ParentBox; | ||
| } | ||
| return false; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.