URL: reimplement URL.createObjectURL()#1150
Conversation
| */ | ||
| @JsxStaticFunction | ||
| public static String createObjectURL(final Object fileOrBlob) { | ||
| if (fileOrBlob instanceof File file) { |
There was a problem hiding this comment.
Maybe i'm blind but looks like the file support is no longer there?
There was a problem hiding this comment.
Oh the support is still there. The previous implementation doing both check was redundant because File itself is a Blob
| * | ||
| * @author Lai Quang Duong | ||
| */ | ||
| public class BlobUrlStore { |
There was a problem hiding this comment.
Great to have a separate class for this.
Maybe we should add a clear() method to support testing use cases where we like to remove urls to test error cases. I guess the page for removal is not always at hand.
| final Blob fileOrBlob = blobUrlStore_.resolve(webRequest.getUrl().toString()); | ||
| if (fileOrBlob == null) { | ||
| throw JavaScriptEngine.typeError("Cannot load data from " + webRequest.getUrl()); | ||
| throw new FileNotFoundException(webRequest.getUrl().toString()); |
There was a problem hiding this comment.
i like to have at lease a small hint in the message text that the file is not found in the BlobUrlStore.
| * | ||
| * @author Lai Quang Duong | ||
| */ | ||
| public class URL2Test extends SimpleWebTestCase { |
There was a problem hiding this comment.
any chance to do this as webdriver tests?
|
And also thanks for that and all the work you already put into this. |
|
|
@rbri i have updated the tests and add a little fix for |



This PR does the following
Make
XMLHttpRequestcheck blob url's origin properly instead of throwingNo permitted "Access-Control-Allow-Origin" headereverytimeRework
URL.createObjectURL()/URL.revokeObjectURL()to back blob URLs with a user-agent-wide blob URL store onWebClient, replacing the previousper-Documentstore.This matches W3C specification where a
blob:URL minted in one document is resolvable from any same-client browsing context.