Bug 1146358 - Adding an item to reading list from reader view fails. r=adw a=readinglist
authorJared Wein <jwein@mozilla.com>
Mon, 23 Mar 2015 16:45:58 -0400
changeset 248462 61685c383230ebb0f2f91c33a93aa608f9205b76
parent 248461 dfd7c0ccfffda4afd76c57bcf5ab5546b1895340
child 248463 54820487703f004e16d29fa1f935bd5faacf465a
push id7837
push userjwein@mozilla.com
push dateFri, 27 Mar 2015 00:27:16 +0000
treeherdermozilla-aurora@cb0db44ce60e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, readinglist
bugs1146358
milestone38.0a2
Bug 1146358 - Adding an item to reading list from reader view fails. r=adw a=readinglist
browser/components/readinglist/ReadingList.jsm
--- a/browser/components/readinglist/ReadingList.jsm
+++ b/browser/components/readinglist/ReadingList.jsm
@@ -53,16 +53,27 @@ const ITEM_RECORD_PROPERTIES = `
   addedBy
   addedOn
   storedOn
   markedReadBy
   markedReadOn
   readPosition
 `.trim().split(/\s+/);
 
+// Article objects that are passed to ReadingList.addItem may contain
+// some properties that are known but are not currently stored in the
+// ReadingList records. This is the list of properties that are knowingly
+// disregarded before the item is normalized.
+const ITEM_DISREGARDED_PROPERTIES = `
+  byline
+  dir
+  content
+  length
+`.trim().split(/\s+/);
+
 /**
  * A reading list contains ReadingListItems.
  *
  * A list maintains only one copy of an item per URL.  So if for example you use
  * an iterator to get two references to items with the same URL, your references
  * actually refer to the same JS object.
  *
  * Options Objects
@@ -848,16 +859,19 @@ ReadingListItemIterator.prototype = {
  * aren't in ITEM_RECORD_PROPERTIES.
  *
  * @param record A non-normalized record object.
  * @return The new normalized record.
  */
 function normalizeRecord(nonNormalizedRecord) {
   let record = {};
   for (let prop in nonNormalizedRecord) {
+    if (ITEM_DISREGARDED_PROPERTIES.includes(prop)) {
+      continue;
+    }
     if (!ITEM_RECORD_PROPERTIES.includes(prop)) {
       throw new Error("Unrecognized item property: " + prop);
     }
     switch (prop) {
     case "url":
     case "resolvedURL":
       if (nonNormalizedRecord[prop]) {
         record[prop] = normalizeURI(nonNormalizedRecord[prop]).spec;