On 2015-07-13 2:40 AM, Tim Guan-tin Chien wrote:
On Fri, Jul 10, 2015 at 2:45 AM, Boris Zbarsky <bzbar...@mit.edu> wrote:
On 7/9/15 4:48 AM, Tim Guan-tin Chien wrote:

In this case, I modified the manifest object passed from mozApp API,
and the object was subsequently removed by the platform, so did my
modifications. Fabrice said I should not be modified the object since
it's marked as read only in WebIDL.


"readonly" just means the property has a getter but no setter.  Whether you
can then modify the value returned by the getter is a separate issue that
needs to be considered as part of designing an API.

I wonder if platform should
protect web authors more by simply freeze the entire structure when
giving it to the content.


If it were a dictionary, you could use
<https://developer.mozilla.org/en-US/docs/Mozilla/WebIDL_bindings#Frozen>.
But note that freezing is not recursive, so if some of the properties are
themselves objects _they_ could still be mutated...

Are there any other APIs expose a structure like this?


Looks like we only use [Frozen] on sequences at the moment...

-Boris

Thanks for reply :bz.

In that case, the right question to ask would be (A) should
DOMApplication#manifest be a recursive frozen JS structure, and maybe
I suppose we could do that, to remove this footgun, even though I can't remember other similar examples in the platform off the top of my head.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to