1. Updated test pages to include Chrome Frame meta tag
2. Updated test pages to use adapter.js
Review URL: https://webrtc-codereview.appspot.com/1142004

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3614 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/test/manual/adapter.js b/test/manual/adapter.js
new file mode 100644
index 0000000..b03d758
--- /dev/null
+++ b/test/manual/adapter.js
@@ -0,0 +1,51 @@
+var RTCPeerConnection = null;
+var getUserMedia = null;
+var attachMediaStream = null;
+
+if (navigator.mozGetUserMedia) {
+  console.log("This appears to be Firefox");
+
+  // The RTCPeerConnection object.
+  RTCPeerConnection = mozRTCPeerConnection;
+
+  // Get UserMedia (only difference is the prefix).
+  // Code from Adam Barth.
+  getUserMedia = navigator.mozGetUserMedia.bind(navigator);
+
+  // Attach a media stream to an element.
+  attachMediaStream = function(element, stream) {
+    console.log("Attaching media stream");
+    element.mozSrcObject = stream;
+    element.play();
+  };
+} else if (navigator.webkitGetUserMedia) {
+  console.log("This appears to be Chrome");
+
+  // The RTCPeerConnection object.
+  RTCPeerConnection = webkitRTCPeerConnection;
+  
+  // Get UserMedia (only difference is the prefix).
+  // Code from Adam Barth.
+  getUserMedia = navigator.webkitGetUserMedia.bind(navigator);
+
+  // Attach a media stream to an element.
+  attachMediaStream = function(element, stream) {
+    element.src = webkitURL.createObjectURL(stream);
+  };
+
+  // The representation of tracks in a stream is changed in M26.
+  // Unify them for earlier Chrome versions in the coexisting period.
+  if (!webkitMediaStream.prototype.getVideoTracks) {
+      webkitMediaStream.prototype.getVideoTracks = function() {
+      return this.videoTracks;
+    } 
+  } 
+  
+  if (!webkitMediaStream.prototype.getAudioTracks) {
+      webkitMediaStream.prototype.getAudioTracks = function() {
+      return this.audioTracks;
+    }
+  } 
+} else {
+  console.log("Browser does not appear to be WebRTC-capable");
+}
diff --git a/test/manual/audio-and-video.html b/test/manual/audio-and-video.html
index 1e54424..c4e1d84 100644
--- a/test/manual/audio-and-video.html
+++ b/test/manual/audio-and-video.html
@@ -11,11 +11,15 @@
 <html>
 <head>
   <title>Single Local Preview (Video and Audio)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
+  <!-- Load the polyfill to switch-hit between Chrome and Firefox -->
+  <script src="adapter.js"></script>
   <script type="text/javascript">
   function requestVideoAndAudio() {
-    navigator.webkitGetUserMedia({video: true, audio: true},
-                                 getUserMediaOkCallback,
-                                 getUserMediaFailedCallback);
+    // Call into getUserMedia via the polyfill (adapter.js).
+    getUserMedia({video: true, audio: true},
+                         getUserMediaOkCallback,
+                         getUserMediaFailedCallback);
   }
 
   function getUserMediaFailedCallback(error) {
@@ -23,9 +27,8 @@
   }
 
   function getUserMediaOkCallback(stream) {
-    var streamUrl = webkitURL.createObjectURL(stream);
-    document.getElementById("view1").src = streamUrl;
-    //document.getElementById("audio1").src = streamUrl;
+    attachMediaStream(document.getElementById("view1"), stream);
+    attachMediaStream(document.getElementById("audio1"), stream);
   }
   </script>
 </head>
@@ -41,4 +44,4 @@
     </tr>
   </table>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/test/manual/iframe-apprtc.html b/test/manual/iframe-apprtc.html
index f2f0f0c..31e0db1 100644
--- a/test/manual/iframe-apprtc.html
+++ b/test/manual/iframe-apprtc.html
@@ -11,6 +11,7 @@
 <html>
 <head>
   <title>AppRTC web app in an IFRAME</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
 </head>
 <body>
   AppRTC in an &lt;iframe&gt; element:<br>
diff --git a/test/manual/iframe-video.html b/test/manual/iframe-video.html
index dffdbef..3cb532b 100644
--- a/test/manual/iframe-video.html
+++ b/test/manual/iframe-video.html
@@ -11,6 +11,7 @@
 <html>
 <head>
   <title>IFRAME Single Local Preview (Video Only)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
 </head>
 <body>
   <iframe width="100%" height="100%" src="single-video.html"></iframe>
diff --git a/test/manual/multiple-audio.html b/test/manual/multiple-audio.html
index 1575c7d..80e4b64 100644
--- a/test/manual/multiple-audio.html
+++ b/test/manual/multiple-audio.html
@@ -11,11 +11,15 @@
 <html>
 <head>
   <title>Multiple Local Preview (Audio Only)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
+  <!-- Load the polyfill to switch-hit between Chrome and Firefox -->
+  <script src="adapter.js"> </script>
   <script type="text/javascript">
   function requestAudio() {
-    navigator.webkitGetUserMedia({video: false, audio: true},
-                                 getUserMediaOkCallback,
-                                 getUserMediaFailedCallback);
+    // Call into getUserMedia via the polyfill (adapter.js).
+    getUserMedia({video: false, audio: true},
+                         getUserMediaOkCallback,
+                         getUserMediaFailedCallback);
   }
 
   function getUserMediaFailedCallback(error) {
@@ -23,9 +27,9 @@
   }
 
   function getUserMediaOkCallback(stream) {
-    var streamUrl = webkitURL.createObjectURL(stream);
+     // Call the polyfill wrapper to attach the media stream to this element.
     for (var i = 1; i <= 10; i++) {
-      document.getElementById("audio" + i).src = streamUrl;
+      attachMediaStream(document.getElementById("audio" + i), stream);
     }
   }
   </script>
