summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authortonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 23:51:26 +0000
committertonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-05 23:51:26 +0000
commita657352b779646d4087e8ec46d03fa482ee4fe32 (patch)
treec68a9858c32089e173b6317f671727c7fbcb3159 /tools/perf
parent9da7806601e420d1553d08fc9cc600173dfac327 (diff)
downloadchromium_src-a657352b779646d4087e8ec46d03fa482ee4fe32.zip
chromium_src-a657352b779646d4087e8ec46d03fa482ee4fe32.tar.gz
chromium_src-a657352b779646d4087e8ec46d03fa482ee4fe32.tar.bz2
Make scrolling work on docs.
Also unhack the gmail scrollable element by moving that to the config file. BUG=154126 TEST=None Review URL: https://codereview.chromium.org/11072007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/page_sets/top_25.json6
-rw-r--r--tools/perf/perf_tools/scroll.js36
-rw-r--r--tools/perf/perf_tools/scrolling_benchmark.py18
3 files changed, 24 insertions, 36 deletions
diff --git a/tools/perf/page_sets/top_25.json b/tools/perf/page_sets/top_25.json
index f919937..928e72f 100644
--- a/tools/perf/page_sets/top_25.json
+++ b/tools/perf/page_sets/top_25.json
@@ -11,8 +11,7 @@
"url": "https://mail.google.com/mail/",
"why": "productivity, top google properties",
"credentials": "google",
- "is_gmail": true,
- "wait_for_javascript_expression": "window.gmonkey !== undefined"
+ "scrollable_element_function": "function(callback) { gmonkey.load('2.0', function(api) { callback(api.getScrollableElement()); }); }"
},
{
"url": "https://www.google.com/calendar/",
@@ -28,7 +27,8 @@
"name": "Docs (1 open document tab)",
"url": "https://docs.google.com/document/d/1L2AUaE4tAsOjE9xyqT85TtbDmAiuBNN1Gl32I65HjTE/edit",
"why": "productivity, top google properties; Sample doc in the link",
- "credentials": "google"
+ "credentials": "google",
+ "scrollable_element_function": "function(callback) { callback(document.getElementsByClassName('kix-appview-editor')[0]); }"
},
{
"url": "https://maps.google.com",
diff --git a/tools/perf/perf_tools/scroll.js b/tools/perf/perf_tools/scroll.js
index 11e9131..48c6e0e 100644
--- a/tools/perf/perf_tools/scroll.js
+++ b/tools/perf/perf_tools/scroll.js
@@ -39,9 +39,8 @@
* Uses smooth scrolling capabilities provided by the platform, if available.
* @constructor
*/
- function SmoothScrollDownGesture(opt_element, opt_isGmailTest) {
+ function SmoothScrollDownGesture(opt_element) {
this.element_ = opt_element || document.body;
- this.isGmailTest_ = opt_isGmailTest;
};
SmoothScrollDownGesture.prototype.start = function(callback) {
@@ -55,12 +54,6 @@
return;
}
- if (this.isGmailTest_) {
- this.element_.scrollByLines(1);
- requestAnimationFrame(callback);
- return;
- }
-
var SCROLL_DELTA = 100;
this.element_.scrollTop += SCROLL_DELTA;
requestAnimationFrame(callback);
@@ -153,31 +146,15 @@
// The page is scrolled down by a set of scroll gestures. These gestures
// correspond to a reading gesture on that platform.
//
- // start_ -> startPass_ -> ...scrolling... -> onGestureComplete_ ->
- // -> startPass_ -> .. scrolling... -> onGestureComplete_ -> callback_
- //
- // TODO(nduca): This test starts in its constructor. That is strange. We
- // should change it to start explicitly.
- function ScrollTest(opt_callback, opt_isGmailTest) {
+ // start -> startPass_ -> ...scrolling... -> onGestureComplete_ ->
+ // -> startPass_ -> .. scrolling... -> onGestureComplete_ -> callback_
+ function ScrollTest(opt_callback) {
var self = this;
this.callback_ = opt_callback;
- this.isGmailTest_ = opt_isGmailTest;
-
- if (this.isGmailTest_) {
- gmonkey.load('2.0', function(api) {
- self.start_(api.getScrollableElement());
- });
- } else {
- if (document.readyState == 'interactive' ||
- document.readyState == 'complete')
- this.start_();
- else
- window.addEventListener('load', function() { self.start_(); });
- }
}
- ScrollTest.prototype.start_ = function(opt_element) {
+ ScrollTest.prototype.start = function(opt_element) {
// Assign this.element_ here instead of constructor, because the constructor
// ensures this method will be called after the document is loaded.
this.element_ = opt_element || document.body;
@@ -196,8 +173,7 @@
this.renderingStats_ = new RafRenderingStats();
this.renderingStats_.start();
- this.gesture_ = new SmoothScrollDownGesture(this.element_,
- this.isGmailTest_);
+ this.gesture_ = new SmoothScrollDownGesture(this.element_);
this.gesture_.start(this.onGestureComplete_.bind(this));
};
diff --git a/tools/perf/perf_tools/scrolling_benchmark.py b/tools/perf/perf_tools/scrolling_benchmark.py
index 96a0424..5eae210 100644
--- a/tools/perf/perf_tools/scrolling_benchmark.py
+++ b/tools/perf/perf_tools/scrolling_benchmark.py
@@ -45,12 +45,24 @@ class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark):
# Run scroll test.
tab.runtime.Execute(scroll_js)
- tab.runtime.Execute("""
+
+ start_scroll_js = """
window.__renderingStatsDeltas = null;
new __ScrollTest(function(rendering_stats_deltas) {
window.__renderingStatsDeltas = rendering_stats_deltas;
- }, %s);
- """ % str(page.is_gmail).lower())
+ }).start(element);
+ """
+ # scrollable_element_function is a function that passes the scrollable
+ # element on the page to a callback. For example:
+ # function (callback) {
+ # callback(document.getElementById('foo'));
+ # }
+ if hasattr(page, 'scrollable_element_function'):
+ tab.runtime.Execute('(%s)(function(element) { %s });' %
+ (page.scrollable_element_function, start_scroll_js))
+ else:
+ tab.runtime.Execute('(function() { var element = document.body; %s})();' %
+ start_scroll_js)
# Poll for scroll benchmark completion.
util.WaitFor(lambda: tab.runtime.Evaluate(