Have media content and chrome browser tests load data from media/test/data

Update remaining encrypted media browser tests to use new player app.

This is similar to r282795 + fix to GN builds. The fix is in
media/BUILD.gn file.

BUG=379314

Review URL: https://codereview.chromium.org/408993002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284803 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/media/encrypted_media_browsertest.cc b/chrome/browser/media/encrypted_media_browsertest.cc
index 40a73b4..65a7280 100644
--- a/chrome/browser/media/encrypted_media_browsertest.cc
+++ b/chrome/browser/media/encrypted_media_browsertest.cc
@@ -115,12 +115,14 @@
   }
 #endif  // defined(WIDEVINE_CDM_AVAILABLE)
 
-  void RunEncryptedMediaTestPage(const std::string& html_page,
-                                 const std::string& key_system,
-                                 std::vector<StringPair>* query_params,
-                                 const std::string& expected_title) {
-    StartLicenseServerIfNeeded(key_system, query_params);
-    RunMediaTestPage(html_page, query_params, expected_title, true);
+  void RunEncryptedMediaTestPage(
+      const std::string& html_page,
+      const std::string& key_system,
+      const media::QueryParams& query_params,
+      const std::string& expected_title) {
+    media::QueryParams new_query_params = query_params;
+    StartLicenseServerIfNeeded(key_system, &new_query_params);
+    RunMediaTestPage(html_page, new_query_params, expected_title, true);
   }
 
   // Tests |html_page| using |media_file| (with |media_type|) and |key_system|.
@@ -144,7 +146,7 @@
       VLOG(0) << "Skipping test - MSE not supported.";
       return;
     }
-    std::vector<StringPair> query_params;
+    media::QueryParams query_params;
     query_params.push_back(std::make_pair("mediaFile", media_file));
     query_params.push_back(std::make_pair("mediaType", media_type));
     query_params.push_back(std::make_pair("keySystem", key_system));
@@ -156,7 +158,7 @@
       query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
     if (!session_to_load.empty())
       query_params.push_back(std::make_pair("sessionToLoad", session_to_load));
-    RunEncryptedMediaTestPage(html_page, key_system, &query_params,
+    RunEncryptedMediaTestPage(html_page, key_system, query_params,
                               expected_title);
   }
 
@@ -188,16 +190,17 @@
     EXPECT_TRUE(receivedKeyMessage);
   }
 
-
+  // Starts a license server if available for the |key_system| and adds a
+  // 'licenseServerURL' query parameter to |query_params|.
   void StartLicenseServerIfNeeded(const std::string& key_system,
-                                  std::vector<StringPair>* query_params) {
+                                  media::QueryParams* query_params) {
     scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system);
     if (!config)
       return;
     license_server_.reset(new TestLicenseServer(config.Pass()));
     EXPECT_TRUE(license_server_->Start());
