diff options
-rw-r--r-- | chrome/common/extensions/docs/examples/extensions/benchmark/script.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/chrome/common/extensions/docs/examples/extensions/benchmark/script.js b/chrome/common/extensions/docs/examples/extensions/benchmark/script.js index 75e07a4..0062f9c 100644 --- a/chrome/common/extensions/docs/examples/extensions/benchmark/script.js +++ b/chrome/common/extensions/docs/examples/extensions/benchmark/script.js @@ -10,8 +10,14 @@ var benchmarkExtensionPort = chrome.extension.connect(); var benchmarkExtensionUrl = window.location.toString(); function sendTimesToExtension() { + if (window.parent != window) { + return; + } + var times = window.chrome.loadTimes(); + // If the load is not finished yet, schedule a timer to check again in a + // little bit. if (times.finishLoadTime != 0) { benchmarkExtensionPort.postMessage({message: "load", url: benchmarkExtensionUrl, values: times}); } else { @@ -19,11 +25,6 @@ function sendTimesToExtension() { } } -function loadComplete() { - // Only trigger for top-level frames (e.g. the one we benchmarked) - if (window.parent == window) { - sendTimesToExtension(); - } -} - -window.addEventListener("load", loadComplete); +// We can't use the onload event because this script runs at document idle, +// which may run after the onload has completed. +sendTimesToExtension(); |