Roll src/third_party/WebKit 3aea697:d9c6159 (svn 201973:201974)
[chromium-blink-merge.git] / tools / perf / page_sets / deterministic_performance_counters.js
blob3ac4ce2b71da72910d512f63747f4b925c5863e5
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Monkey patch performance to get deterministic results.
6 (function () {
7 // Web page replay patches Data.now().
8 var start_time = Date.now();
9 var now_counter = 0;
10 function now() {
11 return now_counter++;
13 function timing() {
14 // These values are arbitrary.
15 // They are obtained by sampling "performance.now()" on a live web site.
16 return {
17 "navigationStart": start_time,
18 "unloadEventStart": 0,
19 "unloadEventEnd": 0,
20 "redirectStart": 0,
21 "redirectEnd": 0,
22 "fetchStart": start_time + 94,
23 "domainLookupStart": start_time + 94,
24 "domainLookupEnd": start_time + 94,
25 "connectStart": start_time + 94,
26 "connectEnd": start_time + 94,
27 "secureConnectionStart":0,
28 "requestStart": start_time + 98,
29 "responseStart": start_time + 546,
30 "responseEnd": start_time + 1511,
31 "domLoading": start_time + 562,
32 "domInteractive": start_time + 1647,
33 "domContentLoadedEventStart": start_time + 1647,
34 "domContentLoadedEventEnd": start_time + 1654,
35 "domComplete": start_time + 2009,
36 "loadEventStart": start_time + 2009,
37 "loadEventEnd": start_time + 2009
40 Object.defineProperty(window, "performance", {
41 get : function() {
42 return { 'now' : now, 'timing' : timing() };
44 });
45 })();