Bug 1119463 - Enable MSE for youtube-nocookie.com. r=kinetik
authorRalph Giles <giles@mozilla.com>
Thu, 08 Jan 2015 12:34:00 -0800
changeset 248662 901e53fd2486a56905744801181ee7833b744de8
parent 248661 61d64583cfe57514e97d14c24b1077ea5ae00ed6
child 248663 15830cc2b55b26588d57dff75597d84fd60ceed6
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1119463
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1119463 - Enable MSE for youtube-nocookie.com. r=kinetik Follow-up to bug 1119463. This is used by some sites for embedding.
dom/media/mediasource/MediaSource.cpp
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -325,37 +325,41 @@ MediaSource::Enabled(JSContext* cx, JSOb
   }
 
   // Check whether it's enabled everywhere or just YouTube.
   bool restrict = Preferences::GetBool("media.mediasource.youtubeonly", false);
   if (!restrict) {
     return true;
   }
 
-  // We want to restrict to YouTube only.  We define that as the
-  // origin being https://*.youtube.com.
+  // We want to restrict to YouTube only.
+  // We define that as the origin being https://*.youtube.com.
+  // We also support https://*.youtube-nocookie.com.
   nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(global);
   nsCOMPtr<nsIURI> uri;
   if (NS_FAILED(principal->GetURI(getter_AddRefs(uri))) || !uri) {
     return false;
   }
 
   bool isHttps = false;
   if (NS_FAILED(uri->SchemeIs("https", &isHttps)) || !isHttps) {
     return false;
   }
 
   nsCOMPtr<nsIEffectiveTLDService> tldServ =
     do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
   NS_ENSURE_TRUE(tldServ, false);
 
   nsAutoCString eTLDplusOne;
-  return
-    NS_SUCCEEDED(tldServ->GetBaseDomain(uri, 0, eTLDplusOne)) &&
-    eTLDplusOne.EqualsLiteral("youtube.com");
+   if (NS_FAILED(tldServ->GetBaseDomain(uri, 0, eTLDplusOne))) {
+     return false;
+   }
+
+   return eTLDplusOne.EqualsLiteral("youtube.com") ||
+          eTLDplusOne.EqualsLiteral("youtube-nocookie.com");
 }
 
 bool
 MediaSource::Attach(MediaSourceDecoder* aDecoder)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("MediaSource(%p)::Attach(aDecoder=%p) owner=%p", this, aDecoder, aDecoder->GetOwner());
   MOZ_ASSERT(aDecoder);