-    query_params->push_back(std::make_pair("licenseServerURL",
-        license_server_->GetServerURL()));
+    query_params->push_back(
+        std::make_pair("licenseServerURL", license_server_->GetServerURL()));
   }
 
   bool IsPlayBackPossible(const std::string& key_system) {
@@ -312,7 +315,7 @@
     // Since we do not test playback, arbitrarily choose a test file and source
     // type.
     RunEncryptedMediaTest(kDefaultEmePlayer,
-                          "bear-a-enc_a.webm",
+                          "bear-a_enc-a.webm",
                           kWebMAudioOnly,
                           key_system,
                           SRC,
@@ -379,7 +382,7 @@
 
   void RunInvalidResponseTest() {
     RunEncryptedMediaTest(kDefaultEmePlayer,
-                          "bear-320x240-av-enc_av.webm",
+                          "bear-320x240-av_enc-av.webm",
                           kWebMAudioVideo,
                           CurrentKeySystem(),
                           CurrentSourceType(),
@@ -391,7 +394,7 @@
 
   void TestFrameSizeChange() {
     RunEncryptedMediaTest("encrypted_frame_size_change.html",
-                          "frame_size_change-av-enc-v.webm",
+                          "frame_size_change-av_enc-v.webm",
                           kWebMAudioVideo,
                           CurrentKeySystem(),
                           CurrentSourceType(),
@@ -403,14 +406,14 @@
 
   void TestConfigChange() {
     DCHECK(IsMSESupported());
-    std::vector<StringPair> query_params;
+    media::QueryParams query_params;
     query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
     query_params.push_back(std::make_pair("runEncrypted", "1"));
     if (CurrentEmeVersion() == PREFIXED)
       query_params.push_back(std::make_pair("usePrefixedEME", "1"));
     RunEncryptedMediaTestPage("mse_config_change.html",
                               CurrentKeySystem(),
-                              &query_params,
+                              query_params,
                               kEnded);
   }
 
@@ -488,7 +491,7 @@
                         Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
                                 Values(MSE),
                                 Values(UNPREFIXED)));
-#endif // defined(ENABLE_PEPPER_CDMS)
+#endif  // defined(ENABLE_PEPPER_CDMS)
 
 #if defined(WIDEVINE_CDM_AVAILABLE)
 // This test doesn't fully test playback with Widevine. So we only run Widevine
@@ -511,27 +514,27 @@
 #endif  // defined(WIDEVINE_CDM_AVAILABLE)
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
-  TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly);
+  TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
-  TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo);
+  TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
-  TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo);
+  TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) {
-  TestSimplePlayback("bear-320x240-v-enc_v.webm", kWebMVideoOnly);
+  TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
-  TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo);
+  TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) {
-  TestSimplePlayback("bear-320x240-v-vp9-enc_v.webm", kWebMVP9VideoOnly);
+  TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) {
@@ -587,7 +590,7 @@
 // The parent key system cannot be used in generateKeyRequest.
 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
   RunEncryptedMediaTest(kDefaultEmePlayer,
-                        "bear-a-enc_a.webm",
+                        "bear-a_enc-a.webm",
                         kWebMAudioOnly,
                         "com.widevine",
                         MSE,
@@ -601,7 +604,7 @@
 // The parent key system cannot be used when creating MediaKeys.
 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
   RunEncryptedMediaTest(kDefaultEmePlayer,
-                        "bear-a-enc_a.webm",
+                        "bear-a_enc-a.webm",
                         kWebMAudioOnly,
                         "com.widevine",
                         MSE,
@@ -640,7 +643,7 @@
 
 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
   RunEncryptedMediaTest(kDefaultEmePlayer,
-                        "bear-320x240-v-enc_v.webm",
+                        "bear-320x240-v_enc-v.webm",
                         kWebMVideoOnly,
                         kExternalClearKeyKeySystem,
                         SRC,
@@ -653,7 +656,7 @@
 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
   // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound.
   RunEncryptedMediaTest(kDefaultEmePlayer,
-                        "bear-320x240-v-enc_v.webm",
+                        "bear-320x240-v_enc-v.webm",
                         kWebMVideoOnly,
                         kExternalClearKeyKeySystem,
                         SRC,
diff --git a/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc b/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc
index 4ffde6f..3e7dc6c 100644
--- a/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc
+++ b/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc
@@ -17,6 +17,7 @@
 #include "chrome/test/base/ui_test_utils.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/test/browser_test_utils.h"
+#include "media/base/test_data_util.h"
 #include "url/gurl.h"
 
 #include "widevine_cdm_version.h"  // In SHARED_INTERMEDIATE_DIR.
@@ -224,9 +225,10 @@
     // Load the test page needed. IsConcreteSupportedKeySystem() needs some
     // JavaScript and a video loaded in order to work.
     if (!is_test_page_loaded_) {
-      ASSERT_TRUE(test_server()->Start());
-      GURL gurl = test_server()->GetURL(
-          "files/media/test_key_system_instantiation.html");
+      scoped_ptr<net::SpawnedTestServer> http_test_server =
+          media::StartMediaHttpTestServer();
+      GURL gurl = http_test_server->GetURL(
+          "files/test_key_system_instantiation.html");
       ui_test_utils::NavigateToURL(browser(), gurl);
       is_test_page_loaded_ = true;
     }
diff --git a/chrome/browser/media/media_browsertest.cc b/chrome/browser/media/media_browsertest.cc
index cf0195e..aca81db 100644
--- a/chrome/browser/media/media_browsertest.cc
+++ b/chrome/browser/media/media_browsertest.cc
@@ -4,12 +4,9 @@
 
 #include "chrome/browser/media/media_browsertest.h"
 
-#include "base/path_service.h"
-#include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/chrome_paths.h"
 #include "chrome/test/base/ui_test_utils.h"
 #include "content/public/browser/navigation_controller.h"
 #include "content/public/browser/navigation_entry.h"
@@ -28,37 +25,27 @@
 MediaBrowserTest::~MediaBrowserTest() {
 }
 
-void MediaBrowserTest::RunMediaTestPage(
-    const std::string& html_page, std::vector<StringPair>* query_params,
-    const std::string& expected_title, bool http) {
+void MediaBrowserTest::RunMediaTestPage(const std::string& html_page,
+                                        const media::QueryParams& query_params,
+                                        const std::string& expected_title,
+                                        bool http) {
   GURL gurl;
-  std::string query = "";
-  if (query_params != NULL && !query_params->empty()) {
-    std::vector<StringPair>::const_iterator itr = query_params->begin();
-    query = itr->first + "=" + itr->second;
-    ++itr;
-    for (; itr != query_params->end(); ++itr) {
-      query.append("&" + itr->first + "=" + itr->second);
-    }
-  }
+  std::string query = media::GetURLQueryString(query_params);
+  scoped_ptr<net::SpawnedTestServer> http_test_server;
   if (http) {
-    ASSERT_TRUE(test_server()->Start());
-    gurl = test_server()->GetURL("files/media/" + html_page + "?" + query);
+    http_test_server = media::StartMediaHttpTestServer();
+    gurl = http_test_server->GetURL("files/" + html_page + "?" + query);
   } else {
-    base::FilePath test_file_path;
-    PathService::Get(chrome::DIR_TEST_DATA, &test_file_path);
-    test_file_path = test_file_path.AppendASCII("media")
-                                   .AppendASCII(html_page);
-    gurl = content::GetFileUrlWithQuery(test_file_path, query);
+    gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page),
+                                        query);
   }
-
-  base::string16 final_title = RunTest(gurl, expected_title);
-  EXPECT_EQ(base::ASCIIToUTF16(expected_title), final_title);
+  std::string final_title = RunTest(gurl, expected_title);
+  EXPECT_EQ(expected_title, final_title);
 }
 
-base::string16 MediaBrowserTest::RunTest(const GURL& gurl,
-                                         const std::string& expected_title) {
-  VLOG(0) << "Running test URL: " << gurl;
+std::string MediaBrowserTest::RunTest(const GURL& gurl,
+                                      const std::string& expected_title) {
+  DVLOG(0) << "Running test URL: " << gurl;
   // Observe the web contents for plugin crashes.
   Observe(browser()->tab_strip_model()->GetActiveWebContents());
   content::TitleWatcher title_watcher(
@@ -66,8 +53,8 @@
       base::ASCIIToUTF16(expected_title));
   AddWaitForTitles(&title_watcher);
   ui_test_utils::NavigateToURL(browser(), gurl);
-
-  return title_watcher.WaitAndGetTitle();
+  base::string16 result = title_watcher.WaitAndGetTitle();
+  return base::UTF16ToASCII(result);
 }
 
 void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) {
diff --git a/chrome/browser/media/media_browsertest.h b/chrome/browser/media/media_browsertest.h
index be62f7a..893fab1 100644
--- a/chrome/browser/media/media_browsertest.h
+++ b/chrome/browser/media/media_browsertest.h
@@ -5,11 +5,11 @@
 #ifndef CHROME_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_
 #define CHROME_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_
 
-#include <utility>
-#include <vector>
+#include <string>
 
 #include "chrome/test/base/in_process_browser_test.h"
 #include "content/public/browser/web_contents_observer.h"
+#include "media/base/test_data_util.h"
 
 namespace content {
 class TitleWatcher;
@@ -21,8 +21,6 @@
 class MediaBrowserTest : public InProcessBrowserTest,
                          public content::WebContentsObserver {
  protected:
-  typedef std::pair<std::string, std::string> StringPair;
-
   // Common test results.
   static const char kEnded[];
   // TODO(xhwang): Report detailed errors, e.g. "ERROR-3".
@@ -38,12 +36,13 @@
   // page, otherwise a local file URL is loaded inside the content shell.
   // It uses RunTest() to check for expected test output.
   void RunMediaTestPage(const std::string& html_page,
-                        std::vector<StringPair>* query_params,
-                        const std::string& expected, bool http);
+                        const media::QueryParams& query_params,
+                        const std::string& expected,
+                        bool http);
 
   // Opens a URL and waits for the document title to match either one of the
-  // default strings or the expected string.
-  base::string16 RunTest(const GURL& gurl, const std::string& expected);
+  // default strings or the expected string. Returns the matching title value.
+  std::string RunTest(const GURL& gurl, const std::string& expected);
 
   virtual void AddWaitForTitles(content::TitleWatcher* title_watcher);
 
diff --git a/chrome/test/data/media/eme_player_js/test_config.js b/chrome/test/data/media/eme_player_js/test_config.js
deleted file mode 100644
index e654a1c..0000000
--- a/chrome/test/data/media/eme_player_js/test_config.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 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.
-
-// Test configuration used by test page to configure the player app and other
-// test specific configurations.
-function TestConfig() {
-  this.mediaFile = null;
-  this.keySystem = null;
-  this.mediaType = null;
-  this.licenseServerURL = null;
-  this.useMSE = false;
-  this.usePrefixedEME = false;
-  this.runFPS = false;
-}
-
-TestConfig.prototype.loadQueryParams = function() {
-  // Load query parameters and set default values.
-  var r = /([^&=]+)=?([^&]*)/g;
-  // Lambda function for decoding extracted match values. Replaces '+' with
-  // space so decodeURIComponent functions properly.
-  var decodeURI = function decodeURI(s) {
-      return decodeURIComponent(s.replace(/\+/g, ' '));
-  };
-  var match;
-  while (match = r.exec(window.location.search.substring(1)))
-    this[decodeURI(match[1])] = decodeURI(match[2]);
-  this.useMSE = this.useMSE == '1' || this.useMSE == 'true';
-  this.usePrefixedEME =
-      this.usePrefixedEME == '1' || this.usePrefixedEME == 'true';
-};
diff --git a/chrome/test/data/media/frame_size_change-av-enc-v.webm b/chrome/test/data/media/frame_size_change-av-enc-v.webm
deleted file mode 100644
index 200be55..0000000
--- a/chrome/test/data/media/frame_size_change-av-enc-v.webm
+++ /dev/null
Binary files differ
diff --git a/content/browser/media/encrypted_media_browsertest.cc b/content/browser/media/encrypted_media_browsertest.cc
index 9c0dbac..9f5e137 100644
--- a/content/browser/media/encrypted_media_browsertest.cc
+++ b/content/browser/media/encrypted_media_browsertest.cc
@@ -3,7 +3,6 @@
 // found in the LICENSE file.
 
 #include "base/command_line.h"
-#include "base/path_service.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/windows_version.h"
 #include "content/browser/media/media_browsertest.h"
@@ -26,6 +25,8 @@
 const char kEmeKeyError[] = "KEYERROR";
 const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
 
+const char kDefaultEmePlayer[] = "eme_player.html";
+
 // The type of video src used to load media.
 enum SrcType {
   SRC,
@@ -52,7 +53,7 @@
     public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > {
  public:
   // Can only be used in parameterized (*_P) tests.
-  const char* CurrentKeySystem() {
+  const std::string CurrentKeySystem() {
     return std::tr1::get<0>(GetParam());
   }
 
@@ -61,14 +62,15 @@
     return std::tr1::get<1>(GetParam());
   }
 
-  void TestSimplePlayback(const char* encrypted_media, const char* media_type) {
+  void TestSimplePlayback(const std::string& encrypted_media,
+                          const std::string& media_type) {
     RunSimpleEncryptedMediaTest(
         encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType());
   }
 
   void TestFrameSizeChange() {
     RunEncryptedMediaTest("encrypted_frame_size_change.html",
-                          "frame_size_change-av-enc-v.webm", kWebMAudioVideo,
+                          "frame_size_change-av_enc-v.webm", kWebMAudioVideo,
                           CurrentKeySystem(), CurrentSourceType(), kEnded);
   }
 
@@ -78,38 +80,42 @@
       return;
     }
 
-    std::vector<StringPair> query_params;
-    query_params.push_back(std::make_pair("keysystem", CurrentKeySystem()));
-    query_params.push_back(std::make_pair("runencrypted", "1"));
-    RunMediaTestPage("mse_config_change.html", &query_params, kEnded, true);
+    media::QueryParams query_params;
+    query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
+    query_params.push_back(std::make_pair("runEncrypted", "1"));
+    RunMediaTestPage("mse_config_change.html", query_params, kEnded, true);
   }
 
-  void RunEncryptedMediaTest(const char* html_page,
-                             const char* media_file,
-                             const char* media_type,
-                             const char* key_system,
+  void RunEncryptedMediaTest(const std::string& html_page,
+                             const std::string& media_file,
+                             const std::string& media_type,
+                             const std::string& key_system,
                              SrcType src_type,
-                             const char* expectation) {
+                             const std::string& expectation) {
     if (src_type == MSE && !IsMSESupported()) {
       VLOG(0) << "Skipping test - MSE not supported.";
       return;
     }
 
-    std::vector<StringPair> query_params;
-    query_params.push_back(std::make_pair("mediafile", media_file));
-    query_params.push_back(std::make_pair("mediatype", media_type));
-    query_params.push_back(std::make_pair("keysystem", key_system));
+    media::QueryParams query_params;
+    query_params.push_back(std::make_pair("mediaFile", media_file));
+    query_params.push_back(std::make_pair("mediaType", media_type));
+    query_params.push_back(std::make_pair("keySystem", key_system));
     if (src_type == MSE)
-      query_params.push_back(std::make_pair("usemse", "1"));
-    RunMediaTestPage(html_page, &query_params, expectation, true);
+      query_params.push_back(std::make_pair("useMSE", "1"));
+    RunMediaTestPage(html_page, query_params, expectation, true);
   }
 
-  void RunSimpleEncryptedMediaTest(const char* media_file,
-                                   const char* media_type,
-                                   const char* key_system,
+  void RunSimpleEncryptedMediaTest(const std::string& media_file,
+                                   const std::string& media_type,
+                                   const std::string& key_system,
                                    SrcType src_type) {
-    RunEncryptedMediaTest("encrypted_media_player.html", media_file,
-                          media_type, key_system, src_type, kEnded);
+    RunEncryptedMediaTest(kDefaultEmePlayer,
+                          media_file,
+                          media_type,
+                          key_system,
+                          src_type,
+                          kEnded);
   }
 
  protected:
@@ -141,23 +147,23 @@
                         Combine(Values(kClearKeyKeySystem), Values(MSE)));
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
-  TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly);
+  TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) {
-  TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo);
+  TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) {
-  TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo);
+  TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) {
-  TestSimplePlayback("bear-320x240-v-enc_v.webm", kWebMVideoOnly);
+  TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) {
-  TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo);
+  TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo);
 }
 
 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) {
@@ -174,8 +180,11 @@
 }
 
 IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) {
-  RunEncryptedMediaTest("encrypted_media_player.html", "bear-a-enc_a.webm",
-                        kWebMAudioOnly, "com.example.foo", MSE,
+  RunEncryptedMediaTest(kDefaultEmePlayer,
+                        "bear-a_enc-a.webm",
+                        kWebMAudioOnly,
+                        "com.example.foo",
+                        MSE,
                         kEmeNotSupportedError);
 }
 
diff --git a/content/browser/media/media_browsertest.cc b/content/browser/media/media_browsertest.cc
index a0658c2..4535880 100644
--- a/content/browser/media/media_browsertest.cc
+++ b/content/browser/media/media_browsertest.cc
@@ -4,10 +4,8 @@
 
 #include "content/browser/media/media_browsertest.h"
 
-#include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "content/public/browser/web_contents.h"
-#include "content/public/common/url_constants.h"
 #include "content/public/test/browser_test_utils.h"
 #include "content/public/test/content_browser_test_utils.h"
 #include "content/shell/browser/shell.h"
@@ -26,39 +24,33 @@
 const char MediaBrowserTest::kError[] = "ERROR";
 const char MediaBrowserTest::kFailed[] = "FAILED";
 
-void MediaBrowserTest::RunMediaTestPage(
-    const char* html_page, std::vector<StringPair>* query_params,
-    const char* expected, bool http) {
+void MediaBrowserTest::RunMediaTestPage(const std::string& html_page,
+                                        const media::QueryParams& query_params,
+                                        const std::string& expected_title,
+                                        bool http) {
   GURL gurl;
-  std::string query = "";
-  if (query_params != NULL && !query_params->empty()) {
-    std::vector<StringPair>::const_iterator itr = query_params->begin();
-    query = base::StringPrintf("%s=%s", itr->first, itr->second);
-    ++itr;
-    for (; itr != query_params->end(); ++itr) {
-      query.append(base::StringPrintf("&%s=%s", itr->first, itr->second));
-    }
-  }
+  std::string query = media::GetURLQueryString(query_params);
+  scoped_ptr<net::SpawnedTestServer> http_test_server;
   if (http) {
-    ASSERT_TRUE(test_server()->Start());
-    gurl = test_server()->GetURL(
-        base::StringPrintf("files/media/%s?%s", html_page, query.c_str()));
+    http_test_server = media::StartMediaHttpTestServer();
+    gurl = http_test_server->GetURL("files/" + html_page + "?" + query);
   } else {
-    base::FilePath test_file_path = GetTestFilePath("media", html_page);
-    gurl = GetFileUrlWithQuery(test_file_path, query);
+    gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page),
+                                        query);
   }
-  RunTest(gurl, expected);
+  std::string final_title = RunTest(gurl, expected_title);
+  EXPECT_EQ(expected_title, final_title);
 }
 
