W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2012

Re: [File API] Blob URI creation

From: Glenn Maynard <glenn@zewt.org>
Date: Tue, 14 Aug 2012 17:00:56 -0500
Message-ID: <CABirCh88uM1GovPNAhKGUDTffMSrm++XaWdrdK3ujF-Wk_Pv0w@mail.gmail.com>
To: Feras Moussa <ferasm@microsoft.com>
Cc: Arun Ranganathan <aranganathan@mozilla.com>, Rich Tibbett <richt@opera.com>, public-webapps <public-webapps@w3.org>, Arun Ranganathan <arun@mozilla.com>, Jonas Sicking <jonas@sicking.cc>
 Please note that there's one other issue outstanding: both microtasks and
stable states are very closed, but neither may be what this needs.  A
separate hook may be needed.

On Tue, Aug 14, 2012 at 4:37 PM, Feras Moussa <ferasm@microsoft.com> wrote:

> In general we are OK with changing it to the autoRevoke behavior below,
> but have some concerns around changing the default behavior.
> Changing the default behavior is a breaking change and any apps which
> expect the URL to work multiple times will now be broken. In Windows 8, we
> also implemented the oneTimeOnly behavior and it was very widely used,
> these consumers will be broken as well.
> We would like to support autoRevoke as the default as it helps reduce the
> chance of leaking unintentionally, but  we think developers should have a
> way to feature detect the new change. If a developer can feature detect
> which default behavior is present, then they can reason about what to
> expect from the API.

I agree that this needs to be feature detectable.  I don't think this
should be fixed in a special way specific to getObjectURL, because this is
a general issue with the Dictionary pattern, where features are used by
setting a flag in an object.  We need a general way to tell if an API
supports a particular dictionary key in its options dictionary, because
this is going to come up again as dictionaries are used in new APIs.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=16953#c4 suggests using a
property of WebIDL dictionaries to accomplish this: use
Object.defineProperty to detect whether the key's value is read by the API

var hasAutoRevoke = false;
var o = {};
Object.defineProperty(o, "autoRevoke", { get: function() { hasAutoRevoke =
true; return false; } });
URL.createObjectURL(new Blob(), o); // getter will be called if supported

This works (supported dictionary keys are guaranteed to be retrieved
exactly once), but it's fairly cumbersome.  It also requires a close
knowledge of WebIDL details, though maybe it's OK if people copy-and-paste
this code without knowing why it works.

Glenn Maynard
Received on Tuesday, 14 August 2012 22:01:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:38 UTC