Bug 1398071 - Rewrite youtube embeds that use enablejsapi; r?cpeterson draft
authorKyle Machulis <kyle@nonpolynomial.com>
Fri, 08 Sep 2017 12:59:52 -0700
changeset 661704 f9de3598a12eff09d28f2007273095c9f963acc6
parent 661528 6d0288c291650ab619dc4ff92cb0b60e3b6e7b3b
child 730658 e16a9cd97dc8d3ecf1fe0c732ac5e79f91450a19
push id78856
push userbmo:kyle@nonpolynomial.com
push dateFri, 08 Sep 2017 22:32:57 +0000
reviewerscpeterson
bugs1398071
milestone57.0a1
Bug 1398071 - Rewrite youtube embeds that use enablejsapi; r?cpeterson Youtube has now deprecated flash embeds completely, meaning enablejsapi in embeds will no longer work. We can now rewrite these to use HTML5, as any functionality related to the js api will no longer function anyways. MozReview-Commit-ID: kZTwpyLaYw
dom/base/nsObjectLoadingContent.cpp
dom/base/nsObjectLoadingContent.h
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -1399,20 +1399,16 @@ nsObjectLoadingContent::MaybeRewriteYout
 
   // See if requester is planning on using the JS API.
   nsAutoCString uri;
   nsresult rv = aURI->GetSpec(uri);
   if (NS_FAILED(rv)) {
     return;
   }
 
-  if (uri.Find("enablejsapi=1", true, 0, -1) != kNotFound) {
-    return;
-  }
-
   // Some YouTube urls have parameters in path components, e.g.
   // http://youtube.com/embed/7LcUOEP7Brc&start=35. These URLs work with flash,
   // but break iframe/object embedding. If this situation occurs with rewritten
   // URLs, convert the parameters to query in order to make the video load
   // correctly as an iframe. In either case, warn about it in the
   // developer console.
   int32_t ampIndex = uri.FindChar('&', 0);
   bool replaceQuery = false;
--- a/dom/base/nsObjectLoadingContent.h
+++ b/dom/base/nsObjectLoadingContent.h
@@ -577,22 +577,22 @@ class nsObjectLoadingContent : public ns
      * Used for identifying whether we can rewrite a youtube flash embed to
      * possibly use HTML5 instead.
      *
      * Returns true if plugin.rewrite_youtube_embeds pref is true and the
      * element this nsObjectLoadingContent instance represents:
      *
      * - is an embed or object node
      * - has a URL pointing at the youtube.com domain, using "/v/" style video
-     *   path reference, and without enablejsapi=1 in the path
+     *   path reference.
      *
      * Having the enablejsapi flag means the document that contains the element
      * could possibly be manipulating the youtube video elsewhere on the page
-     * via javascript. We can't rewrite these kinds of elements without possibly
-     * breaking content, which we want to avoid.
+     * via javascript. In the context of embed elements, this usage has been
+     * deprecated by youtube, so we can just rewrite as normal.
      *
      * If we can rewrite the URL, we change the "/v/" to "/embed/", and change
      * our type to eType_Document so that we render similarly to an iframe
      * embed.
      */
     void MaybeRewriteYoutubeEmbed(nsIURI* aURI,
                                   nsIURI* aBaseURI,
                                   nsIURI** aRewrittenURI);