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

Unified Diff: tools/perf/page_sets/tough_scrolling_cases/busy.js

Issue 11093079: Add http://webstuff.nfshost.com/scrolling/ pageset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: tools/perf/page_sets/tough_scrolling_cases/busy.js
diff --git a/tools/perf/page_sets/tough_scrolling_cases/busy.js b/tools/perf/page_sets/tough_scrolling_cases/busy.js
new file mode 100644
index 0000000000000000000000000000000000000000..c22fbb6d3afc48de370ad895533be6bd14ea2cea
--- /dev/null
+++ b/tools/perf/page_sets/tough_scrolling_cases/busy.js
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function busyLoop(millis) {
+ for (var d = Date.now(); Date.now() - d < millis; ) { }
+}
+
+function visible() {
+ if ("webkitVisibilityState" in document
+ && document.webkitVisibilityState == "hidden")
+ return false;
+ if ("mozVisibilityState" in document
+ && document.mozVisibilityState == "hidden")
+ return false;
+ if ("msVisibilityState" in document
+ && document.msVisibilityState == "hidden")
+ return false;
+ return true;
+}
+
+var timerId = 0;
+function loop() {
+ timerId = 0;
+ if (!visible())
+ return;
+ busyLoop(250);
+ timerId = window.setTimeout(loop, 50);
+}
+
+function handler() {
+ if (visible() && !timerId)
+ timerId = window.setTimeout(loop, 50);
+}
+
+document.addEventListener("webkitvisibilitychange", handler, false);
+document.addEventListener("mozvisibilitychange", handler, false);
+document.addEventListener("msvisibilitychange", handler, false);
+
+loop();

Powered by Google App Engine
This is Rietveld 408576698