Bug 1046500 - Fix mediagroup parsing in feed parser. r=mak, a=sledru
authorWes Johnston <wjohnston@mozilla.com>
Wed, 06 Aug 2014 20:43:47 -0700
changeset 217455 78cc17812ef71fa8524cd5af8a8e9bd8ed6f3468
parent 217454 89133e1972a57d9887f4d069b2ae0ffac86586ac
child 217456 81d788a4bf74c3705e54bba090d95d60c3963cfe
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, sledru
bugs1046500
milestone33.0a2
Bug 1046500 - Fix mediagroup parsing in feed parser. r=mak, a=sledru
toolkit/components/feeds/FeedProcessor.js
--- a/toolkit/components/feeds/FeedProcessor.js
+++ b/toolkit/components/feeds/FeedProcessor.js
@@ -539,20 +539,26 @@ Entry.prototype = {
 
     if (!(enc.getProperty("url")))
       return;
 
     this._addToEnclosures(enc);
   },
 
   _mediaToEnclosures: function Entry_mediaToEnclosures(mediaType, contentType) {
-    var content = this.fields.getPropertyAsInterface(mediaType, Ci.nsIArray);
+    var content;
 
-    if (contentType)
-      content = content.getPropertyAsInterface(contentType, Ci.nsIArray);
+    // If a contentType is specified, the mediaType is a simple propertybag,
+    // and the contentType is an array inside it.
+    if (contentType) {
+      var group = this.fields.getPropertyAsInterface(mediaType, Ci.nsIPropertyBag2);
+      content = group.getPropertyAsInterface(contentType, Ci.nsIArray);
+    } else {
+      content = this.fields.getPropertyAsInterface(mediaType, Ci.nsIArray);
+    }
 
     for (var i = 0; i < content.length; ++i) {
       var contentElement = content.queryElementAt(i, Ci.nsIWritablePropertyBag2);
 
       // media:content don't require url, but if it's not there, we should
       // skip it.
       if (!bagHasKey(contentElement, "url"))
         continue;