-void MediaBrowserTest::RunTest(const GURL& gurl, const char* expected) {
-  const base::string16 expected_title = base::ASCIIToUTF16(expected);
-  DVLOG(1) << "Running test URL: " << gurl;
-  TitleWatcher title_watcher(shell()->web_contents(), expected_title);
+std::string MediaBrowserTest::RunTest(const GURL& gurl,
+                                      const std::string& expected_title) {
+  VLOG(0) << "Running test URL: " << gurl;
+  TitleWatcher title_watcher(shell()->web_contents(),
+                             base::ASCIIToUTF16(expected_title));
   AddWaitForTitles(&title_watcher);
   NavigateToURL(shell(), gurl);
-
-  base::string16 final_title = title_watcher.WaitAndGetTitle();
-  EXPECT_EQ(expected_title, final_title);
+  base::string16 result = title_watcher.WaitAndGetTitle();
+  return base::UTF16ToASCII(result);
 }
 
 void MediaBrowserTest::AddWaitForTitles(content::TitleWatcher* title_watcher) {
@@ -75,25 +67,29 @@
                   public MediaBrowserTest {
  public:
   // Play specified audio over http:// or file:// depending on |http| setting.
-  void PlayAudio(const char* media_file, bool http) {
+  void PlayAudio(const std::string& media_file, bool http) {
     PlayMedia("audio", media_file, http);
   }
 
   // Play specified video over http:// or file:// depending on |http| setting.
-  void PlayVideo(const char* media_file, bool http) {
+  void PlayVideo(const std::string& media_file, bool http) {
     PlayMedia("video", media_file, http);
   }
 
   // Run specified color format test with the expected result.
-  void RunColorFormatTest(const char* media_file, const char* expected) {
-    base::FilePath test_file_path = GetTestFilePath("media", "blackwhite.html");
+  void RunColorFormatTest(const std::string& media_file,
+                          const std::string& expected) {
+    base::FilePath test_file_path =
+        media::GetTestDataFilePath("blackwhite.html");
     RunTest(GetFileUrlWithQuery(test_file_path, media_file), expected);
   }
 
-  void PlayMedia(const char* tag, const char* media_file, bool http) {
-    std::vector<StringPair> query_params;
+  void PlayMedia(const std::string& tag,
+                 const std::string& media_file,
+                 bool http) {
+    media::QueryParams query_params;
     query_params.push_back(std::make_pair(tag, media_file));
-    RunMediaTestPage("player.html", &query_params, kEnded, http);
+    RunMediaTestPage("player.html", query_params, kEnded, http);
   }
 };
 
@@ -140,7 +136,7 @@
 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearMovPcmS24be) {
   PlayVideo("bear_pcm_s24be.mov", GetParam());
 }
-#endif
+#endif  // defined(USE_PROPRIETARY_CODECS)
 
 #if defined(OS_CHROMEOS)
 #if defined(USE_PROPRIETARY_CODECS)
@@ -171,8 +167,9 @@
 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearFlac) {
   PlayAudio("bear.flac", GetParam());
 }
-#endif
-#endif
+#endif  // defined(USE_PROPRIETARY_CODECS)
+#endif  // defined(OS_CHROMEOS)
+
 
 IN_PROC_BROWSER_TEST_P(MediaTest, VideoBearWavAlaw) {
   PlayAudio("bear_alaw.wav", GetParam());
@@ -209,19 +206,19 @@
 INSTANTIATE_TEST_CASE_P(Http, MediaTest, ::testing::Values(true));
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pTheora)) {
-  RunColorFormatTest("yuv420p.ogv", "ENDED");
+  RunColorFormatTest("yuv420p.ogv", kEnded);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv422pTheora)) {
-  RunColorFormatTest("yuv422p.ogv", "ENDED");
+  RunColorFormatTest("yuv422p.ogv", kEnded);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv444pTheora)) {
-  RunColorFormatTest("yuv444p.ogv", "ENDED");
+  RunColorFormatTest("yuv444p.ogv", kEnded);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pVp8)) {
-  RunColorFormatTest("yuv420p.webm", "ENDED");
+  RunColorFormatTest("yuv420p.webm", kEnded);
 }
 
 // TODO(johannkoenig): Reenable after landing libvpx roll
