OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 // The Mozilla DHTML performance tests need to explicitly call a function to | 6 // The Mozilla DHTML performance tests need to explicitly call a function to |
7 // trigger the next page visit, rather than directly using the onload handler. | 7 // trigger the next page visit, rather than directly using the onload handler. |
8 // To meet needs of the DHTML performance tests without forking this head.js | 8 // To meet needs of the DHTML performance tests without forking this head.js |
9 // file, use a variable |__install_onload_handler| to indicate whether the | 9 // file, use a variable |__install_onload_handler| to indicate whether the |
10 // |__onload| handler should be added to onload event listener. | 10 // |__onload| handler should be added to onload event listener. |
(...skipping 15 matching lines...) Expand all Loading... | |
26 function __onbeforeunload() { | 26 function __onbeforeunload() { |
27 // Call GC twice to cleanup JS heap before starting a new test. | 27 // Call GC twice to cleanup JS heap before starting a new test. |
28 if (window.gc) { | 28 if (window.gc) { |
29 window.gc(); | 29 window.gc(); |
30 window.gc(); | 30 window.gc(); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 // The function |__onload| is used by the DHTML tests. | 34 // The function |__onload| is used by the DHTML tests. |
35 window.__onload = function() { | 35 window.__onload = function() { |
36 // window.storeCreated is used by the Indexed DB tests. | 36 if (!__install_onload_handler && !performance.timing.loadEventEnd) |
37 if ((!__install_onload_handler || window.storeCreated) && | |
38 !performance.timing.loadEventEnd) | |
39 return; | 37 return; |
40 | 38 |
41 var unused = document.body.offsetHeight; // force layout | 39 var unused = document.body.offsetHeight; // force layout |
42 | 40 |
43 testComplete(window.performance.now()); | 41 window.__pc_load_time = window.performance.now(); |
44 }; | |
45 | |
46 // The function |testComplete| is used by the Indexed DB tests. | |
47 window.testComplete = function(time) { | |
cmumford
2014/02/05 16:28:50
I do see plenty other users of testComplete in the
| |
48 window.__pc_load_time = time; | |
49 }; | 42 }; |
50 | 43 |
51 // The function |__eval_later| now is only used by the DHTML tests. | 44 // The function |__eval_later| now is only used by the DHTML tests. |
52 window.__eval_later = function(expression) { | 45 window.__eval_later = function(expression) { |
53 setTimeout(expression, __test_timeout); | 46 setTimeout(expression, __test_timeout); |
54 }; | 47 }; |
55 | 48 |
56 if (window.parent == window) { // Ignore subframes. | 49 if (window.parent == window) { // Ignore subframes. |
57 window.__pc_load_time = null; | 50 window.__pc_load_time = null; |
58 addEventListener("load", __onload); | 51 addEventListener("load", __onload); |
59 addEventListener("beforeunload", __onbeforeunload); | 52 addEventListener("beforeunload", __onbeforeunload); |
60 } | 53 } |
61 })(); | 54 })(); |
OLD | NEW |