W3C home > Mailing lists > Public > public-web-perf@w3.org > December 2010

Re: About window.performance namespace

From: Sigbjørn Vik <sigbjorn@opera.com>
Date: Tue, 21 Dec 2010 09:22:49 +0100
To: public-web-perf <public-web-perf@w3.org>
Message-ID: <op.vn11kbfy41y844@id-c0735.oslo.opera.com>
On Tue, 21 Dec 2010 01:11:41 +0100, Zhiheng Wang <zhihengw@google.com>  

>> On the other hand, I see valid use cases for overwriting the  
>> sub-objects.
>> For instance in my debug environment, I know one of the attributes is  
>> way
>> off, so I want to change/overwrite that, in order to see the correct  
>> output
>> from the third party timing script.
>     Instead of changing/overwriting individual attributes, you can  
> create a
> mock performance object and swap out window.performance in the debugging
> environment.
> It takes some extra work but testing/debugging probably worth it. :-)

But in this case, the attributes on the performance object are trivially  

var perf2 = window.performance;
perf2.timing = new Object();
window.performance = perf2;[1]

If this can be done this easily, I am not certain I see the benefit of  
making window.performance.timing read-only in the first place?

Or a more roundabout way, in the case the read-only attribute would be  
copied across on the first line above:
var perf2 = new Object();
for (attr in window.performance) {
	if (attr != "timing") perf2[attr] = window.performance[attr];
perf2.timing = new Object();
window.performance = perf2;

Sigbjørn Vik
Quality Assurance
Opera Software
Received on Tuesday, 21 December 2010 08:23:26 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:04:29 UTC