@@ -232,24 +229,24 @@
 
 #if defined(USE_PROPRIETARY_CODECS)
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv420pH264)) {
-  RunColorFormatTest("yuv420p.mp4", "ENDED");
+  RunColorFormatTest("yuv420p.mp4", kEnded);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuvj420pH264)) {
-  RunColorFormatTest("yuvj420p.mp4", "ENDED");
+  RunColorFormatTest("yuvj420p.mp4", kEnded);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv422pH264)) {
-  RunColorFormatTest("yuv422p.mp4", "ENDED");
+  RunColorFormatTest("yuv422p.mp4", kEnded);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaTest, MAYBE(Yuv444pH264)) {
-  RunColorFormatTest("yuv444p.mp4", "ENDED");
+  RunColorFormatTest("yuv444p.mp4", kEnded);
 }
 
 #if defined(OS_CHROMEOS)
 IN_PROC_BROWSER_TEST_F(MediaTest, Yuv420pMpeg4) {
-  RunColorFormatTest("yuv420p.avi", "ENDED");
+  RunColorFormatTest("yuv420p.avi", kEnded);
 }
 #endif  // defined(OS_CHROMEOS)
 #endif  // defined(USE_PROPRIETARY_CODECS)
diff --git a/content/browser/media/media_browsertest.h b/content/browser/media/media_browsertest.h
index b242db3..4be3197 100644
--- a/content/browser/media/media_browsertest.h
+++ b/content/browser/media/media_browsertest.h
@@ -5,10 +5,10 @@
 #ifndef CONTENT_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_
 #define CONTENT_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_
 
-#include <utility>
-#include <vector>
+#include <string>
 
 #include "content/public/test/content_browser_test.h"
+#include "media/base/test_data_util.h"
 
 namespace content {
 
@@ -19,8 +19,6 @@
 // the test http server.
 class MediaBrowserTest : public ContentBrowserTest {
  public:
-  typedef std::pair<const char*, const char*> StringPair;
-
   // Common test results.
   static const char kEnded[];
   static const char kError[];
@@ -30,17 +28,18 @@
   // If http is true, the test starts a local http test server to load the test
   // page, otherwise a local file URL is loaded inside the content shell.
   // It uses RunTest() to check for expected test output.
-  void RunMediaTestPage(const char* html_page,
-                        std::vector<StringPair>* query_params,
-                        const char* expected, bool http);
+  void RunMediaTestPage(const std::string& html_page,
+                        const media::QueryParams& query_params,
+                        const std::string& expected,
+                        bool http);
 
   // Opens a URL and waits for the document title to match either one of the
-  // default strings or the expected string.
-  void RunTest(const GURL& gurl, const char* expected);
+  // default strings or the expected string. Returns the matching title value.
+  std::string RunTest(const GURL& gurl, const std::string& expected);
 
   virtual void AddWaitForTitles(content::TitleWatcher* title_watcher);
 };
 
-} // namespace content
+}  // namespace content
 
 #endif  // CONTENT_BROWSER_MEDIA_MEDIA_BROWSERTEST_H_
diff --git a/content/browser/media/media_source_browsertest.cc b/content/browser/media/media_source_browsertest.cc
index d5d8615..90d0c84 100644
--- a/content/browser/media/media_source_browsertest.cc
+++ b/content/browser/media/media_source_browsertest.cc
@@ -32,17 +32,18 @@
 
 class MediaSourceTest : public content::MediaBrowserTest {
  public:
-  void TestSimplePlayback(const char* media_file, const char* media_type,
-                          const char* expectation) {
+  void TestSimplePlayback(const std::string& media_file,
+                          const std::string& media_type,
+                          const std::string& expectation) {
     if (!IsMSESupported()) {
       VLOG(0) << "Skipping test - MSE not supported.";
       return;
     }
 
-    std::vector<StringPair> query_params;
-    query_params.push_back(std::make_pair("mediafile", media_file));
-    query_params.push_back(std::make_pair("mediatype", media_type));
-    RunMediaTestPage("media_source_player.html", &query_params, expectation,
+    media::QueryParams query_params;
+    query_params.push_back(std::make_pair("mediaFile", media_file));
+    query_params.push_back(std::make_pair("mediaType", media_type));
+    RunMediaTestPage("media_source_player.html", query_params, expectation,
                      true);
   }
 
@@ -84,7 +85,10 @@
     VLOG(0) << "Skipping test - MSE not supported.";
     return;
   }
-  RunMediaTestPage("mse_config_change.html", NULL, kEnded, true);
+  RunMediaTestPage("mse_config_change.html",
+                   media::QueryParams(),
+                   kEnded,
+                   true);
 }
 
 }  // namespace content
