diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-16 19:52:00 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-16 19:52:00 +0000 |
commit | 6b2ea29a5c2f790c6032f98f920cec97d795ece0 (patch) | |
tree | 3e49abe03f2288ab6d2b8e2da497c25256356c5b | |
parent | 28ebe94fbbe130535b5ef83ccbe8e769ba1d55f1 (diff) | |
download | chromium_src-6b2ea29a5c2f790c6032f98f920cec97d795ece0.zip chromium_src-6b2ea29a5c2f790c6032f98f920cec97d795ece0.tar.gz chromium_src-6b2ea29a5c2f790c6032f98f920cec97d795ece0.tar.bz2 |
Update the benchmark to use the document.readyState to measure page-completedness
rather than the onload event. Extensions were moved from the pre-onload state
to running at document idle some time ago.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/397013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32076 0039d316-1c4b-4281-b951-d872f2087c98
-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(); |