@@ -49,4 +53,4 @@
     </tr>
   </table>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/test/manual/multiple-video.html b/test/manual/multiple-video.html
index 1ba46c1..fd82bf8 100644
--- a/test/manual/multiple-video.html
+++ b/test/manual/multiple-video.html
@@ -11,11 +11,15 @@
 <html>
 <head>
   <title>Multiple Local Preview (Video Only)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
+  <!-- Load the polyfill to switch-hit between Chrome and Firefox -->
+  <script src="adapter.js"></script>
   <script type="text/javascript">
   function requestVideo() {
-    navigator.webkitGetUserMedia({video: true, audio: false},
-                                 getUserMediaOkCallback,
-                                 getUserMediaFailedCallback);
+    // Call into getUserMedia via the polyfill (adapter.js).
+    getUserMedia({video: true, audio: false},
+                         getUserMediaOkCallback,
+                         getUserMediaFailedCallback);
   }
 
   function getUserMediaFailedCallback(error) {
@@ -23,9 +27,9 @@
   }
 
   function getUserMediaOkCallback(stream) {
-    var streamUrl = webkitURL.createObjectURL(stream);
+    // Call the polyfill wrapper to attach the media stream to this element.
     for (var i = 1; i <= 10; i++) {
-      document.getElementById("view" + i).src = streamUrl;
+      attachMediaStream(document.getElementById("view" + i), stream);
     }
   }
   </script>
@@ -65,4 +69,4 @@
     </tr>
   </table>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/test/manual/single-audio.html b/test/manual/single-audio.html
index e003a62..b5d1ed4 100644
--- a/test/manual/single-audio.html
+++ b/test/manual/single-audio.html
@@ -11,11 +11,14 @@
 <html>
 <head>
   <title>Single Local Preview (Audio Only)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
+  <!-- Load the polyfill to switch-hit between Chrome and Firefox -->
+  <script src="adapter.js"> </script>
   <script type="text/javascript">
   function requestAudio() {
-    navigator.webkitGetUserMedia({video: false, audio: true},
-                                 getUserMediaOkCallback,
-                                 getUserMediaFailedCallback);
+    getUserMedia({video: false, audio: true},
+                         getUserMediaOkCallback,
+                         getUserMediaFailedCallback);
   }
 
   function getUserMediaFailedCallback(error) {
@@ -23,8 +26,8 @@
   }
 
   function getUserMediaOkCallback(stream) {
-    var streamUrl = webkitURL.createObjectURL(stream);
-    document.getElementById("audio1").src = streamUrl;
+    // Call the polyfill wrapper to attach the media stream to this element.
+    attachMediaStream(document.getElementById("audio1"), stream);
   }
   </script>
 </head>
@@ -38,4 +41,4 @@
     </tr>
   </table>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/test/manual/single-video.html b/test/manual/single-video.html
index 6b3283c..7a88dcf 100644
--- a/test/manual/single-video.html
+++ b/test/manual/single-video.html
@@ -11,11 +11,14 @@
 <html>
 <head>
   <title>Single Local Preview (Video Only)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
+  <!-- Load the polyfill to switch-hit between Chrome and Firefox -->
+  <script src="adapter.js"> </script>
   <script type="text/javascript">
   function requestVideo() {
-    navigator.webkitGetUserMedia({video: true, audio: false},
-                                 getUserMediaOkCallback,
-                                 getUserMediaFailedCallback);
+    getUserMedia({video: true, audio: false},
+                         getUserMediaOkCallback,
+                         getUserMediaFailedCallback);
   }
 
   function getUserMediaFailedCallback(error) {
@@ -23,8 +26,8 @@
   }
 
   function getUserMediaOkCallback(stream) {
-    var streamUrl = webkitURL.createObjectURL(stream);
-    document.getElementById("view1").src = streamUrl;
+    // Call the polyfill wrapper to attach the media stream to this element.
+    attachMediaStream(document.getElementById("view1"), stream);
   }
   </script>
 </head>
@@ -39,4 +42,4 @@
     </tr>
   </table>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/test/manual/two-video-devices.html b/test/manual/two-video-devices.html
index bdd197c..44c0947 100644
--- a/test/manual/two-video-devices.html
+++ b/test/manual/two-video-devices.html
@@ -11,13 +11,17 @@
 <html>
 <head>
   <title>Single Local Preview (Video Only)</title>
+  <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
+   <!-- Load the polyfill to switch-hit between Chrome and Firefox -->
+  <script src="adapter.js"></script>
   <script type="text/javascript">
   function requestVideo(target) {
-    navigator.webkitGetUserMedia({video: true, audio: false},
-                                 function(stream) {
-                                   getUserMediaOkCallback(stream, target);
-                                 },
-                                 getUserMediaFailedCallback);
+   // Call into getUserMedia via the polyfill (adapter.js).
+    getUserMedia({video: true, audio: false},
+                         function(stream) {
+                           getUserMediaOkCallback(stream, target);
+                         },
+                         getUserMediaFailedCallback);
   }
 
   function getUserMediaFailedCallback(error) {
@@ -25,8 +29,9 @@
   }
 
   function getUserMediaOkCallback(stream, target) {
-    var streamUrl = webkitURL.createObjectURL(stream);
-    document.getElementById(target).src = streamUrl;
+     // Call the polyfill wrapper to attach the media stream to this element.
+     attachMediaStream(document.getElementById("view1"), stream);
+     attachMediaStream(document.getElementById("view2"), stream);
   }
   </script>
 </head>