diff --git a/content/test/data/media/encrypted_frame_size_change.html b/content/test/data/media/encrypted_frame_size_change.html
deleted file mode 100644
index 719d8be..0000000
--- a/content/test/data/media/encrypted_frame_size_change.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <body onload="load()">
-    <p>Tests decoding and rendering encrypted video element that has a changing
-      resolution.</p>
-    <video width=320 controls></video>
-    <video controls></video>
-    <script src="media_utils.js" type="text/javascript"></script>
-    <script src="media_source_utils.js" type="text/javascript"></script>
-    <script src="encrypted_media_utils.js" type="text/javascript"></script>
-    <script>
-      var firstVideoSeek = false;
-      var video_fixed_size = document.getElementsByTagName("video")[0];
-      var video = document.getElementsByTagName("video")[1];
-
-      function load() {
-        loadVideo(video_fixed_size);
-        loadVideo(video);
-      }
-
-      function loadVideo(video) {
-        var mediaSource = loadEncryptedMediaFromURL(video);
-
-        video.addEventListener('playing', function() {
-          // Make sure the video plays for a bit.
-          video.addEventListener('timeupdate', function() {
-            if (video.currentTime > 1.0) {
-              video.pause();
-            }
-          });
-        });
-
-        video.addEventListener('pause', function() {
-          video.addEventListener('seeked', function() {
-            if (!firstVideoSeek) {
-              console.log('One video seeked.');
-              firstVideoSeek = true;
-              return;
-            }
-            setResultInTitle('ENDED');
-          });
-          video.currentTime = 0.5;
-        });
-
-        video.addEventListener('canplay', oncanplay);
-        video.play();
-      }
-    </script>
-  </body>
-</html>
diff --git a/content/test/data/media/encrypted_media_player.html b/content/test/data/media/encrypted_media_player.html
deleted file mode 100644
index 2b16d51..0000000
--- a/content/test/data/media/encrypted_media_player.html
+++ /dev/null
@@ -1,37 +0,0 @@
-<!DOCTYPE html>
-<html>
-  <head>
-    <title>Encrypted Media Player</title>
-  </head>
-  <body onload="runTest();">
-    <video controls></video>
-    <script src="media_utils.js" type="text/javascript"></script>
-    <script src="media_source_utils.js" type="text/javascript"></script>
-    <script src="encrypted_media_utils.js" type="text/javascript"></script>
-    <script type="text/javascript">
-      var video = document.querySelector('video');
-
-      function onTimeUpdate() {
-        if (video.currentTime < 1)
-          return;
-        // keyadded may be fired around the start of playback; check for it
-        // after a delay to avoid timing issues.
-        if (!video.receivedKeyAdded)
-          failTest('Key added event not received.');
-        if (video.isHeartbeatExpected && !video.receivedHeartbeat)
-          failTest('Heartbeat keymessage event not received.');
-        video.removeEventListener('ended', failTest);
-        installTitleEventHandler(video, 'ended');
-        video.removeEventListener('timeupdate', onTimeUpdate);
-      }
-
-      // The test completes after playing the encrypted media for 1 second and
-      // getting the ended event or when an error occurs at any time.
-      function runTest() {
-        loadEncryptedMediaFromURL(video);
-        video.addEventListener('timeupdate', onTimeUpdate);
-        video.play();
-      }
-    </script>
-  </body>
-</html>
diff --git a/content/test/data/media/encrypted_media_utils.js b/content/test/data/media/encrypted_media_utils.js
deleted file mode 100644
index 8fb3f97..0000000
--- a/content/test/data/media/encrypted_media_utils.js
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright (c) 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.
-
-var keySystem = QueryString.keysystem;
-var mediaFile = QueryString.mediafile;
-var mediaType = QueryString.mediatype || 'video/webm; codecs="vorbis, vp8"';
-var useMSE = QueryString.usemse == 1;
-
-// Default key used to encrypt many media files used in browser tests.
-var KEY = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
-                          0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]);
-// KEY_ID constant used as init data while encrypting test media files.
-var KEY_ID = getInitDataFromKeyId("0123456789012345");
-// Heart beat message header.
-var HEART_BEAT_HEADER = 'HEARTBEAT';
-var EXTERNAL_CLEAR_KEY_KEY_SYSTEM = "org.chromium.externalclearkey";
-// Note that his URL has been normalized from the one in clear_key_cdm.cc.
-var EXTERNAL_CLEAR_KEY_HEARTBEAT_URL =
-    'http://test.externalclearkey.chromium.org/';
-
-function isHeartbeatMessage(msg) {
-  if (msg.length < HEART_BEAT_HEADER.length)
-    return false;
-  for (var i = 0; i < HEART_BEAT_HEADER.length; ++i) {
-    if (String.fromCharCode(msg[i]) != HEART_BEAT_HEADER[i])
-      return false;
-  }
-  return true;
-}
-
-function loadEncryptedMediaFromURL(video) {
-  return loadEncryptedMedia(video, mediaFile, keySystem, KEY, useMSE);
-}
-
-function loadEncryptedMedia(video, mediaFile, keySystem, key, useMSE,
-                            appendSourceCallbackFn) {
-  var keyRequested = false;
-  var sourceOpened = false;
-  // Add properties to enable verification that events occurred.
-  video.receivedKeyAdded = false;
-  video.receivedHeartbeat = false;
-  video.isHeartbeatExpected = keySystem === EXTERNAL_CLEAR_KEY_KEY_SYSTEM;
-  video.receivedKeyMessage = false;
-
-  if (!(video && mediaFile && keySystem && key)) {
-    failTest('Missing parameters in loadEncryptedMedia().');
-    return;
-  }
-
-  function onNeedKey(e) {
-    if (keyRequested)
-      return;
-    keyRequested = true;
-    console.log('onNeedKey', e);
-    try {
-      video.webkitGenerateKeyRequest(keySystem, e.initData);
-    }
-    catch(error) {
-      setResultInTitle(error.name);
-    }
-  }
-
-  function onKeyAdded(e) {
-    e.target.receivedKeyAdded = true;
-  }
-
-  function onKeyMessage(e) {
-    video.receivedKeyMessage = true;
-    if (!e.keySystem || e.keySystem != keySystem) {
-      failTest('keymessage with unexpected keySystem: ' + e.keySystem);
-      return;
-    }
-
-    if (!e.sessionId) {
-      failTest('keymessage without a sessionId: ' + e.sessionId);
-      return;
-    }
-
-    if (!e.message) {
-      failTest('keymessage without a message: ' + e.message);
-      return;
-    }
-
-    if (isHeartbeatMessage(e.message)) {
-      console.log('onKeyMessage - heartbeat', e);
-      e.target.receivedHeartbeat = true;
-      verifyHeartbeatMessage(e);
-      return;
-    }
-
-    // No tested key system returns defaultURL in for key request messages.
-    if (e.defaultURL) {
-      failTest('keymessage unexpectedly has defaultURL: ' + e.defaultURL);
-      return;
-    }
-
-    // keymessage in response to generateKeyRequest. Reply with key.
-    console.log('onKeyMessage - key request', e);
-    var initData = e.message;
-    if (mediaType.indexOf('mp4') != -1)
-      initData = KEY_ID; // Temporary hack for Clear Key in v0.1.
-    video.webkitAddKey(keySystem, key, initData);
-  }
-
-  function verifyHeartbeatMessage(e) {
-    // Only External Clear Key sends a HEARTBEAT message.
-    if (e.keySystem != EXTERNAL_CLEAR_KEY_KEY_SYSTEM) {
-      failTest('Unexpected heartbeat from ' + e.keySystem);
-      return;
-    }
-
-    if (e.defaultURL != EXTERNAL_CLEAR_KEY_HEARTBEAT_URL) {
-      failTest('Heartbeat message with unexpected defaultURL: ' + e.defaultURL);
-      return;
-    }
-  }
-
-  video.addEventListener('webkitneedkey', onNeedKey);
-  video.addEventListener('webkitkeymessage', onKeyMessage);
-  video.addEventListener('webkitkeyerror', function() {
-      setResultInTitle("KeyError");
-  });
-  video.addEventListener('webkitkeyadded', onKeyAdded);
-  installTitleEventHandler(video, 'error');
-
-  if (useMSE) {
-    var mediaSource = loadMediaSource(mediaFile, mediaType,
-                                      appendSourceCallbackFn);
-    video.src = window.URL.createObjectURL(mediaSource);
-  } else {
-    video.src = mediaFile;
-  }
-}
-
-function getInitDataFromKeyId(keyID) {
-  var init_key_id = new Uint8Array(keyID.length);
-  for(var i = 0; i < keyID.length; i++) {
-    init_key_id[i] = keyID.charCodeAt(i);
-  }
-  return init_key_id;
-}
diff --git a/content/test/data/media/media_source_utils.js b/content/test/data/media/media_source_utils.js
deleted file mode 100644
index 7f179b5..0000000
--- a/content/test/data/media/media_source_utils.js
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 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.
-
-function loadMediaFromURL(video) {
-  installTitleEventHandler(video, 'error');
-  video.addEventListener('playing', function(event) {
-    console.log('Video Playing.');
-  });
-  var source = loadMediaSource(QueryString.mediafile, QueryString.mediatype);
-  video.src = window.URL.createObjectURL(source);
-}
-
-function loadMediaSource(mediaFiles, mediaTypes, appendSourceCallbackFn) {
-  mediaFiles = convertToArray(mediaFiles);
-  mediaTypes = convertToArray(mediaTypes);
-
-  if (!mediaFiles || !mediaTypes)
-    failTest('Missing parameters in loadMediaSource().');
-
-  var totalAppended = 0;
-  function onSourceOpen(e) {
-    console.log('onSourceOpen', e);
-    // We can load multiple media files using the same media type. However, if
-    // more than one media type is used, we expect to have a media type entry
-    // for each corresponding media file.
-    var srcBuffer = null;
-    for (var i = 0; i < mediaFiles.length; i++) {
-      if (i == 0 || mediaFiles.length == mediaTypes.length) {
-        console.log('Creating a source buffer for type ' + mediaTypes[i]);
-        try {
-          srcBuffer = mediaSource.addSourceBuffer(mediaTypes[i]);
-        } catch (e) {
-          failTest('Exception adding source buffer: ' + e.message);
-          return;
-        }
-      }
-      doAppend(mediaFiles[i], srcBuffer);
-    }
-  }
-
-  function doAppend(mediaFile, srcBuffer) {
-    var xhr = new XMLHttpRequest();
-    xhr.open('GET', mediaFile);
-    xhr.responseType = 'arraybuffer';
-    xhr.addEventListener('load', function(e) {
-      var onUpdateEnd = function(e) {
-        console.log('End of appending buffer from ' + mediaFile);
-        srcBuffer.removeEventListener('updateend', onUpdateEnd);
-        totalAppended++;
-        if (totalAppended == mediaFiles.length) {
-          if (appendSourceCallbackFn)
-            appendSourceCallbackFn(mediaSource);
-          else
-            mediaSource.endOfStream();
-        }
-      };
-      srcBuffer.addEventListener('updateend', onUpdateEnd);
-      srcBuffer.appendBuffer(new Uint8Array(e.target.response));
-    });
-    xhr.send();
-  }
-
-  var mediaSource = new MediaSource();
-  mediaSource.addEventListener('sourceopen', onSourceOpen);
-  return mediaSource;
-}
diff --git a/content/test/data/media/media_utils.js b/content/test/data/media/media_utils.js
deleted file mode 100644
index 8c5c1d6..0000000
--- a/content/test/data/media/media_utils.js
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 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.
-
-var QueryString = function() {
-  // Allows access to query parameters on the URL; e.g., given a URL like:
-  //    http://<server>/my.html?test=123&bob=123
-  // Parameters can then be accessed via QueryString.test or QueryString.bob.
-  var params = {};
-  // RegEx to split out values by &.
-  var r = /([^&=]+)=?([^&]*)/g;
-  // Lambda function for decoding extracted match values. Replaces '+' with
-  // space so decodeURIComponent functions properly.
-  function d(s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }
-  var match;
-  while (match = r.exec(window.location.search.substring(1)))
-    params[d(match[1])] = d(match[2]);
-  return params;
-}();
-
-function failTest(msg) {
-  var failMessage = msg;
-  if (msg instanceof Event)
-    failMessage = msg.target + '.' + msg.type;
-  console.log("FAILED TEST: " + msg);
-  setResultInTitle('FAILED');
-}
-
-var titleChanged = false;
-function setResultInTitle(title) {
-  // If document title is 'ENDED', then update it with new title to possibly
-  // mark a test as failure.  Otherwise, keep the first title change in place.
-  if (!titleChanged || document.title.toUpperCase() == 'ENDED')
-    document.title = title.toUpperCase();
-  console.log('Set document title to: ' + title + ', updated title: ' +
-              document.title);
-  titleChanged = true;
-}
-
-function installTitleEventHandler(element, event) {
-  element.addEventListener(event, function(e) {
-    setResultInTitle(event.toString());
-  }, false);
-}
-
-function convertToArray(input) {
-  if (Array.isArray(input))
-    return input;
-  return [input];
-}
diff --git a/content/test/data/media/mse_config_change.html b/content/test/data/media/mse_config_change.html
deleted file mode 100644
index 13f4174..0000000
--- a/content/test/data/media/mse_config_change.html
+++ /dev/null
@@ -1,132 +0,0 @@
-<html>
-  <head>
-    <title>Test media source config changes.</title>
-  </head>
-  <body onload="runTest();">
-    <video controls></video>
-    <script src="media_utils.js" type="text/javascript"></script>
-    <script src="media_source_utils.js" type="text/javascript"></script>
-    <script src="encrypted_media_utils.js" type="text/javascript"></script>
-    <script type="text/javascript">
-      var runEncrypted = QueryString.runencrypted == 1;
-      var video = document.querySelector('video');
-      var mediaType = 'video/webm; codecs="vorbis, vp8"';
-
-      var MEDIA_1 = 'bear-320x240.webm';
-      var MEDIA_2 = 'bear-640x360.webm';
-      if (runEncrypted) {
-        MEDIA_1 = 'bear-320x240-av-enc_av.webm';
-        MEDIA_2 = 'bear-640x360-av-enc_av.webm';
-      }
-
-      var MEDIA_1_WIDTH = 320;
-      var MEDIA_1_HEIGHT = 240;
-
-      var MEDIA_2_WIDTH = 640;
-      var MEDIA_2_HEIGHT = 360;
-      var MEDIA_2_LENGTH = 2.75;
-
-      // The time in secs to append the second media source.
-      var APPEND_TIME = 1;
-      // DELTA is the time after APPEND_TIME where the second video dimensions
-      // are guaranteed to take effect.
-      var DELTA = 0.1;
-      // Append MEDIA_2 source at APPEND_TIME, so expected total duration is:
-      var TOTAL_DURATION = APPEND_TIME + MEDIA_2_LENGTH;
-
-      function appendNextSource(mediaSource) {
-        console.log('Appending next media source at ' + APPEND_TIME + 'sec.');
-        var xhr = new XMLHttpRequest();
-        xhr.open("GET", MEDIA_2);
-        xhr.responseType = 'arraybuffer';
-        xhr.addEventListener('load', function(e) {
-          var onUpdateEnd = function(e) {
-            console.log('Second buffer append ended.');
-            srcBuffer.removeEventListener('updateend', onUpdateEnd);
-            mediaSource.endOfStream();
-            if (!mediaSource.duration ||
-                Math.abs(mediaSource.duration - TOTAL_DURATION) > DELTA) {
-              failTest('Unexpected mediaSource.duration = ' +
-                       mediaSource.duration + ', expected duration = ' +
-                       TOTAL_DURATION);
-              return;
-            }
-            video.play();
-          };
-          console.log('Appending next media source at ' + APPEND_TIME + 'sec.');
-          var srcBuffer = mediaSource.sourceBuffers[0];
-          srcBuffer.addEventListener('updateend', onUpdateEnd);
-          srcBuffer.timestampOffset = APPEND_TIME;
-          srcBuffer.appendBuffer(new Uint8Array(e.target.response));
-        });
-        xhr.send();
-      }
-
-      function onTimeUpdate() {
-        // crbug.com/246308
-        //checkVideoProperties();
-
-        // Seek to APPEND_TIME because after a seek a timeUpdate event is fired
-        // before video width and height properties get updated.
-        if (video.currentTime < APPEND_TIME - DELTA) {
-          // Seek to save test execution time (about 1 secs) and to test seek
-          // on the first buffer.
-          video.currentTime = APPEND_TIME - DELTA;
-        } else if (video.currentTime > APPEND_TIME + DELTA) {
-          // Check video duration here to guarantee that second segment has been
-          // appended and video total duration is updated.
-          // Video duration is a float value so we check it within a range.
-          if (!video.duration ||
-              Math.abs(video.duration - TOTAL_DURATION) > DELTA) {
-            failTest('Unexpected video.duration = ' + video.duration +
-                     ', expected duration = ' + TOTAL_DURATION);
-            return;
-          }
-
-          video.removeEventListener('timeupdate', onTimeUpdate);
-          video.removeEventListener('ended', failTest);
-          installTitleEventHandler(video, 'ended');
-          // Seek to save test execution time and to test seek on second buffer.
-          video.currentTime = APPEND_TIME + MEDIA_2_LENGTH * 0.9;
-        }
-      }
-
-      function checkVideoProperties() {
-        if (video.currentTime <= APPEND_TIME) {
-          if (video.videoWidth != MEDIA_1_WIDTH ||
-              video.videoHeight != MEDIA_1_HEIGHT) {
-            logVideoDimensions();
-            failTest('Unexpected dimensions for first video segment.');
-            return;
-          }
-        } else if (video.currentTime >= APPEND_TIME + DELTA) {
-          if (video.videoWidth != MEDIA_2_WIDTH ||
-              video.videoHeight != MEDIA_2_HEIGHT) {
-            logVideoDimensions();
-            failTest('Unexpected dimensions for second video segment.');
-            return;
-          }
-        }
-      }
-
-      function logVideoDimensions() {
-        console.log('video.currentTime = ' + video.currentTime +
-                    ', video dimensions = ' + video.videoWidth + 'x' +
-                    video.videoHeight + '.');
-      }
-
-      function runTest() {
-        video.addEventListener('timeupdate', onTimeUpdate);
-        video.addEventListener('ended', failTest);
-        if (runEncrypted) {
-          loadEncryptedMedia(video, MEDIA_1, keySystem, KEY, true,
-                             appendNextSource);
-        } else {
-          var mediaSource = loadMediaSource(MEDIA_1, mediaType,
-                                            appendNextSource);
-          video.src = window.URL.createObjectURL(mediaSource);
-        }
-      }
-      </script>
-  </body>
-</html>
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 3e8a650..aa7daea 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -998,6 +998,7 @@
     ":media",
     ":shared_memory_support",
     "//base",
