Various CanGc fixes in components/script/dom (#33706)

* Propagate 'can_gc' in IFrame DOM code

Signed-off-by: webbeef <me@webbeef.org>

* Propagate 'can_gc' in HTML video and image elements

Signed-off-by: webbeef <me@webbeef.org>

* Propagate 'can_gc' in Blob and dependencies

Signed-off-by: webbeef <me@webbeef.org>

* Leftover can_gc fixes for HTMLMediaElement

Signed-off-by: webbeef <me@webbeef.org>

* Address comment

Signed-off-by: webbeef <me@webbeef.org>

---------

Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
webbeef 2024-10-07 19:30:04 -07:00 committed by GitHub
parent 7d931e673a
commit d3c0785d64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 67 additions and 42 deletions

View file

@ -972,7 +972,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
self.json_response(cx).to_jsval(*cx, rval.handle_mut());
},
XMLHttpRequestResponseType::Blob => unsafe {
self.blob_response().to_jsval(*cx, rval.handle_mut());
self.blob_response(can_gc).to_jsval(*cx, rval.handle_mut());
},
XMLHttpRequestResponseType::Arraybuffer => match self.arraybuffer_response(cx) {
Some(array_buffer) => unsafe { array_buffer.to_jsval(*cx, rval.handle_mut()) },
@ -1326,7 +1326,7 @@ impl XMLHttpRequest {
}
/// <https://xhr.spec.whatwg.org/#blob-response>
fn blob_response(&self) -> DomRoot<Blob> {
fn blob_response(&self, can_gc: CanGc) -> DomRoot<Blob> {
// Step 1
if let Some(response) = self.response_blob.get() {
return response;
@ -1340,7 +1340,11 @@ impl XMLHttpRequest {
// Step 3, 4
let bytes = self.response.borrow().to_vec();
let blob = Blob::new(&self.global(), BlobImpl::new_from_bytes(bytes, mime));
let blob = Blob::new(
&self.global(),
BlobImpl::new_from_bytes(bytes, mime),
can_gc,
);
self.response_blob.set(Some(&blob));
blob
}