- 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>
On Tue, 21 Dec 2010 01:11:41 +0100, Zhiheng Wang <zhihengw@google.com> wrote: >> 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 replaceable: 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? [1] 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