Re: [ResourceTiming] Are PerformanceResourceTiming instances supposed to have a serializer?

On 8/17/14, 4:46 PM, Arvind Jain wrote:
> So should I add the toJSON() method to PerformanceResourceTiming
> object and define is as:
>
> toJSON() method:
> Returns a json object representing the PerformanceResourceTiming object.

What you should do is define a serializer.  See 
http://heycam.github.io/webidl/#idl-serializers and I suspect what you 
want here is:

   serializer = { attribute };

for interfaces that don't inherit from something that needs 
serialization but want to serialize all their own attributes or

   serializer = { inherit, attribute };

for ones that want to serialize their own attributes plus whatever their 
parent interface serializes.  This will automatically create a toJSON 
method that does the right things for you.

> In fact should I define it on PerformanceEntry itself (as well as on
> window.performance.timing) to cover all Performance objects?

I suggest you test what UAs do and whether the spec you write is 
compatible with that.

Gecko does have a serializer on PerformanceEntry and on 
PerformanceTiming, for what that's worth.

-Boris

Received on Monday, 18 August 2014 00:42:47 UTC