fix: don't emit did-fail-load for MediaDocuments (#37824)

* fix: don't emit did-fail-load for MediaDocuments

* spec: add test
This commit is contained in:
Shelley Vohr 2023-04-06 10:23:34 +02:00 committed by GitHub
parent 6bfef67aae
commit 251e567eff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 0 deletions

View file

@ -64,6 +64,7 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
#include "media/base/mime_util.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
@ -1762,6 +1763,16 @@ void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& url,
int error_code) {
// See DocumentLoader::StartLoadingResponse() - when we navigate to a media
// resource the original request for the media resource, which resulted in a
// committed navigation, is simply discarded. The media element created
// inside the MediaDocument then makes *another new* request for the same
// media resource.
bool is_media_document =
media::IsSupportedMediaMimeType(web_contents()->GetContentsMimeType());
if (error_code == net::ERR_ABORTED && is_media_document)
return;
bool is_main_frame = !render_frame_host->GetParent();
int frame_process_id = render_frame_host->GetProcess()->GetID();
int frame_routing_id = render_frame_host->GetRoutingID();