OLD | NEW |
(Empty) | |
| 1 // The port for communicating back to the extension. |
| 2 var benchmarkExtensionPort = chrome.extension.connect(); |
| 3 |
| 4 // The url is what this page is known to the benchmark as. |
| 5 // The benchmark uses this id to differentiate the benchmark's |
| 6 // results from random pages being browsed. |
| 7 |
| 8 // TODO(mbelshe): If the page redirects, the location changed and the |
| 9 // benchmark stalls. |
| 10 var benchmarkExtensionUrl = window.location.toString(); |
| 11 |
| 12 function sendTimesToExtension() { |
| 13 var times = window.chromium.GetLoadTimes(); |
| 14 if (times.finishLoadTime != 0) { |
| 15 benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtension
Url, values: times}); |
| 16 } else { |
| 17 window.setTimeout(sendTimesToExtension, 100); |
| 18 } |
| 19 } |
| 20 |
| 21 function loadComplete() { |
| 22 // Only trigger for top-level frames (e.g. the one we benchmarked) |
| 23 if (window.parent == window) { |
| 24 sendTimesToExtension(); |
| 25 } |
| 26 } |
| 27 |
| 28 window.addEventListener("load", loadComplete); |
OLD | NEW |