Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/test/data/extensions/samples/benchmark/script.js

Issue 119361: Add a benchmark extension. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698