haikuwebkit/LayoutTests/fast/files
Chris Dumez 941412f6fc Blob URL changes after loading it
https://bugs.webkit.org/show_bug.cgi?id=228923

Reviewed by Geoff Garen.

Source/WebCore:

Blob URL changes after loading it. This is because we use URLWithBlobURLLifetimeExtension to
extend the lifetime of the Blob URL during the load and URLWithBlobURLLifetimeExtension ends
up creating a new public Blob URL. This is Web-observable so we need a way to extend the
lifetime of a Blob URL without actually generating a new Blob URL.

This patch replaces URLWithBlobURLLifetimeExtension with a new BlobURLHandle class which
extends the lifetime of a Blob URL as long as there are BlobURLHandle objects referring
to it. BlobURLHandle works with both private and public Blob URLs so it replaces
Blob::Handle as well (which I recently introduced via r280547). The Blob URL no longer
changes when we extend its lifetime. Instead, the Blob registry now keeps track of
references to a given Blob and only removes a Blob URL once there are no longer any
references to it.

Test: fast/files/blob-as-frame-url.html

* Headers.cmake:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::serialize):
(WebCore::CloneSerializer::CloneSerializer):
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::SerializedScriptValue::SerializedScriptValue):
(WebCore::SerializedScriptValue::create):
* bindings/js/SerializedScriptValue.h:
(WebCore::SerializedScriptValue::blobHandles const):
(WebCore::SerializedScriptValue::SerializedScriptValue):
* fileapi/Blob.cpp:
(WebCore::Blob::Blob):
(WebCore::Blob::slice const):
(WebCore::Blob::size const):
(WebCore::Blob::handle const):
* fileapi/Blob.h:
(WebCore::Blob::url const):
* fileapi/BlobURL.cpp:
(WebCore::BlobURLHandle::BlobURLHandle):
(WebCore::BlobURLHandle::~BlobURLHandle):
(WebCore::BlobURLHandle::registerBlobURLHandleIfNecessary):
(WebCore::BlobURLHandle::unregisterBlobURLHandleIfNecessary):
(WebCore::BlobURLHandle::operator=):
(WebCore::BlobURLHandle::clear):
* fileapi/BlobURL.h:
(WebCore::BlobURLHandle::BlobURLHandle):
(WebCore::BlobURLHandle::url const):
* fileapi/ThreadableBlobRegistry.cpp:
(WebCore::ThreadableBlobRegistry::registerBlobURLHandle):
(WebCore::ThreadableBlobRegistry::unregisterBlobURLHandle):
* fileapi/ThreadableBlobRegistry.h:
* loader/PolicyChecker.cpp:
(WebCore::FrameLoader::PolicyChecker::extendBlobURLLifetimeIfNecessary const):
(WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy):
(WebCore::FrameLoader::PolicyChecker::checkNewWindowPolicy):
* loader/PolicyChecker.h:
* platform/network/BlobRegistry.h:
* platform/network/BlobRegistryImpl.cpp:
(WebCore::BlobRegistryImpl::registerFileBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURL):
(WebCore::BlobRegistryImpl::registerBlobURLOptionallyFileBacked):
(WebCore::BlobRegistryImpl::registerBlobURLForSlice):
(WebCore::BlobRegistryImpl::unregisterBlobURL):
(WebCore::BlobRegistryImpl::addBlobData):
(WebCore::BlobRegistryImpl::registerBlobURLHandle):
(WebCore::BlobRegistryImpl::unregisterBlobURLHandle):
* platform/network/BlobRegistryImpl.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::setResponseType):
(WebCore::XMLHttpRequest::open):
(WebCore::XMLHttpRequest::prepareToSend):
(WebCore::XMLHttpRequest::send):
(WebCore::XMLHttpRequest::createRequest):
(WebCore::XMLHttpRequest::clearRequest):
(WebCore::XMLHttpRequest::didFinishLoading):
* xml/XMLHttpRequest.h:

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::registerBlobURLHandle):
(WebKit::NetworkConnectionToWebProcess::unregisterBlobURLHandle):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkProcessPlatformStrategies.cpp:
(WebKit::NetworkProcessPlatformStrategies::createBlobRegistry):
* WebProcess/FileAPI/BlobRegistryProxy.cpp:
(WebKit::BlobRegistryProxy::registerBlobURLHandle):
(WebKit::BlobRegistryProxy::unregisterBlobURLHandle):
* WebProcess/FileAPI/BlobRegistryProxy.h:

Source/WebKitLegacy/mac:

* WebCoreSupport/WebPlatformStrategies.mm:

Source/WebKitLegacy/win:

* WebCoreSupport/WebPlatformStrategies.cpp:

LayoutTests:

Add layout test coverage.

* fast/files/blob-as-frame-url-expected.txt: Added.
* fast/files/blob-as-frame-url.html: Added.


