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