Bug 1146358 - Adding an item to reading list from reader view fails. r=adw
authorJared Wein <jwein@mozilla.com>
Mon, 23 Mar 2015 16:45:58 -0400
changeset 264138 c521d136b0f3d0c1e401ed502de5a2be9756f2cb
parent 264137 3ec9f77647f6116c1720bb5f9367b36e7c61eab2
child 264139 06f1b43f5a7b8f5cba9bb4ae18cdc488946154ff
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw
bugs1146358
milestone39.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 1146358 - Adding an item to reading list from reader view fails. r=adw
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;