chromium/third_party/blink/web_tests/http/tests/misc/resource-timing-sizes-multipart.html

<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const minHeaderSize = 100;
const abePngSize = 12242;
var t = async_test('PerformanceResourceTiming multipart image');

function waitForEntry() {
    var image = document.getElementById('testingImage');
    var src = image.getAttribute('src');
    var absoluteUrl = new URL(src, location.href).href;
    waitForEntryWithUrl(absoluteUrl);
}

function waitForEntryWithUrl(absoluteUrl) {
    var entries = performance.getEntriesByName(absoluteUrl, 'resource');
    if (entries.length === 1) {
        t.step(() => checkTransferSize(entries[0]));
    } else {
        // TODO(ricea): Find a better way to know when the entry is available.
        t.step_timeout(() => waitForEntryWithUrl(absoluteUrl), 10);
    }
}

function checkTransferSize(entry) {
    // These comparisons are not strict because multipart responses are
    // non-standard. Any reasonable answer is acceptable.
    assert_greater_than(entry.encodedBodySize, abePngSize - 1, 'encodedBodySize');
    assert_greater_than(entry.decodedBodySize, abePngSize - 1, 'decodedBodySize');
    assert_greater_than(entry.transferSize, abePngSize + minHeaderSize, 'transferSize');
    t.done();
}
</script>
<img id=testingImage src="/multipart/resources/multipart.php?loop=0&interval=0&img1=abe.png" onload="waitForEntry()">