Tests in html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/ that use resources/slow-code-injector.html relies on a load getting in before a slow image load completes. On slow CI systems this is not guaranteed.
These tests should probably be rewritten using a trickle or better yet, and entirely new python handler that first sends the script part in one chunk, and then basically infinitely continues sending a trickle to the requester, making sure that the response cannot finish before the load during load starts.