+    "//net:test_support",
     "//skia",
     "//testing/gmock",
     "//testing/gtest",
diff --git a/media/DEPS b/media/DEPS
index 8f61ef2..1275117 100644
--- a/media/DEPS
+++ b/media/DEPS
@@ -1,6 +1,7 @@
 include_rules = [
   "+gpu",
   "+jni",
+  "+net/test",
   "+third_party/ffmpeg",
   "+third_party/libvpx",
   "+third_party/libyuv",
diff --git a/media/base/test_data_util.cc b/media/base/test_data_util.cc
index a83fa84..9cd886f 100644
--- a/media/base/test_data_util.cc
+++ b/media/base/test_data_util.cc
@@ -12,14 +12,38 @@
 
 namespace media {
 
+const base::FilePath::CharType kTestDataPath[] =
+    FILE_PATH_LITERAL("media/test/data");
+
 base::FilePath GetTestDataFilePath(const std::string& name) {
   base::FilePath file_path;
   CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
+  return file_path.Append(GetTestDataPath()).AppendASCII(name);
+}
 
-  return file_path.AppendASCII("media")
-      .AppendASCII("test")
-      .AppendASCII("data")
-      .AppendASCII(name);
+base::FilePath GetTestDataPath() {
+  return base::FilePath(kTestDataPath);
+}
+
+std::string GetURLQueryString(const QueryParams& query_params) {
+  std::string query = "";
+  QueryParams::const_iterator itr = query_params.begin();
+  for (; itr != query_params.end(); ++itr) {
+    if (itr != query_params.begin())
+      query.append("&");
+    query.append(itr->first + "=" + itr->second);
+  }
+  return query;
+}
+
+scoped_ptr<net::SpawnedTestServer> StartMediaHttpTestServer() {
+  scoped_ptr<net::SpawnedTestServer> http_test_server;
+  http_test_server.reset(new net::SpawnedTestServer(
+      net::SpawnedTestServer::TYPE_HTTP,
+      net::SpawnedTestServer::kLocalhost,
+      GetTestDataPath()));
+  CHECK(http_test_server->Start());
+  return http_test_server.Pass();
 }
 
 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
diff --git a/media/base/test_data_util.h b/media/base/test_data_util.h
index 8d51e96..955d615 100644
--- a/media/base/test_data_util.h
+++ b/media/base/test_data_util.h
@@ -6,19 +6,34 @@
 #define MEDIA_BASE_TEST_DATA_UTIL_H_
 
 #include <string>
+#include <utility>
+#include <vector>
 
 #include "base/basictypes.h"
 #include "base/files/file_path.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_ptr.h"
+#include "net/test/spawned_test_server/spawned_test_server.h"
 
 namespace media {
 
 class DecoderBuffer;
 
+typedef std::vector<std::pair<std::string, std::string> > QueryParams;
+
 // Returns a file path for a file in the media/test/data directory.
 base::FilePath GetTestDataFilePath(const std::string& name);
 
+// Returns relative path for test data folder: media/test/data.
+base::FilePath GetTestDataPath();
+
+// Starts an HTTP server serving files from media data path.
+scoped_ptr<net::SpawnedTestServer> StartMediaHttpTestServer();
+
+// Returns a string containing key value query params in the form of:
+// "key_1=value_1&key_2=value2"
+std::string GetURLQueryString(const QueryParams& query_params);
+
 // Reads a test file from media/test/data directory and stores it in
 // a DecoderBuffer.  Use DecoderBuffer vs DataBuffer to ensure no matter
 // what a test does, it's safe to use FFmpeg methods.
diff --git a/media/media.gyp b/media/media.gyp
index 8ce7667..a6bfc9b7 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -1356,6 +1356,7 @@
         'media',
         'shared_memory_support',
         '../base/base.gyp:base',
+        '../net/net.gyp:net_test_support',
         '../skia/skia.gyp:skia',
         '../testing/gmock.gyp:gmock',
         '../testing/gtest.gyp:gtest',
diff --git a/content/test/data/media/blackwhite.html b/media/test/data/blackwhite.html
similarity index 100%
rename from content/test/data/media/blackwhite.html
rename to media/test/data/blackwhite.html
diff --git a/chrome/test/data/media/eme_player.html b/media/test/data/eme_player.html
similarity index 100%
rename from chrome/test/data/media/eme_player.html
rename to media/test/data/eme_player.html
diff --git a/chrome/test/data/media/eme_player_js/app_loader.js b/media/test/data/eme_player_js/app_loader.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/app_loader.js
rename to media/test/data/eme_player_js/app_loader.js
diff --git a/chrome/test/data/media/eme_player_js/clearkey_player.js b/media/test/data/eme_player_js/clearkey_player.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/clearkey_player.js
rename to media/test/data/eme_player_js/clearkey_player.js
diff --git a/chrome/test/data/media/eme_player_js/eme_app.js b/media/test/data/eme_player_js/eme_app.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/eme_app.js
rename to media/test/data/eme_player_js/eme_app.js
diff --git a/chrome/test/data/media/eme_player_js/file_io_test_player.js b/media/test/data/eme_player_js/file_io_test_player.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/file_io_test_player.js
rename to media/test/data/eme_player_js/file_io_test_player.js
diff --git a/chrome/test/data/media/eme_player_js/fps_observer.js b/media/test/data/eme_player_js/fps_observer.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/fps_observer.js
rename to media/test/data/eme_player_js/fps_observer.js
diff --git a/chrome/test/data/media/eme_player_js/globals.js b/media/test/data/eme_player_js/globals.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/globals.js
rename to media/test/data/eme_player_js/globals.js
diff --git a/chrome/test/data/media/eme_player_js/media_source_utils.js b/media/test/data/eme_player_js/media_source_utils.js
similarity index 97%
rename from chrome/test/data/media/eme_player_js/media_source_utils.js
rename to media/test/data/eme_player_js/media_source_utils.js
index d75f31c..8888582 100644
--- a/chrome/test/data/media/eme_player_js/media_source_utils.js
+++ b/media/test/data/eme_player_js/media_source_utils.js
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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.
 
diff --git a/chrome/test/data/media/eme_player_js/player_utils.js b/media/test/data/eme_player_js/player_utils.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/player_utils.js
rename to media/test/data/eme_player_js/player_utils.js
diff --git a/chrome/test/data/media/eme_player_js/prefixed_clearkey_player.js b/media/test/data/eme_player_js/prefixed_clearkey_player.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/prefixed_clearkey_player.js
rename to media/test/data/eme_player_js/prefixed_clearkey_player.js
diff --git a/chrome/test/data/media/eme_player_js/prefixed_widevine_player.js b/media/test/data/eme_player_js/prefixed_widevine_player.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/prefixed_widevine_player.js
rename to media/test/data/eme_player_js/prefixed_widevine_player.js
diff --git a/media/test/data/eme_player_js/test_config.js b/media/test/data/eme_player_js/test_config.js
new file mode 100644
index 0000000..8be8a9a
--- /dev/null
+++ b/media/test/data/eme_player_js/test_config.js
@@ -0,0 +1,65 @@
+// Copyright 2014 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.
+
+// Test configuration used by test page to configure the player app and other
+// test specific configurations.
+function TestConfig() {
+  this.mediaFile = null;
+  this.keySystem = null;
+  this.mediaType = null;
+  this.licenseServerURL = null;
+  this.useMSE = false;
+  this.usePrefixedEME = false;
+  this.runFPS = false;
+}
+
+TestConfig.prototype.loadQueryParams = function() {
+  // Load query parameters and set default values.
+  var r = /([^&=]+)=?([^&]*)/g;
+  // Lambda function for decoding extracted match values. Replaces '+' with
+  // space so decodeURIComponent functions properly.
+  var decodeURI = function decodeURI(s) {
+      return decodeURIComponent(s.replace(/\+/g, ' '));
+  };
+  var match;
+  while (match = r.exec(window.location.search.substring(1)))
+    this[decodeURI(match[1])] = decodeURI(match[2]);
+  this.useMSE = this.useMSE == '1' || this.useMSE == 'true';
+  this.usePrefixedEME =
+      this.usePrefixedEME == '1' || this.usePrefixedEME == 'true';
+};
+
+TestConfig.updateDocument = function() {
+  this.loadQueryParams();
+  Utils.addOptions(KEYSYSTEM_ELEMENT_ID, KEY_SYSTEMS);
+  Utils.addOptions(MEDIA_TYPE_ELEMENT_ID, MEDIA_TYPES);
+  Utils.addOptions(USE_PREFIXED_EME_ID, EME_VERSIONS_OPTIONS,
+                   EME_DISABLED_OPTIONS);
+
+  document.getElementById(MEDIA_FILE_ELEMENT_ID).value =
+      this.mediaFile || DEFAULT_MEDIA_FILE;
+
+  document.getElementById(LICENSE_SERVER_ELEMENT_ID).value =
+      this.licenseServerURL || DEFAULT_LICENSE_SERVER;
+
+  if (this.keySystem)
+    Utils.ensureOptionInList(KEYSYSTEM_ELEMENT_ID, this.keySystem);
+  if (this.mediaType)
+    Utils.ensureOptionInList(MEDIA_TYPE_ELEMENT_ID, this.mediaType);
+  document.getElementById(USE_MSE_ELEMENT_ID).value = this.useMSE;
+  if (this.usePrefixedEME)
+    document.getElementById(USE_PREFIXED_EME_ID).value = EME_PREFIXED_VERSION;
+};
+
+TestConfig.init = function() {
+  // Reload test configuration from document.
+  this.mediaFile = document.getElementById(MEDIA_FILE_ELEMENT_ID).value;
+  this.keySystem = document.getElementById(KEYSYSTEM_ELEMENT_ID).value;
+  this.mediaType = document.getElementById(MEDIA_TYPE_ELEMENT_ID).value;
+  this.useMSE = document.getElementById(USE_MSE_ELEMENT_ID).value == 'true';
+  this.usePrefixedEME = document.getElementById(USE_PREFIXED_EME_ID).value ==
+      EME_PREFIXED_VERSION;
+  this.licenseServerURL =
+      document.getElementById(LICENSE_SERVER_ELEMENT_ID).value;
+};
diff --git a/chrome/test/data/media/eme_player_js/utils.js b/media/test/data/eme_player_js/utils.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/utils.js
rename to media/test/data/eme_player_js/utils.js
diff --git a/chrome/test/data/media/eme_player_js/widevine_player.js b/media/test/data/eme_player_js/widevine_player.js
similarity index 100%
rename from chrome/test/data/media/eme_player_js/widevine_player.js
rename to media/test/data/eme_player_js/widevine_player.js
diff --git a/chrome/test/data/media/encrypted_frame_size_change.html b/media/test/data/encrypted_frame_size_change.html
similarity index 100%
rename from chrome/test/data/media/encrypted_frame_size_change.html
rename to media/test/data/encrypted_frame_size_change.html
diff --git a/content/test/data/media/media_source_player.html b/media/test/data/media_source_player.html
similarity index 60%
rename from content/test/data/media/media_source_player.html
rename to media/test/data/media_source_player.html
index 97f3b64..7a2ecbe 100644
--- a/content/test/data/media/media_source_player.html
+++ b/media/test/data/media_source_player.html
@@ -5,8 +5,7 @@
   </head>
   <body onload="runTest();">
     <video controls></video>
-    <script src="media_utils.js" type="text/javascript"></script>
-    <script src="media_source_utils.js" type="text/javascript"></script>
+    <script src='eme_player_js/app_loader.js' type='text/javascript'></script>
     <script type="text/javascript">
       var video = document.querySelector('video');
 
@@ -16,18 +15,22 @@
       }
 
       function onSeeked() {
-        video.removeEventListener('ended', failTest);
-        installTitleEventHandler(video, 'ended');
+        video.removeEventListener('ended', Utils.failTest);
+        Utils.installTitleEventHandler(video, 'ended');
       }
 
       // The test completes after media starts playing, seeks to 0.9 of
       // duration and fires the ended event.
       // The test stops when an error or ended event fire unexpectedly.
       function runTest() {
-        loadMediaFromURL(video);
-        video.addEventListener('ended', failTest);
+        var testConfig = new TestConfig();
+        testConfig.loadQueryParams();
+        Utils.installTitleEventHandler(video, 'error');
+        video.addEventListener('ended', Utils.failTest);
         video.addEventListener('seeked', onSeeked);
         video.addEventListener('timeupdate', onTimeUpdate);
+        var source = MediaSourceUtils.loadMediaSourceFromTestConfig(testConfig);
+        video.src = window.URL.createObjectURL(source);
         video.play();
       }
     </script>
diff --git a/chrome/test/data/media/mse_config_change.html b/media/test/data/mse_config_change.html
similarity index 97%
rename from chrome/test/data/media/mse_config_change.html
rename to media/test/data/mse_config_change.html
index 8765235..f536ece 100644
--- a/chrome/test/data/media/mse_config_change.html
+++ b/media/test/data/mse_config_change.html
@@ -8,7 +8,6 @@
     <script type="text/javascript">
       var testConfig = new TestConfig();
       testConfig.loadQueryParams();
-      testConfig.useMSE = '1';
       var runEncrypted = testConfig.runEncrypted == 1;
 
       var video = document.querySelector('video');
@@ -17,8 +16,8 @@
       var MEDIA_1 = 'bear-320x240.webm';
       var MEDIA_2 = 'bear-640x360.webm';
       if (runEncrypted) {
-        MEDIA_1 = 'bear-320x240-av-enc_av.webm';
-        MEDIA_2 = 'bear-640x360-av-enc_av.webm';
+        MEDIA_1 = 'bear-320x240-av_enc-av.webm';
+        MEDIA_2 = 'bear-640x360-av_enc-av.webm';
       }
 
       var MEDIA_1_WIDTH = 320;
diff --git a/content/test/data/media/player.html b/media/test/data/player.html
similarity index 100%
rename from content/test/data/media/player.html
rename to media/test/data/player.html
diff --git a/chrome/test/data/media/test_key_system_instantiation.html b/media/test/data/test_key_system_instantiation.html
similarity index 89%
rename from chrome/test/data/media/test_key_system_instantiation.html
rename to media/test/data/test_key_system_instantiation.html
index d3fb0e3..0199920 100644
--- a/chrome/test/data/media/test_key_system_instantiation.html
+++ b/media/test/data/test_key_system_instantiation.html
@@ -3,7 +3,7 @@
     <video controls="" name="video">
       <!-- This test doesn't play the video, so any file will do
            as long as it can be loaded. -->
-      <source src="bear-320x240-av-enc_a.webm" type="video/webm">
+      <source src="bear-320x240-av_enc-a.webm" type="video/webm">
     </video>
     <script type="text/javascript">
       function testKeySystemInstantiation(keySystem) {