Canonical link: https://commits.webkit.org/240387@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280824 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-08-10 03:33:03 +00:00
..
resources Implement Blob.stream 2020-10-08 23:28:32 +00:00
workers FileReaderLoader::convertToDataURL should use application/octet-stream if MIME type is empty 2020-11-16 21:45:15 +00:00
apply-blob-url-to-img-expected.txt
apply-blob-url-to-img-using-open-panel-expected.txt
apply-blob-url-to-img-using-open-panel.html
apply-blob-url-to-img.html
apply-blob-url-to-xhr-expected.txt
apply-blob-url-to-xhr-using-open-panel-expected.txt
apply-blob-url-to-xhr-using-open-panel.html
apply-blob-url-to-xhr.html
blob-as-frame-url-expected.txt Blob URL changes after loading it 2021-08-10 03:33:03 +00:00
blob-as-frame-url.html Blob URL changes after loading it 2021-08-10 03:33:03 +00:00
blob-constructor-expected.txt
blob-constructor.html
blob-content-type-expected.txt charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost 2021-04-27 23:01:41 +00:00
blob-content-type.html charset in contentType used in Blob.prototype.slice(start, end, contentType) is lost 2021-04-27 23:01:41 +00:00
blob-network-process-crash-expected.txt
blob-network-process-crash.html
blob-slice-overflow-expected.txt
blob-slice-overflow.html
blob-slice-test-expected.txt Remove trailing spaces from expected.txt files (excluding WPT for now since that contains too many) 2020-09-27 02:15:19 +00:00
blob-slice-test.html
blob-stream-crash-2-expected.txt Fix nullptr dereference introduced in r268228 2021-01-20 21:09:56 +00:00
blob-stream-crash-2.html Fix nullptr dereference introduced in r268228 2021-01-20 21:09:56 +00:00
blob-stream-crash-expected.txt Null check global object in Blob::stream 2021-01-07 17:23:23 +00:00
blob-stream-crash.html Null check global object in Blob::stream 2021-01-07 17:23:23 +00:00
blob-stream-error-expected.txt Implement Blob.stream 2020-10-08 23:28:32 +00:00
blob-stream-error.html Implement Blob.stream 2020-10-08 23:28:32 +00:00
blob-stream-frame-expected.txt Implement Blob.stream 2020-10-08 23:28:32 +00:00
blob-stream-frame.html Implement Blob.stream 2020-10-08 23:28:32 +00:00
blob-text-gc-expected.txt
blob-text-gc.html
blob-with-charget-as-main-resource-expected.html Blob contentType with charset renders html as plain text 2021-05-04 22:37:08 +00:00
blob-with-charget-as-main-resource.html Blob contentType with charset renders html as plain text 2021-05-04 22:37:08 +00:00
create-blob-url-crash-expected.txt
create-blob-url-crash.html
domurl-script-execution-context-crash-expected.txt
domurl-script-execution-context-crash.html
file-constructor-expected.txt
file-constructor.html
file-list-test-expected.txt
file-list-test-using-open-panel-expected.txt
file-list-test-using-open-panel.html
file-list-test.html
file-reader-abort-expected.txt FileReader should transition to readyState DONE after last onprogress event 2020-10-06 16:45:24 +00:00
file-reader-abort-using-open-panel-expected.txt FileReader should transition to readyState DONE after last onprogress event 2020-10-06 16:45:24 +00:00
file-reader-abort-using-open-panel.html
file-reader-abort.html
file-reader-back-forward-cache-expected.txt
file-reader-back-forward-cache.html [Testing] Rename test header commands to match names in WebPreferences*.yaml 2020-10-13 17:16:15 +00:00
file-reader-directory-crash-expected.txt
file-reader-directory-crash-using-open-panel-expected.txt Add a way to test file input without relying on drag and drop 2017-02-27 09:49:29 +00:00
file-reader-directory-crash-using-open-panel.html
file-reader-directory-crash.html
file-reader-done-reading-abort-expected.txt use after free in WebCore::FileReader::doAbort 2012-08-30 02:05:15 +00:00
file-reader-done-reading-abort.html
file-reader-event-listener-expected.txt
file-reader-event-listener.html
file-reader-fffd-expected.txt
file-reader-fffd.html
file-reader-file-url-expected.txt
file-reader-file-url.html Remove remaining alternative preference setting mechanisms from LayoutTests 2020-11-01 20:09:38 +00:00
file-reader-immediate-abort-expected.txt
file-reader-immediate-abort.html
file-reader-sandbox-iframe-expected.txt
file-reader-sandbox-iframe.html Remove remaining alternative preference setting mechanisms from LayoutTests 2020-11-01 20:09:38 +00:00
filereader-invalid-blob-expected.txt FileReader.readAsArrayBuffer misses checking for the type of blob param 2021-06-16 19:58:32 +00:00
filereader-invalid-blob.html FileReader.readAsArrayBuffer misses checking for the type of blob param 2021-06-16 19:58:32 +00:00
filereader-zip-bundle-expected.txt
filereader-zip-bundle-using-open-panel-expected.txt
filereader-zip-bundle-using-open-panel.html
filereader-zip-bundle.html
local-file-drag-security-expected.txt
local-file-drag-security.html
not-enough-arguments-expected.txt Add support for the Blob constructor 2012-04-28 22:24:48 +00:00
not-enough-arguments.html
null-origin-string-expected.txt
null-origin-string.html
read-blob-async-expected.txt FileReaderLoader::convertToDataURL should use application/octet-stream if MIME type is empty 2020-11-16 21:45:15 +00:00
read-blob-async.html
read-file-async-expected.txt FileReader.result should return null if it isn't done yet 2020-10-09 00:03:09 +00:00
read-file-async.html
revoke-blob-url-expected.txt
revoke-blob-url.html
url-null-expected.txt
url-null.html
url-required-arguments-expected.txt
url-required-arguments.html
xhr-blob-request-expected.txt
xhr-blob-request.html
xhr-response-blob-expected.txt
xhr-response-blob.html