forked from mirrors/gecko-dev
Automatic update from web-platform-tests Reland "[FileAPI] Move BlobUrlRegistry to the UI thread" This is a reland of commit b277bdd5bc7cd12c38daf6a1b1c40e61587b5c5d The only difference to the original change is a slight tweak to the url-format.any.js web test, adding explicit revocation of most blob urls to the test. Without this apparently the simultaneous revocation of thousands of blob URLs on the UI thread somehow causes the leak detection bot to check for leaks before blink has managed to fully collect all garbage, while the same problem didn't exist when this work was done on the IO thread. Original change's description: > [FileAPI] Move BlobUrlRegistry to the UI thread > > Moving BlobUrlRegistry to the UI thread has several benefits, one > of which being that it makes it easier for the BlobUrlRegistry to > be exposed directly to the renderer (rather than being retrieved > via the BlobRegistry). As part of that effort we would like to > use a navigation-associated interface associated with the > corresponding RenderFrameHostImpl, but that appears to encounter > a DCHECK in the Mojo code when the interface implementation lives > on the IO thread. > > Change-Id: I3bfd0385407c7ff261978b243ccdcf3dc4812352 > Bug: 957249, 1261328 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343608 > Reviewed-by: Austin Sullivan <asully@chromium.org> > Commit-Queue: Marijn Kruisselbrink <mek@chromium.org> > Cr-Commit-Position: refs/heads/main@{#984144} Bug: 957249, 1261328 Change-Id: I5d72239c8071f61c0238f5881a99c36987666ee0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3546245 Auto-Submit: Marijn Kruisselbrink <mek@chromium.org> Reviewed-by: Austin Sullivan <asully@chromium.org> Commit-Queue: Austin Sullivan <asully@chromium.org> Cr-Commit-Position: refs/heads/main@{#984848} -- wpt-commits: 1dca45433ab7293fc73040764ad631225c31c77f wpt-pr: 33333
70 lines
2.3 KiB
JavaScript
70 lines
2.3 KiB
JavaScript
// META: timeout=long
|
|
const blob = new Blob(['test']);
|
|
const file = new File(['test'], 'name');
|
|
|
|
test(t => {
|
|
const url_count = 5000;
|
|
let list = [];
|
|
|
|
t.add_cleanup(() => {
|
|
for (let url of list) {
|
|
URL.revokeObjectURL(url);
|
|
}
|
|
});
|
|
|
|
for (let i = 0; i < url_count; ++i)
|
|
list.push(URL.createObjectURL(blob));
|
|
|
|
list.sort();
|
|
|
|
for (let i = 1; i < list.length; ++i)
|
|
assert_not_equals(list[i], list[i-1], 'generated Blob URLs should be unique');
|
|
}, 'Generated Blob URLs are unique');
|
|
|
|
test(() => {
|
|
const url = URL.createObjectURL(blob);
|
|
assert_equals(typeof url, 'string');
|
|
assert_true(url.startsWith('blob:'));
|
|
}, 'Blob URL starts with "blob:"');
|
|
|
|
test(() => {
|
|
const url = URL.createObjectURL(file);
|
|
assert_equals(typeof url, 'string');
|
|
assert_true(url.startsWith('blob:'));
|
|
}, 'Blob URL starts with "blob:" for Files');
|
|
|
|
test(() => {
|
|
const url = URL.createObjectURL(blob);
|
|
assert_equals(new URL(url).origin, location.origin);
|
|
if (location.origin !== 'null') {
|
|
assert_true(url.includes(location.origin));
|
|
assert_true(url.startsWith('blob:' + location.protocol));
|
|
}
|
|
}, 'Origin of Blob URL matches our origin');
|
|
|
|
test(() => {
|
|
const url = URL.createObjectURL(blob);
|
|
const url_record = new URL(url);
|
|
assert_equals(url_record.protocol, 'blob:');
|
|
assert_equals(url_record.origin, location.origin);
|
|
assert_equals(url_record.host, '', 'host should be an empty string');
|
|
assert_equals(url_record.port, '', 'port should be an empty string');
|
|
const uuid_path_re = /\/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
assert_true(uuid_path_re.test(url_record.pathname), 'Path must end with a valid UUID');
|
|
if (location.origin !== 'null') {
|
|
const nested_url = new URL(url_record.pathname);
|
|
assert_equals(nested_url.origin, location.origin);
|
|
assert_equals(nested_url.pathname.search(uuid_path_re), 0, 'Path must be a valid UUID');
|
|
assert_true(url.includes(location.origin));
|
|
assert_true(url.startsWith('blob:' + location.protocol));
|
|
}
|
|
}, 'Blob URL parses correctly');
|
|
|
|
test(() => {
|
|
const url = URL.createObjectURL(file);
|
|
assert_equals(new URL(url).origin, location.origin);
|
|
if (location.origin !== 'null') {
|
|
assert_true(url.includes(location.origin));
|
|
assert_true(url.startsWith('blob:' + location.protocol));
|
|
}
|
|
}, 'Origin of Blob URL matches our origin for Files');
|