haikuwebkit/LayoutTests/fast/dom/HTMLAnchorElement
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
anchor-download-expected.txt Source/WebKit: 2020-12-10 19:27:49 +00:00
anchor-download-synthetic-click-expected.txt
anchor-download-synthetic-click.html
anchor-download-unset-expected.txt
anchor-download-unset.html
anchor-download-user-triggered-synthetic-click-expected.txt Source/WebKit: 2020-12-10 19:27:49 +00:00
anchor-download-user-triggered-synthetic-click.html
anchor-download.html
anchor-element-href-parsing-expected.txt
anchor-element-href-parsing.html
anchor-file-blob-convert-to-download-async-delegate-expected.txt Source/WebKit: 2020-12-10 19:27:49 +00:00
anchor-file-blob-convert-to-download-async-delegate.html
anchor-file-blob-convert-to-download-expected.txt Source/WebKit: 2020-12-10 19:27:49 +00:00
anchor-file-blob-convert-to-download.html
anchor-file-blob-download-blank-base-target-popup-not-allowed-expected.txt
anchor-file-blob-download-blank-base-target-popup-not-allowed.html
anchor-file-blob-download-blank-target-expected.txt
anchor-file-blob-download-blank-target-popup-not-allowed-expected.txt
anchor-file-blob-download-blank-target-popup-not-allowed.html
anchor-file-blob-download-blank-target.html
anchor-file-blob-download-expected.txt
anchor-file-blob-download-includes-backslash-expected.txt
anchor-file-blob-download-includes-backslash.html
anchor-file-blob-download-includes-doublequote-expected.txt Download attribute should be sanitized before being used as suggested filename 2017-02-25 00:02:24 +00:00
anchor-file-blob-download-includes-doublequote.html
anchor-file-blob-download-includes-slashes-expected.txt
anchor-file-blob-download-includes-slashes.html
anchor-file-blob-download-includes-unicode-expected.txt
anchor-file-blob-download-includes-unicode.html
anchor-file-blob-download-no-extension-expected.txt
anchor-file-blob-download-no-extension.html
anchor-file-blob-download-then-revoke-expected.txt Blob URL changes after loading it 2021-08-10 03:33:03 +00:00
anchor-file-blob-download-then-revoke.html Blob URL changes after loading it 2021-08-10 03:33:03 +00:00
anchor-file-blob-download.html
anchor-in-noscroll-iframe-crash-expected.txt Tapping after CSS-based table casues an infinite loop in wordRangeFromPosition 2018-05-11 20:39:30 +00:00
anchor-in-noscroll-iframe-crash.html
anchor-in-noscroll-iframe-expected.txt
anchor-in-noscroll-iframe.html
anchor-ismap-crash-expected.txt
anchor-ismap-crash.html
anchor-nodownload-expected.txt
anchor-nodownload-set-expected.txt Source/WebKit: 2020-12-10 19:27:49 +00:00
anchor-nodownload-set.html
anchor-nodownload.html
anchor-non-ASCII-case-folding-expected.txt
anchor-non-ASCII-case-folding.html
anchor-text-attribute-expected.txt
anchor-text-attribute.html
get-href-attribute-port-expected.txt
get-href-attribute-port.html
remove-rel-attribute-expected.txt
remove-rel-attribute.html
set-href-attribute-hash-expected.txt Update URL fragment percent encode set 2020-09-01 16:42:54 +00:00
set-href-attribute-hash.html Update URL fragment percent encode set 2020-09-01 16:42:54 +00:00
set-href-attribute-host-expected.txt Align URL setters with reasonably behaving other browsers 2020-10-06 15:45:33 +00:00
set-href-attribute-host.html Align URL setters with reasonably behaving other browsers 2020-10-06 15:45:33 +00:00
set-href-attribute-hostname-expected.txt Add username / password attributes to HTMLAnchorElement / HTMLAreaElement 2016-02-22 03:28:55 +00:00
set-href-attribute-hostname.html
set-href-attribute-pathname-expected.txt
set-href-attribute-pathname.html
set-href-attribute-port-expected.txt Fix some whitespace handling issues in URL setters 2021-07-08 22:59:59 +00:00
set-href-attribute-port.html Fix some whitespace handling issues in URL setters 2021-07-08 22:59:59 +00:00
set-href-attribute-prevents-rebase-expected.txt
set-href-attribute-prevents-rebase.html
set-href-attribute-protocol-expected.txt
set-href-attribute-protocol.html
set-href-attribute-rebase-expected.txt
set-href-attribute-rebase.html
set-href-attribute-search-expected.txt
set-href-attribute-search.html
set-href-attribute-user-pass-expected.txt
set-href-attribute-user-pass.html
set-href-attribute-whitespace-expected.txt HTMLAnchorElement is inconsistent with its internal handling of the value returned for the href attribute. 2009-11-18 17:57:10 +00:00
set-href-attribute-whitespace.html