summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-17 04:32:09 +0000
committerimcheng@chromium.org <imcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-17 04:32:09 +0000
commit1126c4c9c749f375a3c0fd03cb0b4a0dc77c0a8b (patch)
tree75a9ad4a96930218d44af4caf26e0d4f6f302d55
parent8bc0a213db06face335d290da1fd7944d7fa7b70 (diff)
downloadchromium_src-1126c4c9c749f375a3c0fd03cb0b4a0dc77c0a8b.zip
chromium_src-1126c4c9c749f375a3c0fd03cb0b4a0dc77c0a8b.tar.gz
chromium_src-1126c4c9c749f375a3c0fd03cb0b4a0dc77c0a8b.tar.bz2
Refactoring of player[_fullscreen].html by placing the common functions in a js file. Also, removing media_uitest.cc which is now empty. (it was not removed on last commit due to some svn oddities)
BUG=none TEST=MediaBrowserTest.* Review URL: http://codereview.chromium.org/3454005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59768 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/media_uitest.cc0
-rw-r--r--chrome/test/data/media/player.html31
-rw-r--r--chrome/test/data/media/player.js62
-rw-r--r--chrome/test/data/media/player_fullscreen.html49
4 files changed, 78 insertions, 64 deletions
diff --git a/chrome/browser/media_uitest.cc b/chrome/browser/media_uitest.cc
deleted file mode 100644
index e69de29..0000000
--- a/chrome/browser/media_uitest.cc
+++ /dev/null
diff --git a/chrome/test/data/media/player.html b/chrome/test/data/media/player.html
index 3b8fd9b..a2992f7 100644
--- a/chrome/test/data/media/player.html
+++ b/chrome/test/data/media/player.html
@@ -1,40 +1,25 @@
<html>
<body>
<div id="player_container"></div>
+<script src="player.js"></script>
<script>
-var player = null;
-function InstallEventHandler(event, action) {
- player.addEventListener(event, function(e) {
- eval(action);
- }, false);
-}
// Parse the location and load the media file accordingly.
-var url = window.location.href;
-var url_parts = url.split('?');
+var params = GetTestParameters();
// Make sure the URL is of the form "player.html?query".
var ok = false;
-if (url_parts.length > 1) {
- var query = url_parts[1];
- var query_parts = query.split('=');
- if (query_parts.length == 2) {
- var tag = query_parts[0];
- var media_url = query_parts[1];
+if (params) {
+ var tag = params['tag'];
+ var url = params['url'];
+ if (tag && url) {
if (tag == 'audio' || tag == 'video') {
ok = true;
- var container = document.getElementById('player_container');
- container.innerHTML = '<' + tag + ' controls id="player"></' + tag + '>';
- player = document.getElementById('player');
-
// Install event handlers.
- InstallEventHandler('error',
- 'document.title = "ERROR = " + player.error.code');
- InstallEventHandler('playing', 'document.title = "PLAYING"');
+ SetupPlayer(tag, false);
// Starts the player.
- player.src = media_url;
- player.play();
+ StartPlayer(url);
}
}
}
diff --git a/chrome/test/data/media/player.js b/chrome/test/data/media/player.js
new file mode 100644
index 0000000..038ae34
--- /dev/null
+++ b/chrome/test/data/media/player.js
@@ -0,0 +1,62 @@
+var player = null;
+
+function GetTestParameters() {
+ var parts = window.location.href.split('?');
+ if (parts.length != 2)
+ return null;
+ var query = parts[1];
+ var params = new Array();
+ var query_parts = query.split('=');
+ if (query_parts.length == 2) {
+ params['tag'] = query_parts[0];
+ params['url'] = query_parts[1];
+ } else if (query_parts.length == 1) {
+ params['url'] = query_parts[0];
+ } else {
+ return null;
+ }
+ return params;
+}
+
+function SetupPlayer(tag, fullscreen) {
+ var container = document.getElementById('player_container');
+ container.innerHTML = '<' + tag + ' controls id="player"></' + tag + '>';
+ player = document.getElementById('player');
+ player.addEventListener('error',
+ function() {
+ document.title = "ERROR = " + player.error.code;
+ },
+ false);
+ if (fullscreen) {
+ player.addEventListener('canplay',
+ function() {
+ if (!player.webkitSupportsFullscreen) {
+ document.title = "ERROR fullscreen unsupported";
+ } else {
+ document.title = "READY";
+ }
+ },
+ false);
+ document.onclick = function () {
+ try {
+ player.webkitEnterFullScreen();
+ } catch (err) {}
+ if (!player.webkitDisplayingFullscreen) {
+ document.title = "ERROR entering to fullscreen";
+ } else {
+ document.title = "FULLSCREEN";
+ }
+ };
+ } else {
+ player.addEventListener('playing',
+ function() {
+ document.title = "PLAYING";
+ },
+ false);
+ }
+}
+
+function StartPlayer(media_url) {
+ player.src = media_url;
+ player.play();
+}
diff --git a/chrome/test/data/media/player_fullscreen.html b/chrome/test/data/media/player_fullscreen.html
index d31579c..fbecd67 100644
--- a/chrome/test/data/media/player_fullscreen.html
+++ b/chrome/test/data/media/player_fullscreen.html
@@ -1,54 +1,21 @@
<html>
<body>
<div id="player_container"></div>
+<script src="player.js"></script>
<script>
-var player = null;
-var ready = false;
// Parse the location and load the media file accordingly.
-var url = window.location.href;
-var url_parts = url.split('?');
+var params = GetTestParameters();
-// Make sure the URL is of the form "player.html?media_url".
-var ok = false;
-if (url_parts.length > 1) {
- var media_url = url_parts[1];
+// Make sure the URL is of the form "player_fullscreen.html?media_url".
+if (params) {
ok = true;
- var container = document.getElementById('player_container');
- container.innerHTML = '<video id="player"></video>';
- player = document.getElementById('player');
-
// Install event handlers.
- player.addEventListener('error',
- function() {
- document.title = "ERROR = " + player.error.code;
- },
- false);
- player.addEventListener('canplay',
- function() {
- if (!player.webkitSupportsFullscreen) {
- document.title = "ERROR fullscreen unsupported";
- } else {
- document.title = "READY";
- }
- },
- false);
-
+ SetupPlayer('video', true);
+
// Starts the player.
- player.src = media_url;
- player.play();
- document.onclick = function () {
- try {
- player.webkitEnterFullScreen();
- } catch (err) {}
- if (!player.webkitDisplayingFullscreen) {
- document.title = "ERROR entering to fullscreen";
- } else {
- document.title = "FULLSCREEN";
- }
- };
-}
-if (!ok) {
+ StartPlayer(params['url']);
+} else {
document.title = 'FAILED';
}
</script>