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

Unified Diff: tools/telemetry/telemetry/page/actions/media_action.js

Issue 19482009: Telemetry media Seek action and metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add base media action class and JS code. Created 7 years, 5 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
« no previous file with comments | « tools/perf/perf_tools/media_metrics.py ('k') | tools/telemetry/telemetry/page/actions/media_action.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/actions/media_action.js
diff --git a/tools/telemetry/telemetry/page/actions/media_action.js b/tools/telemetry/telemetry/page/actions/media_action.js
new file mode 100644
index 0000000000000000000000000000000000000000..96f6ffa658eb18397de7075763b8f4d90c9183f5
--- /dev/null
+++ b/tools/telemetry/telemetry/page/actions/media_action.js
@@ -0,0 +1,38 @@
+// Copyright 2013 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.
+
+
+// This file provides common functions for media actions.
+window.__findMediaElements = function(selector) {
+ // Returns elements matching the selector, otherwise returns the first video
+ // or audio tag element that can be found.
+ // If selector == 'all', returns all media elements.
+ if (selector == 'all') {
+ return document.querySelectorAll('video, audio');
+ } else if (selector) {
+ return document.querySelectorAll(selector);
+ } else {
+ var media = document.getElementsByTagName('video');
+ if (media.length > 0) {
+ return [media[0]];
+ } else {
+ media = document.getElementsByTagName('audio');
+ if (media.length > 0) {
+ return [media[0]];
+ }
+ }
+ }
+ console.error('Could not find any media elements matching: ' + selector);
+ return [];
+};
+
+window.__hasEventCompleted = function(selector, event_name) {
+ // Return true if the event_name fired for media satisfying the selector.
+ var mediaElements = window.__findMediaElements(selector);
+ for (var i = 0; i < mediaElements.length; i++) {
+ if (!mediaElements[i][event_name + '_completed'])
+ return false;
+ }
+ return true;
+};
« no previous file with comments | « tools/perf/perf_tools/media_metrics.py ('k') | tools/telemetry/telemetry/page/actions/media_action.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698