Repository navigation
script: Keep blob URLs alive when creating CORS requests in components/script/dom/html/embedded_content/htmlimageelement.rs - #48993
elomscansio wants to merge 2 commits into
Conversation
jdm
left a comment
There was a problem hiding this comment.
I think we'll need to make some deeper changes here and make fetch_request take a UrlWithBlobClaim argument. We can call ensure_blob after https://github.com/elomscansio/servo/blob/22db7e84a0fda687585914fcdcf69a8719f8e885/components/script/dom/html/embedded_content/htmlimageelement.rs#L1030 and https://github.com/elomscansio/servo/blob/22db7e84a0fda687585914fcdcf69a8719f8e885/components/script/dom/html/embedded_content/htmlimageelement.rs#L783 and make sure it reaches the code that calls fetch_request.
Signed-off-by: Emmanuel Paul Elom <[email protected]>
22db7e8 to
6c30c9b
Compare
Signed-off-by: Emmanuel Paul Elom <[email protected]>
|
@jdm ping |
jdm
left a comment
There was a problem hiding this comment.
We will need to write a test for revoking blob URLs in tests/wpt/tests/html/semantics/embedded-content/the-img-element as well. I suggest:
- fetch a same-origin image, get the response as a blob
- use URL.createObjectURL(blob) to create the blob URL from the image data
- create an image element, set the src, then immediately revoke the blob URL
- add a load handler that passes the test, and an error handler that fails the test
| doc: Trusted::new(&document), | ||
| element: Trusted::new(self), | ||
| url: img_url.clone(), | ||
| url: img_url.url(), |
There was a problem hiding this comment.
We need to store the UrlWithBlobClaim in ImageContext.
| // Step 6. Let urlString be the result of encoding-parsing-and-serializing a URL given | ||
| // selected source, relative to the element's node document. | ||
| // Step 7. If urlString is failure, then return. | ||
| let Ok(image_url) = document.base_url().join(&selected_source) else { |
There was a problem hiding this comment.
We should call ensure_blob_referenced_by_url_is_kept_alive right after computing the URL here.
|
|
||
| // Step 13. Set the element's pending request to image request. | ||
| self.image_request.set(ImageRequestPhase::Pending); | ||
| self.init_pending_image_request(cx, &self.pending_request, &image_url, &selected_source); |
There was a problem hiding this comment.
We should store the UrlWithBlobClaim in ImageRequest::parsed_url instead of ServoUrl.
| let url_with_claim = ensure_blob_referenced_by_url_is_kept_alive( | ||
| &self.owner_global(), | ||
| image_url.clone(), | ||
| ); |
There was a problem hiding this comment.
| let url_with_claim = ensure_blob_referenced_by_url_is_kept_alive( | |
| &self.owner_global(), | |
| image_url.clone(), | |
| ); |
| #[expect(non_snake_case)] | ||
| impl HTMLImageElement { | ||
| /// Update the current image with a valid URL. | ||
| fn fetch_image(&self, cx: &mut JSContext, img_url: &ServoUrl) { |
There was a problem hiding this comment.
| fn fetch_image(&self, cx: &mut JSContext, img_url: UrlWithBlobClaim) { |
| let url_with_claim = ensure_blob_referenced_by_url_is_kept_alive( | ||
| &self.owner_global(), | ||
| img_url.clone(), | ||
| ); |
There was a problem hiding this comment.
| let url_with_claim = ensure_blob_referenced_by_url_is_kept_alive( | |
| &self.owner_global(), | |
| img_url.clone(), | |
| ); |
Use ensure_blob_referenced_by_url_is_kept_alive to claim the blob URL in
components/script/dom/html/embedded_content/htmlimageelement.rs, and switch from create_a_potential_cors_request to create_a_potential_cors_request_with_claim.Part of #48892