From 55203d791809ed2eed473284d227c4bcb3fcc8fe Mon Sep 17 00:00:00 2001 From: Delan Azabani Date: Wed, 1 Mar 2023 20:16:39 +0800 Subject: [PATCH 1/2] script: fix BorrowError in (new Blob).slice(0,0).text() --- components/script/dom/globalscope.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index ac2497da004..9a3829f4d0e 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -1838,13 +1838,16 @@ impl GlobalScope { }; match parent { Some((parent_id, rel_pos)) => { - let parent_file_id = { - let parent_info = blobs_map - .get_mut(&parent_id) - .expect("Parent of blob whose url is requested is unknown."); - self.promote(parent_info, /* set_valid is */ false) + let parent_info = blobs_map + .get_mut(&parent_id) + .expect("Parent of blob whose url is requested is unknown."); + let parent_file_id = self.promote(parent_info, /* set_valid is */ false); + let parent_size = match parent_info.blob_impl.blob_data() { + BlobData::File(ref f) => f.get_size(), + BlobData::Memory(ref v) => v.len() as u64, + BlobData::Sliced(_, _) => panic!("Blob ancestry should be only one level."), }; - let parent_size = self.get_blob_size(&parent_id); + let parent_size = rel_pos.to_abs_range(parent_size as usize).len() as u64; let blob_info = blobs_map .get_mut(blob_id) .expect("Blob whose url is requested is unknown."); From 24812f15adc25d7eeed52f7e4a98121c5e900dc6 Mon Sep 17 00:00:00 2001 From: Delan Azabani Date: Thu, 2 Mar 2023 19:22:12 +0800 Subject: [PATCH 2/2] expectations for /fetch/api/basic/scheme-blob.sub.any{,.worker}.html --- .../api/basic/scheme-blob.sub.any.js.ini | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/wpt/metadata/fetch/api/basic/scheme-blob.sub.any.js.ini b/tests/wpt/metadata/fetch/api/basic/scheme-blob.sub.any.js.ini index 04f3b0fe381..dcb842c4c4c 100644 --- a/tests/wpt/metadata/fetch/api/basic/scheme-blob.sub.any.js.ini +++ b/tests/wpt/metadata/fetch/api/basic/scheme-blob.sub.any.js.ini @@ -1,5 +1,44 @@ [scheme-blob.sub.any.html] - expected: CRASH + [Fetching URL.createObjectURL(empty_blob) is OK] + expected: FAIL + + [Fetching URL.createObjectURL(empty_type_blob) is OK] + expected: FAIL + + [Blob content is not sniffed for a content type [image/png\]] + expected: FAIL + + [Blob content is not sniffed for a content type [text/xml\]] + expected: FAIL + + [Set content type to the empty string for slice with invalid content type] + expected: FAIL + + [Set content type to the empty string for slice with no content type ] + expected: FAIL + + [Blob.slice should not sniff the content for a content type] + expected: FAIL + [scheme-blob.sub.any.worker.html] - expected: CRASH + [Fetching URL.createObjectURL(empty_blob) is OK] + expected: FAIL + + [Fetching URL.createObjectURL(empty_type_blob) is OK] + expected: FAIL + + [Blob content is not sniffed for a content type [image/png\]] + expected: FAIL + + [Blob content is not sniffed for a content type [text/xml\]] + expected: FAIL + + [Set content type to the empty string for slice with invalid content type] + expected: FAIL + + [Set content type to the empty string for slice with no content type ] + expected: FAIL + + [Blob.slice should not sniff the content for a content type] + expected: FAIL