There are 2 versions of this test: one in fast/inline/legacy-margin-trim (which forces legacy line layout for both the test and -expected file) and one in imported/w3c/web-platform-tests/css/css-box/margin-trim (which uses IFC for the expected). It seems like the test is failing in the web-platform-tests directory because the text layout using IFC is different from legacy
<rdar://problem/106014778>