Bug 655162: A missing updates property in an update.rdf should be counted as no available updates not as a failure to check for updates. r=robstrong a=asa FIREFOX_AURORA_5
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 23 May 2011 09:54:37 -0700
changeset 68152 2d075d565dc7b2c14a04d83f356820b7ca93b78d
parent 68151 cb9883dbe8ba51c17d2ec4eac15aa37a56b13258
child 68153 24f4709b7425e8ff3c68cb823cbd734c16838876
push idunknown
push userunknown
push dateunknown
reviewersrobstrong, asa
bugs655162
milestone5.0a2
Bug 655162: A missing updates property in an update.rdf should be counted as no available updates not as a failure to check for updates. r=robstrong a=asa
toolkit/mozapps/extensions/AddonUpdateChecker.jsm
toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
--- a/toolkit/mozapps/extensions/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/AddonUpdateChecker.jsm
@@ -327,17 +327,24 @@ function parseRDFManifest(aId, aType, aU
     }
 
     if (!result)
       throw new Error("The signature for " + aId + " was not created by the add-on's updateKey");
   }
 
   let updates = ds.GetTarget(extensionRes, EM_R("updates"), true);
 
-  if (!updates || !(updates instanceof Ci.nsIRDFResource))
+  // A missing updates property doesn't count as a failure, just as no avialable
+  // update information
+  if (!updates) {
+    WARN("Update manifest for " + aId + " did not contain an updates property");
+    return [];
+  }
+
+  if (!(updates instanceof Ci.nsIRDFResource))
     throw new Error("Missing updates property for " + extensionRes.Value);
 
   let cu = Cc["@mozilla.org/rdf/container-utils;1"].
            getService(Ci.nsIRDFContainerUtils);
   if (!cu.IsContainer(ds, updates))
     throw new Error("Updates property was not an RDF container");
 
   let checkSecurity = true;
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
@@ -284,9 +284,16 @@
         </RDF:li>
       </RDF:Seq>
     </em:updates>
     <em:signature>MIGTMA0GCSqGSIb3DQEBBQUAA4GBALQKwzLFr/VOw3gJvv/LCh3/PWDd9FqmFnX+
                   hJjBmCaUDtG7CXn1i0h8ed8IeRHpLLT7FCzVwU3bH9BUjdm8wc3ObtlNbd8go01a
                   CoXz50r3rYPcYz4WS+7/+lvrUqsuWd9Wj+q0NeCPiNaaro6/AolE2Qf5JFRL3lxY
                   lsKWAnVO</em:signature>
   </RDF:Description>
+
+  <!-- There should be no information present for test_bug378216_14 -->
+
+  <!-- Invalid update RDF -->
+  <RDF:Description about="urn:mozilla:extension:test_bug378216_15@tests.mozilla.org">
+    <em:updates>Foo</em:updates>
+  </RDF:Description>
 </RDF>
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
@@ -187,16 +187,46 @@ function run_test_8() {
 function run_test_9() {
   AddonUpdateChecker.checkForUpdates("test_bug378216_13@tests.mozilla.org",
                                      "extension", updateKey,
                                      "http://localhost:4444/data/test_updatecheck.rdf", {
     onUpdateCheckComplete: function(updates) {
       do_check_eq(updates.length, 1);
       do_check_eq(updates[0].version, "2.0");
       do_check_true("updateURL" in updates[0]);
-      end_test();
+      run_test_10();
     },
 
     onUpdateCheckError: function(status) {
       do_throw("Update check failed with status " + status);
     }
   });
 }
+
+function run_test_10() {
+  AddonUpdateChecker.checkForUpdates("test_bug378216_14@tests.mozilla.org",
+                                     "extension", null,
+                                     "http://localhost:4444/data/test_updatecheck.rdf", {
+    onUpdateCheckComplete: function(updates) {
+      do_check_eq(updates.length, 0);
+      run_test_11();
+    },
+
+    onUpdateCheckError: function(status) {
+      do_throw("Update check failed with status " + status);
+    }
+  });
+}
+
+function run_test_11() {
+  AddonUpdateChecker.checkForUpdates("test_bug378216_15@tests.mozilla.org",
+                                     "extension", null,
+                                     "http://localhost:4444/data/test_updatecheck.rdf", {
+    onUpdateCheckComplete: function(updates) {
+      do_throw("Update check should have failed");
+    },
+
+    onUpdateCheckError: function(status) {
+      do_check_eq(status, AddonUpdateChecker.ERROR_PARSE_ERROR);
+      end_test();
+    }
+  });
+}